aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/journey/parser.y
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_dispatch/journey/parser.y')
-rw-r--r--actionpack/lib/action_dispatch/journey/parser.y49
1 files changed, 49 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/journey/parser.y b/actionpack/lib/action_dispatch/journey/parser.y
new file mode 100644
index 0000000000..d3f7c4d765
--- /dev/null
+++ b/actionpack/lib/action_dispatch/journey/parser.y
@@ -0,0 +1,49 @@
+class ActionDispatch::Journey::Parser
+ options no_result_var
+token SLASH LITERAL SYMBOL LPAREN RPAREN DOT STAR OR
+
+rule
+ expressions
+ : expression expressions { Cat.new(val.first, val.last) }
+ | expression { val.first }
+ | or
+ ;
+ expression
+ : terminal
+ | group
+ | star
+ ;
+ group
+ : LPAREN expressions RPAREN { Group.new(val[1]) }
+ ;
+ or
+ : expression OR expression { Or.new([val.first, val.last]) }
+ | expression OR or { Or.new([val.first, val.last]) }
+ ;
+ star
+ : STAR { Star.new(Symbol.new(val.last)) }
+ ;
+ terminal
+ : symbol
+ | literal
+ | slash
+ | dot
+ ;
+ slash
+ : SLASH { Slash.new('/') }
+ ;
+ symbol
+ : SYMBOL { Symbol.new(val.first) }
+ ;
+ literal
+ : LITERAL { Literal.new(val.first) }
+ ;
+ dot
+ : DOT { Dot.new(val.first) }
+ ;
+
+end
+
+---- header
+
+require 'action_dispatch/journey/parser_extras'