activefacts-cql 1.9.3 → 1.9.4
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.
- checksums.yaml +4 -4
- data/activefacts-cql.gemspec +2 -3
- data/lib/activefacts/cql/compiler.rb +1 -1
- data/lib/activefacts/cql/compiler/constraint.rb +2 -12
- data/lib/activefacts/cql/compiler/query.rb +10 -7
- data/lib/activefacts/cql/compiler/shared.rb +10 -0
- data/lib/activefacts/cql/compiler/value_type.rb +115 -6
- data/lib/activefacts/cql/parser.rb +1 -1
- data/lib/activefacts/cql/parser/CQLParser.treetop +21 -9
- data/lib/activefacts/cql/parser/Language/English.treetop +8 -2
- data/lib/activefacts/cql/parser/Language/French.treetop +6 -0
- data/lib/activefacts/cql/parser/Terms.treetop +18 -4
- data/lib/activefacts/cql/parser/ValueTypes.treetop +43 -4
- data/lib/activefacts/cql/parser/nodes.rb +18 -0
- data/lib/activefacts/cql/version.rb +1 -1
- metadata +12 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0b7e982dad70afb43fd9171c3c6cc198dd98fd06
|
|
4
|
+
data.tar.gz: af7013320edfcd4de82ad25ef640539da87b8198
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4ac31ed75cd632ec21c464b802db0ea4a9b5a06bffef119bf9736163bad1b55d67ec7be5fd03fa03cec6fd3bd1defd3ab22c1e378229c1e4127c6f109d3f5201
|
|
7
|
+
data.tar.gz: f7d592f347a8c5e556ab1107597f2db6751ac466083f9ac07100b0701e32b4805c9edc187af0a05924e561c08437303d8afa311503f5f30cf4f167896f4a7f47
|
data/activefacts-cql.gemspec
CHANGED
|
@@ -24,7 +24,6 @@ Gem::Specification.new do |spec|
|
|
|
24
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
|
25
25
|
spec.add_development_dependency "rspec", "~> 3.3"
|
|
26
26
|
|
|
27
|
-
spec.add_runtime_dependency "activefacts-metamodel", "~> 1", ">= 1.9.
|
|
28
|
-
spec.add_runtime_dependency "treetop", ["
|
|
27
|
+
spec.add_runtime_dependency "activefacts-metamodel", "~> 1", ">= 1.9.21"
|
|
28
|
+
spec.add_runtime_dependency "treetop", ["~> 1.6", ">= 1.6.9"]
|
|
29
29
|
end
|
|
30
|
-
|
|
@@ -134,7 +134,7 @@ module ActiveFacts
|
|
|
134
134
|
start_line = @string.line_of(node.interval.first)
|
|
135
135
|
end_line = @string.line_of(node.interval.last-1)
|
|
136
136
|
lines = start_line != end_line ? "s #{start_line}-#{end_line}" : " #{start_line.to_s}"
|
|
137
|
-
ne = StandardError.new("at line#{lines} #{e.message.strip}")
|
|
137
|
+
ne = StandardError.new("at line#{lines}, #{e.message.strip}")
|
|
138
138
|
ne.set_backtrace(e.backtrace)
|
|
139
139
|
raise ne
|
|
140
140
|
end
|
|
@@ -518,16 +518,6 @@ module ActiveFacts
|
|
|
518
518
|
@regular_expression = ast[:regular_expression]
|
|
519
519
|
end
|
|
520
520
|
|
|
521
|
-
def assert_value(val)
|
|
522
|
-
if val.is_a?(String)
|
|
523
|
-
@constellation.Value(eval(val), true, nil)
|
|
524
|
-
elsif val
|
|
525
|
-
@constellation.Value(val.to_s, false , nil)
|
|
526
|
-
else
|
|
527
|
-
nil
|
|
528
|
-
end
|
|
529
|
-
end
|
|
530
|
-
|
|
531
521
|
def compile
|
|
532
522
|
@constraint = @constellation.ValueConstraint(:new)
|
|
533
523
|
raise "Units on value constraints are not yet processed (at line #{'REVISIT'})" if @units
|
|
@@ -537,8 +527,8 @@ module ActiveFacts
|
|
|
537
527
|
@value_ranges.each do |range|
|
|
538
528
|
min, max = Array === range ? range : [range, range]
|
|
539
529
|
v_range = @constellation.ValueRange(
|
|
540
|
-
min && @constellation.Bound(:value =>
|
|
541
|
-
max && @constellation.Bound(:value =>
|
|
530
|
+
min && @constellation.Bound(:value => assert_literal_value(min), :is_inclusive => true),
|
|
531
|
+
max && @constellation.Bound(:value => assert_literal_value(max), :is_inclusive => true))
|
|
542
532
|
ar = @constellation.AllowedRange(@constraint, v_range)
|
|
543
533
|
end
|
|
544
534
|
else
|
|
@@ -39,13 +39,16 @@ module ActiveFacts
|
|
|
39
39
|
def build_step query, clause, roles_by_binding = {}, parent_variable = nil
|
|
40
40
|
return unless clause.refs.size > 0 # Empty clause... really?
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
# A bare object type is a valid clause, but it contains no fact type hence no step
|
|
43
|
+
if clause.fact_type
|
|
44
|
+
step = @constellation.Step(
|
|
45
|
+
query, query.all_step.size,
|
|
46
|
+
:fact_type => clause.fact_type,
|
|
47
|
+
:alternative_set => nil,
|
|
48
|
+
:is_disallowed => clause.certainty == false,
|
|
49
|
+
:is_optional => clause.certainty == nil
|
|
50
|
+
)
|
|
51
|
+
end
|
|
49
52
|
|
|
50
53
|
trace :query, "Creating Plays for #{clause.inspect} with #{clause.refs.size} refs" do
|
|
51
54
|
is_input = true
|
|
@@ -108,6 +108,16 @@ module ActiveFacts
|
|
|
108
108
|
def source
|
|
109
109
|
@tree.text_value
|
|
110
110
|
end
|
|
111
|
+
|
|
112
|
+
def assert_literal_value(val)
|
|
113
|
+
if val.is_a?(String)
|
|
114
|
+
@constellation.Value(eval(val), true, nil)
|
|
115
|
+
elsif val
|
|
116
|
+
@constellation.Value(val.to_s, false , nil)
|
|
117
|
+
else
|
|
118
|
+
nil
|
|
119
|
+
end
|
|
120
|
+
end
|
|
111
121
|
end
|
|
112
122
|
|
|
113
123
|
class Vocabulary < Definition
|
|
@@ -99,27 +99,44 @@ module ActiveFacts
|
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
def compile
|
|
102
|
-
|
|
102
|
+
ordered_parameters, named_parameters = @parameters.partition{|p| Integer === p}
|
|
103
|
+
length, scale = *ordered_parameters
|
|
103
104
|
|
|
104
105
|
# Create the base type unless it already exists:
|
|
105
106
|
base_type = nil
|
|
106
107
|
if (@base_type_name != @name)
|
|
107
108
|
unless base_type = @vocabulary.valid_value_type_name(@base_type_name)
|
|
108
109
|
base_type = @constellation.ValueType(@vocabulary, @base_type_name, :concept => :new)
|
|
109
|
-
return base_type if @base_type_name == @name
|
|
110
110
|
end
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
# Create and initialise the ValueType:
|
|
114
114
|
vt = @vocabulary.valid_value_type_name(@name) ||
|
|
115
115
|
@constellation.ValueType(@vocabulary, @name, :concept => :new)
|
|
116
|
+
|
|
117
|
+
# Apply independence:
|
|
116
118
|
vt.is_independent = true if @pragmas.delete('independent')
|
|
119
|
+
|
|
120
|
+
# Apply pragmas:
|
|
117
121
|
@pragmas.each do |p|
|
|
118
122
|
@constellation.ConceptAnnotation(:concept => vt.concept, :mapping_annotation => p)
|
|
119
123
|
end if @pragmas
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
124
|
+
|
|
125
|
+
# Apply supertype
|
|
126
|
+
if base_type and base_type != vt
|
|
127
|
+
raise "You may not change the supertype of #{vt.name} from #{vt.supertype.name} to #{base_type.name}" if vt.supertype && vt.supertype != base_type
|
|
128
|
+
vt.supertype = base_type
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# Apply ordered parameters:
|
|
132
|
+
if length
|
|
133
|
+
raise "You may not change the length of #{vt.name} from #{vt.length} to #{length}" if vt.length && vt.length != length
|
|
134
|
+
vt.length = length
|
|
135
|
+
end
|
|
136
|
+
if scale
|
|
137
|
+
raise "You may not change the scale of #{vt.name} from #{vt.scale} to #{scale}" if vt.scale && vt.scale != scale
|
|
138
|
+
vt.scale = scale
|
|
139
|
+
end
|
|
123
140
|
vt.transaction_phase = @auto_assigned_at
|
|
124
141
|
|
|
125
142
|
unless @unit.empty?
|
|
@@ -140,18 +157,110 @@ module ActiveFacts
|
|
|
140
157
|
@constellation.Derivation(unit, base_unit).exponent = exponent
|
|
141
158
|
end
|
|
142
159
|
end
|
|
160
|
+
raise "You may not change the units of #{vt.name} from #{vt.unit.describe} to #{unit.describe}" if vt.unit && vt.unit != unit
|
|
143
161
|
vt.unit = unit
|
|
144
162
|
end
|
|
145
163
|
|
|
164
|
+
# Apply a value constraint:
|
|
146
165
|
if @value_constraint
|
|
147
|
-
@value_constraint.constellation = @constellation
|
|
166
|
+
@value_constraint.constellation = @constellation # Pass constellation to the value_constraint compiler
|
|
167
|
+
raise "#{vt.name} is already constrained to #{vt.value_constraint.describe} so you can't change it to #{@value_constraint.describe}" if vt.value_constraint && vt.value_constraint != value_constraint
|
|
148
168
|
vt.value_constraint = @value_constraint.compile
|
|
149
169
|
end
|
|
150
170
|
|
|
171
|
+
# Apply a context note:
|
|
151
172
|
if @context_note
|
|
152
173
|
@context_note.compile(@constellation, vt)
|
|
153
174
|
end
|
|
154
175
|
|
|
176
|
+
# Apply named parameter (definitions, restrictions, and settings):
|
|
177
|
+
trace :vtp, "Applying named parameters for #{@name}" do
|
|
178
|
+
named_parameters.each do |(kind, vtp_name, *rest)|
|
|
179
|
+
# Look up an existing definition of the parameter:
|
|
180
|
+
vtp = nil
|
|
181
|
+
vt.supertypes_transitive.detect do |st|
|
|
182
|
+
vtp = st.all_value_type_parameter.detect{|evtp| evtp.name == vtp_name}
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
trace :vtp, "Applying #{kind} of named parameter #{vtp_name}" do
|
|
186
|
+
restrictions = nil
|
|
187
|
+
case kind
|
|
188
|
+
when :definition
|
|
189
|
+
raise "You may not redefine parameter #{vtp_name} of #{vt.name}" if vtp
|
|
190
|
+
trace :vtp, "Defining parameter #{vtp_name} for #{vt.name}" do
|
|
191
|
+
parameter_value_type_name = rest.shift.term
|
|
192
|
+
parameter_value_type = @vocabulary.valid_value_type_name(parameter_value_type_name)
|
|
193
|
+
raise "Type #{parameter_value_type_name} for parameter #{vtp_name} of #{vt.name} is not defined" unless parameter_value_type
|
|
194
|
+
vtp = @constellation.ValueTypeParameter(value_type: vt, name: vtp_name, parameter_value_type: parameter_value_type)
|
|
195
|
+
restrictions = rest[0]
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
when :restriction
|
|
199
|
+
raise "parameter #{vtp_name} of #{vt.name} is not defined" unless vtp
|
|
200
|
+
trace :vtp, "Restricting parameter #{vtp_name} for #{vt.name} to #{rest[0].inspect}"
|
|
201
|
+
restrictions = rest[0]
|
|
202
|
+
|
|
203
|
+
when :setting
|
|
204
|
+
raise "parameter #{vtp_name} of #{vt.name} is not defined" unless vtp
|
|
205
|
+
# A Setting is a single-valued restriction
|
|
206
|
+
trace :vtp, "Setting parameter #{vtp_name} for #{vt.name} to #{[rest[0]].inspect}"
|
|
207
|
+
restrictions = [rest[0]]
|
|
208
|
+
else
|
|
209
|
+
raise "AST error: unknown valuetype parameter #{kind}"
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
if restrictions && restrictions[0] == :value
|
|
213
|
+
# This is a value restriction which perhaps sets the RestrictionStyle
|
|
214
|
+
value = restrictions[1]
|
|
215
|
+
vtp.restriction_style = restrictions[2]
|
|
216
|
+
case restrictions[2]
|
|
217
|
+
when '', nil
|
|
218
|
+
restrictions = [[value, value]]
|
|
219
|
+
when 'min'
|
|
220
|
+
restrictions = [[value, nil]]
|
|
221
|
+
when 'max'
|
|
222
|
+
restrictions = [[nil, value]] # Or should it be [0, value]? But we can get that using a range...
|
|
223
|
+
end
|
|
224
|
+
trace :vtp, "Setting value for parameter #{vtp_name} for #{vt.name} to #{value.inspect} with style #{vtp.restriction_style.inspect}"
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
if restrictions
|
|
228
|
+
# Find all ValueTypeParameterRestrictions for this parameter in this type's closest restricted supertype
|
|
229
|
+
vtprs = nil
|
|
230
|
+
restricted_supertype = nil
|
|
231
|
+
vt.supertypes_transitive.detect do |st|
|
|
232
|
+
vtprs = st.all_value_type_parameter_restriction.select{|evtpr| evtpr.value_type_parameter == vtp}
|
|
233
|
+
vtprs = nil if vtprs.empty?
|
|
234
|
+
restricted_supertype = st
|
|
235
|
+
trace :vtp, "Existing #{vtp_name} restriction on #{st.name} allows #{vt.name} to use #{vtprs.map(&:value_range).inspect}" if vtprs
|
|
236
|
+
vtprs
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
if vtprs && vt == restricted_supertype
|
|
240
|
+
raise "You can't change the existing restrictions on parameter #{vtp_name} of #{vt.name}"
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
trace :vtp, "Restricting parameter #{vtp_name}#{vt != vtp.value_type ? " (of #{vtp.value_type.name})" : ''} for #{vt.name} to #{restrictions.inspect}" do
|
|
244
|
+
restrictions.each do |restriction|
|
|
245
|
+
|
|
246
|
+
min, max = Array === restriction ? restriction : [restriction, restriction]
|
|
247
|
+
value_range = @constellation.ValueRange(
|
|
248
|
+
min && @constellation.Bound(:value => assert_literal_value(min), :is_inclusive => true),
|
|
249
|
+
max && @constellation.Bound(:value => assert_literal_value(max), :is_inclusive => true)
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
# This restriction may not widen the supertype's restriction:
|
|
253
|
+
if vtprs && !vtprs.detect{|r| r.value_range.includes?(value_range)}
|
|
254
|
+
raise "#{vtp_name} of #{@name} may not be set to #{restriction} because #{vtprs[0].value_type.name} restricts it to #{vtprs.map(&:value_range).map(&:inspect)*', '}"
|
|
255
|
+
end
|
|
256
|
+
@constellation.ValueTypeParameterRestriction(value_type: vt, value_type_parameter: vtp, value_range: value_range)
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
|
|
155
264
|
vt
|
|
156
265
|
end
|
|
157
266
|
|
|
@@ -258,7 +258,7 @@ module ActiveFacts
|
|
|
258
258
|
begin
|
|
259
259
|
node = parse(InputProxy.new(input, context, self), :index => @index)
|
|
260
260
|
unless node
|
|
261
|
-
raise failure_reason unless @index == input.size
|
|
261
|
+
raise failure_reason || "not all input was understood" unless @index == input.size
|
|
262
262
|
return nil # No input, or no more input
|
|
263
263
|
end
|
|
264
264
|
if @block
|
|
@@ -54,7 +54,8 @@ module ActiveFacts
|
|
|
54
54
|
rule definition_body
|
|
55
55
|
vocabulary_definition
|
|
56
56
|
/ import_definition
|
|
57
|
-
|
|
57
|
+
# Magic here to avoid a Treetop bug with sem-preds, which require a sequence (this doesn't need to make a sequence)
|
|
58
|
+
/ '' &{|s| _nt_prescan; false } # Always fails, but its side-effects are needed in the following
|
|
58
59
|
/ constraint
|
|
59
60
|
/ unit_definition # REVISIT: Move this above the prescan?
|
|
60
61
|
/ object_type
|
|
@@ -160,23 +161,34 @@ module ActiveFacts
|
|
|
160
161
|
|
|
161
162
|
rule informal_description
|
|
162
163
|
informally s ',' s
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
signifier:when S reading:phrase+ s ',' # or a fact type
|
|
167
|
-
) s
|
|
168
|
-
text:(!(!. / '.' [ \t\r]* "\n") (string / .))* # Allow . inside a string
|
|
169
|
-
(!. / '.' [ \t\r]* "\n") # The description terminates in a fullstop at the end of a line, or EOF
|
|
164
|
+
subject:informal_description_subject s
|
|
165
|
+
informal_description_body
|
|
166
|
+
informal_description_closer
|
|
170
167
|
{
|
|
171
168
|
def ast
|
|
172
169
|
kind = subject.signifier.text_value.to_sym
|
|
173
170
|
subject_name = (kind == :each ? subject.term.text_value : subject.reading.text_value)
|
|
174
171
|
phrases = subject.reading.elements.map(&:ast) if kind == :when
|
|
175
|
-
Compiler::InformalDefinition.new(kind, subject_name, phrases,
|
|
172
|
+
Compiler::InformalDefinition.new(kind, subject_name, phrases, informal_description_body.text_value)
|
|
176
173
|
end
|
|
177
174
|
}
|
|
178
175
|
end
|
|
179
176
|
|
|
177
|
+
rule informal_description_subject
|
|
178
|
+
signifier:each S term # Informal definition of an object type
|
|
179
|
+
/
|
|
180
|
+
signifier:when S reading:phrase+ s ',' # or a fact type
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
rule informal_description_body
|
|
184
|
+
(!informal_description_closer (string / .))* # Allow . inside a string
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# The description terminates in a fullstop at the end of a line, or EOF
|
|
188
|
+
rule informal_description_closer
|
|
189
|
+
(!. / '.' [ \t\r]* "\n")
|
|
190
|
+
end
|
|
191
|
+
|
|
180
192
|
rule constraint
|
|
181
193
|
subset_constraint /
|
|
182
194
|
equality_constraint /
|
|
@@ -225,7 +225,7 @@ module ActiveFacts
|
|
|
225
225
|
|
|
226
226
|
rule agg_of of end
|
|
227
227
|
rule agg_in in end
|
|
228
|
-
rule restricted_to
|
|
228
|
+
rule restricted_to restricted s 'to' s !alphanumeric end
|
|
229
229
|
# any is optionally used in an identifying role_list
|
|
230
230
|
rule any one / a end
|
|
231
231
|
|
|
@@ -254,6 +254,7 @@ module ActiveFacts
|
|
|
254
254
|
rule some 'some' !alphanumeric end
|
|
255
255
|
|
|
256
256
|
# >>>>>>>>>>>>>>>>>>>> External vocabulary <<<<<<<<<<<<<<<<<<<<
|
|
257
|
+
rule accepts 'accepts' !alphanumeric end
|
|
257
258
|
rule according_to 'according' S to end
|
|
258
259
|
rule acyclic 'acyclic' !alphanumeric end
|
|
259
260
|
rule alias 'alias' !alphanumeric end
|
|
@@ -284,7 +285,9 @@ module ActiveFacts
|
|
|
284
285
|
rule it 'it' !alphanumeric end
|
|
285
286
|
rule its 'its' !alphanumeric end
|
|
286
287
|
rule masculine 'masculine' !alphanumeric end
|
|
288
|
+
rule max 'max' !alphanumeric end
|
|
287
289
|
rule maybe 'maybe' !alphanumeric end
|
|
290
|
+
rule min 'min' !alphanumeric end
|
|
288
291
|
rule only 'only' !alphanumeric end
|
|
289
292
|
rule or 'or' !alphanumeric end
|
|
290
293
|
rule of 'of' !alphanumeric end
|
|
@@ -294,6 +297,8 @@ module ActiveFacts
|
|
|
294
297
|
rule personal 'personal' !alphanumeric end
|
|
295
298
|
rule radix_point '.' end
|
|
296
299
|
rule reflexive 'reflexive' !alphanumeric end
|
|
300
|
+
rule restricted 'restricted' !alphanumeric end
|
|
301
|
+
rule restricts 'restricts' !alphanumeric end
|
|
297
302
|
rule returning 'returning' !alphanumeric end
|
|
298
303
|
rule schema 'schema' !alphanumeric end
|
|
299
304
|
rule separate 'separate' !alphanumeric end
|
|
@@ -312,11 +317,12 @@ module ActiveFacts
|
|
|
312
317
|
rule true 'true' !alphanumeric end
|
|
313
318
|
rule version 'version' !alphanumeric end
|
|
314
319
|
rule vocabulary 'vocabulary' !alphanumeric end
|
|
320
|
+
rule was 'was' !alphanumeric end
|
|
315
321
|
rule when 'when' !alphanumeric end
|
|
316
322
|
rule where 'where' !alphanumeric end
|
|
317
323
|
rule which 'which' !alphanumeric end
|
|
318
|
-
rule was 'was' !alphanumeric end
|
|
319
324
|
rule who 'who' !alphanumeric end
|
|
325
|
+
rule with 'with' !alphanumeric end
|
|
320
326
|
|
|
321
327
|
end
|
|
322
328
|
end
|
|
@@ -256,6 +256,7 @@ module ActiveFacts
|
|
|
256
256
|
rule according_to 'selon' !alphanumeric end
|
|
257
257
|
rule acyclic 'acyclique' !alphanumeric end
|
|
258
258
|
rule alias 'alias' !alphanumeric end
|
|
259
|
+
rule accepts 'accepte' !alphanumeric end
|
|
259
260
|
rule and 'et' !alphanumeric end
|
|
260
261
|
rule antisymmetric 'antisymmetric' !alphanumeric end
|
|
261
262
|
rule approximately 'environ' !alphanumeric end # REVISIT: google translate
|
|
@@ -282,7 +283,9 @@ module ActiveFacts
|
|
|
282
283
|
rule is est end # Called from ObjectTypes.treetop in "is identified by"
|
|
283
284
|
rule its ('sa' / 'son') !alphanumeric end
|
|
284
285
|
rule masculine 'masculin' !alphanumeric end
|
|
286
|
+
rule max 'max' !alphanumeric end
|
|
285
287
|
rule maybe 'peut-être' !alphanumeric end # REVISIT: eventuellement = possibly?
|
|
288
|
+
rule min 'min' !alphanumeric end
|
|
286
289
|
rule only 'que' !alphanumeric end # REVISIT: Used in constraints
|
|
287
290
|
rule or 'ou' !alphanumeric end
|
|
288
291
|
rule ordering_prefix by s (ascending/descending)? s end
|
|
@@ -291,6 +294,8 @@ module ActiveFacts
|
|
|
291
294
|
rule personal 'personelle' !alphanumeric end
|
|
292
295
|
rule radix_point ',' end
|
|
293
296
|
rule reflexive 'réflexive' !alphanumeric end
|
|
297
|
+
rule restricted 'limité' !alphanumeric s end
|
|
298
|
+
rule restricts 'limit' [ée] !alphanumeric s end
|
|
294
299
|
rule returning 'retour' !alphanumeric end
|
|
295
300
|
rule separate 'distincte' !alphanumeric end
|
|
296
301
|
rule schema 'schema' !alphanumeric end
|
|
@@ -312,6 +317,7 @@ module ActiveFacts
|
|
|
312
317
|
rule vocabulary 'vocabulaire' !alphanumeric end
|
|
313
318
|
rule where 'où' !alphanumeric end
|
|
314
319
|
rule who 'qui' !alphanumeric end
|
|
320
|
+
rule with 'avec' !alphanumeric end
|
|
315
321
|
|
|
316
322
|
end
|
|
317
323
|
end
|
|
@@ -31,6 +31,8 @@ module ActiveFacts
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
rule prescan
|
|
34
|
+
informally_prescan
|
|
35
|
+
/
|
|
34
36
|
s each?
|
|
35
37
|
s (
|
|
36
38
|
term_definition_name mapping_pragmas entity_prefix
|
|
@@ -50,14 +52,27 @@ module ActiveFacts
|
|
|
50
52
|
prescan_rest
|
|
51
53
|
&{|s|
|
|
52
54
|
# Wipe any terminal failures that were added:
|
|
53
|
-
|
|
54
|
-
@max_terminal_failure_index = start_index
|
|
55
|
+
forget_failures_to_here
|
|
55
56
|
|
|
56
57
|
# puts "========== prescan is complete on #{(s.map{|e|e.text_value}*" ").inspect} =========="
|
|
57
58
|
false
|
|
58
59
|
}
|
|
59
60
|
end
|
|
60
61
|
|
|
62
|
+
rule informally_prescan
|
|
63
|
+
informally s ',' s
|
|
64
|
+
informal_description_subject_prescan s
|
|
65
|
+
informal_description_body
|
|
66
|
+
informal_description_closer
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
rule informal_description_subject_prescan
|
|
70
|
+
each S term_definition_name # Informal definition of an object type
|
|
71
|
+
/
|
|
72
|
+
when S phrase+ s ',' # or a fact type; we can't forward-reference these
|
|
73
|
+
# This could memoize a bad parse for 'phrase'!!!
|
|
74
|
+
end
|
|
75
|
+
|
|
61
76
|
# Do a first-pass mainly lexical analysis, looking for role name definitions and adjectives,
|
|
62
77
|
# for use in detecting terms later.
|
|
63
78
|
rule prescan_rest
|
|
@@ -74,9 +89,8 @@ module ActiveFacts
|
|
|
74
89
|
/ id
|
|
75
90
|
# / literal # REVISIT: Literals might contain "(as Foo)" and mess things up
|
|
76
91
|
/ range # Covers all numbers and strings
|
|
77
|
-
/ comparator # handle two-character operators
|
|
78
92
|
/ S # White space and comments, must precede / and *
|
|
79
|
-
/ [
|
|
93
|
+
/ [^;] # Skip anything else, we want the prescan to finish
|
|
80
94
|
)* [?;] s
|
|
81
95
|
end
|
|
82
96
|
|
|
@@ -62,12 +62,51 @@ module ActiveFacts
|
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
rule type_parameter_list
|
|
65
|
-
head:
|
|
66
|
-
|
|
65
|
+
head:parameter s tail:( ',' s parameter s)*
|
|
66
|
+
{
|
|
67
67
|
def values
|
|
68
|
-
[head.value, *tail.elements.map{|i| i.
|
|
68
|
+
[head.value, *tail.elements.map{|i| i.parameter.value}]
|
|
69
69
|
end
|
|
70
|
-
|
|
70
|
+
}
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
rule parameter
|
|
74
|
+
number / named_parameter
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
rule ordered_parameter
|
|
78
|
+
number
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
rule named_parameter
|
|
82
|
+
( # Set the value for a parameter
|
|
83
|
+
with s parameter_name as s literal:parameter_literal
|
|
84
|
+
/
|
|
85
|
+
parameter_name ':' s literal:parameter_literal
|
|
86
|
+
) <Parser::ValueTypeParameterSetting>
|
|
87
|
+
/ # Define a new parameter
|
|
88
|
+
accepts s parameter_name as value_type:term s vr:(restricted s to s parameter_restriction)? <Parser::ValueTypeParameterDefinition>
|
|
89
|
+
/ # Restrict values for a parameter
|
|
90
|
+
restricts s parameter_name to s parameter_restriction <Parser::ValueTypeParameterRestriction>
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
rule parameter_name
|
|
94
|
+
!(with/accepts/restricts/as/term) id s
|
|
95
|
+
{ def value; id.text_value; end }
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
rule parameter_literal
|
|
99
|
+
number
|
|
100
|
+
/ # We need the text_value of a string here, not the result of parsing it
|
|
101
|
+
string { def value; text_value; end }
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
rule parameter_restriction
|
|
105
|
+
range_list s
|
|
106
|
+
{ def values; range_list.ranges; end}
|
|
107
|
+
/
|
|
108
|
+
parameter_literal s direction:(min / max)? s
|
|
109
|
+
{ def values; [:value, parameter_literal.value, direction.text_value]; end}
|
|
71
110
|
end
|
|
72
111
|
|
|
73
112
|
rule unit_definition
|
|
@@ -44,6 +44,24 @@ module ActiveFacts
|
|
|
44
44
|
:term
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
|
+
|
|
48
|
+
module ValueTypeParameterSetting
|
|
49
|
+
def value
|
|
50
|
+
[:setting, parameter_name.value, literal.value]
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
module ValueTypeParameterDefinition
|
|
55
|
+
def value
|
|
56
|
+
[:definition, parameter_name.value, value_type.ast, vr.empty? ? nil : vr.parameter_restriction.values]
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
module ValueTypeParameterRestriction
|
|
61
|
+
def value
|
|
62
|
+
[:restriction, parameter_name.value, parameter_restriction.values]
|
|
63
|
+
end
|
|
64
|
+
end
|
|
47
65
|
end
|
|
48
66
|
end
|
|
49
67
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activefacts-cql
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.9.
|
|
4
|
+
version: 1.9.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Clifford Heath
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2018-01-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -61,7 +61,7 @@ dependencies:
|
|
|
61
61
|
version: '1'
|
|
62
62
|
- - ">="
|
|
63
63
|
- !ruby/object:Gem::Version
|
|
64
|
-
version: 1.9.
|
|
64
|
+
version: 1.9.21
|
|
65
65
|
type: :runtime
|
|
66
66
|
prerelease: false
|
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -71,27 +71,27 @@ dependencies:
|
|
|
71
71
|
version: '1'
|
|
72
72
|
- - ">="
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: 1.9.
|
|
74
|
+
version: 1.9.21
|
|
75
75
|
- !ruby/object:Gem::Dependency
|
|
76
76
|
name: treetop
|
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
|
78
78
|
requirements:
|
|
79
|
-
- - ">="
|
|
80
|
-
- !ruby/object:Gem::Version
|
|
81
|
-
version: 1.4.14
|
|
82
79
|
- - "~>"
|
|
83
80
|
- !ruby/object:Gem::Version
|
|
84
|
-
version: '1.
|
|
81
|
+
version: '1.6'
|
|
82
|
+
- - ">="
|
|
83
|
+
- !ruby/object:Gem::Version
|
|
84
|
+
version: 1.6.9
|
|
85
85
|
type: :runtime
|
|
86
86
|
prerelease: false
|
|
87
87
|
version_requirements: !ruby/object:Gem::Requirement
|
|
88
88
|
requirements:
|
|
89
|
-
- - ">="
|
|
90
|
-
- !ruby/object:Gem::Version
|
|
91
|
-
version: 1.4.14
|
|
92
89
|
- - "~>"
|
|
93
90
|
- !ruby/object:Gem::Version
|
|
94
|
-
version: '1.
|
|
91
|
+
version: '1.6'
|
|
92
|
+
- - ">="
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: 1.6.9
|
|
95
95
|
description: Compiler for the Constellation Query Language, part of the ActiveFacts
|
|
96
96
|
suite for Fact Modeling
|
|
97
97
|
email:
|