diff --git a/lib/parser/basic_types.rb b/lib/parser/basic_types.rb index 8e6c134a..5b1f8067 100644 --- a/lib/parser/basic_types.rb +++ b/lib/parser/basic_types.rb @@ -8,7 +8,7 @@ module Parser # rule of thumb is that anything eats space behind it, but only space, no newlines rule(:space) { (str('\t') | str(' ')).repeat(1) } rule(:space?) { space.maybe } - rule(:newline){ str("\n") >> space?} + rule(:newline){ str("\n") >> space? >> newline.repeat } rule(:quote) { str('"') } rule(:nonquote) { str('"').absent? >> any } @@ -25,11 +25,7 @@ module Parser rule(:dot) { str('.') } rule(:digit) { match('[0-9]') } rule(:exponent) { (str('e')| str('E')) } - - rule(:true) { str('true').as(:true) >> space?} - rule(:false){ str('false').as(:false) >> space?} - rule(:nil) { str('null').as(:nil) >> space?} - + # identifier must start with lower case rule(:name) { (match['a-z'] >> match['a-zA-Z0-9'].repeat).as(:name) >> space? } diff --git a/lib/parser/keywords.rb b/lib/parser/keywords.rb index 0f9aa6f4..10ea6ff6 100644 --- a/lib/parser/keywords.rb +++ b/lib/parser/keywords.rb @@ -5,5 +5,8 @@ module Parser rule(:keyword_else) { str('else') >> space? } rule(:keyword_def) { str('def') >> space? } rule(:keyword_end) { str('end') >> space? } + rule(:keyword_true) { str('true').as(:true) >> space?} + rule(:keyword_false){ str('false').as(:false) >> space?} + rule(:keyword_nil) { str('null').as(:nil) >> space?} end end \ No newline at end of file