expressir 0.2.8-x86-linux → 0.2.13-x86-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +1 -7
- data/exe/format +20 -0
- data/expressir.gemspec +3 -2
- data/lib/expressir/express_exp/2.4/express_parser.so +0 -0
- data/lib/expressir/express_exp/2.5/express_parser.so +0 -0
- data/lib/expressir/express_exp/2.6/express_parser.so +0 -0
- data/lib/expressir/express_exp/2.7/express_parser.so +0 -0
- data/lib/expressir/express_exp/3.0/express_parser.so +0 -0
- data/lib/expressir/express_exp/formatter.rb +147 -110
- data/lib/expressir/express_exp/hyperlink_formatter.rb +25 -0
- data/lib/expressir/express_exp/parser.rb +14 -1
- data/lib/expressir/express_exp/schema_head_formatter.rb +14 -0
- data/lib/expressir/express_exp/visitor.rb +197 -111
- data/lib/expressir/model.rb +3 -1
- data/lib/expressir/model/attribute.rb +5 -1
- data/lib/expressir/model/constant.rb +5 -1
- data/lib/expressir/model/entity.rb +14 -20
- data/lib/expressir/model/enumeration_item.rb +5 -1
- data/lib/expressir/model/expressions/aggregate_initializer.rb +4 -2
- data/lib/expressir/model/expressions/aggregate_item.rb +3 -1
- data/lib/expressir/model/expressions/attribute_reference.rb +3 -1
- data/lib/expressir/model/expressions/binary_expression.rb +3 -1
- data/lib/expressir/model/expressions/call.rb +4 -2
- data/lib/expressir/model/expressions/entity_constructor.rb +4 -2
- data/lib/expressir/model/expressions/group_reference.rb +3 -1
- data/lib/expressir/model/expressions/index_reference.rb +3 -1
- data/lib/expressir/model/expressions/interval.rb +3 -1
- data/lib/expressir/model/expressions/query_expression.rb +5 -2
- data/lib/expressir/model/expressions/simple_reference.rb +3 -1
- data/lib/expressir/model/expressions/unary_expression.rb +3 -1
- data/lib/expressir/model/function.rb +28 -39
- data/lib/expressir/model/identifier.rb +1 -3
- data/lib/expressir/model/informal_proposition.rb +15 -0
- data/lib/expressir/model/interface.rb +4 -2
- data/lib/expressir/model/literals/binary.rb +3 -1
- data/lib/expressir/model/literals/integer.rb +3 -1
- data/lib/expressir/model/literals/logical.rb +3 -1
- data/lib/expressir/model/literals/real.rb +3 -1
- data/lib/expressir/model/literals/string.rb +3 -1
- data/lib/expressir/model/model_element.rb +140 -0
- data/lib/expressir/model/parameter.rb +5 -1
- data/lib/expressir/model/procedure.rb +29 -40
- data/lib/expressir/model/renamed_ref.rb +3 -1
- data/lib/expressir/model/repository.rb +5 -5
- data/lib/expressir/model/rule.rb +33 -41
- data/lib/expressir/model/schema.rb +44 -46
- data/lib/expressir/model/statements/alias.rb +6 -3
- data/lib/expressir/model/statements/assignment.rb +3 -1
- data/lib/expressir/model/statements/call.rb +4 -2
- data/lib/expressir/model/statements/case.rb +4 -2
- data/lib/expressir/model/statements/case_action.rb +4 -2
- data/lib/expressir/model/statements/compound.rb +4 -2
- data/lib/expressir/model/statements/escape.rb +1 -1
- data/lib/expressir/model/statements/if.rb +5 -3
- data/lib/expressir/model/statements/null.rb +1 -1
- data/lib/expressir/model/statements/repeat.rb +6 -3
- data/lib/expressir/model/statements/return.rb +3 -1
- data/lib/expressir/model/statements/skip.rb +1 -1
- data/lib/expressir/model/subtype_constraint.rb +5 -2
- data/lib/expressir/model/type.rb +11 -4
- data/lib/expressir/model/types/aggregate.rb +5 -1
- data/lib/expressir/model/types/array.rb +3 -1
- data/lib/expressir/model/types/bag.rb +3 -1
- data/lib/expressir/model/types/binary.rb +3 -1
- data/lib/expressir/model/types/boolean.rb +1 -1
- data/lib/expressir/model/types/enumeration.rb +5 -3
- data/lib/expressir/model/types/generic.rb +5 -1
- data/lib/expressir/model/types/generic_entity.rb +5 -1
- data/lib/expressir/model/types/integer.rb +1 -1
- data/lib/expressir/model/types/list.rb +3 -1
- data/lib/expressir/model/types/logical.rb +1 -1
- data/lib/expressir/model/types/number.rb +1 -1
- data/lib/expressir/model/types/real.rb +3 -1
- data/lib/expressir/model/types/select.rb +5 -3
- data/lib/expressir/model/types/set.rb +3 -1
- data/lib/expressir/model/types/string.rb +3 -1
- data/lib/expressir/model/unique.rb +6 -2
- data/lib/expressir/model/variable.rb +5 -1
- data/lib/expressir/model/where.rb +5 -1
- data/lib/expressir/version.rb +1 -1
- data/original/examples/syntax/hyperlink.exp +8 -0
- data/original/examples/syntax/hyperlink_formatted.exp +19 -0
- data/original/examples/syntax/remark.exp +63 -20
- data/original/examples/syntax/remark_formatted.exp +62 -24
- data/original/examples/syntax/simple.exp +3 -0
- data/original/examples/syntax/source.exp +16 -0
- data/original/examples/syntax/syntax.exp +201 -190
- data/original/examples/syntax/syntax_formatted.exp +370 -799
- data/spec/expressir/express_exp/{format_remark_spec.rb → formatter/remark_spec.rb} +2 -2
- data/spec/expressir/express_exp/{format_syntax_spec.rb → formatter/syntax_spec.rb} +2 -2
- data/spec/expressir/express_exp/hyperlink_formatter_spec.rb +24 -0
- data/spec/expressir/express_exp/parser/head_source_spec.rb +38 -0
- data/spec/expressir/express_exp/parser/multiple_spec.rb +32 -0
- data/spec/expressir/express_exp/{parse_remark_spec.rb → parser/remark_spec.rb} +120 -55
- data/spec/expressir/express_exp/{source_spec.rb → parser/source_spec.rb} +3 -6
- data/spec/expressir/express_exp/parser/syntax_spec.rb +3080 -0
- data/spec/expressir/express_exp/schema_head_formatter_spec.rb +36 -0
- data/spec/expressir/model/{find_spec.rb → model_element/find_spec.rb} +26 -8
- data/spec/expressir/model/model_element/hash_spec.rb +66 -0
- metadata +38 -13
- data/lib/expressir/model/scope.rb +0 -32
- data/spec/expressir/express_exp/ap233_spec.rb +0 -22
- data/spec/expressir/express_exp/find_spec.rb +0 -28
- data/spec/expressir/express_exp/parse_syntax_spec.rb +0 -3003
@@ -0,0 +1,25 @@
|
|
1
|
+
require "expressir/express_exp/formatter"
|
2
|
+
|
3
|
+
module Expressir
|
4
|
+
module ExpressExp
|
5
|
+
class HyperlinkFormatter < Formatter
|
6
|
+
def format_expressions_simple_reference(node)
|
7
|
+
return node.id if node.parent.is_a? Model::Expressions::AttributeReference
|
8
|
+
|
9
|
+
# skip hyperlink if target node can't be found
|
10
|
+
target_node = node.find(node.id)
|
11
|
+
return node.id unless target_node
|
12
|
+
|
13
|
+
# skip hyperlink for implicit scopes
|
14
|
+
return node.id if target_node.is_a? Model::Statements::Alias or target_node.is_a? Model::Statements::Repeat or target_node.is_a? Model::Expressions::QueryExpression
|
15
|
+
|
16
|
+
# skip hyperlink if this node and target node are in the same main item
|
17
|
+
node_path_parts = node.path.split(".")
|
18
|
+
target_node_path_parts = target_node.path.split(".")
|
19
|
+
return node.id if node_path_parts[0..1] == target_node_path_parts[0..1]
|
20
|
+
|
21
|
+
"{{{<<express:#{target_node.path},#{node.id}>>}}}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -9,7 +9,7 @@ require 'expressir/express_exp/visitor'
|
|
9
9
|
module Expressir
|
10
10
|
module ExpressExp
|
11
11
|
class Parser
|
12
|
-
def self.
|
12
|
+
def self.from_file(file)
|
13
13
|
input = File.read(file)
|
14
14
|
|
15
15
|
=begin
|
@@ -36,6 +36,19 @@ module Expressir
|
|
36
36
|
|
37
37
|
repo
|
38
38
|
end
|
39
|
+
|
40
|
+
def self.from_files(files)
|
41
|
+
schemas = files.map{|file| self.from_file(file).schemas}.flatten
|
42
|
+
|
43
|
+
Model::Repository.new({
|
44
|
+
schemas: schemas
|
45
|
+
})
|
46
|
+
end
|
47
|
+
|
48
|
+
# deprecated
|
49
|
+
def self.from_exp(file)
|
50
|
+
self.from_file(file)
|
51
|
+
end
|
39
52
|
end
|
40
53
|
end
|
41
54
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "expressir/express_exp/formatter"
|
2
|
+
|
3
|
+
module Expressir
|
4
|
+
module ExpressExp
|
5
|
+
class SchemaHeadFormatter < Formatter
|
6
|
+
def format_schema(node)
|
7
|
+
[
|
8
|
+
"SCHEMA #{node.id}#{node.version ? " #{format(node.version)}" : ""};",
|
9
|
+
*node.interfaces.map{|x| format(x)}
|
10
|
+
].join("\n")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -5,10 +5,8 @@ rescue LoadError
|
|
5
5
|
require_relative "express_parser"
|
6
6
|
end
|
7
7
|
require "expressir/model"
|
8
|
+
require "set"
|
8
9
|
|
9
|
-
# static shorthands are unwrapped
|
10
|
-
# - entity attributes, function/procedure parameters, local variables
|
11
|
-
#
|
12
10
|
# reference type is not recognized
|
13
11
|
# see note in A.1.5 Interpreted identifiers
|
14
12
|
# > It is expected that identifiers matching these syntax rules are known to an implementation.
|
@@ -16,7 +14,7 @@ require "expressir/model"
|
|
16
14
|
# > method of gaining this information is multi-pass parsing: the first pass collects the identifiers from their
|
17
15
|
# > declarations, so that subsequent passes are then able to distinguish a veriable_ref from a function_ref,
|
18
16
|
# > for example.
|
19
|
-
#
|
17
|
+
# - such multi-pass parsing is not implemented yet
|
20
18
|
# - xxxRef - merged to SimpleReference
|
21
19
|
# - entityConstructor, functionCall - merged to Call
|
22
20
|
#
|
@@ -25,6 +23,13 @@ require "expressir/model"
|
|
25
23
|
# > A syntactic construct such as ARRAY[1:3] OF REAL satisfies two syntactic productions —
|
26
24
|
# > aggregation_type and general_aggregation_type. It is considered to be instantiable no matter which
|
27
25
|
# > production it is required to satisfy in the syntax.
|
26
|
+
#
|
27
|
+
# static shorthands are unwrapped
|
28
|
+
# - entity attributes, function/procedure parameters, local variables
|
29
|
+
#
|
30
|
+
# all access to ctx members must happen before calling other visitor code
|
31
|
+
# - prevents segfault in ANTLR4 C++ runtime, not sure why they are caused
|
32
|
+
# - e.g. see visit_schema_decl
|
28
33
|
|
29
34
|
module Expressir
|
30
35
|
module ExpressExp
|
@@ -33,33 +38,52 @@ module Expressir
|
|
33
38
|
|
34
39
|
def initialize(tokens)
|
35
40
|
@tokens = tokens
|
36
|
-
@
|
41
|
+
@attached_remark_tokens = ::Set.new
|
37
42
|
|
38
43
|
super()
|
39
44
|
end
|
40
45
|
|
41
46
|
def visit(ctx)
|
42
|
-
|
43
|
-
attach_source(ctx,
|
44
|
-
|
45
|
-
|
46
|
-
result
|
47
|
+
node = super(ctx)
|
48
|
+
attach_source(ctx, node)
|
49
|
+
attach_remarks(ctx, node)
|
50
|
+
node
|
47
51
|
end
|
48
52
|
|
49
|
-
def visit_if(ctx)
|
50
|
-
|
53
|
+
def visit_if(ctx, default = nil)
|
54
|
+
if ctx
|
55
|
+
visit(ctx)
|
56
|
+
else
|
57
|
+
default
|
58
|
+
end
|
51
59
|
end
|
52
60
|
|
53
61
|
def visit_if_map(ctx)
|
54
|
-
|
62
|
+
if ctx
|
63
|
+
ctx.map{|ctx2| visit(ctx2)}
|
64
|
+
else
|
65
|
+
[]
|
66
|
+
end
|
55
67
|
end
|
56
68
|
|
57
69
|
def visit_if_map_flatten(ctx)
|
58
|
-
|
70
|
+
if ctx
|
71
|
+
ctx.map{|ctx2| visit(ctx2)}.flatten
|
72
|
+
else
|
73
|
+
[]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def get_tokens_source(tokens)
|
78
|
+
if tokens.last.text == '<EOF>'
|
79
|
+
tokens.pop
|
80
|
+
end
|
81
|
+
|
82
|
+
tokens.map{|x| x.text}.join('').force_encoding('UTF-8')
|
59
83
|
end
|
60
84
|
|
61
85
|
def get_tokens(ctx)
|
62
|
-
start_index, stop_index = if ctx.
|
86
|
+
start_index, stop_index = if ctx.is_a? ::ExpressParser::SyntaxContext
|
63
87
|
[0, @tokens.size - 1]
|
64
88
|
else
|
65
89
|
[ctx.start.token_index, ctx.stop.token_index]
|
@@ -68,66 +92,94 @@ module Expressir
|
|
68
92
|
@tokens[start_index..stop_index]
|
69
93
|
end
|
70
94
|
|
95
|
+
def get_head_tokens(ctx)
|
96
|
+
start_index, stop_index = if ctx.is_a? ::ExpressParser::SchemaDeclContext
|
97
|
+
start_index = ctx.start.token_index
|
98
|
+
stop_index = if ctx.schema_body.interface_specification.length > 0
|
99
|
+
ctx.schema_body.interface_specification.last.stop.token_index
|
100
|
+
elsif ctx.schema_version_id
|
101
|
+
ctx.schema_version_id.stop.token_index + 1
|
102
|
+
else
|
103
|
+
ctx.schema_id.stop.token_index + 1
|
104
|
+
end
|
105
|
+
|
106
|
+
[start_index, stop_index]
|
107
|
+
end
|
108
|
+
|
109
|
+
if start_index and stop_index
|
110
|
+
@tokens[start_index..stop_index]
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
71
114
|
def attach_source(ctx, node)
|
72
115
|
if node.class.method_defined? :source
|
73
|
-
|
74
|
-
node.source =
|
116
|
+
tokens = get_tokens(ctx)
|
117
|
+
node.source = get_tokens_source(tokens)
|
75
118
|
end
|
76
|
-
end
|
77
119
|
|
78
|
-
|
79
|
-
|
80
|
-
node.
|
81
|
-
if child_node.class.method_defined? :parent
|
82
|
-
child_node.parent = node
|
83
|
-
end
|
84
|
-
end
|
120
|
+
if node.class.method_defined? :head_source
|
121
|
+
tokens = get_head_tokens(ctx)
|
122
|
+
node.head_source = get_tokens_source(tokens)
|
85
123
|
end
|
86
124
|
end
|
87
125
|
|
126
|
+
def find_remark_target(node, path)
|
127
|
+
target_node = node.find(path)
|
128
|
+
return target_node if target_node
|
129
|
+
|
130
|
+
# check if path should create implicit informal proposal
|
131
|
+
# see https://github.com/lutaml/expressir/issues/50
|
132
|
+
rest, _, current_path = path.rpartition(".") # get last path part
|
133
|
+
_, _, current_path = current_path.rpartition(":") # ignore prefix
|
134
|
+
|
135
|
+
# match informal proposition id
|
136
|
+
informal_proposition_id = current_path.match(/^IP\d+$/).to_a[0]
|
137
|
+
return unless informal_proposition_id
|
138
|
+
|
139
|
+
# find informal proposition target
|
140
|
+
target_node = node.find(rest)
|
141
|
+
return unless target_node and target_node.class.method_defined? :informal_propositions
|
142
|
+
|
143
|
+
# create implicit informal proposition
|
144
|
+
informal_proposition = Model::InformalProposition.new({
|
145
|
+
id: informal_proposition_id
|
146
|
+
})
|
147
|
+
target_node.informal_propositions << informal_proposition
|
148
|
+
informal_proposition.parent = target_node
|
149
|
+
informal_proposition
|
150
|
+
end
|
151
|
+
|
88
152
|
def attach_remarks(ctx, node)
|
89
153
|
remark_tokens = get_tokens(ctx).select{|x| x.channel == REMARK_CHANNEL}
|
90
|
-
if remark_tokens
|
91
|
-
remark_tokens.each do |remark_token|
|
92
|
-
remark_text = remark_token.text
|
93
|
-
|
94
|
-
# check if it is tagged remark
|
95
|
-
match = if remark_text.start_with?('--')
|
96
|
-
remark_text[2..-1].match(/^"([^"]*)"(.*)$/)
|
97
|
-
elsif remark_text.start_with?('(*') and remark_text.end_with?('*)')
|
98
|
-
remark_text[2..-3].match(/^"([^"]*)"(.*)$/m)
|
99
|
-
end
|
100
|
-
if !match
|
101
|
-
next
|
102
|
-
end
|
103
154
|
|
104
|
-
|
105
|
-
|
106
|
-
next
|
107
|
-
end
|
155
|
+
# skip already attached remarks
|
156
|
+
remark_tokens = remark_tokens.select{|x| !@attached_remark_tokens.include?(x)}
|
108
157
|
|
109
|
-
|
110
|
-
|
111
|
-
|
158
|
+
# parse remarks, find remark targets
|
159
|
+
tagged_remark_tokens = remark_tokens.map do |remark_token|
|
160
|
+
_, remark_tag, remark_text = if remark_token.text.start_with?('--')
|
161
|
+
remark_token.text.match(/^--"([^"]*)"(.*)$/).to_a
|
162
|
+
else
|
163
|
+
remark_token.text.match(/^\(\*"([^"]*)"(.*)\*\)$/m).to_a
|
164
|
+
end
|
112
165
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
current_node = current_node.parent
|
120
|
-
target_node = current_node.find(remark_tag)
|
121
|
-
end
|
166
|
+
if remark_tag
|
167
|
+
remark_target = find_remark_target(node, remark_tag)
|
168
|
+
end
|
169
|
+
if remark_text
|
170
|
+
remark_text = remark_text.strip.force_encoding('UTF-8')
|
171
|
+
end
|
122
172
|
|
123
|
-
|
124
|
-
|
125
|
-
target_node.remarks << remark_content
|
173
|
+
[remark_token, remark_target, remark_text]
|
174
|
+
end.select{|x| x[1]}
|
126
175
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
176
|
+
tagged_remark_tokens.each do |remark_token, remark_target, remark_text|
|
177
|
+
# attach remark
|
178
|
+
remark_target.remarks ||= []
|
179
|
+
remark_target.remarks << remark_text
|
180
|
+
|
181
|
+
# mark remark as attached, so that it is not attached again at higher nesting level
|
182
|
+
@attached_remark_tokens << remark_token
|
131
183
|
end
|
132
184
|
end
|
133
185
|
|
@@ -380,8 +432,8 @@ module Expressir
|
|
380
432
|
|
381
433
|
bound1 = visit_if(ctx__bound_spec__bound1)
|
382
434
|
bound2 = visit_if(ctx__bound_spec__bound2)
|
383
|
-
optional =
|
384
|
-
unique =
|
435
|
+
optional = ctx__OPTIONAL && true
|
436
|
+
unique = ctx__UNIQUE && true
|
385
437
|
base_type = visit_if(ctx__instantiable_type)
|
386
438
|
|
387
439
|
Model::Types::Array.new({
|
@@ -465,7 +517,7 @@ module Expressir
|
|
465
517
|
ctx__width_spec__FIXED = ctx__width_spec&.FIXED
|
466
518
|
|
467
519
|
width = visit_if(ctx__width_spec__width)
|
468
|
-
fixed =
|
520
|
+
fixed = ctx__width_spec__FIXED && true
|
469
521
|
|
470
522
|
Model::Types::Binary.new({
|
471
523
|
width: width,
|
@@ -717,16 +769,16 @@ module Expressir
|
|
717
769
|
ctx__entity_body__where_clause = ctx__entity_body&.where_clause
|
718
770
|
|
719
771
|
id = visit_if(ctx__entity_head__entity_id)
|
720
|
-
abstract =
|
772
|
+
abstract = (ctx__entity_head__subsuper__supertype_constraint__abstract_entity_declaration || ctx__entity_head__subsuper__supertype_constraint__abstract_supertype_declaration) && true
|
721
773
|
supertype_expression = visit_if(ctx__entity_head__subsuper__supertype_constraint__abstract_supertype_declaration || ctx__entity_head__subsuper__supertype_constraint__supertype_rule)
|
722
|
-
subtype_of = visit_if(ctx__entity_head__subsuper__subtype_declaration)
|
774
|
+
subtype_of = visit_if(ctx__entity_head__subsuper__subtype_declaration, [])
|
723
775
|
attributes = [
|
724
776
|
*visit_if_map_flatten(ctx__entity_body__explicit_attr),
|
725
777
|
*visit_if(ctx__entity_body__derive_clause),
|
726
778
|
*visit_if(ctx__entity_body__inverse_clause)
|
727
779
|
]
|
728
|
-
unique = visit_if(ctx__entity_body__unique_clause)
|
729
|
-
where = visit_if(ctx__entity_body__where_clause)
|
780
|
+
unique = visit_if(ctx__entity_body__unique_clause, [])
|
781
|
+
where = visit_if(ctx__entity_body__where_clause, [])
|
730
782
|
|
731
783
|
Model::Entity.new({
|
732
784
|
id: id,
|
@@ -799,10 +851,10 @@ module Expressir
|
|
799
851
|
ctx__enumeration_extension__type_ref = ctx__enumeration_extension&.type_ref
|
800
852
|
ctx__enumeration_extension__enumeration_items = ctx__enumeration_extension&.enumeration_items
|
801
853
|
|
802
|
-
extensible =
|
803
|
-
items = visit_if(ctx__enumeration_items)
|
854
|
+
extensible = ctx__EXTENSIBLE && true
|
855
|
+
items = visit_if(ctx__enumeration_items, [])
|
804
856
|
extension_type = visit_if(ctx__enumeration_extension__type_ref)
|
805
|
-
extension_items = visit_if(ctx__enumeration_extension__enumeration_items)
|
857
|
+
extension_items = visit_if(ctx__enumeration_extension__enumeration_items, [])
|
806
858
|
|
807
859
|
Model::Types::Enumeration.new({
|
808
860
|
extensible: extensible,
|
@@ -822,7 +874,7 @@ module Expressir
|
|
822
874
|
ctx__parameter_type = ctx.parameter_type
|
823
875
|
|
824
876
|
attributes = visit_if_map(ctx__attribute_decl)
|
825
|
-
optional =
|
877
|
+
optional = ctx__OPTIONAL && true
|
826
878
|
type = visit_if(ctx__parameter_type)
|
827
879
|
|
828
880
|
attributes.map do |attribute|
|
@@ -896,7 +948,7 @@ module Expressir
|
|
896
948
|
ctx__actual_parameter_list = ctx.actual_parameter_list
|
897
949
|
|
898
950
|
ref = visit_if(ctx__built_in_function || ctx__function_ref)
|
899
|
-
parameters = visit_if(ctx__actual_parameter_list)
|
951
|
+
parameters = visit_if(ctx__actual_parameter_list, [])
|
900
952
|
|
901
953
|
Model::Expressions::Call.new({
|
902
954
|
ref: ref,
|
@@ -919,15 +971,24 @@ module Expressir
|
|
919
971
|
parameters = visit_if_map_flatten(ctx__function_head__formal_parameter)
|
920
972
|
return_type = visit_if(ctx__function_head__parameter_type)
|
921
973
|
declarations = visit_if_map(ctx__algorithm_head__declaration)
|
922
|
-
|
923
|
-
|
974
|
+
types = declarations.select{|x| x.is_a? Model::Type}
|
975
|
+
entities = declarations.select{|x| x.is_a? Model::Entity}
|
976
|
+
subtype_constraints = declarations.select{|x| x.is_a? Model::SubtypeConstraint}
|
977
|
+
functions = declarations.select{|x| x.is_a? Model::Function}
|
978
|
+
procedures = declarations.select{|x| x.is_a? Model::Procedure}
|
979
|
+
constants = visit_if(ctx__algorithm_head__constant_decl, [])
|
980
|
+
variables = visit_if(ctx__algorithm_head__local_decl, [])
|
924
981
|
statements = visit_if_map(ctx__stmt)
|
925
982
|
|
926
983
|
Model::Function.new({
|
927
984
|
id: id,
|
928
985
|
parameters: parameters,
|
929
986
|
return_type: return_type,
|
930
|
-
|
987
|
+
types: types,
|
988
|
+
entities: entities,
|
989
|
+
subtype_constraints: subtype_constraints,
|
990
|
+
functions: functions,
|
991
|
+
procedures: procedures,
|
931
992
|
constants: constants,
|
932
993
|
variables: variables,
|
933
994
|
statements: statements
|
@@ -972,8 +1033,8 @@ module Expressir
|
|
972
1033
|
|
973
1034
|
bound1 = visit_if(ctx__bound_spec__bound1)
|
974
1035
|
bound2 = visit_if(ctx__bound_spec__bound2)
|
975
|
-
optional =
|
976
|
-
unique =
|
1036
|
+
optional = ctx__OPTIONAL && true
|
1037
|
+
unique = ctx__UNIQUE && true
|
977
1038
|
base_type = visit_if(ctx__parameter_type)
|
978
1039
|
|
979
1040
|
Model::Types::Array.new({
|
@@ -1011,7 +1072,7 @@ module Expressir
|
|
1011
1072
|
|
1012
1073
|
bound1 = visit_if(ctx__bound_spec__bound1)
|
1013
1074
|
bound2 = visit_if(ctx__bound_spec__bound2)
|
1014
|
-
unique =
|
1075
|
+
unique = ctx__UNIQUE && true
|
1015
1076
|
base_type = visit_if(ctx__parameter_type)
|
1016
1077
|
|
1017
1078
|
Model::Types::List.new({
|
@@ -1086,8 +1147,8 @@ module Expressir
|
|
1086
1147
|
ctx__if_stmt_else_statements = ctx.if_stmt_else_statements
|
1087
1148
|
|
1088
1149
|
expression = visit_if(ctx__logical_expression)
|
1089
|
-
statements = visit_if(ctx__if_stmt_statements)
|
1090
|
-
else_statements = visit_if(ctx__if_stmt_else_statements)
|
1150
|
+
statements = visit_if(ctx__if_stmt_statements, [])
|
1151
|
+
else_statements = visit_if(ctx__if_stmt_else_statements, [])
|
1091
1152
|
|
1092
1153
|
Model::Statements::If.new({
|
1093
1154
|
expression: expression,
|
@@ -1301,7 +1362,7 @@ module Expressir
|
|
1301
1362
|
|
1302
1363
|
bound1 = visit_if(ctx__bound_spec__bound1)
|
1303
1364
|
bound2 = visit_if(ctx__bound_spec__bound2)
|
1304
|
-
unique =
|
1365
|
+
unique = ctx__UNIQUE && true
|
1305
1366
|
base_type = visit_if(ctx__instantiable_type)
|
1306
1367
|
|
1307
1368
|
Model::Types::List.new({
|
@@ -1517,7 +1578,7 @@ module Expressir
|
|
1517
1578
|
ctx__actual_parameter_list = ctx.actual_parameter_list
|
1518
1579
|
|
1519
1580
|
ref = visit_if(ctx__built_in_procedure || ctx__procedure_ref)
|
1520
|
-
parameters = visit_if(ctx__actual_parameter_list)
|
1581
|
+
parameters = visit_if(ctx__actual_parameter_list, [])
|
1521
1582
|
|
1522
1583
|
Model::Statements::Call.new({
|
1523
1584
|
ref: ref,
|
@@ -1538,14 +1599,23 @@ module Expressir
|
|
1538
1599
|
id = visit_if(ctx__procedure_head__procedure_id)
|
1539
1600
|
parameters = visit_if_map_flatten(ctx__procedure_head__procedure_head_parameter)
|
1540
1601
|
declarations = visit_if_map(ctx__algorithm_head__declaration)
|
1541
|
-
|
1542
|
-
|
1602
|
+
types = declarations.select{|x| x.is_a? Model::Type}
|
1603
|
+
entities = declarations.select{|x| x.is_a? Model::Entity}
|
1604
|
+
subtype_constraints = declarations.select{|x| x.is_a? Model::SubtypeConstraint}
|
1605
|
+
functions = declarations.select{|x| x.is_a? Model::Function}
|
1606
|
+
procedures = declarations.select{|x| x.is_a? Model::Procedure}
|
1607
|
+
constants = visit_if(ctx__algorithm_head__constant_decl, [])
|
1608
|
+
variables = visit_if(ctx__algorithm_head__local_decl, [])
|
1543
1609
|
statements = visit_if_map(ctx__stmt)
|
1544
1610
|
|
1545
1611
|
Model::Procedure.new({
|
1546
1612
|
id: id,
|
1547
1613
|
parameters: parameters,
|
1548
|
-
|
1614
|
+
types: types,
|
1615
|
+
entities: entities,
|
1616
|
+
subtype_constraints: subtype_constraints,
|
1617
|
+
functions: functions,
|
1618
|
+
procedures: procedures,
|
1549
1619
|
constants: constants,
|
1550
1620
|
variables: variables,
|
1551
1621
|
statements: statements
|
@@ -1771,20 +1841,16 @@ module Expressir
|
|
1771
1841
|
ctx__resource_ref = ctx.resource_ref
|
1772
1842
|
ctx__rename_id = ctx.rename_id
|
1773
1843
|
|
1774
|
-
|
1775
|
-
|
1776
|
-
ref = visit(ctx__resource_ref)
|
1777
|
-
id = visit(ctx__rename_id)
|
1844
|
+
ref = visit_if(ctx__resource_ref)
|
1845
|
+
id = visit_if(ctx__rename_id)
|
1778
1846
|
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
1784
|
-
visit(ctx__resource_ref)
|
1785
|
-
end
|
1847
|
+
if id
|
1848
|
+
Model::RenamedRef.new({
|
1849
|
+
ref: ref,
|
1850
|
+
id: id
|
1851
|
+
})
|
1786
1852
|
else
|
1787
|
-
|
1853
|
+
ref
|
1788
1854
|
end
|
1789
1855
|
end
|
1790
1856
|
|
@@ -1822,15 +1888,24 @@ module Expressir
|
|
1822
1888
|
id = visit_if(ctx__rule_head__rule_id)
|
1823
1889
|
applies_to = visit_if_map(ctx__rule_head__entity_ref)
|
1824
1890
|
declarations = visit_if_map(ctx__algorithm_head__declaration)
|
1825
|
-
|
1826
|
-
|
1891
|
+
types = declarations.select{|x| x.is_a? Model::Type}
|
1892
|
+
entities = declarations.select{|x| x.is_a? Model::Entity}
|
1893
|
+
subtype_constraints = declarations.select{|x| x.is_a? Model::SubtypeConstraint}
|
1894
|
+
functions = declarations.select{|x| x.is_a? Model::Function}
|
1895
|
+
procedures = declarations.select{|x| x.is_a? Model::Procedure}
|
1896
|
+
constants = visit_if(ctx__algorithm_head__constant_decl, [])
|
1897
|
+
variables = visit_if(ctx__algorithm_head__local_decl, [])
|
1827
1898
|
statements = visit_if_map(ctx__stmt)
|
1828
|
-
where = visit_if(ctx__where_clause)
|
1899
|
+
where = visit_if(ctx__where_clause, [])
|
1829
1900
|
|
1830
1901
|
Model::Rule.new({
|
1831
1902
|
id: id,
|
1832
1903
|
applies_to: applies_to,
|
1833
|
-
|
1904
|
+
types: types,
|
1905
|
+
entities: entities,
|
1906
|
+
subtype_constraints: subtype_constraints,
|
1907
|
+
functions: functions,
|
1908
|
+
procedures: procedures,
|
1834
1909
|
constants: constants,
|
1835
1910
|
variables: variables,
|
1836
1911
|
statements: statements,
|
@@ -1876,15 +1951,26 @@ module Expressir
|
|
1876
1951
|
id = visit_if(ctx__schema_id)
|
1877
1952
|
version = visit_if(ctx__schema_version_id)
|
1878
1953
|
interfaces = visit_if_map(ctx__schema_body__interface_specification)
|
1879
|
-
constants = visit_if(ctx__schema_body__constant_decl)
|
1954
|
+
constants = visit_if(ctx__schema_body__constant_decl, [])
|
1880
1955
|
declarations = visit_if_map(ctx__schema_body__schema_body_declaration)
|
1956
|
+
types = declarations.select{|x| x.is_a? Model::Type}
|
1957
|
+
entities = declarations.select{|x| x.is_a? Model::Entity}
|
1958
|
+
subtype_constraints = declarations.select{|x| x.is_a? Model::SubtypeConstraint}
|
1959
|
+
functions = declarations.select{|x| x.is_a? Model::Function}
|
1960
|
+
procedures = declarations.select{|x| x.is_a? Model::Procedure}
|
1961
|
+
rules = declarations.select{|x| x.is_a? Model::Rule}
|
1881
1962
|
|
1882
1963
|
Model::Schema.new({
|
1883
1964
|
id: id,
|
1884
1965
|
version: version,
|
1885
1966
|
interfaces: interfaces,
|
1886
1967
|
constants: constants,
|
1887
|
-
|
1968
|
+
types: types,
|
1969
|
+
entities: entities,
|
1970
|
+
subtype_constraints: subtype_constraints,
|
1971
|
+
functions: functions,
|
1972
|
+
procedures: procedures,
|
1973
|
+
rules: rules
|
1888
1974
|
})
|
1889
1975
|
end
|
1890
1976
|
|
@@ -1924,11 +2010,11 @@ module Expressir
|
|
1924
2010
|
ctx__select_extension__type_ref = ctx.select_extension&.type_ref
|
1925
2011
|
ctx__select_extension__select_list = ctx__select_extension&.select_list
|
1926
2012
|
|
1927
|
-
extensible =
|
1928
|
-
generic_entity =
|
1929
|
-
items = visit_if(ctx__select_list)
|
2013
|
+
extensible = ctx__EXTENSIBLE && true
|
2014
|
+
generic_entity = ctx__GENERIC_ENTITY && true
|
2015
|
+
items = visit_if(ctx__select_list, [])
|
1930
2016
|
extension_type = visit_if(ctx__select_extension__type_ref)
|
1931
|
-
extension_items = visit_if(ctx__select_extension__select_list)
|
2017
|
+
extension_items = visit_if(ctx__select_extension__select_list, [])
|
1932
2018
|
|
1933
2019
|
Model::Types::Select.new({
|
1934
2020
|
extensible: extensible,
|
@@ -2061,7 +2147,7 @@ module Expressir
|
|
2061
2147
|
ctx__width_spec__FIXED = ctx__width_spec&.FIXED
|
2062
2148
|
|
2063
2149
|
width = visit_if(ctx__width_spec__width)
|
2064
|
-
fixed =
|
2150
|
+
fixed = ctx__width_spec__FIXED && true
|
2065
2151
|
|
2066
2152
|
Model::Types::String.new({
|
2067
2153
|
width: width,
|
@@ -2094,7 +2180,7 @@ module Expressir
|
|
2094
2180
|
|
2095
2181
|
id = visit_if(ctx__subtype_constraint_head__subtype_constraint_id)
|
2096
2182
|
applies_to = visit_if(ctx__subtype_constraint_head__entity_ref)
|
2097
|
-
abstract =
|
2183
|
+
abstract = ctx__subtype_constraint_body__abstract_supertype && true
|
2098
2184
|
total_over = visit_if(ctx__subtype_constraint_body__total_over)
|
2099
2185
|
supertype_expression = visit_if(ctx__subtype_constraint_body__supertype_expression)
|
2100
2186
|
|
@@ -2230,7 +2316,7 @@ module Expressir
|
|
2230
2316
|
|
2231
2317
|
id = visit_if(ctx__type_id)
|
2232
2318
|
type = visit_if(ctx__underlying_type)
|
2233
|
-
where = visit_if(ctx__where_clause)
|
2319
|
+
where = visit_if(ctx__where_clause, [])
|
2234
2320
|
|
2235
2321
|
Model::Type.new({
|
2236
2322
|
id: id,
|