Module: Expressive

Defined in:
lib/scope.rb,
lib/webhook.rb,
lib/expressive.rb,
lib/extended_value.rb,
lib/errors/run_error.rb,
lib/errors/parse_error.rb,
lib/expressive/version.rb

Defined Under Namespace

Modules: Boolean, FloatValue, IntegerValue, StringValue Classes: ExtendedValue, Function, Identifier, List, ParseError, Program, RunError, Scope, Statement, Syntax, TopLevel, Webhook

Constant Summary collapse

VERSION =
"0.0.35"

Class Method Summary collapse

Class Method Details

.all_symbolsObject



37
38
39
# File 'lib/expressive.rb', line 37

def self.all_symbols
  %w(+ - * / = set sum $sub post >= > < <= and or if date datetime get put lookup $lookup $head $tail $reverse round $round $days_ago $hours_ago $minutes_ago $append $id $hash $concat $split $sms $hval $index $random $join $not $include)
end

.parse(expressions) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/expressive.rb', line 23

def self.parse(expressions)
  parser = ::ExpressiveParser.new
  begin
    parser.parse(expressions)
  rescue Exception => e
    if expressions.nil?
      message = "Error parsing nil expression:  #{$!}"
    else
      message = "Error parsing '#{expressions}':  #{$!}"
    end
    raise ParseError, message, $!.backtrace
  end
end

.run(source_code, scope = TopLevel.new) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/expressive.rb', line 14

def self.run(source_code, scope = TopLevel.new )
  program = parse(source_code)
  begin
    program.eval(scope)
  rescue Exception => e
    raise RunError, "Error running '#{source_code}':  #{$!}", $!.backtrace
  end
end