Class: SportDb::Parser

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

Instance Method Summary collapse

Instance Method Details

#parse(lines, debug: false) ⇒ Object

convience helper - ignore errors by default



78
79
80
81
# File 'lib/sportdb/parser.rb', line 78

def parse( lines, debug: false )
  tree, _ = parse_with_errors( lines, debug: debug )
  tree
end

#parse_with_errors(lines, debug: false) ⇒ Object



69
70
71
72
73
74
75
# File 'lib/sportdb/parser.rb', line 69

def parse_with_errors( lines, debug: false )
  ## todo/check - if lines needs to chack for array of lines and such
  ##                        or handled by tokenizer???
  parser = RaccMatchParser.new( lines )
  tree, errors = parser.parse_with_errors
  [tree, errors]
end

#tokenize(lines, debug: false) ⇒ Object

convience helper - ignore errors by default



63
64
65
66
# File 'lib/sportdb/parser.rb', line 63

def tokenize( lines, debug: false )
  tokens, _ = tokenize_with_errors( lines, debug: debug )
  tokens
end

#tokenize_with_errors(lines, debug: false) ⇒ Object

“default” lexer & parser (wraps RaccMatchParser)



56
57
58
59
60
# File 'lib/sportdb/parser.rb', line 56

def tokenize_with_errors( lines, debug: false )
   lexer = Lexer.new( lines )  
   tokens, errors = lexer.tokenize_with_errors
   [tokens, errors]
end