diff options
author | Jack Danger Canty <jackdanger@squareup.com> | 2014-08-03 15:23:56 -0700 |
---|---|---|
committer | Jack Danger Canty <jackdanger@squareup.com> | 2014-08-03 15:23:56 -0700 |
commit | 0b8f35dd9ca6d1ae72e6021e64688e2d88b84537 (patch) | |
tree | 770aaf14c785e030a363c48e1ee69159144004b0 /actionpack/lib/action_dispatch/journey/parser.y | |
parent | cadc8a0dfce85a10fecb3c366f8d847c189c36da (diff) | |
download | rails-0b8f35dd9ca6d1ae72e6021e64688e2d88b84537.tar.gz rails-0b8f35dd9ca6d1ae72e6021e64688e2d88b84537.tar.bz2 rails-0b8f35dd9ca6d1ae72e6021e64688e2d88b84537.zip |
Using no_result_var in Journey's parser generator
Previously the generated parser had an intermediate local variable
`result` that really useful if you're building up a stateful object but
Journey always discards the result argument to the reduce functions.
This produces a simpler parser for anybody who actually wants to read
the thing.
Sadly, there's no real performance speedup with this change.
Diffstat (limited to 'actionpack/lib/action_dispatch/journey/parser.y')
-rw-r--r-- | actionpack/lib/action_dispatch/journey/parser.y | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/actionpack/lib/action_dispatch/journey/parser.y b/actionpack/lib/action_dispatch/journey/parser.y index 0ead222551..d3f7c4d765 100644 --- a/actionpack/lib/action_dispatch/journey/parser.y +++ b/actionpack/lib/action_dispatch/journey/parser.y @@ -1,11 +1,11 @@ class ActionDispatch::Journey::Parser - + options no_result_var token SLASH LITERAL SYMBOL LPAREN RPAREN DOT STAR OR rule expressions - : expression expressions { result = Cat.new(val.first, val.last) } - | expression { result = val.first } + : expression expressions { Cat.new(val.first, val.last) } + | expression { val.first } | or ; expression @@ -14,14 +14,14 @@ rule | star ; group - : LPAREN expressions RPAREN { result = Group.new(val[1]) } + : LPAREN expressions RPAREN { Group.new(val[1]) } ; or - : expression OR expression { result = Or.new([val.first, val.last]) } - | expression OR or { result = Or.new([val.first, val.last]) } + : expression OR expression { Or.new([val.first, val.last]) } + | expression OR or { Or.new([val.first, val.last]) } ; star - : STAR { result = Star.new(Symbol.new(val.last)) } + : STAR { Star.new(Symbol.new(val.last)) } ; terminal : symbol @@ -30,16 +30,16 @@ rule | dot ; slash - : SLASH { result = Slash.new('/') } + : SLASH { Slash.new('/') } ; symbol - : SYMBOL { result = Symbol.new(val.first) } + : SYMBOL { Symbol.new(val.first) } ; literal - : LITERAL { result = Literal.new(val.first) } + : LITERAL { Literal.new(val.first) } ; dot - : DOT { result = Dot.new(val.first) } + : DOT { Dot.new(val.first) } ; end |