expressir 2.1.22 → 2.1.23
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/.rubocop.yml +9 -9
- data/.rubocop_todo.yml +62 -64
- data/Gemfile +2 -2
- data/README.adoc +202 -5
- data/bin/rspec +2 -1
- data/docs/liquid_drops.adoc +1 -1
- data/expressir.gemspec +0 -2
- data/lib/expressir/benchmark.rb +6 -3
- data/lib/expressir/cli.rb +24 -12
- data/lib/expressir/commands/benchmark.rb +7 -16
- data/lib/expressir/commands/benchmark_cache.rb +9 -17
- data/lib/expressir/commands/coverage.rb +43 -42
- data/lib/expressir/coverage.rb +41 -15
- data/lib/expressir/express/cache.rb +2 -1
- data/lib/expressir/express/formatter.rb +54 -12
- data/lib/expressir/express/hyperlink_formatter.rb +2 -1
- data/lib/expressir/express/parser.rb +329 -112
- data/lib/expressir/express/schema_head_formatter.rb +2 -1
- data/lib/expressir/express/visitor.rb +114 -51
- data/lib/expressir/model/declarations/entity.rb +2 -1
- data/lib/expressir/model/declarations/informal_proposition_rule.rb +24 -0
- data/lib/expressir/model/declarations/rule.rb +2 -1
- data/lib/expressir/model/declarations/schema.rb +4 -1
- data/lib/expressir/model/declarations/type.rb +2 -1
- data/lib/expressir/model/identifier.rb +2 -1
- data/lib/expressir/model/literals/string.rb +2 -1
- data/lib/expressir/model/model_element.rb +84 -145
- data/lib/expressir/model/repository.rb +2 -1
- data/lib/expressir/schema_manifest.rb +150 -0
- data/lib/expressir/schema_manifest_entry.rb +17 -0
- data/lib/expressir/version.rb +1 -1
- data/lib/expressir.rb +29 -12
- metadata +5 -2
@@ -32,22 +32,26 @@ module Expressir
|
|
32
32
|
].freeze
|
33
33
|
|
34
34
|
def keyword_rule(str)
|
35
|
-
key_chars = str.to_s.
|
35
|
+
key_chars = str.to_s.chars
|
36
36
|
key_chars
|
37
37
|
.collect! { |char| match("[#{char}#{char.downcase}]") }
|
38
38
|
.reduce(:>>) >> match["a-zA-Z0-9_"].absent?
|
39
39
|
end
|
40
40
|
|
41
41
|
KEYWORDS.each do |keyword|
|
42
|
-
sym = "t#{keyword}"
|
42
|
+
sym = :"t#{keyword}"
|
43
43
|
rule(sym) { cts(keyword_rule(keyword).as(:str)).as(sym) }
|
44
44
|
end
|
45
45
|
|
46
|
-
rule(:abstractEntityDeclaration)
|
46
|
+
rule(:abstractEntityDeclaration) do
|
47
|
+
tABSTRACT.as(:abstractEntityDeclaration)
|
48
|
+
end
|
47
49
|
rule(:abstractSupertypeDeclaration) do
|
48
50
|
(tABSTRACT >> tSUPERTYPE >> subtypeConstraint.maybe).as(:abstractSupertypeDeclaration)
|
49
51
|
end
|
50
|
-
rule(:abstractSupertype)
|
52
|
+
rule(:abstractSupertype) do
|
53
|
+
(tABSTRACT >> tSUPERTYPE >> op_delim).as(:abstractSupertype)
|
54
|
+
end
|
51
55
|
rule(:actualParameterList) do
|
52
56
|
(op_leftparen >> (parameter >> (op_comma >> parameter).repeat).as(:listOf_parameter).maybe >> op_rightparen)
|
53
57
|
.as(:actualParameterList)
|
@@ -61,7 +65,9 @@ module Expressir
|
|
61
65
|
rule(:aggregateType) do
|
62
66
|
(tAGGREGATE >> (op_colon >> typeLabel).maybe >> tOF >> parameterType).as(:aggregateType)
|
63
67
|
end
|
64
|
-
rule(:aggregationTypes)
|
68
|
+
rule(:aggregationTypes) do
|
69
|
+
(arrayType | bagType | listType | setType).as(:aggregationTypes)
|
70
|
+
end
|
65
71
|
rule(:algorithmHead) do
|
66
72
|
(declaration.repeat.as(:declaration) >> constantDecl.maybe >> localDecl.maybe).as(:algorithmHead)
|
67
73
|
end
|
@@ -73,79 +79,141 @@ module Expressir
|
|
73
79
|
rule(:arrayType) do
|
74
80
|
(tARRAY >> boundSpec >> tOF >> tOPTIONAL.maybe >> tUNIQUE.maybe >> instantiableType).as(:arrayType)
|
75
81
|
end
|
76
|
-
rule(:assignmentStmt)
|
77
|
-
|
82
|
+
rule(:assignmentStmt) do
|
83
|
+
(generalRef >> qualifier.repeat.as(:qualifier) >> op_decl >> expression >> op_delim).as(:assignmentStmt)
|
84
|
+
end
|
85
|
+
rule(:attributeDecl) do
|
86
|
+
(attributeId | redeclaredAttribute).as(:attributeDecl)
|
87
|
+
end
|
78
88
|
rule(:attributeId) { simpleId.as(:attributeId) }
|
79
|
-
rule(:attributeQualifier)
|
89
|
+
rule(:attributeQualifier) do
|
90
|
+
(op_period >> attributeRef).as(:attributeQualifier)
|
91
|
+
end
|
80
92
|
rule(:attributeRef) { attributeId.as(:attributeRef) }
|
81
|
-
rule(:bagType)
|
82
|
-
|
93
|
+
rule(:bagType) do
|
94
|
+
(tBAG >> boundSpec.maybe >> tOF >> instantiableType).as(:bagType)
|
95
|
+
end
|
96
|
+
rule(:binaryLiteral) do
|
97
|
+
cts((str("%") >> bit.repeat(1)).as(:str)).as(:binaryLiteral)
|
98
|
+
end
|
83
99
|
rule(:binaryType) { (tBINARY >> widthSpec.maybe).as(:binaryType) }
|
84
100
|
rule(:bit) { match["0-1"] }
|
85
101
|
rule(:booleanType) { tBOOLEAN.as(:booleanType) }
|
86
102
|
rule(:bound1) { numericExpression.as(:bound1) }
|
87
103
|
rule(:bound2) { numericExpression.as(:bound2) }
|
88
|
-
rule(:boundSpec)
|
89
|
-
|
104
|
+
rule(:boundSpec) do
|
105
|
+
(op_leftbracket >> bound1 >> op_colon >> bound2 >> op_rightbracket).as(:boundSpec)
|
106
|
+
end
|
107
|
+
rule(:builtInConstant) do
|
108
|
+
(tCONST_E | tPI | tSELF | op_question_mark).as(:builtInConstant)
|
109
|
+
end
|
90
110
|
rule(:builtInFunction) do
|
91
111
|
(tABS | tACOS | tASIN | tATAN | tBLENGTH | tCOS | tEXISTS | tEXP | tFORMAT | tHIBOUND | tHIINDEX | tLENGTH |
|
92
112
|
tLOBOUND | tLOINDEX | tLOG2 | tLOG10 | tLOG | tNVL | tODD | tROLESOF | tSIN | tSIZEOF | tSQRT | tTAN |
|
93
113
|
tTYPEOF | tUSEDIN | tVALUE_IN | tVALUE_UNIQUE | tVALUE).as(:builtInFunction)
|
94
114
|
end
|
95
115
|
rule(:builtInProcedure) { (tINSERT | tREMOVE).as(:builtInProcedure) }
|
96
|
-
rule(:caseAction)
|
116
|
+
rule(:caseAction) do
|
117
|
+
((caseLabel >> (op_comma >> caseLabel).repeat).as(:listOf_caseLabel) >> op_colon >> stmt).as(:caseAction)
|
118
|
+
end
|
97
119
|
rule(:caseLabel) { expression.as(:caseLabel) }
|
98
120
|
rule(:caseStmt) do
|
99
121
|
(tCASE >> selector >> tOF >> caseAction.repeat.as(:caseAction) >> (tOTHERWISE >> op_colon >> stmt).maybe >> tEND_CASE >> op_delim).as(:caseStmt)
|
100
122
|
end
|
101
|
-
rule(:compoundStmt)
|
102
|
-
|
103
|
-
|
104
|
-
rule(:
|
105
|
-
|
123
|
+
rule(:compoundStmt) do
|
124
|
+
(tBEGIN >> stmt.repeat(1).as(:stmt) >> tEND >> op_delim).as(:compoundStmt)
|
125
|
+
end
|
126
|
+
rule(:concreteTypes) do
|
127
|
+
(aggregationTypes | simpleTypes | typeRef).as(:concreteTypes)
|
128
|
+
end
|
129
|
+
rule(:constantBody) do
|
130
|
+
(constantId >> op_colon >> instantiableType >> op_decl >> expression >> op_delim).as(:constantBody)
|
131
|
+
end
|
132
|
+
rule(:constantDecl) do
|
133
|
+
(tCONSTANT >> constantBody.repeat(1).as(:constantBody) >> tEND_CONSTANT >> op_delim).as(:constantDecl)
|
134
|
+
end
|
135
|
+
rule(:constantFactor) do
|
136
|
+
(builtInConstant | constantRef).as(:constantFactor)
|
137
|
+
end
|
106
138
|
rule(:constantId) { simpleId.as(:constantId) }
|
107
139
|
rule(:constantRef) { constantId.as(:constantRef) }
|
108
|
-
rule(:constructedTypes)
|
109
|
-
|
140
|
+
rule(:constructedTypes) do
|
141
|
+
(enumerationType | selectType).as(:constructedTypes)
|
142
|
+
end
|
143
|
+
rule(:declaration) do
|
144
|
+
(entityDecl | functionDecl | procedureDecl | subtypeConstraintDecl | typeDecl).as(:declaration)
|
145
|
+
end
|
110
146
|
rule(:delim) { cts(str(";").as(:delim)) }
|
111
|
-
rule(:deriveClause)
|
112
|
-
|
147
|
+
rule(:deriveClause) do
|
148
|
+
(tDERIVE >> derivedAttr.repeat(1).as(:derivedAttr)).as(:deriveClause)
|
149
|
+
end
|
150
|
+
rule(:derivedAttr) do
|
151
|
+
(attributeDecl >> op_colon >> parameterType >> op_decl >> expression >> op_delim).as(:derivedAttr)
|
152
|
+
end
|
113
153
|
rule(:digit) { match["0-9"] }
|
114
154
|
rule(:digits) { (digit >> digit.repeat) }
|
115
|
-
rule(:domainRule)
|
116
|
-
|
117
|
-
|
155
|
+
rule(:domainRule) do
|
156
|
+
((ruleLabelId >> op_colon).maybe >> expression).as(:domainRule)
|
157
|
+
end
|
158
|
+
rule(:element) do
|
159
|
+
(expression >> (op_colon >> repetition).maybe).as(:element)
|
160
|
+
end
|
161
|
+
rule(:embeddedRemark) do
|
162
|
+
(str("(*") >> (str("*)").absent? >> (embeddedRemark | any)).repeat >> str("*)")).as(:embeddedRemark)
|
163
|
+
end
|
118
164
|
rule(:encodedCharacter) { (octet >> octet >> octet >> octet) }
|
119
|
-
rule(:encodedStringLiteral)
|
165
|
+
rule(:encodedStringLiteral) do
|
166
|
+
cts((str('"') >> encodedCharacter.repeat(1) >> str('"')).as(:str)).as(:encodedStringLiteral)
|
167
|
+
end
|
120
168
|
rule(:entityBody) do
|
121
169
|
(explicitAttr.repeat.as(:explicitAttr) >> deriveClause.maybe >> inverseClause.maybe >> uniqueClause.maybe >> whereClause.maybe).as(:entityBody)
|
122
170
|
end
|
123
171
|
rule(:entityConstructor) do
|
124
172
|
(entityRef >> op_leftparen >> (expression >> (op_comma >> expression).repeat).as(:listOf_expression).maybe >> op_rightparen).as(:entityConstructor)
|
125
173
|
end
|
126
|
-
rule(:entityDecl)
|
127
|
-
|
174
|
+
rule(:entityDecl) do
|
175
|
+
(entityHead >> entityBody >> tEND_ENTITY >> op_delim).as(:entityDecl)
|
176
|
+
end
|
177
|
+
rule(:entityHead) do
|
178
|
+
(tENTITY >> entityId >> subsuper >> op_delim).as(:entityHead)
|
179
|
+
end
|
128
180
|
rule(:entityId) { simpleId.as(:entityId) }
|
129
181
|
rule(:entityRef) { entityId.as(:entityRef) }
|
130
|
-
rule(:enumerationExtension)
|
182
|
+
rule(:enumerationExtension) do
|
183
|
+
(tBASED_ON >> typeRef >> (tWITH >> enumerationItems).maybe).as(:enumerationExtension)
|
184
|
+
end
|
131
185
|
rule(:enumerationId) { simpleId.as(:enumerationId) }
|
132
186
|
rule(:enumerationItem) { enumerationId.as(:enumerationItem) }
|
133
187
|
rule(:enumerationItems) do
|
134
188
|
(op_leftparen >> (enumerationItem >> (op_comma >> enumerationItem).repeat).as(:listOf_enumerationItem) >> op_rightparen).as(:enumerationItems)
|
135
189
|
end
|
136
190
|
rule(:enumerationRef) { enumerationId.as(:enumerationRef) }
|
137
|
-
rule(:enumerationReference)
|
138
|
-
|
191
|
+
rule(:enumerationReference) do
|
192
|
+
((typeRef >> op_period).maybe >> enumerationRef).as(:enumerationReference)
|
193
|
+
end
|
194
|
+
rule(:enumerationType) do
|
195
|
+
(tEXTENSIBLE.maybe >> tENUMERATION >> ((tOF >> enumerationItems) | enumerationExtension).maybe).as(:enumerationType)
|
196
|
+
end
|
139
197
|
rule(:escapeStmt) { (tESCAPE >> op_delim).as(:escapeStmt) }
|
140
198
|
rule(:explicitAttr) do
|
141
199
|
((attributeDecl >> (op_comma >> attributeDecl).repeat).as(:listOf_attributeDecl) >> op_colon >>
|
142
200
|
tOPTIONAL.maybe >> parameterType >> op_delim).as(:explicitAttr)
|
143
201
|
end
|
144
|
-
rule(:expression)
|
145
|
-
|
146
|
-
|
147
|
-
rule(:
|
148
|
-
|
202
|
+
rule(:expression) do
|
203
|
+
(simpleExpression >> (relOpExtended >> simpleExpression.as(:rhs)).maybe).as(:expression)
|
204
|
+
end
|
205
|
+
rule(:factor) do
|
206
|
+
(simpleFactor >> (op_double_asterisk >> simpleFactor.as(:rhs)).maybe).as(:factor)
|
207
|
+
end
|
208
|
+
rule(:formalParameter) do
|
209
|
+
((parameterId >> (op_comma >> parameterId).repeat).as(:listOf_parameterId) >> op_colon >> parameterType).as(:formalParameter)
|
210
|
+
end
|
211
|
+
rule(:functionCall) do
|
212
|
+
((builtInFunction | functionRef) >> actualParameterList.maybe).as(:functionCall)
|
213
|
+
end
|
214
|
+
rule(:functionDecl) do
|
215
|
+
(functionHead >> algorithmHead >> stmt.repeat(1).as(:stmt) >> tEND_FUNCTION >> op_delim).as(:functionDecl)
|
216
|
+
end
|
149
217
|
rule(:functionHead) do
|
150
218
|
(tFUNCTION >> functionId >>
|
151
219
|
(op_leftparen >> (formalParameter >> (op_delim >> formalParameter).repeat).as(:listOf_formalParameter) >> op_rightparen).maybe >>
|
@@ -153,30 +221,62 @@ module Expressir
|
|
153
221
|
end
|
154
222
|
rule(:functionId) { simpleId.as(:functionId) }
|
155
223
|
rule(:functionRef) { functionId.as(:functionRef) }
|
156
|
-
rule(:generalAggregationTypes)
|
157
|
-
|
158
|
-
|
159
|
-
rule(:
|
160
|
-
|
224
|
+
rule(:generalAggregationTypes) do
|
225
|
+
(generalArrayType | generalBagType | generalListType | generalSetType).as(:generalAggregationTypes)
|
226
|
+
end
|
227
|
+
rule(:generalArrayType) do
|
228
|
+
(tARRAY >> boundSpec.maybe >> tOF >> tOPTIONAL.maybe >> tUNIQUE.maybe >> parameterType).as(:generalArrayType)
|
229
|
+
end
|
230
|
+
rule(:generalBagType) do
|
231
|
+
(tBAG >> boundSpec.maybe >> tOF >> parameterType).as(:generalBagType)
|
232
|
+
end
|
233
|
+
rule(:generalizedTypes) do
|
234
|
+
(aggregateType | generalAggregationTypes | genericEntityType | genericType).as(:generalizedTypes)
|
235
|
+
end
|
236
|
+
rule(:generalListType) do
|
237
|
+
(tLIST >> boundSpec.maybe >> tOF >> tUNIQUE.maybe >> parameterType).as(:generalListType)
|
238
|
+
end
|
161
239
|
rule(:generalRef) { (parameterRef | variableId).as(:generalRef) }
|
162
|
-
rule(:generalSetType)
|
163
|
-
|
164
|
-
|
165
|
-
rule(:
|
240
|
+
rule(:generalSetType) do
|
241
|
+
(tSET >> boundSpec.maybe >> tOF >> parameterType).as(:generalSetType)
|
242
|
+
end
|
243
|
+
rule(:genericEntityType) do
|
244
|
+
(tGENERIC_ENTITY >> (op_colon >> typeLabel).maybe).as(:genericEntityType)
|
245
|
+
end
|
246
|
+
rule(:genericType) do
|
247
|
+
(tGENERIC >> (op_colon >> typeLabel).maybe).as(:genericType)
|
248
|
+
end
|
249
|
+
rule(:groupQualifier) do
|
250
|
+
(op_double_backslash >> entityRef).as(:groupQualifier)
|
251
|
+
end
|
166
252
|
rule(:hexDigit) { match["0-9a-fA-F"] }
|
167
|
-
rule(:ifStmtElseStatements)
|
168
|
-
|
169
|
-
|
170
|
-
rule(:
|
253
|
+
rule(:ifStmtElseStatements) do
|
254
|
+
stmt.repeat(1).as(:stmt).as(:ifStmtElseStatements)
|
255
|
+
end
|
256
|
+
rule(:ifStmtStatements) do
|
257
|
+
stmt.repeat(1).as(:stmt).as(:ifStmtStatements)
|
258
|
+
end
|
259
|
+
rule(:ifStmt) do
|
260
|
+
(tIF >> logicalExpression >> tTHEN >> ifStmtStatements >> (tELSE >> ifStmtElseStatements).maybe >> tEND_IF >> op_delim).as(:ifStmt)
|
261
|
+
end
|
262
|
+
rule(:incrementControl) do
|
263
|
+
(variableId >> op_decl >> bound1 >> tTO >> bound2 >> (tBY >> increment).maybe).as(:incrementControl)
|
264
|
+
end
|
171
265
|
rule(:increment) { numericExpression.as(:increment) }
|
172
266
|
rule(:index1) { index.as(:index1) }
|
173
267
|
rule(:index2) { index.as(:index2) }
|
174
268
|
rule(:index) { numericExpression.as(:index) }
|
175
|
-
rule(:indexQualifier)
|
176
|
-
|
269
|
+
rule(:indexQualifier) do
|
270
|
+
(op_leftbracket >> index1 >> (op_colon >> index2).maybe >> op_rightbracket).as(:indexQualifier)
|
271
|
+
end
|
272
|
+
rule(:instantiableType) do
|
273
|
+
(concreteTypes | entityRef).as(:instantiableType)
|
274
|
+
end
|
177
275
|
rule(:integerLiteral) { cts(digits.as(:str)).as(:integerLiteral) }
|
178
276
|
rule(:integerType) { tINTEGER.as(:integerType) }
|
179
|
-
rule(:interfaceSpecification)
|
277
|
+
rule(:interfaceSpecification) do
|
278
|
+
(referenceClause | useClause).as(:interfaceSpecification)
|
279
|
+
end
|
180
280
|
rule(:intervalHigh) { simpleExpression.as(:intervalHigh) }
|
181
281
|
rule(:intervalItem) { simpleExpression.as(:intervalItem) }
|
182
282
|
rule(:intervalLow) { simpleExpression.as(:intervalLow) }
|
@@ -188,22 +288,38 @@ module Expressir
|
|
188
288
|
rule(:inverseAttr) do
|
189
289
|
(attributeDecl >> op_colon >> inverseAttrType >> tFOR >> (entityRef >> op_period).maybe >> attributeRef >> op_delim).as(:inverseAttr)
|
190
290
|
end
|
191
|
-
rule(:inverseAttrType)
|
192
|
-
|
291
|
+
rule(:inverseAttrType) do
|
292
|
+
(((tSET | tBAG) >> boundSpec.maybe >> tOF).maybe >> entityRef).as(:inverseAttrType)
|
293
|
+
end
|
294
|
+
rule(:inverseClause) do
|
295
|
+
(tINVERSE >> inverseAttr.repeat(1).as(:inverseAttr)).as(:inverseClause)
|
296
|
+
end
|
193
297
|
rule(:letter) { match["a-zA-Z"] }
|
194
|
-
rule(:listType)
|
195
|
-
|
196
|
-
|
298
|
+
rule(:listType) do
|
299
|
+
(tLIST >> boundSpec.maybe >> tOF >> tUNIQUE.maybe >> instantiableType).as(:listType)
|
300
|
+
end
|
301
|
+
rule(:literal) do
|
302
|
+
(binaryLiteral | logicalLiteral | realLiteral | integerLiteral | stringLiteral).as(:literal)
|
303
|
+
end
|
304
|
+
rule(:localDecl) do
|
305
|
+
(tLOCAL >> localVariable.repeat(1).as(:localVariable) >> tEND_LOCAL >> op_delim).as(:localDecl)
|
306
|
+
end
|
197
307
|
rule(:localVariable) do
|
198
308
|
((variableId >> (op_comma >> variableId).repeat).as(:listOf_variableId) >>
|
199
309
|
op_colon >> parameterType >>
|
200
310
|
(op_decl >> expression).maybe >> op_delim).as(:localVariable)
|
201
311
|
end
|
202
312
|
rule(:logicalExpression) { expression.as(:logicalExpression) }
|
203
|
-
rule(:logicalLiteral)
|
313
|
+
rule(:logicalLiteral) do
|
314
|
+
(tFALSE | tTRUE | tUNKNOWN).as(:logicalLiteral)
|
315
|
+
end
|
204
316
|
rule(:logicalType) { tLOGICAL.as(:logicalType) }
|
205
|
-
rule(:multiplicationLikeOp)
|
206
|
-
|
317
|
+
rule(:multiplicationLikeOp) do
|
318
|
+
(op_asterisk | op_slash | tDIV | tMOD | tAND | op_double_pipe).as(:multiplicationLikeOp)
|
319
|
+
end
|
320
|
+
rule(:namedTypeOrRename) do
|
321
|
+
(namedTypes >> (tAS >> (entityId | typeId)).maybe).as(:namedTypeOrRename)
|
322
|
+
end
|
207
323
|
rule(:namedTypes) { (entityRef | typeRef).as(:namedTypes) }
|
208
324
|
rule(:nullStmt) { op_delim.as(:nullStmt) }
|
209
325
|
rule(:numberType) { tNUMBER.as(:numberType) }
|
@@ -216,7 +332,9 @@ module Expressir
|
|
216
332
|
rule(:op_asterisk) { cstr("*").as(:op_asterisk) }
|
217
333
|
rule(:op_colon) { cstr(":").as(:op_colon) }
|
218
334
|
rule(:op_colon_equals_colon) { cstr(":=:").as(:op_colon_equals_colon) }
|
219
|
-
rule(:op_colon_less_greater_colon)
|
335
|
+
rule(:op_colon_less_greater_colon) do
|
336
|
+
cstr(":<>:").as(:op_colon_less_greater_colon)
|
337
|
+
end
|
220
338
|
rule(:op_comma) { cstr(",").as(:op_comma) }
|
221
339
|
rule(:op_decl) { cstr(":=").as(:op_decl) }
|
222
340
|
rule(:op_delim) { cstr(";").as(:op_delim) }
|
@@ -246,13 +364,23 @@ module Expressir
|
|
246
364
|
rule(:parameter) { expression.as(:parameter) }
|
247
365
|
rule(:parameterId) { simpleId.as(:parameterId) }
|
248
366
|
rule(:parameterRef) { parameterId.as(:parameterRef) }
|
249
|
-
rule(:parameterType)
|
367
|
+
rule(:parameterType) do
|
368
|
+
(generalizedTypes | namedTypes | simpleTypes).as(:parameterType)
|
369
|
+
end
|
250
370
|
rule(:population) { entityRef.as(:population) }
|
251
371
|
rule(:precisionSpec) { numericExpression.as(:precisionSpec) }
|
252
|
-
rule(:primary)
|
253
|
-
|
254
|
-
|
255
|
-
rule(:
|
372
|
+
rule(:primary) do
|
373
|
+
(literal | (qualifiableFactor >> qualifier.repeat.as(:qualifier))).as(:primary)
|
374
|
+
end
|
375
|
+
rule(:procedureCallStmt) do
|
376
|
+
((builtInProcedure | procedureRef) >> actualParameterList.maybe >> op_delim).as(:procedureCallStmt)
|
377
|
+
end
|
378
|
+
rule(:procedureDecl) do
|
379
|
+
(procedureHead >> algorithmHead >> stmt.repeat.as(:stmt) >> tEND_PROCEDURE >> op_delim).as(:procedureDecl)
|
380
|
+
end
|
381
|
+
rule(:procedureHeadParameter) do
|
382
|
+
(tVAR.maybe >> formalParameter).as(:procedureHeadParameter)
|
383
|
+
end
|
256
384
|
rule(:procedureHead) do
|
257
385
|
(tPROCEDURE >> procedureId >>
|
258
386
|
(op_leftparen >> (procedureHeadParameter >>
|
@@ -260,33 +388,61 @@ module Expressir
|
|
260
388
|
end
|
261
389
|
rule(:procedureId) { simpleId.as(:procedureId) }
|
262
390
|
rule(:procedureRef) { procedureId.as(:procedureRef) }
|
263
|
-
rule(:qualifiableFactor)
|
264
|
-
|
265
|
-
|
391
|
+
rule(:qualifiableFactor) do
|
392
|
+
(functionCall | attributeRef | constantFactor | generalRef | population).as(:qualifiableFactor)
|
393
|
+
end
|
394
|
+
rule(:qualifiedAttribute) do
|
395
|
+
(tSELF >> groupQualifier >> attributeQualifier).as(:qualifiedAttribute)
|
396
|
+
end
|
397
|
+
rule(:qualifier) do
|
398
|
+
(attributeQualifier | groupQualifier | indexQualifier).as(:qualifier)
|
399
|
+
end
|
266
400
|
rule(:queryExpression) do
|
267
401
|
(tQUERY >> op_leftparen >> variableId >> op_query_begin >> aggregateSource >> op_pipe >> logicalExpression >> op_rightparen).as(:queryExpression)
|
268
402
|
end
|
269
|
-
rule(:realLiteral)
|
270
|
-
|
271
|
-
|
403
|
+
rule(:realLiteral) do
|
404
|
+
cts((digits >> str(".") >> digits.maybe >> (match["eE"] >> sign.maybe >> digits).maybe).as(:str)).as(:realLiteral)
|
405
|
+
end
|
406
|
+
rule(:realType) do
|
407
|
+
(tREAL >> (op_leftparen >> precisionSpec >> op_rightparen).maybe).as(:realType)
|
408
|
+
end
|
409
|
+
rule(:redeclaredAttribute) do
|
410
|
+
(qualifiedAttribute >> (tRENAMED >> attributeId).maybe).as(:redeclaredAttribute)
|
411
|
+
end
|
272
412
|
rule(:referenceClause) do
|
273
413
|
(tREFERENCE >> tFROM >> schemaRef >>
|
274
414
|
(op_leftparen >> (resourceOrRename >> (op_comma >> resourceOrRename).repeat).as(:listOf_resourceOrRename) >> op_rightparen).maybe >> op_delim).as(:referenceClause)
|
275
415
|
end
|
276
|
-
rule(:referencedAttribute)
|
416
|
+
rule(:referencedAttribute) do
|
417
|
+
(attributeRef | qualifiedAttribute).as(:referencedAttribute)
|
418
|
+
end
|
277
419
|
rule(:relOpExtended) { (relOp | tIN | tLIKE).as(:relOpExtended) }
|
278
420
|
rule(:relOp) do
|
279
421
|
(op_less_equal | op_greater_equal | op_less_greater | op_less_than | op_greater_than | op_equals |
|
280
422
|
op_colon_less_greater_colon | op_colon_equals_colon).as(:relOp)
|
281
423
|
end
|
282
|
-
rule(:renameId)
|
283
|
-
|
284
|
-
|
424
|
+
rule(:renameId) do
|
425
|
+
(constantId | entityId | functionId | procedureId | typeId).as(:renameId)
|
426
|
+
end
|
427
|
+
rule(:repeatControl) do
|
428
|
+
(incrementControl.maybe >> whileControl.maybe >> untilControl.maybe).as(:repeatControl)
|
429
|
+
end
|
430
|
+
rule(:repeatStmt) do
|
431
|
+
(tREPEAT >> repeatControl >> op_delim >> stmt.repeat(1).as(:stmt) >> tEND_REPEAT >> op_delim.as(:op_delim2)).as(:repeatStmt)
|
432
|
+
end
|
285
433
|
rule(:repetition) { numericExpression.as(:repetition) }
|
286
|
-
rule(:resourceOrRename)
|
287
|
-
|
288
|
-
|
289
|
-
rule(:
|
434
|
+
rule(:resourceOrRename) do
|
435
|
+
(resourceRef >> (tAS >> renameId).maybe).as(:resourceOrRename)
|
436
|
+
end
|
437
|
+
rule(:resourceRef) do
|
438
|
+
(constantRef | entityRef | functionRef | procedureRef | typeRef).as(:resourceRef)
|
439
|
+
end
|
440
|
+
rule(:returnStmt) do
|
441
|
+
(tRETURN >> (op_leftparen >> expression >> op_rightparen).maybe >> op_delim).as(:returnStmt)
|
442
|
+
end
|
443
|
+
rule(:ruleDecl) do
|
444
|
+
(ruleHead >> algorithmHead >> stmt.repeat.as(:stmt) >> whereClause >> tEND_RULE >> op_delim).as(:ruleDecl)
|
445
|
+
end
|
290
446
|
rule(:ruleHead) do
|
291
447
|
(tRULE >> ruleId >> tFOR >> op_leftparen >>
|
292
448
|
(entityRef >> (op_comma >> entityRef).repeat).as(:listOf_entityRef) >> op_rightparen >> op_delim).as(:ruleHead)
|
@@ -295,7 +451,9 @@ module Expressir
|
|
295
451
|
rule(:ruleLabelId) { simpleId.as(:ruleLabelId) }
|
296
452
|
rule(:ruleLabelRef) { ruleLabelId.as(:ruleLabelRef) }
|
297
453
|
rule(:ruleRef) { ruleId.as(:ruleRef) }
|
298
|
-
rule(:schemaBodyDeclaration)
|
454
|
+
rule(:schemaBodyDeclaration) do
|
455
|
+
(declaration | ruleDecl).as(:schemaBodyDeclaration)
|
456
|
+
end
|
299
457
|
rule(:schemaBody) do
|
300
458
|
(interfaceSpecification.repeat.as(:interfaceSpecification) >> constantDecl.maybe >>
|
301
459
|
schemaBodyDeclaration.repeat.as(:schemaBodyDeclaration)).as(:schemaBody)
|
@@ -306,22 +464,42 @@ module Expressir
|
|
306
464
|
rule(:schemaId) { simpleId.as(:schemaId) }
|
307
465
|
rule(:schemaRef) { schemaId.as(:schemaRef) }
|
308
466
|
rule(:schemaVersionId) { stringLiteral.as(:schemaVersionId) }
|
309
|
-
rule(:selectExtension)
|
310
|
-
|
467
|
+
rule(:selectExtension) do
|
468
|
+
(tBASED_ON >> typeRef >> (tWITH >> selectList).maybe).as(:selectExtension)
|
469
|
+
end
|
470
|
+
rule(:selectList) do
|
471
|
+
(op_leftparen >> (namedTypes >> (op_comma >> namedTypes).repeat).as(:listOf_namedTypes) >> op_rightparen).as(:selectList)
|
472
|
+
end
|
311
473
|
rule(:selector) { expression.as(:selector) }
|
312
|
-
rule(:selectType)
|
313
|
-
|
474
|
+
rule(:selectType) do
|
475
|
+
((tEXTENSIBLE >> tGENERIC_ENTITY.maybe).maybe >> tSELECT >> (selectList | selectExtension).maybe).as(:selectType)
|
476
|
+
end
|
477
|
+
rule(:setType) do
|
478
|
+
(tSET >> boundSpec.maybe >> tOF >> instantiableType).as(:setType)
|
479
|
+
end
|
314
480
|
rule(:sign) { match["+-"] }
|
315
|
-
rule(:simpleExpression)
|
481
|
+
rule(:simpleExpression) do
|
482
|
+
(term >> (addLikeOp.as(:operator) >> term).as(:item).repeat.as(:rhs)).as(:simpleExpression)
|
483
|
+
end
|
316
484
|
rule(:simpleFactor) do
|
317
485
|
(simpleFactorExpression | aggregateInitializer | entityConstructor | interval | queryExpression | stringLiteral |
|
318
486
|
simpleFactorUnaryExpression | enumerationReference).as(:simpleFactor)
|
319
487
|
end
|
320
|
-
rule(:simpleFactorExpression)
|
321
|
-
|
322
|
-
|
323
|
-
rule(:
|
324
|
-
|
488
|
+
rule(:simpleFactorExpression) do
|
489
|
+
((op_leftparen >> expression >> op_rightparen) | primary).as(:simpleFactorExpression)
|
490
|
+
end
|
491
|
+
rule(:simpleFactorUnaryExpression) do
|
492
|
+
(unaryOp >> simpleFactorExpression).as(:simpleFactorUnaryExpression)
|
493
|
+
end
|
494
|
+
rule(:simpleId) do
|
495
|
+
anyKeyword.absent? >> cts((match["a-zA-Z_"] >> match["a-zA-Z0-9_"].repeat).as(:str)).as(:simpleId)
|
496
|
+
end
|
497
|
+
rule(:simpleStringLiteral) do
|
498
|
+
cts((str("'") >> (str("'").absent? >> any).repeat >> str("'")).as(:str)).as(:simpleStringLiteral)
|
499
|
+
end
|
500
|
+
rule(:simpleTypes) do
|
501
|
+
(binaryType | booleanType | integerType | logicalType | numberType | realType | stringType).as(:simpleTypes)
|
502
|
+
end
|
325
503
|
rule(:skipStmt) { (tSKIP >> op_delim).as(:skipStmt) }
|
326
504
|
rule(:space) { match[" \r\n\t\f"] | embeddedRemark | tailRemark }
|
327
505
|
rule(:spaces) { space.repeat.as(:spaces) }
|
@@ -329,26 +507,56 @@ module Expressir
|
|
329
507
|
(aliasStmt | assignmentStmt | caseStmt | compoundStmt | escapeStmt | ifStmt |
|
330
508
|
nullStmt | procedureCallStmt | repeatStmt | returnStmt | skipStmt).as(:stmt)
|
331
509
|
end
|
332
|
-
rule(:stringLiteral)
|
510
|
+
rule(:stringLiteral) do
|
511
|
+
(simpleStringLiteral | encodedStringLiteral).as(:stringLiteral)
|
512
|
+
end
|
333
513
|
rule(:stringType) { (tSTRING >> widthSpec.maybe).as(:stringType) }
|
334
|
-
rule(:subsuper)
|
335
|
-
|
336
|
-
|
337
|
-
rule(:
|
514
|
+
rule(:subsuper) do
|
515
|
+
(supertypeConstraint.maybe >> subtypeDeclaration.maybe).as(:subsuper)
|
516
|
+
end
|
517
|
+
rule(:subtypeConstraintBody) do
|
518
|
+
(abstractSupertype.maybe >> totalOver.maybe >> (supertypeExpression >> op_delim).maybe).as(:subtypeConstraintBody)
|
519
|
+
end
|
520
|
+
rule(:subtypeConstraintDecl) do
|
521
|
+
(subtypeConstraintHead >> subtypeConstraintBody >> tEND_SUBTYPE_CONSTRAINT >> op_delim).as(:subtypeConstraintDecl)
|
522
|
+
end
|
523
|
+
rule(:subtypeConstraintHead) do
|
524
|
+
(tSUBTYPE_CONSTRAINT >> subtypeConstraintId >> tFOR >> entityRef >> op_delim).as(:subtypeConstraintHead)
|
525
|
+
end
|
338
526
|
rule(:subtypeConstraintId) { simpleId.as(:subtypeConstraintId) }
|
339
|
-
rule(:subtypeConstraintRef)
|
340
|
-
|
527
|
+
rule(:subtypeConstraintRef) do
|
528
|
+
subtypeConstraintId.as(:subtypeConstraintRef)
|
529
|
+
end
|
530
|
+
rule(:subtypeConstraint) do
|
531
|
+
(tOF >> op_leftparen >> supertypeExpression >> op_rightparen).as(:subtypeConstraint)
|
532
|
+
end
|
341
533
|
rule(:subtypeDeclaration) do
|
342
534
|
(tSUBTYPE >> tOF >> op_leftparen >> entityRef >> (op_comma >> entityRef).repeat >> op_rightparen).as(:listOf_entityRef).as(:subtypeDeclaration)
|
343
535
|
end
|
344
|
-
rule(:supertypeConstraint)
|
345
|
-
|
346
|
-
|
347
|
-
rule(:
|
348
|
-
|
349
|
-
|
350
|
-
rule(:
|
351
|
-
|
536
|
+
rule(:supertypeConstraint) do
|
537
|
+
(abstractSupertypeDeclaration | abstractEntityDeclaration | supertypeRule).as(:supertypeConstraint)
|
538
|
+
end
|
539
|
+
rule(:supertypeExpression) do
|
540
|
+
(supertypeFactor >> (tANDOR.as(:operator) >> supertypeFactor).as(:item).repeat.as(:rhs)).as(:supertypeExpression)
|
541
|
+
end
|
542
|
+
rule(:supertypeFactor) do
|
543
|
+
(supertypeTerm >> (tAND.as(:operator) >> supertypeTerm).as(:item).repeat.as(:rhs)).as(:supertypeFactor)
|
544
|
+
end
|
545
|
+
rule(:supertypeRule) do
|
546
|
+
(tSUPERTYPE >> subtypeConstraint).as(:supertypeRule)
|
547
|
+
end
|
548
|
+
rule(:supertypeTerm) do
|
549
|
+
(entityRef | oneOf | (op_leftparen >> supertypeExpression >> op_rightparen)).as(:supertypeTerm)
|
550
|
+
end
|
551
|
+
rule(:syntax) do
|
552
|
+
(spaces.as(:spaces) >> schemaDecl.repeat(1).as(:schemaDecl) >> spaces.as(:trailer)).as(:syntax)
|
553
|
+
end
|
554
|
+
rule(:tailRemark) do
|
555
|
+
(str("--") >> (str("\n").absent? >> any).repeat >> str("\n").maybe).as(:tailRemark)
|
556
|
+
end
|
557
|
+
rule(:term) do
|
558
|
+
(factor >> (multiplicationLikeOp >> factor).as(:item).repeat.as(:rhs)).as(:term)
|
559
|
+
end
|
352
560
|
rule(:totalOver) do
|
353
561
|
(tTOTAL_OVER >> op_leftparen >> (entityRef >> (op_comma >> entityRef).repeat).as(:listOf_entityRef) >> op_rightparen >> op_delim).as(:totalOver)
|
354
562
|
end
|
@@ -361,7 +569,9 @@ module Expressir
|
|
361
569
|
rule(:typeLabel) { (typeLabelId | typeLabelRef).as(:typeLabel) }
|
362
570
|
rule(:typeRef) { typeId.as(:typeRef) }
|
363
571
|
rule(:unaryOp) { (op_plus | op_minus | tNOT).as(:unaryOp) }
|
364
|
-
rule(:underlyingType)
|
572
|
+
rule(:underlyingType) do
|
573
|
+
(concreteTypes | constructedTypes).as(:underlyingType)
|
574
|
+
end
|
365
575
|
rule(:uniqueClause) do
|
366
576
|
(tUNIQUE >> (uniqueRule >> op_delim >> (uniqueRule >> op_delim.as(:op_delim2)).repeat).as(:listOf_uniqueRule)).as(:uniqueClause)
|
367
577
|
end
|
@@ -376,10 +586,14 @@ module Expressir
|
|
376
586
|
end
|
377
587
|
rule(:variableId) { simpleId.as(:variableId) }
|
378
588
|
rule(:variableRef) { variableId.as(:variableRef) }
|
379
|
-
rule(:whereClause)
|
589
|
+
rule(:whereClause) do
|
590
|
+
(tWHERE >> (domainRule >> op_delim).repeat.as(:listOf_domainRule)).as(:whereClause)
|
591
|
+
end
|
380
592
|
rule(:whileControl) { (tWHILE >> logicalExpression).as(:whileControl) }
|
381
593
|
rule(:width) { numericExpression.as(:width) }
|
382
|
-
rule(:widthSpec)
|
594
|
+
rule(:widthSpec) do
|
595
|
+
(op_leftparen >> width >> op_rightparen >> tFIXED.maybe).as(:widthSpec)
|
596
|
+
end
|
383
597
|
end
|
384
598
|
|
385
599
|
# Parses Express file into an Express model
|
@@ -402,7 +616,8 @@ module Expressir
|
|
402
616
|
raise Error::SchemaParseFailure.new(schema_file, e)
|
403
617
|
end
|
404
618
|
|
405
|
-
visitor = Expressir::Express::Visitor.new(source,
|
619
|
+
visitor = Expressir::Express::Visitor.new(source,
|
620
|
+
include_source: include_source)
|
406
621
|
@repository = visitor.visit_ast ast, :top
|
407
622
|
|
408
623
|
@repository.schemas.each do |schema|
|
@@ -431,11 +646,13 @@ module Expressir
|
|
431
646
|
# @yieldparam schemas [Array, nil] Array of parsed schemas (nil if parsing failed)
|
432
647
|
# @yieldparam error [Exception, nil] Error that occurred (nil if parsing succeeded)
|
433
648
|
# @return [Model::Repository]
|
434
|
-
def self.from_files(files, skip_references: nil, include_source: nil,
|
649
|
+
def self.from_files(files, skip_references: nil, include_source: nil,
|
650
|
+
root_path: nil)
|
435
651
|
all_schemas = []
|
436
652
|
|
437
653
|
files.each do |file|
|
438
|
-
repository = from_file(file, skip_references: true,
|
654
|
+
repository = from_file(file, skip_references: true,
|
655
|
+
root_path: root_path)
|
439
656
|
file_schemas = repository.schemas
|
440
657
|
all_schemas.concat(file_schemas)
|
441
658
|
|