delorean_lang 0.2.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MThkOGViN2U0NDc5MjEyMmVhM2Y0NGIyN2QwNTRhZjFhY2M1NTMyMA==
4
+ NTA5ZTg4OTNlZWQ4NWZmYTRjZWI0M2ZkYjRkZGQ4ZjM2ZmZhOWU2Yg==
5
5
  data.tar.gz: !binary |-
6
- ODhlNDc3ODRkZGI4OWMwNzRiNzM1ODA4ZWI3MzY2OWYzNTdhZGRiOA==
6
+ NDg5MDRmMTQ0NjNiN2Q0ZGVjZmIyMjM5OTkxN2QwZjliMmI4NTQwMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjY0MzZiZTZmNDUzMmM2YmYyYjAxZjNiY2QxODY1OTQzNmZiNjJkOWM3NTMz
10
- ZDhjYTFjZWRjYzE4ZmFmYWYyMmQ5NzY3OTFiODg5MDdlZGM5YWMwZjRiZWFh
11
- MGNkYTczZGJmOTY1Zjg2MTM0ZjlhNDcyZTQzNjUzYzdmMDBiODM=
9
+ ZmFjNGMwZDAxZjNhZTQ0ZTdkOWNmOTRmYTY2ZDZlY2Q0NGY3MDVlZDc2Yjlk
10
+ ZWExNWNlODIyZjJmZWFkMDRiMGMwMzU5NDBlM2UwZjYwYTMwMTgzZjFjNTk5
11
+ NmU0NzgwYTg4ODUzYWJjYWQxMTlmYTgwZTZkNGM2NzZmNmQzNTQ=
12
12
  data.tar.gz: !binary |-
13
- YjFiN2E5YjdiYmE1NjA3OTY5OTYyZDE5N2MzZGUyMjk1YjdmMTYzNmExNjRm
14
- ZDhmMWE2OTFlMGYyZGRmNzMxZTIwMTliNjAyNDljNWRiN2MxYTdkMjg0OTcz
15
- NGUwYjhmYTIzNDE3MDgzODE0YTdhMGNmNzM3NWEzN2VhYmRiNzk=
13
+ ZDhlNzQ3MDA1NzFlYTEwMzRmZWUwNTc3MWRjY2NkYzY0MTJhOWY4MjFkMTNm
14
+ ZWUzYTQ5NTAyMWYwNDgwMTAxOTkyODg0NGFhY2Q0NWE0OGUyMTJmODYxMDk5
15
+ YzA2ZWEyMGZkYzJlY2FjOTNjNmQ1YjQyYmRjNTMwOGU2MmQ3ODM=
@@ -255,34 +255,37 @@ module Delorean
255
255
  next if line.length == 0
256
256
 
257
257
  if multi_line
258
- # Inside a multiline and next line doesn't look like a
259
- # continuation => syntax error.
260
- err(ParseError, "syntax error") unless line =~ /^\s+/
261
-
262
- multi_line += line
263
- t = parser.parse(multi_line)
258
+ # if line starts with >4 spaces, assume it's a multline
259
+ # continuation.
260
+ if line =~ /\A {5}/
261
+ multi_line += line
262
+ next
263
+ else
264
+ t = parser.parse(multi_line)
265
+ err(ParseError, "syntax error") unless t
264
266
 
265
- if t
266
267
  multi_line, @multi_no = nil, nil
267
268
  generate(t)
268
269
  end
270
+ end
269
271
 
270
- else
271
- t = parser.parse(line)
272
+ t = parser.parse(line)
272
273
 
273
- if !t
274
- err(ParseError, "syntax error") unless line =~ /^\s+/
274
+ if !t
275
+ err(ParseError, "syntax error") unless line =~ /^\s+/
275
276
 
276
- multi_line = line
277
- @multi_no = @line_no
278
- else
279
- generate(t)
280
- end
277
+ multi_line = line
278
+ @multi_no = @line_no
279
+ else
280
+ generate(t)
281
281
  end
282
282
  end
283
283
 
284
- # left over multi_line
285
- err(ParseError, "syntax error") if multi_line
284
+ if multi_line
285
+ t = parser.parse(multi_line)
286
+ err(ParseError, "syntax error") unless t
287
+ generate(t)
288
+ end
286
289
  end
287
290
 
288
291
  ######################################################################
@@ -1,3 +1,3 @@
1
1
  module Delorean
2
- VERSION = "0.2.4"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -672,13 +672,13 @@ eof
672
672
  engine.parse defn("A:",
673
673
  " a = 1",
674
674
  " b = [a+1",
675
- " for a in [1,2,3]",
676
- " ]",
675
+ " for a in [1,2,3]",
676
+ " ]",
677
677
  )
678
678
  engine.evaluate("A", "b").should == [2, 3, 4]
679
679
  end
680
680
 
681
- it "should eval multiline expressions" do
681
+ it "should eval multiline expressions (2)" do
682
682
  engine.parse defn("A:",
683
683
  " a = 123",
684
684
  " b = 456 + ",
@@ -701,6 +701,33 @@ describe "Delorean" do
701
701
  end
702
702
  end
703
703
 
704
+ it "should give proper errors when multiline doesn't end properly" do
705
+ begin
706
+ engine.parse defn("A:",
707
+ " a = 1",
708
+ " b = [a+1",
709
+ " for a in [1,2,3]",
710
+ "B:",
711
+ )
712
+ raise "fail"
713
+ rescue Delorean::ParseError => exc
714
+ exc.line.should == 3
715
+ end
716
+ end
717
+
718
+ it "should error on multiline not properly spaced" do
719
+ begin
720
+ engine.parse defn("A:",
721
+ " a = [1,",
722
+ " 2]",
723
+ " b = 456",
724
+ )
725
+ raise "fail"
726
+ rescue Delorean::ParseError => exc
727
+ exc.line.should == 2
728
+ end
729
+ end
730
+
704
731
  it "should parse imports" do
705
732
  engine.parse defn("import AAA",
706
733
  "A:",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delorean_lang
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arman Bostani
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-14 00:00:00.000000000 Z
11
+ date: 2014-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: treetop