activefacts 1.6.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +14 -0
- data/LICENSE.txt +21 -0
- data/README.md +60 -0
- data/Rakefile +3 -80
- data/activefacts.gemspec +36 -0
- data/bin/afgen +4 -2
- data/bin/cql +5 -1
- data/lib/activefacts.rb +3 -12
- data/lib/activefacts/{vocabulary/query_evaluator.rb → query/evaluator.rb} +0 -0
- data/lib/activefacts/version.rb +2 -2
- metadata +48 -296
- data/History.txt +0 -4
- data/LICENSE +0 -19
- data/Manifest.txt +0 -165
- data/README.rdoc +0 -81
- data/css/offline.css +0 -3
- data/css/orm2.css +0 -124
- data/css/print.css +0 -8
- data/css/style-print.css +0 -357
- data/css/style.css +0 -387
- data/download.html +0 -110
- data/examples/CQL/Address.cql +0 -44
- data/examples/CQL/Blog.cql +0 -54
- data/examples/CQL/CompanyDirectorEmployee.cql +0 -56
- data/examples/CQL/Death.cql +0 -17
- data/examples/CQL/Diplomacy.cql +0 -48
- data/examples/CQL/Genealogy.cql +0 -98
- data/examples/CQL/Insurance.cql +0 -320
- data/examples/CQL/Marriage.cql +0 -18
- data/examples/CQL/Metamodel.cql +0 -493
- data/examples/CQL/Monogamy.cql +0 -24
- data/examples/CQL/MultiInheritance.cql +0 -22
- data/examples/CQL/NonRoleId.cql +0 -14
- data/examples/CQL/OddIdentifier.cql +0 -18
- data/examples/CQL/OilSupply.cql +0 -53
- data/examples/CQL/OneToOnes.cql +0 -17
- data/examples/CQL/Orienteering.cql +0 -111
- data/examples/CQL/PersonPlaysGame.cql +0 -18
- data/examples/CQL/RedundantDependency.cql +0 -34
- data/examples/CQL/SchoolActivities.cql +0 -33
- data/examples/CQL/SeparateSubtype.cql +0 -30
- data/examples/CQL/ServiceDirector.cql +0 -276
- data/examples/CQL/SimplestUnary.cql +0 -12
- data/examples/CQL/Supervision.cql +0 -34
- data/examples/CQL/WaiterTips.cql +0 -33
- data/examples/CQL/Warehousing.cql +0 -101
- data/examples/CQL/WindowInRoomInBldg.cql +0 -28
- data/examples/CQL/unit.cql +0 -474
- data/examples/index.html +0 -420
- data/examples/intro.html +0 -327
- data/examples/local.css +0 -24
- data/index.html +0 -111
- data/lib/activefacts/cql.rb +0 -35
- data/lib/activefacts/cql/CQLParser.treetop +0 -158
- data/lib/activefacts/cql/Context.treetop +0 -48
- data/lib/activefacts/cql/Expressions.treetop +0 -67
- data/lib/activefacts/cql/FactTypes.treetop +0 -358
- data/lib/activefacts/cql/Language/English.treetop +0 -315
- data/lib/activefacts/cql/LexicalRules.treetop +0 -253
- data/lib/activefacts/cql/ObjectTypes.treetop +0 -210
- data/lib/activefacts/cql/Rakefile +0 -14
- data/lib/activefacts/cql/Terms.treetop +0 -183
- data/lib/activefacts/cql/ValueTypes.treetop +0 -202
- data/lib/activefacts/cql/compiler.rb +0 -156
- data/lib/activefacts/cql/compiler/clause.rb +0 -1137
- data/lib/activefacts/cql/compiler/constraint.rb +0 -581
- data/lib/activefacts/cql/compiler/entity_type.rb +0 -457
- data/lib/activefacts/cql/compiler/expression.rb +0 -443
- data/lib/activefacts/cql/compiler/fact.rb +0 -390
- data/lib/activefacts/cql/compiler/fact_type.rb +0 -421
- data/lib/activefacts/cql/compiler/query.rb +0 -106
- data/lib/activefacts/cql/compiler/shared.rb +0 -161
- data/lib/activefacts/cql/compiler/value_type.rb +0 -174
- data/lib/activefacts/cql/nodes.rb +0 -49
- data/lib/activefacts/cql/parser.rb +0 -241
- data/lib/activefacts/dependency_analyser.rb +0 -182
- data/lib/activefacts/generate/absorption.rb +0 -70
- data/lib/activefacts/generate/composition.rb +0 -118
- data/lib/activefacts/generate/cql.rb +0 -714
- data/lib/activefacts/generate/dm.rb +0 -279
- data/lib/activefacts/generate/help.rb +0 -64
- data/lib/activefacts/generate/helpers/inject.rb +0 -16
- data/lib/activefacts/generate/helpers/oo.rb +0 -162
- data/lib/activefacts/generate/helpers/ordered.rb +0 -605
- data/lib/activefacts/generate/helpers/rails.rb +0 -57
- data/lib/activefacts/generate/html/glossary.rb +0 -461
- data/lib/activefacts/generate/json.rb +0 -337
- data/lib/activefacts/generate/null.rb +0 -32
- data/lib/activefacts/generate/rails/models.rb +0 -246
- data/lib/activefacts/generate/rails/schema.rb +0 -216
- data/lib/activefacts/generate/records.rb +0 -46
- data/lib/activefacts/generate/ruby.rb +0 -133
- data/lib/activefacts/generate/sql/mysql.rb +0 -280
- data/lib/activefacts/generate/sql/server.rb +0 -273
- data/lib/activefacts/generate/stats.rb +0 -69
- data/lib/activefacts/generate/text.rb +0 -27
- data/lib/activefacts/generate/topics.rb +0 -265
- data/lib/activefacts/generate/traits/datavault.rb +0 -241
- data/lib/activefacts/generate/traits/oo.rb +0 -73
- data/lib/activefacts/generate/traits/ordered.rb +0 -33
- data/lib/activefacts/generate/traits/ruby.rb +0 -210
- data/lib/activefacts/generate/transform/datavault.rb +0 -266
- data/lib/activefacts/generate/transform/surrogate.rb +0 -214
- data/lib/activefacts/generate/version.rb +0 -26
- data/lib/activefacts/input/cql.rb +0 -43
- data/lib/activefacts/input/orm.rb +0 -1636
- data/lib/activefacts/mapping/rails.rb +0 -132
- data/lib/activefacts/persistence.rb +0 -15
- data/lib/activefacts/persistence/columns.rb +0 -446
- data/lib/activefacts/persistence/foreignkey.rb +0 -187
- data/lib/activefacts/persistence/index.rb +0 -240
- data/lib/activefacts/persistence/object_type.rb +0 -198
- data/lib/activefacts/persistence/reference.rb +0 -434
- data/lib/activefacts/persistence/tables.rb +0 -380
- data/lib/activefacts/registry.rb +0 -11
- data/lib/activefacts/support.rb +0 -132
- data/lib/activefacts/vocabulary.rb +0 -9
- data/lib/activefacts/vocabulary/extensions.rb +0 -1348
- data/lib/activefacts/vocabulary/metamodel.rb +0 -570
- data/lib/activefacts/vocabulary/verbaliser.rb +0 -804
- data/script/txt2html +0 -71
- data/spec/absorption_spec.rb +0 -95
- data/spec/cql/comparison_spec.rb +0 -89
- data/spec/cql/context_spec.rb +0 -94
- data/spec/cql/contractions_spec.rb +0 -224
- data/spec/cql/deontic_spec.rb +0 -88
- data/spec/cql/entity_type_spec.rb +0 -320
- data/spec/cql/expressions_spec.rb +0 -66
- data/spec/cql/fact_type_matching_spec.rb +0 -338
- data/spec/cql/french_spec.rb +0 -21
- data/spec/cql/parser/bad_literals_spec.rb +0 -86
- data/spec/cql/parser/constraints_spec.rb +0 -19
- data/spec/cql/parser/entity_types_spec.rb +0 -106
- data/spec/cql/parser/expressions_spec.rb +0 -199
- data/spec/cql/parser/fact_types_spec.rb +0 -44
- data/spec/cql/parser/literals_spec.rb +0 -312
- data/spec/cql/parser/pragmas_spec.rb +0 -89
- data/spec/cql/parser/value_types_spec.rb +0 -42
- data/spec/cql/role_matching_spec.rb +0 -148
- data/spec/cql/samples_spec.rb +0 -244
- data/spec/cql_cql_spec.rb +0 -73
- data/spec/cql_dm_spec.rb +0 -136
- data/spec/cql_mysql_spec.rb +0 -69
- data/spec/cql_parse_spec.rb +0 -34
- data/spec/cql_ruby_spec.rb +0 -73
- data/spec/cql_sql_spec.rb +0 -72
- data/spec/cql_symbol_tables_spec.rb +0 -261
- data/spec/cqldump_spec.rb +0 -170
- data/spec/helpers/array_matcher.rb +0 -23
- data/spec/helpers/ctrl_c_support.rb +0 -52
- data/spec/helpers/diff_matcher.rb +0 -39
- data/spec/helpers/file_matcher.rb +0 -34
- data/spec/helpers/parse_to_ast_matcher.rb +0 -80
- data/spec/helpers/string_matcher.rb +0 -30
- data/spec/helpers/test_parser.rb +0 -15
- data/spec/norma_cql_spec.rb +0 -66
- data/spec/norma_ruby_spec.rb +0 -62
- data/spec/norma_ruby_sql_spec.rb +0 -107
- data/spec/norma_sql_spec.rb +0 -57
- data/spec/norma_tables_spec.rb +0 -95
- data/spec/ruby_api_spec.rb +0 -23
- data/spec/spec_helper.rb +0 -35
- data/spec/transform_surrogate_spec.rb +0 -59
- data/status.html +0 -138
- data/why.html +0 -60
@@ -1,253 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# ActiveFacts CQL Parser.
|
3
|
-
# Various lexical rules for CQL.
|
4
|
-
#
|
5
|
-
# Copyright (c) 2009 Clifford Heath. Read the LICENSE file.
|
6
|
-
#
|
7
|
-
module ActiveFacts
|
8
|
-
module CQL
|
9
|
-
grammar LexicalRules
|
10
|
-
|
11
|
-
rule range
|
12
|
-
(numeric_range / string_range)
|
13
|
-
{
|
14
|
-
def node_type; :literal; end
|
15
|
-
}
|
16
|
-
end
|
17
|
-
|
18
|
-
rule numeric_range
|
19
|
-
number s tail:( '..' s end:number? s )?
|
20
|
-
{
|
21
|
-
def value
|
22
|
-
if !tail.empty?
|
23
|
-
last = tail.end.value unless tail.end.empty?
|
24
|
-
[ number.value, last ]
|
25
|
-
else
|
26
|
-
number.value
|
27
|
-
end
|
28
|
-
end
|
29
|
-
}
|
30
|
-
/ '..' s number s
|
31
|
-
{
|
32
|
-
def value
|
33
|
-
[ nil, number.value ]
|
34
|
-
end
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
rule string_range
|
39
|
-
string s tail:( '..' s end:string? s )?
|
40
|
-
{
|
41
|
-
# Ranges require the original text of the string, not the content:
|
42
|
-
def value
|
43
|
-
first = string.text_value
|
44
|
-
if !tail.empty?
|
45
|
-
last = tail.end.text_value unless tail.end.empty?
|
46
|
-
[ first, last ]
|
47
|
-
else
|
48
|
-
first
|
49
|
-
end
|
50
|
-
end
|
51
|
-
}
|
52
|
-
/ '..' s string s
|
53
|
-
{
|
54
|
-
def value
|
55
|
-
[ nil, string.value ]
|
56
|
-
end
|
57
|
-
}
|
58
|
-
end
|
59
|
-
|
60
|
-
rule url
|
61
|
-
# url_scheme ':' (user ( ':' !(port '/') password )? '@' )? hostname ( ':' port )? '/' path query? fragment?
|
62
|
-
( !(white / ';') .)+
|
63
|
-
{
|
64
|
-
def node_type; :literal; end
|
65
|
-
}
|
66
|
-
end
|
67
|
-
|
68
|
-
rule literal
|
69
|
-
( boolean_literal
|
70
|
-
/ string
|
71
|
-
/ number
|
72
|
-
) s
|
73
|
-
{
|
74
|
-
def value
|
75
|
-
elements[0].value
|
76
|
-
end
|
77
|
-
def node_type; :literal; end
|
78
|
-
}
|
79
|
-
end
|
80
|
-
|
81
|
-
rule boolean_literal
|
82
|
-
( true { def value; true; end }
|
83
|
-
/ false { def value; false; end }
|
84
|
-
) !alphanumeric
|
85
|
-
{
|
86
|
-
def value; elements[0].value end
|
87
|
-
}
|
88
|
-
end
|
89
|
-
|
90
|
-
rule string
|
91
|
-
"'" (string_char)* "'"
|
92
|
-
{
|
93
|
-
def value
|
94
|
-
text_value
|
95
|
-
eval(text_value.sub(/\A'(.*)'\Z/,'"\1"'))
|
96
|
-
end
|
97
|
-
}
|
98
|
-
end
|
99
|
-
|
100
|
-
rule number
|
101
|
-
( real /
|
102
|
-
fractional_real /
|
103
|
-
hexnumber /
|
104
|
-
octalnumber
|
105
|
-
) !alphanumeric
|
106
|
-
{
|
107
|
-
def value
|
108
|
-
eval(text_value)
|
109
|
-
end
|
110
|
-
def node_type; :literal; end
|
111
|
-
}
|
112
|
-
end
|
113
|
-
|
114
|
-
# All purely lexical rules from here down, no-one looks at the structure, just the text_value:
|
115
|
-
|
116
|
-
rule string_char
|
117
|
-
( '\\' [befntr\\']
|
118
|
-
/ '\\' [0-7] [0-7] [0-7]
|
119
|
-
/ '\\' [\r]* [\n] [\r]*
|
120
|
-
/ '\\0'
|
121
|
-
/ '\\x' [0-9A-Fa-f] [0-9A-Fa-f]
|
122
|
-
/ '\\u' [0-9A-Fa-f] [0-9A-Fa-f] [0-9A-Fa-f] [0-9A-Fa-f]
|
123
|
-
/ (![\'\\\0-\x07\x0A-\x1F] .)
|
124
|
-
)
|
125
|
-
end
|
126
|
-
|
127
|
-
rule real
|
128
|
-
[-+]? [1-9] [0-9]* fraction? exponent?
|
129
|
-
end
|
130
|
-
|
131
|
-
rule fractional_real
|
132
|
-
[-+]? '0' fraction exponent?
|
133
|
-
end
|
134
|
-
|
135
|
-
rule fraction
|
136
|
-
radix_point [0-9]+
|
137
|
-
end
|
138
|
-
|
139
|
-
rule exponent
|
140
|
-
( [Ee] [-+]? [0-9]+ )
|
141
|
-
end
|
142
|
-
|
143
|
-
rule hexnumber
|
144
|
-
'0x' [0-9A-Fa-f]+
|
145
|
-
end
|
146
|
-
|
147
|
-
rule octalnumber
|
148
|
-
'0' [0-7]*
|
149
|
-
end
|
150
|
-
|
151
|
-
rule mul_op
|
152
|
-
'/' / '%' / '*'
|
153
|
-
end
|
154
|
-
|
155
|
-
rule id
|
156
|
-
alpha alphanumeric*
|
157
|
-
{ def value; text_value; end }
|
158
|
-
end
|
159
|
-
|
160
|
-
rule alpha
|
161
|
-
[[:alpha:]_]
|
162
|
-
end
|
163
|
-
|
164
|
-
rule alphanumeric
|
165
|
-
alpha / [0-9]
|
166
|
-
end
|
167
|
-
|
168
|
-
rule s # Optional space
|
169
|
-
S?
|
170
|
-
end
|
171
|
-
|
172
|
-
rule S # Mandatory space
|
173
|
-
(white / comment_to_eol / comment_c_style)+
|
174
|
-
end
|
175
|
-
|
176
|
-
rule white
|
177
|
-
[ \t\n\r]+
|
178
|
-
end
|
179
|
-
|
180
|
-
rule comment_to_eol
|
181
|
-
'//' (!"\n" .)*
|
182
|
-
{
|
183
|
-
def node_type; :comment; end
|
184
|
-
}
|
185
|
-
end
|
186
|
-
|
187
|
-
rule comment_c_style
|
188
|
-
'/*' (!'*/' . )* '*/'
|
189
|
-
{
|
190
|
-
def node_type; :comment; end
|
191
|
-
}
|
192
|
-
end
|
193
|
-
|
194
|
-
rule regular_expression
|
195
|
-
'/' !'/' regular_expression_contents '/'
|
196
|
-
{
|
197
|
-
def contents
|
198
|
-
regular_expression_contents.text_value
|
199
|
-
end
|
200
|
-
}
|
201
|
-
end
|
202
|
-
|
203
|
-
rule regular_expression_contents
|
204
|
-
regular_expression_alternate ( '|' regular_expression_alternate )*
|
205
|
-
end
|
206
|
-
|
207
|
-
rule regular_expression_alternate
|
208
|
-
regular_expression_sequence
|
209
|
-
end
|
210
|
-
|
211
|
-
rule regular_expression_sequence
|
212
|
-
regular_expression_atom*
|
213
|
-
end
|
214
|
-
|
215
|
-
rule regular_expression_atom
|
216
|
-
(
|
217
|
-
'[' character_classes ']'
|
218
|
-
/ regular_expression_group
|
219
|
-
/ ![*+?()|/] string_char
|
220
|
-
) regular_expression_multiplicity?
|
221
|
-
end
|
222
|
-
|
223
|
-
rule character_classes
|
224
|
-
character_class+
|
225
|
-
end
|
226
|
-
|
227
|
-
rule character_class
|
228
|
-
!']' string_char '-' !']' string_char
|
229
|
-
/ '-'
|
230
|
-
/ !']' string_char
|
231
|
-
end
|
232
|
-
|
233
|
-
rule regular_expression_multiplicity
|
234
|
-
'*' / '+' / '?'
|
235
|
-
end
|
236
|
-
|
237
|
-
rule regular_expression_group
|
238
|
-
'('
|
239
|
-
regular_expression_group_extension?
|
240
|
-
regular_expression_contents
|
241
|
-
')'
|
242
|
-
end
|
243
|
-
|
244
|
-
rule regular_expression_group_extension
|
245
|
-
'?' (
|
246
|
-
'<' ( !'>' .)+ '>' # A tag for a regular expression group
|
247
|
-
# REVISIT: Add more group extensions as needed
|
248
|
-
)
|
249
|
-
end
|
250
|
-
|
251
|
-
end
|
252
|
-
end
|
253
|
-
end
|
@@ -1,210 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# ActiveFacts CQL Parser.
|
3
|
-
# Parse rules relating to ObjectType definitions.
|
4
|
-
#
|
5
|
-
# Copyright (c) 2009 Clifford Heath. Read the LICENSE file.
|
6
|
-
#
|
7
|
-
module ActiveFacts
|
8
|
-
module CQL
|
9
|
-
grammar ObjectTypes
|
10
|
-
rule object_type
|
11
|
-
value_type
|
12
|
-
/ entity_type
|
13
|
-
/ named_fact_type
|
14
|
-
/ anonymous_fact_type
|
15
|
-
end
|
16
|
-
|
17
|
-
rule entity_type
|
18
|
-
s each?
|
19
|
-
s term_definition_name
|
20
|
-
m1:mapping_pragmas
|
21
|
-
c:context_note?
|
22
|
-
sup:(basetype / subtype)
|
23
|
-
&{|s|
|
24
|
-
# There's an implicit type when we use an identification mode, register it:
|
25
|
-
mode = s[6].identification_mode
|
26
|
-
if mode
|
27
|
-
input.context.object_type(s[3].value+mode, "identification mode type")
|
28
|
-
input.context.object_type(s[3].value+' '+mode, "identification mode type")
|
29
|
-
end
|
30
|
-
true
|
31
|
-
}
|
32
|
-
m2:mapping_pragmas
|
33
|
-
c2:context_note?
|
34
|
-
ec:entity_clauses?
|
35
|
-
';'
|
36
|
-
{
|
37
|
-
def ast
|
38
|
-
name = term_definition_name.value
|
39
|
-
clauses_ast = ec.empty? ? [] : ec.ast
|
40
|
-
pragmas = m1.value+m2.value
|
41
|
-
pragmas << 'independent' if sup.independent
|
42
|
-
context_note = !c.empty? ? c.ast : (!c2.empty? ? c2.ast : nil)
|
43
|
-
Compiler::EntityType.new name, sup.supers, sup.ast, pragmas, clauses_ast, context_note
|
44
|
-
end
|
45
|
-
}
|
46
|
-
end
|
47
|
-
|
48
|
-
rule basetype
|
49
|
-
basetype_expression
|
50
|
-
{
|
51
|
-
def ast; identification.ast; end
|
52
|
-
def supers; []; end
|
53
|
-
def identification_mode; identification.mode; end
|
54
|
-
def independent; !i.empty?; end
|
55
|
-
}
|
56
|
-
end
|
57
|
-
|
58
|
-
rule subtype
|
59
|
-
subtype_expression
|
60
|
-
{
|
61
|
-
def ast; ident.empty? ? nil : ident.ast; end
|
62
|
-
def supers; supertype_list.value; end
|
63
|
-
def identification_mode; ident.empty? ? nil : ident.mode; end
|
64
|
-
def independent; !i.empty?; end
|
65
|
-
}
|
66
|
-
end
|
67
|
-
|
68
|
-
rule supertype_list
|
69
|
-
primary:term s alternate_supertypes:( (','/'and' !alpha) s !identified_by name:term s )*
|
70
|
-
{
|
71
|
-
def value
|
72
|
-
[primary.value, *alternate_supertypes.elements.map { |sup| sup.name.value } ]
|
73
|
-
end
|
74
|
-
}
|
75
|
-
end
|
76
|
-
|
77
|
-
rule identification
|
78
|
-
# REVISIT: Consider distinguishing "-Id" from just "Id", and not prepending the entity type name if no "-"
|
79
|
-
identified_by its s i:(term/implicit_value_type_name) value_type_parameters
|
80
|
-
r:(value_constraint enforcement)? # Reference Mode; value_constraint may be needed for the ValueType
|
81
|
-
{
|
82
|
-
def ast
|
83
|
-
if r.empty?
|
84
|
-
value_constraint = nil
|
85
|
-
else
|
86
|
-
value_constraint = Compiler::ValueConstraint.new(r.value_constraint.ast, r.enforcement.ast)
|
87
|
-
end
|
88
|
-
Compiler::ReferenceMode.new(i.value, value_constraint, value_type_parameters.values)
|
89
|
-
end
|
90
|
-
|
91
|
-
def mode
|
92
|
-
i.value
|
93
|
-
end
|
94
|
-
}
|
95
|
-
/
|
96
|
-
identified_by role_list
|
97
|
-
&{|s|
|
98
|
-
role_list = s[-1]
|
99
|
-
forwards = role_list.ast.
|
100
|
-
map do |role|
|
101
|
-
next nil if role.is_a?(Compiler::Clause) # Can't forward-reference unaries
|
102
|
-
next nil if role.leading_adjective or role.trailing_adjective
|
103
|
-
role.term
|
104
|
-
end.
|
105
|
-
compact
|
106
|
-
input.context.allowed_forward_terms(forwards)
|
107
|
-
true
|
108
|
-
}
|
109
|
-
{
|
110
|
-
def ast
|
111
|
-
role_list.ast
|
112
|
-
end
|
113
|
-
|
114
|
-
def mode
|
115
|
-
nil
|
116
|
-
end
|
117
|
-
}
|
118
|
-
end
|
119
|
-
|
120
|
-
# Identified by roles... also used for constraints, beware
|
121
|
-
rule role_list
|
122
|
-
a:any? s
|
123
|
-
head:term_or_unary s
|
124
|
-
tail:(
|
125
|
-
( and S / ',' s )
|
126
|
-
any? s
|
127
|
-
term_or_unary s
|
128
|
-
)*
|
129
|
-
{
|
130
|
-
def ast
|
131
|
-
[head.ast, *tail.elements.map{|e| e.term_or_unary.ast}]
|
132
|
-
end
|
133
|
-
}
|
134
|
-
end
|
135
|
-
|
136
|
-
rule unary_text
|
137
|
-
(s !any !non_phrase !term id)*
|
138
|
-
{
|
139
|
-
def node_type; :linking; end
|
140
|
-
}
|
141
|
-
end
|
142
|
-
|
143
|
-
rule term_or_unary
|
144
|
-
pre_text:unary_text s term post_text:unary_text s ss:subscript?
|
145
|
-
{
|
146
|
-
def ast
|
147
|
-
t = term.ast
|
148
|
-
t.role_name = ss.value if !ss.empty?
|
149
|
-
if pre_text.elements.size == 0 && post_text.elements.size == 0
|
150
|
-
t
|
151
|
-
else
|
152
|
-
pre_words = pre_text.elements.map{|w| w.id.text_value}
|
153
|
-
post_words = post_text.elements.map{|w| w.id.text_value}
|
154
|
-
Compiler::Clause.new(pre_words + [t] + post_words, [], nil)
|
155
|
-
end
|
156
|
-
end
|
157
|
-
}
|
158
|
-
/
|
159
|
-
s !non_phrase id s &non_phrase s ss:subscript?
|
160
|
-
{ # A forward-referenced entity type
|
161
|
-
# REVISIT: A change in this rule might allow forward-referencing a multi-word term
|
162
|
-
def ast
|
163
|
-
Compiler::Reference.new(id.text_value, nil, nil, nil, nil, ss.empty? ? nil : ss.value)
|
164
|
-
end
|
165
|
-
}
|
166
|
-
end
|
167
|
-
|
168
|
-
rule mapping_pragmas
|
169
|
-
'[' s h:mapping_pragma t:(s ',' s mapping_pragma)* s ']' s
|
170
|
-
{
|
171
|
-
def value
|
172
|
-
t.elements.inject([h.value*' ']) do |a, e|
|
173
|
-
a << e.mapping_pragma.value*' '
|
174
|
-
end
|
175
|
-
end
|
176
|
-
}
|
177
|
-
/
|
178
|
-
s
|
179
|
-
{ def value; []; end }
|
180
|
-
end
|
181
|
-
|
182
|
-
# Each mapping_pragma returns an array of words
|
183
|
-
rule mapping_pragma
|
184
|
-
was s names:(id s)+
|
185
|
-
{ # Old or previous name of an object type:
|
186
|
-
def value
|
187
|
-
[ was.text_value ] + names.elements.map{|n|n.text_value}
|
188
|
-
end
|
189
|
-
}
|
190
|
-
/
|
191
|
-
head:id tail:(s id)*
|
192
|
-
{ # A sequence of one or more words denoting a pragma:
|
193
|
-
def value
|
194
|
-
([head]+tail.elements.map(&:id)).map(&:text_value)
|
195
|
-
end
|
196
|
-
}
|
197
|
-
end
|
198
|
-
|
199
|
-
rule entity_clauses
|
200
|
-
(':' / where) s query_clauses
|
201
|
-
{
|
202
|
-
def ast
|
203
|
-
query_clauses.ast
|
204
|
-
end
|
205
|
-
}
|
206
|
-
end
|
207
|
-
|
208
|
-
end
|
209
|
-
end
|
210
|
-
end
|