Sha256: 55d63b067d154eab3e58501c0da8041200318234add966fdb3dd6d0e21edbe1f

Contents?: true

Size: 640 Bytes

Versions: 2

Compression:

Stored size: 640 Bytes

Contents

# frozen_string_literal: true

require 'namarara/version'

module Namarara; end

require 'rly'

require 'namarara/lexer'
require 'namarara/parser'
require 'namarara/eval_error'
require 'namarara/errors/var_not_defined'
require 'namarara/errors/invalid_grammar'

module Namarara
  def self.parse_string(line, vars, debug = false)
    parser = Parser.new(Lexer.new)
    parser.names = vars
    parser_bet = parser.parse(line.chomp, debug)
    parser.check_grammar line, parser_bet

    {
      expr: line,
      tree: parser_bet.to_s,
      errors: parser_bet&.errors&.map { |e| e.message },
      result: parser_bet&.compute
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
namarara-0.9.5 lib/namarara.rb
namarara-0.9.4 lib/namarara.rb