treetop 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ end
15
15
 
16
16
  gemspec = Gem::Specification.new do |s|
17
17
  s.name = "treetop"
18
- s.version = "1.1.0"
18
+ s.version = "1.1.1"
19
19
  s.author = "Nathan Sobo"
20
20
  s.email = "nathansobo@gmail.com"
21
21
  s.homepage = "http://functionalform.blogspot.com"
@@ -4,9 +4,13 @@ grammar Arithmetic
4
4
  end
5
5
 
6
6
  rule comparative
7
- exp_1:additive space '==' space exp_2:additive {
8
- def eval(env={})
9
- exp_1.eval(env) == exp_2.eval(env)
7
+ operand_1:additive space operator:equality_op space operand_2:additive <BinaryOperation>
8
+ end
9
+
10
+ rule equality_op
11
+ '==' {
12
+ def apply(a, b)
13
+ a == b
10
14
  end
11
15
  }
12
16
  end
@@ -68,7 +72,7 @@ grammar Arithmetic
68
72
  end
69
73
 
70
74
  rule variable
71
- [a-z] {
75
+ [a-z]+ {
72
76
  def eval(env={})
73
77
  env[name]
74
78
  end
@@ -80,13 +84,7 @@ grammar Arithmetic
80
84
  end
81
85
 
82
86
  rule number
83
- [1-9] [0-9]* {
84
- def eval(env={})
85
- text_value.to_i
86
- end
87
- }
88
- /
89
- '0' {
87
+ ([1-9] [0-9]* / '0') {
90
88
  def eval(env={})
91
89
  text_value.to_i
92
90
  end
@@ -105,23 +105,17 @@ grammar LambdaCalculus
105
105
  end
106
106
 
107
107
  rule variable
108
- !keyword [a-z]+ {
109
- def eval(env={})
110
- env.has_key?(name) ? env[name] : self
111
- end
112
-
113
- def bind(value, env)
114
- env.merge(name => value)
115
- end
116
-
117
- def name
118
- text_value
119
- end
120
-
121
- def to_s(env={})
122
- env.has_key?(name) ? env[name].to_s : name
108
+ !keyword (
109
+ super {
110
+ def bind(value, env)
111
+ env.merge(name => value)
112
+ end
113
+
114
+ def to_s(env={})
115
+ env.has_key?(name) ? env[name].to_s : name
123
116
  end
124
- }
117
+ }
118
+ )
125
119
  end
126
120
 
127
121
  rule keyword
@@ -893,7 +893,7 @@ module Treetop
893
893
  end
894
894
 
895
895
  module Primary1
896
- def compile(address, builder)
896
+ def compile(address, builder, parent_expression=nil)
897
897
  prefix.compile(address, builder, self)
898
898
  end
899
899
 
@@ -925,7 +925,7 @@ module Treetop
925
925
  end
926
926
 
927
927
  module Primary3
928
- def compile(address, builder)
928
+ def compile(address, builder, parent_expression=nil)
929
929
  suffix.compile(address, builder, self)
930
930
  end
931
931
 
@@ -957,7 +957,7 @@ module Treetop
957
957
  end
958
958
 
959
959
  module Primary5
960
- def compile(address, builder)
960
+ def compile(address, builder, parent_expression=nil)
961
961
  atomic.compile(address, builder, self)
962
962
  end
963
963
 
@@ -106,7 +106,7 @@ module Treetop
106
106
 
107
107
  rule primary
108
108
  prefix atomic {
109
- def compile(address, builder)
109
+ def compile(address, builder, parent_expression=nil)
110
110
  prefix.compile(address, builder, self)
111
111
  end
112
112
 
@@ -124,7 +124,7 @@ module Treetop
124
124
  }
125
125
  /
126
126
  atomic suffix node_class_declarations {
127
- def compile(address, builder)
127
+ def compile(address, builder, parent_expression=nil)
128
128
  suffix.compile(address, builder, self)
129
129
  end
130
130
 
@@ -146,7 +146,7 @@ module Treetop
146
146
  }
147
147
  /
148
148
  atomic node_class_declarations {
149
- def compile(address, builder)
149
+ def compile(address, builder, parent_expression=nil)
150
150
  atomic.compile(address, builder, self)
151
151
  end
152
152
 
@@ -0,0 +1,17 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'test_helper')
2
+
3
+ describe "An unadorned expression inside of parentheses", :extend => CompilerTestCase do
4
+ testing_expression '("foo")'
5
+
6
+ it "should behave as normal" do
7
+ parse('foo').should be_success
8
+ end
9
+ end
10
+
11
+ describe "A prefixed-expression inside of parentheses", :extend => CompilerTestCase do
12
+ testing_expression '(!"foo")'
13
+
14
+ it "should behave as normal" do
15
+ parse('foo').should_not be_success
16
+ end
17
+ end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: treetop
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.1.0
7
- date: 2007-10-25 00:00:00 -07:00
6
+ version: 1.1.1
7
+ date: 2007-11-05 00:00:00 -08:00
8
8
  summary: A Ruby-based text parsing and interpretation DSL
9
9
  require_paths:
10
10
  - lib
@@ -32,10 +32,15 @@ files:
32
32
  - README
33
33
  - Rakefile
34
34
  - test/compilation_target
35
+ - test/compiler
36
+ - test/composition
37
+ - test/parser
38
+ - test/ruby_extensions
39
+ - test/screw
40
+ - test/test_helper.rb
35
41
  - test/compilation_target/target.rb
36
42
  - test/compilation_target/target.treetop
37
43
  - test/compilation_target/target_test.rb
38
- - test/compiler
39
44
  - test/compiler/and_predicate_test.rb
40
45
  - test/compiler/anything_symbol_test.rb
41
46
  - test/compiler/character_class_test.rb
@@ -48,31 +53,27 @@ files:
48
53
  - test/compiler/not_predicate_test.rb
49
54
  - test/compiler/one_or_more_test.rb
50
55
  - test/compiler/optional_test.rb
56
+ - test/compiler/parenthesized_expression_test.rb
51
57
  - test/compiler/parsing_rule_test.rb
52
58
  - test/compiler/sequence_test.rb
53
59
  - test/compiler/terminal_symbol_test.rb
54
60
  - test/compiler/test_grammar.treetop
55
61
  - test/compiler/zero_or_more_test.rb
56
- - test/composition
57
62
  - test/composition/a.treetop
58
63
  - test/composition/b.treetop
59
64
  - test/composition/c.treetop
60
65
  - test/composition/d.treetop
61
66
  - test/composition/grammar_composition_test.rb
62
- - test/parser
63
67
  - test/parser/syntax_node_test.rb
64
68
  - test/parser/terminal_parse_failure_test.rb
65
- - test/ruby_extensions
66
69
  - test/ruby_extensions/string_test.rb
67
- - test/screw
68
70
  - test/screw/Rakefile
69
71
  - test/screw/unit
72
+ - test/screw/unit.rb
70
73
  - test/screw/unit/assertion_failed_error.rb
71
74
  - test/screw/unit/assertions.rb
72
75
  - test/screw/unit/auto_runner.rb
73
76
  - test/screw/unit/collector
74
- - test/screw/unit/collector/dir.rb
75
- - test/screw/unit/collector/objectspace.rb
76
77
  - test/screw/unit/collector.rb
77
78
  - test/screw/unit/error.rb
78
79
  - test/screw/unit/failure.rb
@@ -81,34 +82,42 @@ files:
81
82
  - test/screw/unit/test_result.rb
82
83
  - test/screw/unit/test_suite.rb
83
84
  - test/screw/unit/ui
85
+ - test/screw/unit/ui.rb
86
+ - test/screw/unit/util
87
+ - test/screw/unit/util.rb
88
+ - test/screw/unit/collector/dir.rb
89
+ - test/screw/unit/collector/objectspace.rb
84
90
  - test/screw/unit/ui/console
85
- - test/screw/unit/ui/console/test_runner.rb
86
91
  - test/screw/unit/ui/fox
87
- - test/screw/unit/ui/fox/test_runner.rb
88
92
  - test/screw/unit/ui/gtk
89
- - test/screw/unit/ui/gtk/test_runner.rb
90
93
  - test/screw/unit/ui/gtk2
91
- - test/screw/unit/ui/gtk2/testrunner.rb
92
94
  - test/screw/unit/ui/test_runner_mediator.rb
93
95
  - test/screw/unit/ui/test_runner_utilities.rb
94
96
  - test/screw/unit/ui/tk
97
+ - test/screw/unit/ui/console/test_runner.rb
98
+ - test/screw/unit/ui/fox/test_runner.rb
99
+ - test/screw/unit/ui/gtk/test_runner.rb
100
+ - test/screw/unit/ui/gtk2/testrunner.rb
95
101
  - test/screw/unit/ui/tk/test_runner.rb
96
- - test/screw/unit/ui.rb
97
- - test/screw/unit/util
98
102
  - test/screw/unit/util/backtrace_filter.rb
99
103
  - test/screw/unit/util/observable.rb
100
104
  - test/screw/unit/util/proc_wrapper.rb
101
- - test/screw/unit/util.rb
102
- - test/screw/unit.rb
103
- - test/test_helper.rb
104
105
  - lib/treetop
106
+ - lib/treetop.rb
105
107
  - lib/treetop/compiler
108
+ - lib/treetop/compiler.rb
109
+ - lib/treetop/ruby_extensions
110
+ - lib/treetop/ruby_extensions.rb
111
+ - lib/treetop/runtime
112
+ - lib/treetop/runtime.rb
106
113
  - lib/treetop/compiler/grammar_compiler.rb
107
114
  - lib/treetop/compiler/lexical_address_space.rb
108
115
  - lib/treetop/compiler/load_grammar.rb
109
116
  - lib/treetop/compiler/metagrammar.rb
110
117
  - lib/treetop/compiler/metagrammar.treetop
111
118
  - lib/treetop/compiler/node_classes
119
+ - lib/treetop/compiler/node_classes.rb
120
+ - lib/treetop/compiler/ruby_builder.rb
112
121
  - lib/treetop/compiler/node_classes/anything_symbol.rb
113
122
  - lib/treetop/compiler/node_classes/atomic_expression.rb
114
123
  - lib/treetop/compiler/node_classes/character_class.rb
@@ -126,13 +135,7 @@ files:
126
135
  - lib/treetop/compiler/node_classes/sequence.rb
127
136
  - lib/treetop/compiler/node_classes/terminal.rb
128
137
  - lib/treetop/compiler/node_classes/treetop_file.rb
129
- - lib/treetop/compiler/node_classes.rb
130
- - lib/treetop/compiler/ruby_builder.rb
131
- - lib/treetop/compiler.rb
132
- - lib/treetop/ruby_extensions
133
138
  - lib/treetop/ruby_extensions/string.rb
134
- - lib/treetop/ruby_extensions.rb
135
- - lib/treetop/runtime
136
139
  - lib/treetop/runtime/compiled_parser.rb
137
140
  - lib/treetop/runtime/node_cache.rb
138
141
  - lib/treetop/runtime/parse_cache.rb
@@ -141,10 +144,9 @@ files:
141
144
  - lib/treetop/runtime/syntax_node.rb
142
145
  - lib/treetop/runtime/terminal_parse_failure.rb
143
146
  - lib/treetop/runtime/terminal_syntax_node.rb
144
- - lib/treetop/runtime.rb
145
- - lib/treetop.rb
146
147
  - bin/tt
147
148
  - examples/lambda_calculus
149
+ - examples/TALK
148
150
  - examples/lambda_calculus/arithmetic.treetop
149
151
  - examples/lambda_calculus/arithmetic_node_classes.rb
150
152
  - examples/lambda_calculus/arithmetic_test.rb
@@ -152,7 +154,6 @@ files:
152
154
  - examples/lambda_calculus/lambda_calculus_node_classes.rb
153
155
  - examples/lambda_calculus/lambda_calculus_test.rb
154
156
  - examples/lambda_calculus/test_helper.rb
155
- - examples/TALK
156
157
  test_files: []
157
158
 
158
159
  rdoc_options: []