Module: Atomy::Parser
Instance Method Summary collapse
Instance Method Details
#parse_file(file) ⇒ Object
7 8 9 |
# File 'lib/atomy/parser.rb', line 7 def parse_file(file) parse_string(File.read(file)) end |
#parse_string(source) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/atomy/parser.rb', line 11 def parse_string(source) grammar = Atomy::Grammar.new(source) grammar.raise_error unless grammar.parse grammar.result rescue KPeg::CompiledParser::ParseError => e raise SyntaxError, e.to_s end |