Class: Journey::Parser

Inherits:
Racc::Parser
  • Object
show all
Includes:
Nodes
Defined in:
lib/journey/parser.rb,
lib/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",
"literal",
"symbol",
"slash",
"dot" ]
Racc_debug_parser =
false

Instance Method Summary collapse

Constructor Details

#initializeParser

Returns a new instance of Parser.



8
9
10
# File 'lib/journey/parser_extras.rb', line 8

def initialize
  @scanner = Scanner.new
end

Instance Method Details

#_reduce_1(val, _values, result) ⇒ Object

reduce 0 omitted



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

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

#_reduce_14(val, _values, result) ⇒ Object

reduce 13 omitted



179
180
181
182
# File 'lib/journey/parser.rb', line 179

def _reduce_14(val, _values, result)
 result = Slash.new('/') 
    result
end

#_reduce_15(val, _values, result) ⇒ Object



184
185
186
187
# File 'lib/journey/parser.rb', line 184

def _reduce_15(val, _values, result)
 result = Symbol.new(val.first) 
    result
end

#_reduce_16(val, _values, result) ⇒ Object



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

def _reduce_16(val, _values, result)
 result = Literal.new(val.first) 
    result
end

#_reduce_17(val, _values, result) ⇒ Object



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

def _reduce_17(val, _values, result)
 result = Dot.new(val.first) 
    result
end

#_reduce_2(val, _values, result) ⇒ Object



143
144
145
146
# File 'lib/journey/parser.rb', line 143

def _reduce_2(val, _values, result)
 result = val.first 
    result
end

#_reduce_7(val, _values, result) ⇒ Object

reduce 6 omitted



156
157
158
159
# File 'lib/journey/parser.rb', line 156

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

#_reduce_8(val, _values, result) ⇒ Object



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

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

#_reduce_9(val, _values, result) ⇒ Object



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

def _reduce_9(val, _values, result)
 result = Star.new(Symbol.new(val.last.left)) 
    result
end

#_reduce_none(val, _values, result) ⇒ Object



199
200
201
# File 'lib/journey/parser.rb', line 199

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

#next_tokenObject



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

def next_token
  @scanner.next_token
end

#parse(string) ⇒ Object



12
13
14
15
# File 'lib/journey/parser_extras.rb', line 12

def parse string
  @scanner.scan_setup string
  do_parse
end