goodguide-gibbon 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,23 +25,32 @@ module GoodGuide
25
25
  class RuntimeError < StandardError; end
26
26
 
27
27
  class Program
28
- attr_reader :source
29
- def initialize(global, context, source)
30
- @global = global
31
- @context = context
32
- @source = source
28
+ def self.parse(context, global, source)
29
+ syntax = context.parse(source)
30
+ semantics, errors = context.analyze(syntax, global)
31
+ raise SemanticError.new(errors) if errors
32
+
33
+ Program.new(context,
34
+ :global => global,
35
+ :syntax => syntax,
36
+ :semantics => semantics,
37
+ )
33
38
  end
34
39
 
35
- def syntax
36
- @syntax ||= @context.parse(@source)
40
+ attr_reader :syntax, :semantics
41
+ def initialize(context, info={})
42
+ @context = context
43
+ @global = info[:global]
44
+ @syntax = info[:syntax]
45
+ @semantics = info[:semantics]
37
46
  end
38
47
 
39
- def semantics
40
- @semantics ||= begin
41
- semantics, errors = @context.analyze(self.syntax, @global)
42
- raise SemanticError.new(errors) if errors
43
- semantics
44
- end
48
+ def as_json
49
+ {
50
+ global: @global,
51
+ syntax: @syntax,
52
+ semantics: @semantics,
53
+ }
45
54
  end
46
55
 
47
56
  def call(entity_id)
@@ -55,16 +64,12 @@ module GoodGuide
55
64
  end
56
65
 
57
66
  class Client
58
- def self.parse(global, source)
59
- self.new.parse(global, source)
60
- end
61
-
62
- def parse(global, source)
63
- Program.new(global, context, source)
67
+ def self.make_context
68
+ new.make_context
64
69
  end
65
70
 
66
- def context
67
- @context ||= Context.new(self)
71
+ def make_context
72
+ Context.new(self)
68
73
  end
69
74
 
70
75
  def lookup_type(id, name)
@@ -1,7 +1,7 @@
1
1
  module GoodGuide
2
2
  module Gibbon
3
3
  def self.version
4
- '0.2.0'
4
+ '0.2.1'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goodguide-gibbon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-15 00:00:00.000000000 Z
12
+ date: 2013-07-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  type: :runtime