Class: SportDb::Parser
- Inherits:
-
Object
- Object
- SportDb::Parser
- Defined in:
- lib/sportdb/parser.rb
Instance Method Summary collapse
-
#parse(lines, debug: false) ⇒ Object
convience helper - ignore errors by default.
- #parse_with_errors(lines, debug: false) ⇒ Object
-
#tokenize(lines, debug: false) ⇒ Object
convience helper - ignore errors by default.
-
#tokenize_with_errors(lines, debug: false) ⇒ Object
“default” lexer & parser (wraps RaccMatchParser).
Instance Method Details
#parse(lines, debug: false) ⇒ Object
convience helper - ignore errors by default
132 133 134 135 |
# File 'lib/sportdb/parser.rb', line 132 def parse( lines, debug: false ) tree, _ = parse_with_errors( lines, debug: debug ) tree end |
#parse_with_errors(lines, debug: false) ⇒ Object
123 124 125 126 127 128 129 |
# File 'lib/sportdb/parser.rb', line 123 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
117 118 119 120 |
# File 'lib/sportdb/parser.rb', line 117 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)
110 111 112 113 114 |
# File 'lib/sportdb/parser.rb', line 110 def tokenize_with_errors( lines, debug: false ) lexer = Lexer.new( lines ) tokens, errors = lexer.tokenize_with_errors [tokens, errors] end |