Module: Einstein
- Defined in:
- lib/einstein.rb,
lib/einstein/version.rb,
lib/einstein/evaluator.rb,
lib/einstein/processor.rb,
lib/einstein/expression.rb,
lib/einstein/parser.rex.rb,
lib/einstein/parser.racc.rb,
lib/einstein/pretty_printer.rb
Defined Under Namespace
Modules: VERSION Classes: Evaluator, Expression, Parser, PrettyPrinter, Processor, ResolveError
Class Method Summary collapse
-
.evaluate(expression, scope = {}) ⇒ Object
Evaluate the given
expression
with the givenscope
. -
.parse(expression) ⇒ Object
Parse the given
expression
and return the AST as an instance of Einstein::Expression.
Class Method Details
.evaluate(expression, scope = {}) ⇒ Object
Evaluate the given expression
with the given scope
. Any variables used by the expression
, but undeclared in the scope
, will cause a Einstein::ResolveError to be raised.
22 23 24 |
# File 'lib/einstein.rb', line 22 def self.evaluate(expression, scope = {}) parse(expression).evaluate(scope) end |
.parse(expression) ⇒ Object
Parse the given expression
and return the AST as an instance of Einstein::Expression.
15 16 17 |
# File 'lib/einstein.rb', line 15 def self.parse(expression) Expression.new(Parser.new.scan_str(expression)) end |