Class: RaccMatchParser

Inherits:
Racc::Parser
  • Object
show all
Defined in:
lib/sportdb/parser.rb,
lib/sportdb/parser/parser.rb

Overview

RaccMatchParser support machinery (incl. node classes/abstract syntax tree)

Defined Under Namespace

Classes: DateHeader, Goal, GoalLine, GroupDef, GroupHeader, MatchLine, Minute, RoundDef, RoundHeader

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",
"GROUP",
"\"|\"",
"NEWLINE",
"TEXT",
"ROUND",
"DATE",
"DURATION",
"\"[\"",
"\"]\"",
"\"-\"",
"\",\"",
"ORD",
"TIME",
"\"@\"",
"SCORE",
"VS",
"\";\"",
"MINUTE",
"OG",
"PEN",
"$start",
"statements",
"statement",
"date_header",
"group_header",
"round_header",
"group_def",
"round_def",
"match_line",
"goal_lines",
"empty_line",
"team_values",
"round_date_opts",
"round_values",
"round_sep",
"match_opts",
"match",
"more_match_opts",
"date_opts",
"geo_opts",
"geo_values",
"score_value",
"goal_lines_body",
"goals",
"goal_sep",
"goal",
"minutes",
"minute",
"minute_opts" ]
Racc_debug_parser =
false

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ RaccMatchParser

Returns a new instance of RaccMatchParser.



249
250
251
252
253
# File 'lib/sportdb/parser.rb', line 249

def initialize(input)
  puts "==> input:"
  puts input
  @tokenizer = SportDb::Tokenizer.new(input)
end

Instance Method Details

#_reduce_none(val, _values, result) ⇒ Object



629
630
631
# File 'lib/sportdb/parser/parser.rb', line 629

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

#next_tokenObject



256
257
258
259
260
# File 'lib/sportdb/parser.rb', line 256

def next_token
  tok = @tokenizer.next_token
  puts "next_token => #{tok.pretty_inspect}"
  tok
end

#on_error(*args) ⇒ Object



274
275
276
277
# File 'lib/sportdb/parser.rb', line 274

def on_error(*args)
  puts "!! on error:"
  puts "args=#{args.pretty_inspect}"
end

#parseObject

on_error do |error_token_id, error_value, value_stack|

    puts "Parse error on token: #{error_token_id}, value: #{error_value}"
end


266
267
268
269
270
271
# File 'lib/sportdb/parser.rb', line 266

def parse    
   puts "parse:"
   @tree = [] 
   do_parse
   @tree
end