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: Card, DateHeader, Goal, GoalLine, GroupDef, GroupHeader, Lineup, LineupLine, MatchLine, Minute, RoundDef, RoundHeader, Sub

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",
"PROP",
"\".\"",
"NEWLINE",
"\",\"",
"\"-\"",
"\";\"",
"PROP_NAME",
"\"(\"",
"\")\"",
"\"[\"",
"\"]\"",
"YELLOW_CARD",
"RED_CARD",
"GROUP",
"\"|\"",
"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",
"lineup_lines",
"lineup",
"lineup_name",
"lineup_sep",
"lineup_name_more",
"card",
"lineup_sub",
"minute",
"card_body",
"card_type",
"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_opts" ]
Racc_debug_parser =
false

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ RaccMatchParser

Returns a new instance of RaccMatchParser.



304
305
306
307
308
# File 'lib/sportdb/parser.rb', line 304

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

Instance Method Details

#_reduce_none(val, _values, result) ⇒ Object



818
819
820
# File 'lib/sportdb/parser/parser.rb', line 818

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

#next_tokenObject



311
312
313
314
315
# File 'lib/sportdb/parser.rb', line 311

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

#on_error(*args) ⇒ Object



329
330
331
332
333
334
# File 'lib/sportdb/parser.rb', line 329

def on_error(*args)
  puts
  puts "!! on parse error:"
  puts "args=#{args.pretty_inspect}"
  exit 1  ##   exit for now  -  get and print more info about context etc.!!
end

#parseObject

on_error do |error_token_id, error_value, value_stack|

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


321
322
323
324
325
326
# File 'lib/sportdb/parser.rb', line 321

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