slight shuffling

This commit is contained in:
Torsten Ruger 2014-05-10 12:54:31 +03:00
parent 20128627c7
commit e69decee90
2 changed files with 5 additions and 6 deletions

View File

@ -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? }

View File

@ -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