Class: ActionDispatch::Journey::Parser

Inherits:
Racc::Parser
  • Object
show all
Includes:
Nodes
Defined in:
lib/action_dispatch/journey/parser.rb,
lib/action_dispatch/journey/parser_extras.rb

Constant Summary collapse

Racc_arg =
[
racc_action_table,
racc_action_check,
racc_action_default,
racc_action_pointer,
racc_goto_table,
racc_goto_check,
racc_goto_default,
racc_goto_pointer,
racc_nt_base,
racc_reduce_table,
racc_token_table,
racc_shift_n,
racc_reduce_n,
racc_use_result_var ]
Racc_token_to_s_table =
[
"$end",
"error",
"SLASH",
"LITERAL",
"SYMBOL",
"LPAREN",
"RPAREN",
"DOT",
"STAR",
"OR",
"$start",
"expressions",
"expression",
"or",
"terminal",
"group",
"star",
"symbol",
"literal",
"slash",
"dot" ]
Racc_debug_parser =
false

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeParser

Returns a new instance of Parser.



18
19
20
# File 'lib/action_dispatch/journey/parser_extras.rb', line 18

def initialize
  @scanner = Scanner.new
end

Class Method Details

.parse(string) ⇒ Object



14
15
16
# File 'lib/action_dispatch/journey/parser_extras.rb', line 14

def self.parse(string)
  new.parse string
end

Instance Method Details

#_reduce_1(val, _values) ⇒ Object

reduce 0 omitted



138
139
140
# File 'lib/action_dispatch/journey/parser.rb', line 138

def _reduce_1(val, _values)
 Cat.new(val.first, val.last)
end

#_reduce_10(val, _values) ⇒ Object



166
167
168
# File 'lib/action_dispatch/journey/parser.rb', line 166

def _reduce_10(val, _values)
 Star.new(Symbol.new(val.last, Symbol::GREEDY_EXP))
end

#_reduce_15(val, _values) ⇒ Object

reduce 14 omitted



178
179
180
# File 'lib/action_dispatch/journey/parser.rb', line 178

def _reduce_15(val, _values)
 Slash.new(val.first)
end

#_reduce_16(val, _values) ⇒ Object



182
183
184
# File 'lib/action_dispatch/journey/parser.rb', line 182

def _reduce_16(val, _values)
 Symbol.new(val.first)
end

#_reduce_17(val, _values) ⇒ Object



186
187
188
# File 'lib/action_dispatch/journey/parser.rb', line 186

def _reduce_17(val, _values)
 Literal.new(val.first)
end

#_reduce_18(val, _values) ⇒ Object



190
191
192
# File 'lib/action_dispatch/journey/parser.rb', line 190

def _reduce_18(val, _values)
 Dot.new(val.first)
end

#_reduce_2(val, _values) ⇒ Object



142
143
144
# File 'lib/action_dispatch/journey/parser.rb', line 142

def _reduce_2(val, _values)
 val.first
end

#_reduce_7(val, _values) ⇒ Object

reduce 6 omitted



154
155
156
# File 'lib/action_dispatch/journey/parser.rb', line 154

def _reduce_7(val, _values)
 Group.new(val[1])
end

#_reduce_8(val, _values) ⇒ Object



158
159
160
# File 'lib/action_dispatch/journey/parser.rb', line 158

def _reduce_8(val, _values)
 Or.new([val.first, val.last])
end

#_reduce_9(val, _values) ⇒ Object



162
163
164
# File 'lib/action_dispatch/journey/parser.rb', line 162

def _reduce_9(val, _values)
 Or.new([val.first, val.last])
end

#_reduce_none(val, _values) ⇒ Object



194
195
196
# File 'lib/action_dispatch/journey/parser.rb', line 194

def _reduce_none(val, _values)
  val[0]
end

#next_tokenObject



27
28
29
# File 'lib/action_dispatch/journey/parser_extras.rb', line 27

def next_token
  @scanner.next_token
end

#parse(string) ⇒ Object



22
23
24
25
# File 'lib/action_dispatch/journey/parser_extras.rb', line 22

def parse(string)
  @scanner.scan_setup(string)
  do_parse
end