Sha256: 1fca312366f23507f0beb7f165e5916900a4ca74e3ca2ac576eca314fb505013
Contents?: true
Size: 544 Bytes
Versions: 28
Compression:
Stored size: 544 Bytes
Contents
# Purpose: to demonstrate how to build and render a parse tree for JSON # language require_relative 'calc_lexer' require_relative 'calc_grammar' # A parser for arithmetic expressions class CalcParser < Rley::Parser::GFGEarleyParser attr_reader(:source_file) # Constructor def initialize() # Builder the Earley parser with the calculator grammar super(CalcGrammar) end def parse_expression(aText) lexer = CalcLexer.new(aText, grammar) result = parse(lexer.tokens) return result end end # class # End of file
Version data entries
28 entries across 17 versions & 1 rubygems