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



104
105
106
107
# File 'lib/sportdb/parser.rb', line 104

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

#parse_with_errors(lines, debug: false) ⇒ Object



95
96
97
98
99
100
101
# File 'lib/sportdb/parser.rb', line 95

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



89
90
91
92
# File 'lib/sportdb/parser.rb', line 89

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)



82
83
84
85
86
# File 'lib/sportdb/parser.rb', line 82

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