sexpr 0.4.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +91 -17
  3. data/Gemfile +1 -8
  4. data/README.md +26 -1
  5. data/Rakefile +0 -12
  6. data/lib/sexpr/grammar/matching.rb +9 -4
  7. data/lib/sexpr/grammar/parsing.rb +1 -1
  8. data/lib/sexpr/grammar/tagging.rb +27 -15
  9. data/lib/sexpr/matcher/many.rb +16 -1
  10. data/lib/sexpr/matcher/non_terminal.rb +31 -0
  11. data/lib/sexpr/matcher/rule.rb +3 -6
  12. data/lib/sexpr/matcher/terminal.rb +1 -1
  13. data/lib/sexpr/matcher.rb +3 -2
  14. data/lib/sexpr/node.rb +1 -1
  15. data/lib/sexpr/parser.rb +1 -1
  16. data/lib/sexpr/processor/helper.rb +1 -1
  17. data/lib/sexpr/processor/sexpr_coercions.rb +6 -14
  18. data/lib/sexpr/processor.rb +69 -21
  19. data/lib/sexpr/rewriter.rb +1 -9
  20. data/lib/sexpr/version.rb +3 -3
  21. data/lib/sexpr.rb +11 -3
  22. data/spec/fixtures/bar.rb +9 -0
  23. data/spec/fixtures/foo.rb +14 -0
  24. data/spec/fixtures/preprocessed.rb +33 -0
  25. data/spec/fixtures/simple_processor.rb +19 -0
  26. data/spec/integration/bool_expr/test_not_push.rb +38 -0
  27. data/spec/integration/bool_expr/test_parsing.rb +15 -0
  28. data/spec/integration/bool_expr/test_tagging.rb +25 -0
  29. data/spec/integration/bool_expr/test_validation.rb +15 -0
  30. data/spec/{test_readme_examples.rb → integration/test_readme_examples.rb} +4 -4
  31. data/spec/spec_helper.rb +3 -22
  32. data/spec/unit/grammar/matching/test_compile_rule.rb +55 -0
  33. data/spec/{grammar → unit/grammar}/matching/test_compile_rule_defn.rb +26 -2
  34. data/spec/unit/grammar/matching/test_compile_rules.rb +45 -0
  35. data/spec/{grammar → unit/grammar}/options/test_install_parser.rb +0 -0
  36. data/spec/{grammar → unit/grammar}/options/test_install_path.rb +0 -0
  37. data/spec/{grammar → unit/grammar}/options/test_install_root.rb +0 -0
  38. data/spec/{grammar → unit/grammar}/tagging/test_looks_a_sexpr.rb +4 -4
  39. data/spec/{grammar → unit/grammar}/tagging/test_mod2rulename.rb +0 -0
  40. data/spec/{grammar → unit/grammar}/tagging/test_rule2modname.rb +0 -0
  41. data/spec/unit/grammar/tagging/test_tag_sexpr.rb +61 -0
  42. data/spec/unit/grammar/tagging/test_tagging_module_for.rb +72 -0
  43. data/spec/{grammar → unit/grammar}/test_new.rb +0 -0
  44. data/spec/{grammar → unit/grammar}/test_parse.rb +0 -0
  45. data/spec/{grammar → unit/grammar}/test_sexpr.rb +0 -0
  46. data/spec/{matcher → unit/matcher}/alternative/test_eat.rb +1 -1
  47. data/spec/{matcher → unit/matcher}/alternative/test_match_q.rb +0 -0
  48. data/spec/{matcher → unit/matcher}/many/test_eat.rb +0 -0
  49. data/spec/{matcher → unit/matcher}/many/test_initialize.rb +0 -0
  50. data/spec/{matcher → unit/matcher}/many/test_match_q.rb +0 -0
  51. data/spec/unit/matcher/non_terminal/test_eat.rb +31 -0
  52. data/spec/unit/matcher/non_terminal/test_match_q.rb +32 -0
  53. data/spec/{matcher → unit/matcher}/reference/test_eat.rb +0 -0
  54. data/spec/{matcher → unit/matcher}/reference/test_match_q.rb +1 -1
  55. data/spec/unit/matcher/rule/test_eat.rb +17 -0
  56. data/spec/unit/matcher/rule/test_match_q.rb +17 -0
  57. data/spec/{matcher → unit/matcher}/sequence/test_eat.rb +0 -0
  58. data/spec/{matcher → unit/matcher}/sequence/test_match_q.rb +0 -0
  59. data/spec/{matcher → unit/matcher}/terminal/test_eat.rb +1 -1
  60. data/spec/{matcher → unit/matcher}/terminal/test_match_q.rb +3 -3
  61. data/spec/unit/matcher/terminal/test_terminal_match.rb +108 -0
  62. data/spec/{node → unit/node}/test_sexpr_body.rb +0 -0
  63. data/spec/{node → unit/node}/test_sexpr_copy.rb +0 -0
  64. data/spec/{node → unit/node}/test_sexpr_type.rb +0 -0
  65. data/spec/{node → unit/node}/test_tracking_markers.rb +0 -0
  66. data/spec/{parser → unit/parser}/citrus/test_new.rb +0 -0
  67. data/spec/{parser → unit/parser}/citrus/test_parse.rb +0 -0
  68. data/spec/{parser → unit/parser}/citrus/test_recognize.rb +1 -1
  69. data/spec/{parser → unit/parser}/citrus/test_registration.rb +0 -0
  70. data/spec/{parser → unit/parser}/citrus/test_to_sexpr.rb +0 -0
  71. data/spec/{parser → unit/parser}/test_factor.rb +0 -0
  72. data/spec/{parser → unit/parser}/test_input_text.rb +0 -0
  73. data/spec/{processor → unit/processor}/helper/test_call.rb +0 -0
  74. data/spec/unit/processor/test_apply.rb +34 -0
  75. data/spec/{processor → unit/processor}/test_build_helper_chain.rb +0 -0
  76. data/spec/unit/processor/test_call.rb +47 -0
  77. data/spec/unit/processor/test_grammar.rb +56 -0
  78. data/spec/{processor → unit/processor}/test_helper.rb +0 -0
  79. data/spec/{processor → unit/processor}/test_sexpr_coercions.rb +6 -2
  80. data/spec/unit/processor/test_use.rb +22 -0
  81. data/spec/{rewriter → unit/rewriter}/test_copy_and_apply.rb +0 -0
  82. data/spec/{test_load.rb → unit/test_load.rb} +3 -2
  83. data/spec/{test_rewriter.rb → unit/test_rewriter.rb} +0 -0
  84. data/spec/unit/test_sexpr.rb +8 -0
  85. data/tasks/gem.rake +9 -4
  86. data/tasks/test.rake +11 -0
  87. metadata +126 -183
  88. data/Gemfile.lock +0 -27
  89. data/LICENCE.md +0 -22
  90. data/Manifest.txt +0 -16
  91. data/examples/bool_expr/bool_expr.citrus +0 -72
  92. data/examples/bool_expr/bool_expr.rb +0 -153
  93. data/examples/bool_expr/bool_expr.sexp.yml +0 -23
  94. data/lib/sexpr/loader.rb +0 -0
  95. data/sexpr.gemspec +0 -189
  96. data/sexpr.noespec +0 -26
  97. data/spec/grammar/matching/test_compile_rule.rb +0 -23
  98. data/spec/grammar/tagging/test_tag_sexpr.rb +0 -28
  99. data/spec/grammar.yml +0 -24
  100. data/spec/matcher/rule/test_eat.rb +0 -21
  101. data/spec/matcher/rule/test_match_q.rb +0 -24
  102. data/spec/matcher/terminal/test_terminal_match.rb +0 -89
  103. data/spec/processor/test_call.rb +0 -46
  104. data/spec/processor/test_main_processor.rb +0 -18
  105. data/spec/test_sexpr.rb +0 -8
  106. data/tasks/debug_mail.rake +0 -75
  107. data/tasks/debug_mail.txt +0 -13
  108. data/tasks/spec_test.rake +0 -71
  109. data/tasks/unit_test.rake +0 -76
  110. data/tasks/yard.rake +0 -51
metadata CHANGED
@@ -1,249 +1,192 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sexpr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Bernard Lambeau
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-02-23 00:00:00.000000000Z
11
+ date: 2021-12-11 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: epath
16
- requirement: &84257100 !ruby/object:Gem::Requirement
17
- none: false
14
+ name: path
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: 0.0.1
19
+ version: '1.3'
22
20
  type: :development
23
21
  prerelease: false
24
- version_requirements: *84257100
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: citrus
27
- requirement: &84256730 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ~>
31
+ - - "~>"
31
32
  - !ruby/object:Gem::Version
32
- version: '2.4'
33
+ version: '3.0'
33
34
  type: :development
34
35
  prerelease: false
35
- version_requirements: *84256730
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: rake
38
- requirement: &84256430 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
- - - ~>
45
+ - - "~>"
42
46
  - !ruby/object:Gem::Version
43
- version: 0.9.2
47
+ version: '13.0'
44
48
  type: :development
45
49
  prerelease: false
46
- version_requirements: *84256430
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '13.0'
47
55
  - !ruby/object:Gem::Dependency
48
56
  name: rspec
49
- requirement: &84256090 !ruby/object:Gem::Requirement
50
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
51
58
  requirements:
52
- - - ~>
59
+ - - "~>"
53
60
  - !ruby/object:Gem::Version
54
- version: 2.8.0
61
+ version: '3.10'
55
62
  type: :development
56
63
  prerelease: false
57
- version_requirements: *84256090
58
- - !ruby/object:Gem::Dependency
59
- name: wlang
60
- requirement: &84255790 !ruby/object:Gem::Requirement
61
- none: false
64
+ version_requirements: !ruby/object:Gem::Requirement
62
65
  requirements:
63
- - - ~>
66
+ - - "~>"
64
67
  - !ruby/object:Gem::Version
65
- version: 0.10.2
66
- type: :development
67
- prerelease: false
68
- version_requirements: *84255790
68
+ version: '3.10'
69
69
  description: Sexpr helps manipulating s-expressions in ruby.
70
70
  email:
71
71
  - blambeau@gmail.com
72
72
  executables: []
73
73
  extensions: []
74
- extra_rdoc_files:
75
- - README.md
76
- - CHANGELOG.md
77
- - LICENCE.md
74
+ extra_rdoc_files: []
78
75
  files:
79
- - sexpr.gemspec
80
- - sexpr.noespec
81
76
  - CHANGELOG.md
82
77
  - Gemfile
83
- - Gemfile.lock
84
- - examples/bool_expr/bool_expr.rb
85
- - examples/bool_expr/bool_expr.citrus
86
- - examples/bool_expr/bool_expr.sexp.yml
78
+ - README.md
79
+ - Rakefile
87
80
  - lib/sexpr.rb
88
- - lib/sexpr/matcher/terminal.rb
89
- - lib/sexpr/matcher/rule.rb
81
+ - lib/sexpr/errors.rb
82
+ - lib/sexpr/grammar.rb
83
+ - lib/sexpr/grammar/matching.rb
84
+ - lib/sexpr/grammar/options.rb
85
+ - lib/sexpr/grammar/parsing.rb
86
+ - lib/sexpr/grammar/tagging.rb
87
+ - lib/sexpr/matcher.rb
90
88
  - lib/sexpr/matcher/alternative.rb
91
- - lib/sexpr/matcher/sequence.rb
92
- - lib/sexpr/matcher/reference.rb
93
89
  - lib/sexpr/matcher/many.rb
94
- - lib/sexpr/rewriter.rb
95
- - lib/sexpr/grammar.rb
90
+ - lib/sexpr/matcher/non_terminal.rb
91
+ - lib/sexpr/matcher/reference.rb
92
+ - lib/sexpr/matcher/rule.rb
93
+ - lib/sexpr/matcher/sequence.rb
94
+ - lib/sexpr/matcher/terminal.rb
96
95
  - lib/sexpr/node.rb
97
- - lib/sexpr/processor/sexpr_coercions.rb
98
- - lib/sexpr/processor/helper.rb
99
- - lib/sexpr/processor/null_helper.rb
100
- - lib/sexpr/processor.rb
96
+ - lib/sexpr/parser.rb
101
97
  - lib/sexpr/parser/citrus.rb
102
98
  - lib/sexpr/parser/ext.rb
103
- - lib/sexpr/errors.rb
104
- - lib/sexpr/loader.rb
105
- - lib/sexpr/grammar/parsing.rb
106
- - lib/sexpr/grammar/tagging.rb
107
- - lib/sexpr/grammar/options.rb
108
- - lib/sexpr/grammar/matching.rb
109
- - lib/sexpr/parser.rb
110
- - lib/sexpr/matcher.rb
99
+ - lib/sexpr/processor.rb
100
+ - lib/sexpr/processor/helper.rb
101
+ - lib/sexpr/processor/null_helper.rb
102
+ - lib/sexpr/processor/sexpr_coercions.rb
103
+ - lib/sexpr/rewriter.rb
111
104
  - lib/sexpr/version.rb
112
- - LICENCE.md
113
- - Manifest.txt
114
- - Rakefile
115
- - README.md
105
+ - spec/fixtures/bar.rb
106
+ - spec/fixtures/foo.rb
107
+ - spec/fixtures/preprocessed.rb
108
+ - spec/fixtures/simple_processor.rb
109
+ - spec/integration/bool_expr/test_not_push.rb
110
+ - spec/integration/bool_expr/test_parsing.rb
111
+ - spec/integration/bool_expr/test_tagging.rb
112
+ - spec/integration/bool_expr/test_validation.rb
113
+ - spec/integration/test_readme_examples.rb
116
114
  - spec/spec_helper.rb
117
- - spec/matcher/reference/test_eat.rb
118
- - spec/matcher/reference/test_match_q.rb
119
- - spec/matcher/rule/test_eat.rb
120
- - spec/matcher/rule/test_match_q.rb
121
- - spec/matcher/many/test_eat.rb
122
- - spec/matcher/many/test_initialize.rb
123
- - spec/matcher/many/test_match_q.rb
124
- - spec/matcher/sequence/test_eat.rb
125
- - spec/matcher/sequence/test_match_q.rb
126
- - spec/matcher/terminal/test_eat.rb
127
- - spec/matcher/terminal/test_terminal_match.rb
128
- - spec/matcher/terminal/test_match_q.rb
129
- - spec/matcher/alternative/test_eat.rb
130
- - spec/matcher/alternative/test_match_q.rb
131
- - spec/rewriter/test_copy_and_apply.rb
132
- - spec/processor/test_helper.rb
133
- - spec/processor/test_sexpr_coercions.rb
134
- - spec/processor/test_main_processor.rb
135
- - spec/processor/test_build_helper_chain.rb
136
- - spec/processor/test_call.rb
137
- - spec/processor/helper/test_call.rb
138
- - spec/test_rewriter.rb
139
- - spec/grammar.yml
140
- - spec/parser/citrus/test_new.rb
141
- - spec/parser/citrus/test_registration.rb
142
- - spec/parser/citrus/test_parse.rb
143
- - spec/parser/citrus/test_to_sexpr.rb
144
- - spec/parser/citrus/test_recognize.rb
145
- - spec/parser/test_factor.rb
146
- - spec/parser/test_input_text.rb
147
- - spec/test_sexpr.rb
148
- - spec/test_load.rb
149
- - spec/grammar/test_new.rb
150
- - spec/grammar/tagging/test_mod2rulename.rb
151
- - spec/grammar/tagging/test_rule2modname.rb
152
- - spec/grammar/tagging/test_looks_a_sexpr.rb
153
- - spec/grammar/tagging/test_tag_sexpr.rb
154
- - spec/grammar/test_sexpr.rb
155
- - spec/grammar/options/test_install_root.rb
156
- - spec/grammar/options/test_install_parser.rb
157
- - spec/grammar/options/test_install_path.rb
158
- - spec/grammar/test_parse.rb
159
- - spec/grammar/matching/test_compile_rule.rb
160
- - spec/grammar/matching/test_compile_rule_defn.rb
161
- - spec/node/test_tracking_markers.rb
162
- - spec/node/test_sexpr_copy.rb
163
- - spec/node/test_sexpr_body.rb
164
- - spec/node/test_sexpr_type.rb
165
- - spec/test_readme_examples.rb
166
- - tasks/debug_mail.rake
167
- - tasks/yard.rake
115
+ - spec/unit/grammar/matching/test_compile_rule.rb
116
+ - spec/unit/grammar/matching/test_compile_rule_defn.rb
117
+ - spec/unit/grammar/matching/test_compile_rules.rb
118
+ - spec/unit/grammar/options/test_install_parser.rb
119
+ - spec/unit/grammar/options/test_install_path.rb
120
+ - spec/unit/grammar/options/test_install_root.rb
121
+ - spec/unit/grammar/tagging/test_looks_a_sexpr.rb
122
+ - spec/unit/grammar/tagging/test_mod2rulename.rb
123
+ - spec/unit/grammar/tagging/test_rule2modname.rb
124
+ - spec/unit/grammar/tagging/test_tag_sexpr.rb
125
+ - spec/unit/grammar/tagging/test_tagging_module_for.rb
126
+ - spec/unit/grammar/test_new.rb
127
+ - spec/unit/grammar/test_parse.rb
128
+ - spec/unit/grammar/test_sexpr.rb
129
+ - spec/unit/matcher/alternative/test_eat.rb
130
+ - spec/unit/matcher/alternative/test_match_q.rb
131
+ - spec/unit/matcher/many/test_eat.rb
132
+ - spec/unit/matcher/many/test_initialize.rb
133
+ - spec/unit/matcher/many/test_match_q.rb
134
+ - spec/unit/matcher/non_terminal/test_eat.rb
135
+ - spec/unit/matcher/non_terminal/test_match_q.rb
136
+ - spec/unit/matcher/reference/test_eat.rb
137
+ - spec/unit/matcher/reference/test_match_q.rb
138
+ - spec/unit/matcher/rule/test_eat.rb
139
+ - spec/unit/matcher/rule/test_match_q.rb
140
+ - spec/unit/matcher/sequence/test_eat.rb
141
+ - spec/unit/matcher/sequence/test_match_q.rb
142
+ - spec/unit/matcher/terminal/test_eat.rb
143
+ - spec/unit/matcher/terminal/test_match_q.rb
144
+ - spec/unit/matcher/terminal/test_terminal_match.rb
145
+ - spec/unit/node/test_sexpr_body.rb
146
+ - spec/unit/node/test_sexpr_copy.rb
147
+ - spec/unit/node/test_sexpr_type.rb
148
+ - spec/unit/node/test_tracking_markers.rb
149
+ - spec/unit/parser/citrus/test_new.rb
150
+ - spec/unit/parser/citrus/test_parse.rb
151
+ - spec/unit/parser/citrus/test_recognize.rb
152
+ - spec/unit/parser/citrus/test_registration.rb
153
+ - spec/unit/parser/citrus/test_to_sexpr.rb
154
+ - spec/unit/parser/test_factor.rb
155
+ - spec/unit/parser/test_input_text.rb
156
+ - spec/unit/processor/helper/test_call.rb
157
+ - spec/unit/processor/test_apply.rb
158
+ - spec/unit/processor/test_build_helper_chain.rb
159
+ - spec/unit/processor/test_call.rb
160
+ - spec/unit/processor/test_grammar.rb
161
+ - spec/unit/processor/test_helper.rb
162
+ - spec/unit/processor/test_sexpr_coercions.rb
163
+ - spec/unit/processor/test_use.rb
164
+ - spec/unit/rewriter/test_copy_and_apply.rb
165
+ - spec/unit/test_load.rb
166
+ - spec/unit/test_rewriter.rb
167
+ - spec/unit/test_sexpr.rb
168
168
  - tasks/gem.rake
169
- - tasks/spec_test.rake
170
- - tasks/unit_test.rake
171
- - tasks/debug_mail.txt
169
+ - tasks/test.rake
172
170
  homepage: https://github.com/blambeau/sexp
173
171
  licenses: []
174
- post_install_message:
172
+ metadata: {}
173
+ post_install_message:
175
174
  rdoc_options: []
176
175
  require_paths:
177
176
  - lib
178
177
  required_ruby_version: !ruby/object:Gem::Requirement
179
- none: false
180
178
  requirements:
181
- - - ! '>='
179
+ - - ">="
182
180
  - !ruby/object:Gem::Version
183
181
  version: '0'
184
- segments:
185
- - 0
186
- hash: -185808739
187
182
  required_rubygems_version: !ruby/object:Gem::Requirement
188
- none: false
189
183
  requirements:
190
- - - ! '>='
184
+ - - ">="
191
185
  - !ruby/object:Gem::Version
192
186
  version: '0'
193
187
  requirements: []
194
- rubyforge_project:
195
- rubygems_version: 1.8.15
196
- signing_key:
197
- specification_version: 3
188
+ rubygems_version: 3.1.4
189
+ signing_key:
190
+ specification_version: 4
198
191
  summary: A compilation framework around s-expressions
199
- test_files:
200
- - spec/spec_helper.rb
201
- - spec/matcher/reference/test_eat.rb
202
- - spec/matcher/reference/test_match_q.rb
203
- - spec/matcher/rule/test_eat.rb
204
- - spec/matcher/rule/test_match_q.rb
205
- - spec/matcher/many/test_eat.rb
206
- - spec/matcher/many/test_initialize.rb
207
- - spec/matcher/many/test_match_q.rb
208
- - spec/matcher/sequence/test_eat.rb
209
- - spec/matcher/sequence/test_match_q.rb
210
- - spec/matcher/terminal/test_eat.rb
211
- - spec/matcher/terminal/test_terminal_match.rb
212
- - spec/matcher/terminal/test_match_q.rb
213
- - spec/matcher/alternative/test_eat.rb
214
- - spec/matcher/alternative/test_match_q.rb
215
- - spec/rewriter/test_copy_and_apply.rb
216
- - spec/processor/test_helper.rb
217
- - spec/processor/test_sexpr_coercions.rb
218
- - spec/processor/test_main_processor.rb
219
- - spec/processor/test_build_helper_chain.rb
220
- - spec/processor/test_call.rb
221
- - spec/processor/helper/test_call.rb
222
- - spec/test_rewriter.rb
223
- - spec/grammar.yml
224
- - spec/parser/citrus/test_new.rb
225
- - spec/parser/citrus/test_registration.rb
226
- - spec/parser/citrus/test_parse.rb
227
- - spec/parser/citrus/test_to_sexpr.rb
228
- - spec/parser/citrus/test_recognize.rb
229
- - spec/parser/test_factor.rb
230
- - spec/parser/test_input_text.rb
231
- - spec/test_sexpr.rb
232
- - spec/test_load.rb
233
- - spec/grammar/test_new.rb
234
- - spec/grammar/tagging/test_mod2rulename.rb
235
- - spec/grammar/tagging/test_rule2modname.rb
236
- - spec/grammar/tagging/test_looks_a_sexpr.rb
237
- - spec/grammar/tagging/test_tag_sexpr.rb
238
- - spec/grammar/test_sexpr.rb
239
- - spec/grammar/options/test_install_root.rb
240
- - spec/grammar/options/test_install_parser.rb
241
- - spec/grammar/options/test_install_path.rb
242
- - spec/grammar/test_parse.rb
243
- - spec/grammar/matching/test_compile_rule.rb
244
- - spec/grammar/matching/test_compile_rule_defn.rb
245
- - spec/node/test_tracking_markers.rb
246
- - spec/node/test_sexpr_copy.rb
247
- - spec/node/test_sexpr_body.rb
248
- - spec/node/test_sexpr_type.rb
249
- - spec/test_readme_examples.rb
192
+ test_files: []
data/Gemfile.lock DELETED
@@ -1,27 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- citrus (2.4.1)
5
- diff-lcs (1.1.3)
6
- epath (0.0.1)
7
- rake (0.9.2.2)
8
- rspec (2.8.0)
9
- rspec-core (~> 2.8.0)
10
- rspec-expectations (~> 2.8.0)
11
- rspec-mocks (~> 2.8.0)
12
- rspec-core (2.8.0)
13
- rspec-expectations (2.8.0)
14
- diff-lcs (~> 1.1.2)
15
- rspec-mocks (2.8.0)
16
- wlang (0.10.2)
17
-
18
- PLATFORMS
19
- java
20
- ruby
21
-
22
- DEPENDENCIES
23
- citrus (~> 2.4)
24
- epath (~> 0.0.1)
25
- rake (~> 0.9.2)
26
- rspec (~> 2.8.0)
27
- wlang (~> 0.10.2)
data/LICENCE.md DELETED
@@ -1,22 +0,0 @@
1
- # The MIT Licence
2
-
3
- Copyright (c) 2012 - Bernard Lambeau
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt DELETED
@@ -1,16 +0,0 @@
1
- sexpr.gemspec
2
- sexpr.noespec
3
- .gemtest
4
- CHANGELOG.md
5
- Gemfile
6
- Gemfile.lock
7
- bin/**/*
8
- examples/**/*
9
- lib/**/*
10
- LICENCE.md
11
- Manifest.txt
12
- Rakefile
13
- README.md
14
- spec/**/*
15
- tasks/**/*
16
- test/**/*
@@ -1,72 +0,0 @@
1
- #
2
- # This is a Citrus grammar for boolean expressions.
3
- #
4
- # The parser is automatically loaded under the BoolExpr::Parser constant by Citrus
5
- # itself. It is also automatically registered under BoolExpr::Grammar.parser by
6
- # `Sexpr.load` when invoked on the bool_expr.sexp.yml file.
7
- #
8
- # The coupon codes returns s-expressions that correctly refer to the abstract grammar
9
- # definition in that file (AST).
10
- #
11
- grammar BoolExpr::Parser
12
-
13
- rule bool_expr
14
- bool_or
15
- end
16
-
17
- rule bool_or
18
- (l:bool_and spaces 'or' spaces r:bool_or){
19
- [:bool_or, l.sexpr, r.sexpr]
20
- }
21
- | bool_and
22
- end
23
-
24
- rule bool_and
25
- (l:bool_not spaces 'and' spaces r:bool_and){
26
- [:bool_and, l.sexpr, r.sexpr]
27
- }
28
- | bool_not
29
- end
30
-
31
- rule bool_not
32
- ('not' spacing e:bool_not){
33
- [:bool_not, e.sexpr]
34
- }
35
- | bool_term
36
- end
37
-
38
- rule bool_term
39
- bool_paren | bool_lit | var_ref
40
- end
41
-
42
- rule bool_paren
43
- ('(' spacing e:bool_or spacing ')'){
44
- e.sexpr
45
- }
46
- end
47
-
48
- rule bool_lit
49
- ("true" | "false"){
50
- [:bool_lit, ::Kernel.eval(strip) ]
51
- }
52
- end
53
-
54
- rule var_ref
55
- (!(keyword (spaces | !.)) [a-z]+){
56
- [:var_ref, strip]
57
- }
58
- end
59
-
60
- rule spacing
61
- [ \t]*
62
- end
63
-
64
- rule spaces
65
- [ \t]+
66
- end
67
-
68
- rule keyword
69
- "true" | "false" | "or" | "and" | "not"
70
- end
71
-
72
- end
@@ -1,153 +0,0 @@
1
- require 'sexpr'
2
- require 'citrus'
3
-
4
- # Let load the grammar from the .yml definition file.
5
- BoolExpr = Sexpr.load File.expand_path('../bool_expr.sexp.yml', __FILE__)
6
-
7
- # A Sexpr grammar is simply a module. Ruby allows us to re-open it later.
8
- module BoolExpr
9
-
10
- # These are the modules automatically installed on the s-expressions
11
- # that the grammar produces
12
- module And; end
13
- module Or; end
14
- module Not; end
15
- module Lit; end
16
- module VarRef; end
17
-
18
- # The two following methods allows converting rule names (e.g. bool_and)
19
- # to module names (And). A default implementation is provided by Sexpr
20
- # that enforces convention over configuration (BoolAnd <-> bool_and). We
21
- # override the methods here for the sake of the example/documentation.
22
-
23
- def rule2modname(rule)
24
- (rule.to_s =~ /^bool_(.*)$/) ? $1.capitalize.to_sym : super
25
- end
26
-
27
- def mod2rulename(mod)
28
- rule = super
29
- (rule.to_s =~ /^bool_(.*)$/) ? const_get($1.to_sym) : rule
30
- end
31
-
32
- # This class pushes `[:not, ...]` as far as possible in boolean expressions.
33
- # It provides an example of s-expression rewriter
34
- class NotPushProcessor < Sexpr::Rewriter
35
-
36
- # Let the default implementation know that we are working on the BoolExpr
37
- # grammar. This way, all rewriting results will automatically be tagged
38
- # with the correct modules above (And, Not, ...)
39
- grammar BoolExpr
40
-
41
- # The main rewriting rule, that pushes a NOT according to the different
42
- # cases
43
- def on_bool_not(sexpr)
44
- case expr = sexpr.last
45
- when And then call [:bool_or, [:bool_not, expr[1]], [:bool_not, expr[2]] ]
46
- when Or then call [:bool_and, [:bool_not, expr[1]], [:bool_not, expr[2]] ]
47
- when Not then call expr.last
48
- when Lit then [:bool_lit, !expr.last]
49
- else
50
- sexpr
51
- end
52
- end
53
-
54
- # By default, we simply copy the node and apply rewriting rules on children
55
- alias :on_missing :copy_and_apply
56
-
57
- end # class NotPushProcessor
58
-
59
- end # module BoolExpr
60
-
61
- describe BoolExpr do
62
- subject{ BoolExpr }
63
-
64
- describe "the parsing feature" do
65
-
66
- it 'parses boolean expressions without error' do
67
- subject.parse("x and y").should be_a(Citrus::Match)
68
- subject.parse("not(y)").should be_a(Citrus::Match)
69
- subject.parse("not(true)").should be_a(Citrus::Match)
70
- end
71
-
72
- it 'provides a shortcut to get s-expressions directly' do
73
- subject.sexpr("x and y").should eq([:bool_and, [:var_ref, "x"], [:var_ref, "y"]])
74
- end
75
-
76
- end # parsing
77
-
78
- describe "the tagging feature" do
79
-
80
- it 'tags parsing results with the Sexpr module' do
81
- sexpr = subject.sexpr("x and y")
82
- sexpr.should be_a(Sexpr)
83
- sexpr.sexpr_type.should eq(:bool_and)
84
- sexpr.sexpr_body.should eq([[:var_ref, "x"], [:var_ref, "y"]])
85
- end
86
-
87
- it 'tags parsing results with user modules' do
88
- subject.sexpr("x and y").should be_a(BoolExpr::And)
89
- end
90
-
91
- it 'allows tagging manually' do
92
- subject.sexpr([:bool_lit, true]).should be_a(BoolExpr::Lit)
93
- end
94
-
95
- it 'applies tagging recursively' do
96
- sexpr = subject.sexpr([:bool_not, [:bool_lit, true]])
97
- sexpr.last.should be_a(BoolExpr::Lit)
98
- end
99
-
100
- end # taggging
101
-
102
- describe 'the validation feature' do
103
-
104
- it 'validates s-expressions' do
105
- subject.match?([:bool_lit, true]).should be_true
106
- subject.match?([:bool_lit, "x"]).should be_false
107
- end
108
-
109
- it 'validates s-expressions against specific rules' do
110
- subject[:bool_lit].match?([:bool_lit, true]).should be_true
111
- subject[:bool_and].match?([:bool_lit, true]).should be_false
112
- end
113
-
114
- end # validating
115
-
116
- describe BoolExpr::NotPushProcessor do
117
-
118
- def _(expr)
119
- BoolExpr.sexpr(expr)
120
- end
121
-
122
- def rw(expr)
123
- BoolExpr::NotPushProcessor.new.call(expr)
124
- end
125
-
126
- it 'does nothing on variable references' do
127
- rw("not x").should eq([:bool_not, [:var_ref, "x"]])
128
- end
129
-
130
- it 'rewrites literals through negating them' do
131
- rw("not true").should eq(_ "false")
132
- rw("not false").should eq(_ "true")
133
- end
134
-
135
- it 'rewrites not through removing them' do
136
- rw("not not true").should eq(_ "true")
137
- end
138
-
139
- it 'rewrites or through and of negated terms' do
140
- rw("not(x or y)").should eq(_ "not(x) and not(y)")
141
- end
142
-
143
- it 'rewrites and through or of negated terms' do
144
- rw("not(x and y)").should eq(_ "not(x) or not(y)")
145
- end
146
-
147
- it 'rewrites recursively' do
148
- rw("not(x and not(y))").should eq(_ "not(x) or y")
149
- end
150
-
151
- end # rewriting
152
-
153
- end if defined?(RSpec)