Class: GoodGuide::Gibbon::Program
- Inherits:
-
Object
- Object
- GoodGuide::Gibbon::Program
- Defined in:
- lib/goodguide/gibbon.rb
Instance Attribute Summary collapse
-
#semantics ⇒ Object
readonly
Returns the value of attribute semantics.
-
#syntax ⇒ Object
readonly
Returns the value of attribute syntax.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json ⇒ Object
- #call(runtime_client, entity_id) ⇒ Object
-
#initialize(info = {}) ⇒ Program
constructor
A new instance of Program.
Constructor Details
Instance Attribute Details
#semantics ⇒ Object (readonly)
Returns the value of attribute semantics.
134 135 136 |
# File 'lib/goodguide/gibbon.rb', line 134 def semantics @semantics end |
#syntax ⇒ Object (readonly)
Returns the value of attribute syntax.
134 135 136 |
# File 'lib/goodguide/gibbon.rb', line 134 def syntax @syntax end |
Class Method Details
.compile(source, info = {}) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/goodguide/gibbon.rb', line 116 def self.compile(source, info={}) client = info[:client] || raise('please pass a static client') global = info[:global] || raise('please pass a global table id') context = info[:context] || Context.new syntax = context.parse(source) semantics, errors = context.analyze(syntax, global, client.to_js) raise SemanticError.new(errors) if errors Program.new( :syntax => syntax, :semantics => semantics, :context => context, ) end |
Instance Method Details
#as_json ⇒ Object
141 142 143 144 145 146 |
# File 'lib/goodguide/gibbon.rb', line 141 def as_json { syntax: @syntax, semantics: @semantics, } end |
#call(runtime_client, entity_id) ⇒ Object
148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/goodguide/gibbon.rb', line 148 def call(runtime_client, entity_id) # TODO context = Context.new values, error = context.eval_gibbon( self.semantics, entity_id, runtime_client.to_js ) raise error if error values end |