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

Version Path
rley-0.5.14 examples/general/calc_iter2/calc_parser.rb
rley-0.5.14 examples/general/calc_iter1/calc_parser.rb
rley-0.5.13 examples/general/calc_iter2/calc_parser.rb
rley-0.5.13 examples/general/calc_iter1/calc_parser.rb
rley-0.5.12 examples/general/calc_iter1/calc_parser.rb
rley-0.5.12 examples/general/calc_iter2/calc_parser.rb
rley-0.5.11 examples/general/calc_iter2/calc_parser.rb
rley-0.5.11 examples/general/calc_iter1/calc_parser.rb
rley-0.5.10 examples/general/calc_iter2/calc_parser.rb
rley-0.5.10 examples/general/calc_iter1/calc_parser.rb
rley-0.5.09 examples/general/calc_iter2/calc_parser.rb
rley-0.5.09 examples/general/calc_iter1/calc_parser.rb
rley-0.5.08 examples/general/calc_iter1/calc_parser.rb
rley-0.5.08 examples/general/calc_iter2/calc_parser.rb
rley-0.5.07 examples/general/calc_iter2/calc_parser.rb
rley-0.5.07 examples/general/calc_iter1/calc_parser.rb
rley-0.5.06 examples/general/calc_iter2/calc_parser.rb
rley-0.5.06 examples/general/calc_iter1/calc_parser.rb
rley-0.5.05 examples/general/calc_iter1/calc_parser.rb
rley-0.5.05 examples/general/calc_iter2/calc_parser.rb