Sha256: e5ade99a08e8761f41dd49bb823fc4bce39e5f179219779f5df204045aa2d01b

Contents?: true

Size: 654 Bytes

Versions: 1

Compression:

Stored size: 654 Bytes

Contents

require_relative 'calc_parser'

# Create a calculator parser object
parser = CalcParser.new

# Parse the input expression in command-line
if ARGV.empty?
  msg = <<-END_MSG
Command-line symtax:
  ruby #{__FILE__} "arithmetic expression"
  where:
    the arithmetic expression is enclosed between double quotes (")

  Example:
  ruby #{__FILE__} "2 * 3 + (4 - 1)"
END_MSG
  puts msg
  exit(1)
end
puts ARGV[0]
result = parser.parse_expression(ARGV[0])

unless result.success?
  # Stop if the parse failed...
  puts "Parsing of '#{file_name}' failed"
  exit(1)
end

# Generate a parse forest from the parse result
pforest = result.parse_forest
# End of file

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rley-0.3.12 examples/general/calc/calc_demo.rb