Module: Jaina

Extended by:
Forwardable
Defined in:
lib/jaina.rb,
lib/jaina/version.rb

Overview

Since:

  • 0.1.0

Defined Under Namespace

Classes: Parser

Constant Summary collapse

TerminalExpr =

Since:

  • 0.1.0

Parser::Expression::Operator::Terminal
NonTerminalExpr =

Since:

  • 0.1.0

Parser::Expression::Operator::NonTerminal
GroupingExpr =

Since:

  • 0.1.0

Parser::Expression::Operator::Grouping
VERSION =

Returns:

  • (String)

Since:

  • 0.0.0

'0.6.0'

Class Method Summary collapse

Class Method Details

.evaluate(program, **initial_context) ⇒ Any

Parameters:

  • program (String)
  • initial_context (Hash<Symbol,Any>)

Returns:

  • (Any)

Since:

  • 0.1.0



32
33
34
# File 'lib/jaina.rb', line 32

def evaluate(program, **initial_context)
  parse(program).evaluate(**initial_context)
end

.expressionsArray<String>

Returns:

  • (Array<String>)

Since:

  • 0.1.0



58
59
60
# File 'lib/jaina.rb', line 58

def expressions
  Jaina::Parser::Expression.expressions
end

.fetch_expression(expression_token) ⇒ Class{Jaina::Parser::Expressions::Operator::Abstract} Also known as: []

Parameters:

  • expression_token (String)

Returns:

  • (Class{Jaina::Parser::Expressions::Operator::Abstract})

Since:

  • 0.1.0



67
68
69
# File 'lib/jaina.rb', line 67

def fetch_expression(expression_token)
  Jaina::Parser::Expression.fetch(expression_token)
end

.parse(program) ⇒ Jaina::Parser::AST

Parameters:

  • program (String)

Returns:

Since:

  • 0.1.0



22
23
24
# File 'lib/jaina.rb', line 22

def parse(program)
  Parser.parse(program)
end

.redefine_expression(expression_klass) ⇒ void

This method returns an undefined value.

Parameters:

Since:

  • 0.5.0



50
51
52
# File 'lib/jaina.rb', line 50

def redefine_expression(expression_klass)
  Jaina::Parser::Expression.redefine(expression_klass)
end

.register_expression(expression_klass) ⇒ void

This method returns an undefined value.

Parameters:

Since:

  • 0.1.0



41
42
43
# File 'lib/jaina.rb', line 41

def register_expression(expression_klass)
  Jaina::Parser::Expression.register(expression_klass)
end