activefacts-cql 1.8.2 → 1.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/activefacts/cql/compiler/clause.rb +3 -3
- data/lib/activefacts/cql/compiler/entity_type.rb +12 -3
- data/lib/activefacts/cql/parser/CQLParser.treetop +7 -2
- data/lib/activefacts/cql/parser/FactTypes.treetop +22 -9
- data/lib/activefacts/cql/parser/Language/English.treetop +2 -3
- data/lib/activefacts/cql/parser/ObjectTypes.treetop +2 -3
- data/lib/activefacts/cql/parser/ValueTypes.treetop +3 -0
- data/lib/activefacts/cql/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17b326a796d8f23d4b73ca8af114df35ae8d1cb0
|
4
|
+
data.tar.gz: 9b99bebe1d49eb09878bb3df01302f7649e58fea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15e06b8dea51d28928b9618f0b3903c6db8721a4695f5682a8d0391f5d48a88851d04e6aa7db215f97b64296e97f0a4a4ab660a549634d5632efbbb96101badf
|
7
|
+
data.tar.gz: bff64b710592ac5bf3ff9da9b1a99243da09a6dd8c613af478da0b15e363c5bfb7ef08826e4fa16573d0f23f8b63062fe2ea60287f899c9edf93da465c98add0
|
@@ -860,8 +860,8 @@ module ActiveFacts
|
|
860
860
|
end
|
861
861
|
|
862
862
|
class Reference
|
863
|
-
attr_reader :term, :
|
864
|
-
attr_accessor :leading_adjective, :trailing_adjective, :role_name
|
863
|
+
attr_reader :term, :function_call, :value_constraint, :literal, :nested_clauses
|
864
|
+
attr_accessor :quantifier, :leading_adjective, :trailing_adjective, :role_name
|
865
865
|
attr_accessor :player # What ObjectType does the Binding denote
|
866
866
|
attr_accessor :binding # What Binding for that ObjectType
|
867
867
|
attr_accessor :role # Which Role of this ObjectType
|
@@ -1105,7 +1105,7 @@ module ActiveFacts
|
|
1105
1105
|
attr_accessor :enforcement
|
1106
1106
|
attr_accessor :context_note
|
1107
1107
|
attr_accessor :pragmas
|
1108
|
-
|
1108
|
+
attr_accessor :min, :max
|
1109
1109
|
|
1110
1110
|
def initialize min, max, enforcement = nil, context_note = nil, pragmas = nil
|
1111
1111
|
@min = min
|
@@ -54,7 +54,7 @@ module ActiveFacts
|
|
54
54
|
|
55
55
|
# At this point, @identification is an array of References and/or Clauses (for unary fact types)
|
56
56
|
# Have to do this after creating the necessary fact types
|
57
|
-
complete_reference_mode_fact_type fact_types
|
57
|
+
complete_reference_mode_fact_type context, fact_types
|
58
58
|
|
59
59
|
# Find the roles to use if we have to create an identifying uniqueness constraint:
|
60
60
|
identifying_roles = bind_identifying_roles context
|
@@ -276,8 +276,17 @@ module ActiveFacts
|
|
276
276
|
@reference_mode_value_type = vt
|
277
277
|
end
|
278
278
|
|
279
|
-
def complete_reference_mode_fact_type
|
280
|
-
|
279
|
+
def complete_reference_mode_fact_type context, fact_types
|
280
|
+
identifying_type =
|
281
|
+
@reference_mode_value_type ||
|
282
|
+
begin
|
283
|
+
@identification && # There's an "identified by" clause
|
284
|
+
@identification.size == 1 && # With just one identifying role
|
285
|
+
(id = @identification[0]).is_a?(Reference) && # Which is a simple reference
|
286
|
+
@clauses.size == 0 && # No readings for this role
|
287
|
+
id.binding.player # And the player is bound already
|
288
|
+
end
|
289
|
+
return unless identifying_type
|
281
290
|
|
282
291
|
# Find an existing fact type, if any:
|
283
292
|
entity_role = identifying_role = nil
|
@@ -71,8 +71,13 @@ module ActiveFacts
|
|
71
71
|
end
|
72
72
|
|
73
73
|
rule vocabulary_name
|
74
|
-
id
|
75
|
-
{
|
74
|
+
id tail:(S id)*
|
75
|
+
{
|
76
|
+
def node_type; :vocabulary; end
|
77
|
+
def value
|
78
|
+
[id.value, *tail.elements.map{|e| e.id.value }].join(' ')
|
79
|
+
end
|
80
|
+
}
|
76
81
|
end
|
77
82
|
|
78
83
|
rule import_definition
|
@@ -16,18 +16,31 @@ module ActiveFacts
|
|
16
16
|
}
|
17
17
|
end
|
18
18
|
|
19
|
-
rule
|
20
|
-
s each?
|
21
|
-
|
22
|
-
mapping_pragmas is_where
|
19
|
+
rule fact_type
|
20
|
+
s each:(each)? # Chew the "each" or it will get accepted as a quantifier
|
21
|
+
name:(s term_definition_name mapping_pragmas is_where)? # Name of objectifying entity type
|
23
22
|
anonymous_fact_type
|
24
23
|
{
|
25
24
|
def ast
|
26
25
|
ft = anonymous_fact_type.ast
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
if !name.empty?
|
27
|
+
# "each" is often used, and doesn't imply uniqueness
|
28
|
+
ft.name = name.term_definition_name.value
|
29
|
+
pragmas = name.mapping_pragmas.value
|
30
|
+
pragmas << 'independent' if name.is_where.independent
|
31
|
+
ft.pragmas = pragmas
|
32
|
+
elsif !each.empty?
|
33
|
+
# Handle the implied mandatory constraint on the appropriate role
|
34
|
+
first_reading = ft.clauses[0]
|
35
|
+
refs = first_reading.refs
|
36
|
+
raise "Ambiguous 'each' implies mandatory on fact type of arity #{refs.size}" unless refs.size == 2
|
37
|
+
q = refs[-1].quantifier
|
38
|
+
if q
|
39
|
+
q.min = 1 # Make the existing quantifier mandatory
|
40
|
+
else
|
41
|
+
refs[-1].quantifier = q = Compiler::Quantifier.new(1, nil)
|
42
|
+
end
|
43
|
+
end
|
31
44
|
ft
|
32
45
|
end
|
33
46
|
}
|
@@ -66,7 +79,7 @@ module ActiveFacts
|
|
66
79
|
rule query_clauses
|
67
80
|
qualified_clauses
|
68
81
|
# REVISIT: This creates no precedence between and/or, which could cause confusion.
|
69
|
-
# Should disallow mixed
|
82
|
+
# Should disallow mixed conjunctions - using a sempred?
|
70
83
|
ftail:( conjunction:(',' / and / or ) s qualified_clauses s )*
|
71
84
|
{
|
72
85
|
def ast
|
@@ -167,8 +167,7 @@ module ActiveFacts
|
|
167
167
|
end
|
168
168
|
|
169
169
|
rule quantifier1
|
170
|
-
|
171
|
-
/ (some s { def value; nil; end })
|
170
|
+
(some s { def value; nil; end })
|
172
171
|
# REVISIT: "Some" means that any prior occurrence of this role player is to be ignored; this is a new occurrence
|
173
172
|
# "that" on the other hand means that this role player was *previously* designated using "some".
|
174
173
|
# These distinctions are lost here
|
@@ -308,7 +307,7 @@ module ActiveFacts
|
|
308
307
|
rule transient 'transient' !alphanumeric end
|
309
308
|
rule transitive 'transitive' !alphanumeric end
|
310
309
|
rule true 'true' !alphanumeric end
|
311
|
-
rule vocabulary 'vocabulary' !alphanumeric end
|
310
|
+
rule vocabulary ('vocabulary' / 'schema') !alphanumeric end
|
312
311
|
rule when 'when' !alphanumeric end
|
313
312
|
rule where 'where' !alphanumeric end
|
314
313
|
rule which 'which' !alphanumeric end
|
@@ -10,8 +10,7 @@ module ActiveFacts
|
|
10
10
|
rule object_type
|
11
11
|
value_type
|
12
12
|
/ entity_type
|
13
|
-
/
|
14
|
-
/ anonymous_fact_type
|
13
|
+
/ fact_type
|
15
14
|
end
|
16
15
|
|
17
16
|
rule entity_type
|
@@ -93,7 +92,7 @@ module ActiveFacts
|
|
93
92
|
end
|
94
93
|
}
|
95
94
|
/
|
96
|
-
identified_by role_list
|
95
|
+
identified_by role_list # REVISIT: We'd like to be able to use implicit_value_type_names here too.
|
97
96
|
&{|s|
|
98
97
|
role_list = s[-1]
|
99
98
|
forwards = role_list.ast.
|
@@ -44,6 +44,9 @@ module ActiveFacts
|
|
44
44
|
in S units
|
45
45
|
end
|
46
46
|
|
47
|
+
# A ValueType name that might not yet have been identified or registered as a Term
|
48
|
+
# REVISIT: We'd like to support multi-word terms here (cannot include "where", "and", or anything that could follow in the value_type definition)
|
49
|
+
# REVISIT: We'd like these to be forward-referenced ObjectTypes too, not immediately created as ValueTypes
|
47
50
|
rule implicit_value_type_name
|
48
51
|
id
|
49
52
|
{
|
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.8.
|
4
|
+
version: 1.8.3
|
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: 2017-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|