activefacts-cql 1.8.1 → 1.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile +6 -5
  4. data/activefacts-cql.gemspec +4 -3
  5. data/lib/activefacts/cql/compiler.rb +29 -22
  6. data/lib/activefacts/cql/compiler/clause.rb +86 -84
  7. data/lib/activefacts/cql/compiler/constraint.rb +53 -53
  8. data/lib/activefacts/cql/compiler/entity_type.rb +28 -28
  9. data/lib/activefacts/cql/compiler/expression.rb +27 -27
  10. data/lib/activefacts/cql/compiler/fact.rb +37 -37
  11. data/lib/activefacts/cql/compiler/fact_type.rb +91 -85
  12. data/lib/activefacts/cql/compiler/informal.rb +48 -0
  13. data/lib/activefacts/cql/compiler/query.rb +52 -52
  14. data/lib/activefacts/cql/compiler/shared.rb +17 -17
  15. data/lib/activefacts/cql/compiler/value_type.rb +11 -11
  16. data/lib/activefacts/cql/parser/CQLParser.treetop +76 -56
  17. data/lib/activefacts/cql/parser/Context.treetop +15 -17
  18. data/lib/activefacts/cql/parser/Expressions.treetop +21 -21
  19. data/lib/activefacts/cql/parser/FactTypes.treetop +216 -216
  20. data/lib/activefacts/cql/parser/Language/English.treetop +136 -131
  21. data/lib/activefacts/cql/parser/Language/French.treetop +118 -118
  22. data/lib/activefacts/cql/parser/Language/Mandarin.treetop +111 -111
  23. data/lib/activefacts/cql/parser/LexicalRules.treetop +45 -45
  24. data/lib/activefacts/cql/parser/ObjectTypes.treetop +120 -120
  25. data/lib/activefacts/cql/parser/Terms.treetop +63 -63
  26. data/lib/activefacts/cql/parser/ValueTypes.treetop +71 -71
  27. data/lib/activefacts/cql/require.rb +8 -8
  28. data/lib/activefacts/cql/verbaliser.rb +88 -88
  29. data/lib/activefacts/cql/version.rb +1 -1
  30. data/lib/activefacts/input/cql.rb +7 -7
  31. metadata +12 -16
@@ -15,12 +15,12 @@ module ActiveFacts
15
15
  end
16
16
 
17
17
  rule auto_assignment
18
- 'auto-assigned' S at s time:('assert' / 'commit') !alphanumeric s
19
- {
20
- def auto_assigned_at
21
- time.text_value
22
- end
23
- }
18
+ 'auto-assigned' S at s time:('assert' / 'commit') !alphanumeric s
19
+ {
20
+ def auto_assigned_at
21
+ time.text_value
22
+ end
23
+ }
24
24
  end
25
25
 
26
26
  # The pattern to introduce an Entity Type
@@ -43,148 +43,151 @@ module ActiveFacts
43
43
 
44
44
  # The pattern to introduce an objectified fact type with implicit identification
45
45
  rule is_where
46
- is s i:(independent s)? where
47
- { def independent; !i.empty?; end }
46
+ is s i:(independent s)? where
47
+ { def independent; !i.empty?; end }
48
48
  end
49
49
 
50
- rule in_which # Introduce an objectification step
51
- where / # Old syntax
52
- in s which # preferred syntax
50
+ rule in_which # Introduce an objectification step
51
+ where / # Old syntax
52
+ in s which # preferred syntax
53
53
  end
54
54
 
55
55
  # Units conversion keyword
56
56
  rule conversion
57
- converts s a:(approximately s)? to s
58
- {
59
- def approximate?
60
- !a.empty?
61
- end
62
- }
57
+ converts s a:(approximately s)? to s
58
+ {
59
+ def approximate?
60
+ !a.empty?
61
+ end
62
+ }
63
63
  end
64
64
 
65
65
  # >>>>>>>>>>>>>>>>>>>> Constraints <<<<<<<<<<<<<<<<<<<<
66
66
  # External presence constraint syntax:
67
67
  rule each_occurs_in_clauses
68
68
  s 'each' s ('combination' S)? role_list s occurs s quantifier s 'time' 's'? s enforcement 'in' s
69
- clauses_list s c:context_note? ';'
70
- {
71
- def role_list_ast
72
- role_list.ast
73
- end
74
- def quantifier_ast
75
- quantifier.ast
76
- end
77
- def clauses_ast
78
- clauses_list.ast
79
- end
80
- }
69
+ clauses_list s c:context_note? ';'
70
+ {
71
+ def role_list_ast
72
+ role_list.ast
73
+ end
74
+ def quantifier_ast
75
+ quantifier.ast
76
+ end
77
+ def clauses_ast
78
+ clauses_list.ast
79
+ end
80
+ }
81
81
  end
82
82
 
83
83
  # Alternate external presence constraint syntax:
84
84
  rule either_or
85
85
  s either? s r1:clauses s or s r2:clauses c:context_note? enforcement ';'
86
86
  {
87
- def role_list_ast
88
- nil
89
- end
90
- def quantifier_ast
91
- Compiler::Quantifier.new(1, nil)
92
- end
93
- def clauses_ast
94
- [r1.ast, r2.ast]
95
- end
96
- }
87
+ def role_list_ast
88
+ nil
89
+ end
90
+ def quantifier_ast
91
+ Compiler::Quantifier.new(1, nil)
92
+ end
93
+ def clauses_ast
94
+ [r1.ast, r2.ast]
95
+ end
96
+ }
97
97
  end
98
98
 
99
99
  # Exclusion (at most one) and mandatory exclusion (exactly one) constraint syntax:
100
100
  rule for_each_how_many
101
101
  s 'for' s 'each' s role_list s quantifier s 'of' s 'these' s 'holds' s enforcement ':' s
102
- clauses_list s c:context_note? ';'
103
- {
104
- def role_list_ast
105
- role_list.ast
106
- end
107
- def quantifier_ast
108
- quantifier.ast
109
- end
110
- def clauses_ast
111
- clauses_list.ast
112
- end
113
- }
102
+ clauses_list s c:context_note? ';'
103
+ {
104
+ def role_list_ast
105
+ role_list.ast
106
+ end
107
+ def quantifier_ast
108
+ quantifier.ast
109
+ end
110
+ def clauses_ast
111
+ clauses_list.ast
112
+ end
113
+ }
114
114
  end
115
115
 
116
116
  # Alternate mandatory exclusion constraint syntax:
117
117
  rule either_or_not_both
118
118
  s either? s r1:clauses s or s r2:clauses but s not s both s c:context_note? enforcement ';'
119
- {
120
- def role_list_ast
121
- nil
122
- end
123
- def quantifier_ast
124
- Compiler::Quantifier.new(1, 1)
125
- end
126
- def clauses_ast
127
- [r1.ast, r2.ast]
128
- end
129
- }
119
+ {
120
+ def role_list_ast
121
+ nil
122
+ end
123
+ def quantifier_ast
124
+ Compiler::Quantifier.new(1, 1)
125
+ end
126
+ def clauses_ast
127
+ [r1.ast, r2.ast]
128
+ end
129
+ }
130
130
  end
131
131
 
132
132
  # Subset constraint using "A only if B" syntax
133
133
  rule a_only_if_b
134
- s clauses:query_clauses s only s if s r2:query_clauses s c:context_note? enforcement ';'
134
+ s clauses:query_clauses s only s if s r2:query_clauses s c:context_note? enforcement ';'
135
135
  end
136
136
 
137
137
  rule only_if
138
- only s if s
138
+ only s if s
139
139
  end
140
140
 
141
141
  # Subset constraint using "if A then B" syntax
142
142
  rule if_b_then_a
143
- s if s clauses s then s r2:clauses s c:context_note? enforcement ';'
143
+ s if s clauses s then s r2:clauses s c:context_note? enforcement ';'
144
144
  end
145
145
 
146
146
  # Equality constraint syntax:
147
147
  rule if_and_only_if
148
148
  s clauses s tail:( if s and s only s if s clauses s)+
149
- c:context_note? enforcement ';'
149
+ c:context_note? enforcement ';'
150
150
  end
151
151
 
152
152
  # During the prescan we need to know where terms in a role list finish.
153
153
  # This rule matches any non-term expressions that may follow a role list.
154
154
  rule role_list_constraint_followers
155
- occurs s quantifier s 'time'
155
+ occurs s quantifier s 'time'
156
156
  end
157
157
 
158
158
  # >>>>>>>>>>>>>>>>>>>> Quantifiers <<<<<<<<<<<<<<<<<<<<
159
159
  rule quantifier
160
- (
161
- each s { def value; [1, nil]; end }
162
- / some s { def value; nil; end }
163
- # REVISIT: "Some" means that any prior occurrence of this role player is to be ignored; this is a new occurrence
164
- # "that" on the other hand means that this role player was *previously* designated using "some".
165
- # These distinctions are lost here
166
- / that s { def value; nil; end }
167
- / which s { def value; nil; end }
168
- / one s { def value; [1, 1]; end }
169
- / no s { def value; [0, 0]; end }
170
- / exactly s quantity { def value; q = quantity.value; [q, q]; end }
171
- / at s least s quantity most:( and s at s most s q:quantity )?
172
- { def value;
173
- [ quantity.value,
174
- most.empty? ? nil : most.q.value
175
- ]
176
- end
177
- }
178
- / at s most s quantity { def value; [ nil, quantity.value ]; end }
179
- / from s numeric_range s { def value; numeric_range.value; end }
180
- # / either_all_or_none s { def value; [ -1, 1 ]; end }
181
- )
182
- {
183
- def ast
184
- v = value
185
- Compiler::Quantifier.new(v[0], v[1])
186
- end
187
- }
160
+ quantifier1
161
+ {
162
+ def ast
163
+ v = value
164
+ Compiler::Quantifier.new(v[0], v[1])
165
+ end
166
+ }
167
+ end
168
+
169
+ rule quantifier1
170
+ (each s { def value; [1, nil]; end })
171
+ / (some s { def value; nil; end })
172
+ # REVISIT: "Some" means that any prior occurrence of this role player is to be ignored; this is a new occurrence
173
+ # "that" on the other hand means that this role player was *previously* designated using "some".
174
+ # These distinctions are lost here
175
+ / (that s { def value; nil; end })
176
+ / (which s { def value; nil; end })
177
+ / (one s { def value; [1, 1]; end })
178
+ / (no s { def value; [0, 0]; end })
179
+ / (exactly s quantity { def value; q = quantity.value; [q, q]; end })
180
+ / (at s least s quantity most:( and s at s most s q:quantity )?
181
+ { def value;
182
+ [ quantity.value,
183
+ most.empty? ? nil : most.q.value
184
+ ]
185
+ end
186
+ }
187
+ )
188
+ / (at s most s quantity { def value; [ nil, quantity.value ]; end })
189
+ / (from s numeric_range s { def value; numeric_range.value; end })
190
+ # / (either_all_or_none s { def value; [ -1, 1 ]; end })
188
191
  end
189
192
 
190
193
  # rule either_all_or_none either s all s or s ( none / no ) end
@@ -208,9 +211,9 @@ module ActiveFacts
208
211
  rule agents
209
212
  s h:agent s t:(',' s !context_type agent s)*
210
213
  {
211
- def value; [h.text_value] + t.elements.map{|e| e.agent.text_value }; end
212
- def node_type; :linking; end
213
- }
214
+ def value; [h.text_value] + t.elements.map{|e| e.agent.text_value }; end
215
+ def node_type; :linking; end
216
+ }
214
217
  end
215
218
 
216
219
  rule agent
@@ -218,11 +221,11 @@ module ActiveFacts
218
221
  end
219
222
 
220
223
  rule negative_prefix
221
- s it s is s not s the s case s that s
224
+ s it s is s not s the s case s that s
222
225
  end
223
226
 
224
- rule agg_of of end
225
- rule agg_in in end
227
+ rule agg_of of end
228
+ rule agg_in in end
226
229
  rule restricted_to 'restricted' s 'to' s !alphanumeric end
227
230
  # any is optionally used in an identifying role_list
228
231
  rule any one / a end
@@ -232,12 +235,12 @@ module ActiveFacts
232
235
  rule all 'all' !alphanumeric end
233
236
  rule ascending 'ascending' !alphanumeric end
234
237
  rule at 'at' !alphanumeric end
235
- rule both 'both' !alphanumeric end
236
- rule converts 'converts' !alphanumeric end
238
+ rule both 'both' !alphanumeric end
239
+ rule converts 'converts' !alphanumeric end
237
240
  rule descending 'descending' !alphanumeric end
238
- rule each 'each' !alphanumeric end
239
- rule either 'either' !alphanumeric end
240
- rule entity 'entity' !alphanumeric end
241
+ rule each 'each' !alphanumeric end
242
+ rule either 'either' !alphanumeric end
243
+ rule entity 'entity' !alphanumeric end
241
244
  rule exactly 'exactly' !alphanumeric end
242
245
  rule from 'from' !alphanumeric end
243
246
  rule includes 'includes' !alphanumeric end
@@ -254,61 +257,63 @@ module ActiveFacts
254
257
  # >>>>>>>>>>>>>>>>>>>> External vocabulary <<<<<<<<<<<<<<<<<<<<
255
258
  rule according_to 'according' S to end
256
259
  rule acyclic 'acyclic' !alphanumeric end
257
- rule alias 'alias' !alphanumeric end
260
+ rule alias 'alias' !alphanumeric end
258
261
  rule and 'and' !alphanumeric end
259
262
  rule antisymmetric 'antisymmetric' !alphanumeric end
260
263
  rule approximately 'approximately' !alphanumeric end
261
264
  rule as 'as' !alphanumeric end
262
- rule as_opposed_to as s 'opposed' S to end
265
+ rule as_opposed_to as s 'opposed' S to end
263
266
  rule asymmetric 'asymmetric' !alphanumeric end
264
267
  rule because 'because' !alphanumeric end
265
- rule but 'but' !alphanumeric end
266
- rule by 'by' !alphanumeric end # fix? Used in 'returning' for ordering
267
- rule case 'case' !alphanumeric end
268
+ rule but 'but' !alphanumeric end
269
+ rule by 'by' !alphanumeric end # fix? Used in 'returning' for ordering
270
+ rule case 'case' !alphanumeric end
268
271
  rule definitely 'definitely' !alphanumeric end
269
- rule ephemera 'ephemera' !alphanumeric end
270
- rule false 'false' !alphanumeric end
271
- rule feminine 'feminine' !alphanumeric end
272
- rule identified ('known'/'identified') !alphanumeric end
272
+ rule ephemera 'ephemera' !alphanumeric end
273
+ rule false 'false' !alphanumeric end
274
+ rule feminine 'feminine' !alphanumeric end
275
+ rule identified ('known'/'identified') !alphanumeric end
273
276
  rule if 'if' !alphanumeric end
274
277
  rule in 'in' !alphanumeric end
275
278
  rule import 'import' !alphanumeric end
276
- rule independent 'independent' !alphanumeric end
279
+ rule independent 'independent' !alphanumeric end
277
280
  rule stronglyintransitive 'strongly' s 'intransitive' !alphanumeric end
281
+ rule informally [Ii] 'nformally' !alphanumeric end
278
282
  rule intransitive 'intransitive' !alphanumeric end
279
283
  rule irreflexive 'irreflexive' !alphanumeric end
280
- rule is 'is' !alphanumeric end
284
+ rule is 'is' !alphanumeric end
281
285
  rule it 'it' !alphanumeric end
282
286
  rule its 'its' !alphanumeric end
283
- rule masculine 'masculine' !alphanumeric end
287
+ rule masculine 'masculine' !alphanumeric end
284
288
  rule maybe 'maybe' !alphanumeric end
285
289
  rule only 'only' !alphanumeric end
286
- rule or 'or' !alphanumeric end
287
- rule of 'of' !alphanumeric end
290
+ rule or 'or' !alphanumeric end
291
+ rule of 'of' !alphanumeric end
288
292
  rule ordering_prefix by s (ascending/descending)? s end
289
- rule otherwise 'otherwise' !alphanumeric end
290
- rule partitioned 'partitioned' !alphanumeric end
291
- rule personal 'personal' !alphanumeric end
293
+ rule otherwise 'otherwise' !alphanumeric end
294
+ rule partitioned 'partitioned' !alphanumeric end
295
+ rule personal 'personal' !alphanumeric end
292
296
  rule radix_point '.' end
293
297
  rule reflexive 'reflexive' !alphanumeric end
294
298
  rule returning 'returning' !alphanumeric end
295
- rule separate 'separate' !alphanumeric end
299
+ rule separate 'separate' !alphanumeric end
296
300
  rule so_that 'so' S that end
297
301
  rule static 'static' !alphanumeric end
298
302
  rule symmetric 'symmetric' !alphanumeric end
299
303
  rule that 'that' !alphanumeric end
300
- rule the 'the' !alphanumeric end
304
+ rule the 'the' !alphanumeric end
301
305
  rule then 'then' !alphanumeric end
302
306
  rule to 'to' !alphanumeric end
303
307
  rule to_avoid to s 'avoid' !alphanumeric end
304
308
  rule transient 'transient' !alphanumeric end
305
309
  rule transitive 'transitive' !alphanumeric end
306
- rule true 'true' !alphanumeric end
307
- rule vocabulary 'vocabulary' !alphanumeric end
308
- rule where 'where' !alphanumeric end
309
- rule which 'which' !alphanumeric end
310
- rule was 'was' !alphanumeric end
311
- rule who 'who' !alphanumeric end
310
+ rule true 'true' !alphanumeric end
311
+ rule vocabulary 'vocabulary' !alphanumeric end
312
+ rule when 'when' !alphanumeric end
313
+ rule where 'where' !alphanumeric end
314
+ rule which 'which' !alphanumeric end
315
+ rule was 'was' !alphanumeric end
316
+ rule who 'who' !alphanumeric end
312
317
 
313
318
  end
314
319
  end
@@ -12,21 +12,21 @@ module ActiveFacts
12
12
  # >>>>>>>>>>>>>>>>>>>> Object Types <<<<<<<<<<<<<<<<<<<<
13
13
  # The pattern to introduce a Value Type
14
14
  rule written_as
15
- s est s 'écrit' S 'en' s
15
+ s est s 'écrit' S 'en' s
16
16
  end
17
17
 
18
18
  rule auto_assignment
19
- 'auto-assigné' S to time:('assertion' / 'validation') !alphanumeric s
20
- {
21
- def auto_assigned_at
22
- time.text_value == 'assertion' ? 'assert' : 'commit'
23
- end
24
- }
19
+ 'auto-assigné' S to time:('assertion' / 'validation') !alphanumeric s
20
+ {
21
+ def auto_assigned_at
22
+ time.text_value == 'assertion' ? 'assert' : 'commit'
23
+ end
24
+ }
25
25
  end
26
26
 
27
27
  # The pattern to introduce an Entity Type
28
28
  rule identified_by
29
- 'identifié' s 'par' s
29
+ 'identifié' s 'par' s
30
30
  end
31
31
 
32
32
  rule basetype_expression
@@ -44,147 +44,147 @@ module ActiveFacts
44
44
 
45
45
  # The pattern to introduce an objectified fact type with implicit identification
46
46
  rule is_where
47
- existe s i:(independent s)? si
48
- { def independent; !i.empty?; end }
47
+ existe s i:(independent s)? si
48
+ { def independent; !i.empty?; end }
49
49
  end
50
50
 
51
- rule in_which # Introduce an objectification step
52
- where / # Old syntax
53
- dans s laquel # preferred syntax
51
+ rule in_which # Introduce an objectification step
52
+ where / # Old syntax
53
+ dans s laquel # preferred syntax
54
54
  end
55
55
 
56
56
  # Units conversion keyword
57
57
  rule conversion
58
- converts s a:(approximately s)? to s
59
- {
60
- def approximate?
61
- !a.empty?
62
- end
63
- }
58
+ converts s a:(approximately s)? to s
59
+ {
60
+ def approximate?
61
+ !a.empty?
62
+ end
63
+ }
64
64
  end
65
65
 
66
66
  # >>>>>>>>>>>>>>>>>>>> Constraints <<<<<<<<<<<<<<<<<<<<
67
67
  # External presence constraint syntax:
68
68
  rule each_occurs_in_clauses
69
- s chaque s ('combinaison' S)? role_list s existe s quantifier 'fois' S
70
- 'parmis' S ce S 'qui' S 'suit' s ':' s
71
- clauses_list s c:context_note? ';'
72
- {
73
- def role_list_ast
74
- role_list.ast
75
- end
76
- def quantifier_ast
77
- quantifier.ast
78
- end
79
- def clauses_ast
80
- clauses_list.ast
81
- end
82
- }
69
+ s chaque s ('combinaison' S)? role_list s existe s quantifier 'fois' S
70
+ 'parmis' S ce S 'qui' S 'suit' s ':' s
71
+ clauses_list s c:context_note? ';'
72
+ {
73
+ def role_list_ast
74
+ role_list.ast
75
+ end
76
+ def quantifier_ast
77
+ quantifier.ast
78
+ end
79
+ def clauses_ast
80
+ clauses_list.ast
81
+ end
82
+ }
83
83
  end
84
84
 
85
85
  rule either_or
86
86
  s soit s r1:clauses s 'ou' S r2:clauses
87
- s c:context_note? enforcement ';'
87
+ s c:context_note? enforcement ';'
88
88
  {
89
- def role_list_ast
90
- nil
91
- end
92
- def quantifier_ast
93
- Compiler::Quantifier.new(1, nil)
94
- end
95
- def clauses_ast
96
- [r1.ast, r2.ast]
97
- end
98
- }
89
+ def role_list_ast
90
+ nil
91
+ end
92
+ def quantifier_ast
93
+ Compiler::Quantifier.new(1, nil)
94
+ end
95
+ def clauses_ast
96
+ [r1.ast, r2.ast]
97
+ end
98
+ }
99
99
  end
100
100
 
101
101
  # Used for exclusion (at most one) and mandatory exclusion (exactly one)
102
102
  rule for_each_how_many
103
- 'pour' S 'chaque' S role_list s
104
- quantifier s 'des' S 'suivants' S 's\'applique' s ':' s
105
- clauses_list s c:context_note? ';'
106
- {
107
- def role_list_ast
108
- role_list.ast
109
- end
110
- def quantifier_ast
111
- quantifier.ast
112
- end
113
- def clauses_ast
114
- clauses_list.ast
115
- end
116
- }
103
+ 'pour' S 'chaque' S role_list s
104
+ quantifier s 'des' S 'suivants' S 's\'applique' s ':' s
105
+ clauses_list s c:context_note? ';'
106
+ {
107
+ def role_list_ast
108
+ role_list.ast
109
+ end
110
+ def quantifier_ast
111
+ quantifier.ast
112
+ end
113
+ def clauses_ast
114
+ clauses_list.ast
115
+ end
116
+ }
117
117
  end
118
118
 
119
119
  rule either_or_not_both
120
- s soit s r1:clauses s 'ou' S r2:clauses 'mais' S 'pas' S 'les' S 'deux'
121
- s c:context_note? enforcement ';'
122
- {
123
- def role_list_ast
124
- nil
125
- end
126
- def quantifier_ast
127
- Compiler::Quantifier.new(1, 1)
128
- end
129
- def clauses_ast
130
- [r1.ast, r2.ast]
131
- end
132
- }
120
+ s soit s r1:clauses s 'ou' S r2:clauses 'mais' S 'pas' S 'les' S 'deux'
121
+ s c:context_note? enforcement ';'
122
+ {
123
+ def role_list_ast
124
+ nil
125
+ end
126
+ def quantifier_ast
127
+ Compiler::Quantifier.new(1, 1)
128
+ end
129
+ def clauses_ast
130
+ [r1.ast, r2.ast]
131
+ end
132
+ }
133
133
  end
134
134
 
135
135
  rule a_only_if_b
136
- s clauses s only_if r2:clauses s c:context_note? enforcement ';'
136
+ s clauses s only_if r2:clauses s c:context_note? enforcement ';'
137
137
  end
138
138
 
139
139
  rule only_if
140
- que s si s
140
+ que s si s
141
141
  end
142
142
 
143
143
  rule if_b_then_a
144
- s 'si' S clauses s 'puis' S r2:clauses s c:context_note? enforcement ';'
144
+ s 'si' S clauses s 'puis' S r2:clauses s c:context_note? enforcement ';'
145
145
  end
146
146
 
147
147
  rule if_and_only_if
148
148
  s clauses s tail:( 'si' S 'et' S ('seulement'/'uniquement'/'que') S 'si' S clauses s)+
149
- c:context_note? enforcement ';'
149
+ c:context_note? enforcement ';'
150
150
  end
151
151
 
152
152
  # During the prescan we need to know where terms in a role list finish.
153
153
  # This rule matches any non-term expressions that may follow a role list.
154
154
  rule role_list_constraint_followers
155
- existe
155
+ existe
156
156
  end
157
157
 
158
158
  # >>>>>>>>>>>>>>>>>>>> Quantifiers <<<<<<<<<<<<<<<<<<<<
159
159
  rule quantifier
160
- (
161
- ( chaque s # "each"
162
- { def value; [1, nil]; end }
163
- / un s 'certain' 'e'? ) s # "some"
164
- { def value; nil; end }
165
- / ce s # "that"
166
- { def value; nil; end }
167
- / un s # "one"; masculine or feminine
168
- { def value; [1, 1]; end }
169
- / 'pas' s 'de' s # REVISIT: Example: "Personne n'a pas de Casier-judiciaire"
170
- { def value; [0, 0]; end }
171
- / exactement s quantity
172
- { def value; q = quantity.value; [q, q]; end }
173
- / au s moins s quantity most:( et s au s plus q:quantity )? # At least (or at most)
174
- { def value; [ quantity.value, most.empty? ? nil : most.q.value ]; end }
175
- / au s plus s quantity # At most
176
- { def value; [ nil, quantity.value ]; end }
177
- / entre s numeric_range s # within numeric_range
178
- { def value; numeric_range.value; end }
179
- / soit s tous s soit s aucun # either all or none
180
- { def value; [ -1, 1 ]; end }
181
- )
182
- {
183
- def ast
184
- v = value
185
- Compiler::Quantifier.new(v[0], v[1])
186
- end
187
- }
160
+ (
161
+ ( chaque s # "each"
162
+ { def value; [1, nil]; end }
163
+ / un s 'certain' 'e'? ) s # "some"
164
+ { def value; nil; end }
165
+ / ce s # "that"
166
+ { def value; nil; end }
167
+ / un s # "one"; masculine or feminine
168
+ { def value; [1, 1]; end }
169
+ / 'pas' s 'de' s # REVISIT: Example: "Personne n'a pas de Casier-judiciaire"
170
+ { def value; [0, 0]; end }
171
+ / exactement s quantity
172
+ { def value; q = quantity.value; [q, q]; end }
173
+ / au s moins s quantity most:( et s au s plus q:quantity )? # At least (or at most)
174
+ { def value; [ quantity.value, most.empty? ? nil : most.q.value ]; end }
175
+ / au s plus s quantity # At most
176
+ { def value; [ nil, quantity.value ]; end }
177
+ / entre s numeric_range s # within numeric_range
178
+ { def value; numeric_range.value; end }
179
+ / soit s tous s soit s aucun # either all or none
180
+ { def value; [ -1, 1 ]; end }
181
+ )
182
+ {
183
+ def ast
184
+ v = value
185
+ Compiler::Quantifier.new(v[0], v[1])
186
+ end
187
+ }
188
188
  end
189
189
 
190
190
  rule quantity
@@ -194,7 +194,7 @@ module ActiveFacts
194
194
 
195
195
  # >>>>>>>>>>>>>>>>>>>> Context Notes <<<<<<<<<<<<<<<<<<<<
196
196
  rule as_agreed_by
197
- s 'comme' S 'convenu' S d:('le' s date s)? 'par' S agents
197
+ s 'comme' S 'convenu' S d:('le' s date s)? 'par' S agents
198
198
  { def value; [ d.empty? ? nil : d.date.value, agents.value ]; end }
199
199
  end
200
200
 
@@ -206,9 +206,9 @@ module ActiveFacts
206
206
  rule agents
207
207
  s h:agent s t:(',' s !context_type agent s)*
208
208
  {
209
- def value; [h.text_value] + t.elements.map{|e| e.agent.text_value }; end
210
- def node_type; :linking; end
211
- }
209
+ def value; [h.text_value] + t.elements.map{|e| e.agent.text_value }; end
210
+ def node_type; :linking; end
211
+ }
212
212
  end
213
213
 
214
214
  rule agent
@@ -216,7 +216,7 @@ module ActiveFacts
216
216
  end
217
217
 
218
218
  rule negative_prefix
219
- s 'ce' S "n'est" s 'pas' s 'le' s 'cas' s 'que'
219
+ s 'ce' S "n'est" s 'pas' s 'le' s 'cas' s 'que'
220
220
  end
221
221
 
222
222
  rule agg_of de end
@@ -228,7 +228,7 @@ module ActiveFacts
228
228
  rule all 'tous' !alphanumeric end
229
229
  rule at 'a' !alphanumeric end
230
230
  rule both 'les deux' !alphanumeric end
231
- rule ce ('cette'/'cet'/'ce') !alphanumeric end # ce is masculine, cette feminine, cet is ce before a noun
231
+ rule ce ('cette'/'cet'/'ce') !alphanumeric end # ce is masculine, cette feminine, cet is ce before a noun
232
232
  rule chaque 'chaque' !alphanumeric end
233
233
  rule converts 'convertit' !alphanumeric end
234
234
  rule de 'de' !alphanumeric end
@@ -241,15 +241,15 @@ module ActiveFacts
241
241
  rule est 'est' !alphanumeric end
242
242
  rule exactement 'exactement' !alphanumeric end
243
243
  rule existe 'existe' !alphanumeric end
244
- rule from 'à partir de' !alphanumeric end # REVISIT: google translate
244
+ rule from 'à partir de' !alphanumeric end # REVISIT: google translate
245
245
  rule includes 'comprend' !alphanumeric end
246
246
  rule matches 'matches' !alphanumeric end
247
247
  rule moins 'moins' !alphanumeric end
248
248
  rule none 'aucun' !alphanumeric end
249
- rule not 'not' !alphanumeric end # REVISIT: Used in constraints
249
+ rule not 'not' !alphanumeric end # REVISIT: Used in constraints
250
250
  rule plus 'plus' !alphanumeric end
251
251
  rule some 'quelques' !alphanumeric end
252
- rule un 'un' 'e'? !alphanumeric end # un is masculine, une is feminine
252
+ rule un 'un' 'e'? !alphanumeric end # un is masculine, une is feminine
253
253
  rule que 'que' !alphanumeric end
254
254
 
255
255
  # >>>>>>>>>>>>>>>>>>>> External vocabulary <<<<<<<<<<<<<<<<<<<<
@@ -258,7 +258,7 @@ module ActiveFacts
258
258
  rule alias 'alias' !alphanumeric end
259
259
  rule and 'et' !alphanumeric end
260
260
  rule antisymmetric 'antisymmetric' !alphanumeric end
261
- rule approximately 'environ' !alphanumeric end # REVISIT: google translate
261
+ rule approximately 'environ' !alphanumeric end # REVISIT: google translate
262
262
  rule as 'comme' !alphanumeric end
263
263
  rule as_opposed_to 'au' S 'lieu' S 'de' !alphanumeric end
264
264
  rule asymmetric 'asymétrique' !alphanumeric end
@@ -274,16 +274,16 @@ module ActiveFacts
274
274
  rule feminine 'féminin' !alphanumeric end
275
275
  rule identified ('identifié') !alphanumeric end
276
276
  rule if 'si' !alphanumeric end
277
- rule import 'import' !alphanumeric end # REVISIT: translation?
277
+ rule import 'import' !alphanumeric end # REVISIT: translation?
278
278
  rule independent 'indépendant' !alphanumeric end
279
279
  rule stronglyintransitive 'stronglyintransitif' !alphanumeric end
280
280
  rule intransitive 'intransitif' !alphanumeric end
281
281
  rule irreflexive 'irréflexive' !alphanumeric end
282
- rule is est end # Called from ObjectTypes.treetop in "is identified by"
282
+ rule is est end # Called from ObjectTypes.treetop in "is identified by"
283
283
  rule its ('sa' / 'son') !alphanumeric end
284
284
  rule masculine 'masculin' !alphanumeric end
285
- rule maybe 'peut-être' !alphanumeric end # REVISIT: eventuellement = possibly?
286
- rule only 'que' !alphanumeric end # REVISIT: Used in constraints
285
+ rule maybe 'peut-être' !alphanumeric end # REVISIT: eventuellement = possibly?
286
+ rule only 'que' !alphanumeric end # REVISIT: Used in constraints
287
287
  rule or 'ou' !alphanumeric end
288
288
  rule ordering_prefix by s (ascending/descending)? s end
289
289
  rule otherwise 'sinon' !alphanumeric end