expressir 0.2.11-x86-linux → 0.2.12-x86-linux
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/exe/format +16 -0
- data/expressir.gemspec +1 -0
- 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 +75 -89
- data/lib/expressir/express_exp/hyperlink_formatter.rb +25 -0
- data/lib/expressir/express_exp/schema_head_formatter.rb +14 -0
- data/lib/expressir/express_exp/visitor.rb +58 -58
- data/lib/expressir/model.rb +0 -1
- data/lib/expressir/model/attribute.rb +2 -0
- data/lib/expressir/model/constant.rb +2 -0
- data/lib/expressir/model/entity.rb +3 -2
- data/lib/expressir/model/enumeration_item.rb +2 -0
- data/lib/expressir/model/expressions/aggregate_initializer.rb +2 -0
- data/lib/expressir/model/expressions/aggregate_item.rb +2 -0
- data/lib/expressir/model/expressions/attribute_reference.rb +2 -0
- data/lib/expressir/model/expressions/binary_expression.rb +2 -0
- data/lib/expressir/model/expressions/call.rb +2 -0
- data/lib/expressir/model/expressions/entity_constructor.rb +2 -0
- data/lib/expressir/model/expressions/group_reference.rb +2 -0
- data/lib/expressir/model/expressions/index_reference.rb +2 -0
- data/lib/expressir/model/expressions/interval.rb +2 -0
- data/lib/expressir/model/expressions/query_expression.rb +2 -1
- data/lib/expressir/model/expressions/simple_reference.rb +2 -0
- data/lib/expressir/model/expressions/unary_expression.rb +2 -0
- data/lib/expressir/model/function.rb +3 -8
- data/lib/expressir/model/identifier.rb +0 -1
- data/lib/expressir/model/informal_proposition.rb +2 -0
- data/lib/expressir/model/interface.rb +2 -0
- data/lib/expressir/model/literals/binary.rb +2 -0
- data/lib/expressir/model/literals/integer.rb +2 -0
- data/lib/expressir/model/literals/logical.rb +2 -0
- data/lib/expressir/model/literals/real.rb +2 -0
- data/lib/expressir/model/literals/string.rb +2 -0
- data/lib/expressir/model/model_element.rb +71 -4
- data/lib/expressir/model/parameter.rb +2 -0
- data/lib/expressir/model/procedure.rb +3 -8
- data/lib/expressir/model/renamed_ref.rb +2 -0
- data/lib/expressir/model/repository.rb +2 -2
- data/lib/expressir/model/rule.rb +4 -9
- data/lib/expressir/model/schema.rb +5 -8
- data/lib/expressir/model/statements/alias.rb +2 -1
- data/lib/expressir/model/statements/assignment.rb +2 -0
- data/lib/expressir/model/statements/call.rb +2 -0
- data/lib/expressir/model/statements/case.rb +2 -0
- data/lib/expressir/model/statements/case_action.rb +2 -0
- data/lib/expressir/model/statements/compound.rb +2 -0
- data/lib/expressir/model/statements/if.rb +2 -0
- data/lib/expressir/model/statements/repeat.rb +2 -1
- data/lib/expressir/model/statements/return.rb +2 -0
- data/lib/expressir/model/subtype_constraint.rb +2 -1
- data/lib/expressir/model/type.rb +3 -6
- data/lib/expressir/model/types/aggregate.rb +2 -0
- data/lib/expressir/model/types/array.rb +2 -0
- data/lib/expressir/model/types/bag.rb +2 -0
- data/lib/expressir/model/types/binary.rb +2 -0
- data/lib/expressir/model/types/enumeration.rb +2 -0
- data/lib/expressir/model/types/generic.rb +2 -0
- data/lib/expressir/model/types/generic_entity.rb +2 -0
- data/lib/expressir/model/types/list.rb +2 -0
- data/lib/expressir/model/types/real.rb +2 -0
- data/lib/expressir/model/types/select.rb +2 -0
- data/lib/expressir/model/types/set.rb +2 -0
- data/lib/expressir/model/types/string.rb +2 -0
- data/lib/expressir/model/unique.rb +2 -0
- data/lib/expressir/model/variable.rb +2 -0
- data/lib/expressir/model/where.rb +2 -0
- 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/syntax.exp +18 -18
- data/original/examples/syntax/syntax_formatted.exp +32 -24
- 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/{head_source_spec.rb → parser/head_source_spec.rb} +1 -1
- data/spec/expressir/express_exp/{parse_multiple_spec.rb → parser/multiple_spec.rb} +1 -1
- data/spec/expressir/express_exp/{parse_remark_spec.rb → parser/remark_spec.rb} +2 -2
- data/spec/expressir/express_exp/{source_spec.rb → parser/source_spec.rb} +1 -1
- data/spec/expressir/express_exp/{parse_syntax_spec.rb → parser/syntax_spec.rb} +76 -44
- data/spec/expressir/express_exp/schema_head_formatter_spec.rb +36 -0
- data/spec/expressir/model/{scope_spec.rb → model_element/find_spec.rb} +7 -2
- data/spec/expressir/model/{model_element_spec.rb → model_element/hash_spec.rb} +7 -18
- metadata +32 -13
- data/lib/expressir/model/scope.rb +0 -71
- data/spec/expressir/express_exp/ap233_spec.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 432faff204670f985cc301c087b0c9da0c689b08f0a848a95fc3e3f95fc6b7b4
|
4
|
+
data.tar.gz: 59403e704f248d53d94663a8ece3d6a7650f895e8edd416983701e0b91f42f4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3291946e2a534e087d8f288bdcba3e43854280a2d4ffda087cfbbad25ca1f4517dc14dda9a6f2ae57b9804aeff86b25a158bc686c4d2f8777648fbd1913ccfa
|
7
|
+
data.tar.gz: 7a2c7cc654c8ac2518f659006ffd006830f7f58c93eaf908af7714d58f7a25ba63964f2e13ea09cf036fc527ab4d46133dee7bdc3dec20248c1767bd33e2504f
|
data/exe/format
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "expressir/express_exp/parser"
|
4
|
+
require "expressir/express_exp/hyperlink_formatter"
|
5
|
+
|
6
|
+
input_files = [
|
7
|
+
'../iso-10303-stepmod/data/resources/action_schema/action_schema_annotated.exp',
|
8
|
+
'../iso-10303-stepmod/data/resources/basic_attribute_schema/basic_attribute_schema_annotated.exp',
|
9
|
+
'../iso-10303-stepmod/data/resources/support_resource_schema/support_resource_schema_annotated.exp'
|
10
|
+
]
|
11
|
+
|
12
|
+
repo = Expressir::ExpressExp::Parser.from_files(input_files)
|
13
|
+
schema = repo.schemas.find{|x| x.id == 'action_schema'}
|
14
|
+
result = Expressir::ExpressExp::HyperlinkFormatter.format(schema)
|
15
|
+
|
16
|
+
puts result
|
data/expressir.gemspec
CHANGED
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_development_dependency "antlr4-native", "~> 1.1.0"
|
37
37
|
spec.add_development_dependency "bundler", "~> 2.0"
|
38
38
|
spec.add_development_dependency "pry", "~> 0.12.2"
|
39
|
+
spec.add_development_dependency "byebug", "~> 11.1"
|
39
40
|
spec.add_development_dependency "rake", "~> 13.0"
|
40
41
|
spec.add_development_dependency "rake-compiler", "~> 1.1"
|
41
42
|
spec.add_development_dependency "rake-compiler-dock", "~> 1.1"
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -38,129 +38,129 @@ module Expressir
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def format(node)
|
41
|
-
if node.
|
41
|
+
if node.is_a? Model::Attribute
|
42
42
|
format_attribute(node)
|
43
|
-
elsif node.
|
43
|
+
elsif node.is_a? Model::Constant
|
44
44
|
format_constant(node)
|
45
|
-
elsif node.
|
45
|
+
elsif node.is_a? Model::Entity
|
46
46
|
format_entity(node)
|
47
|
-
elsif node.
|
47
|
+
elsif node.is_a? Model::EnumerationItem
|
48
48
|
format_enumeration_item(node)
|
49
|
-
elsif node.
|
49
|
+
elsif node.is_a? Model::Function
|
50
50
|
format_function(node)
|
51
|
-
elsif node.
|
51
|
+
elsif node.is_a? Model::Interface
|
52
52
|
format_interface(node)
|
53
|
-
elsif node.
|
53
|
+
elsif node.is_a? Model::Parameter
|
54
54
|
format_parameter(node)
|
55
|
-
elsif node.
|
55
|
+
elsif node.is_a? Model::Procedure
|
56
56
|
format_procedure(node)
|
57
|
-
elsif node.
|
57
|
+
elsif node.is_a? Model::RenamedRef
|
58
58
|
format_renamed_ref(node)
|
59
|
-
elsif node.
|
59
|
+
elsif node.is_a? Model::Repository
|
60
60
|
format_repository(node)
|
61
|
-
elsif node.
|
61
|
+
elsif node.is_a? Model::Rule
|
62
62
|
format_rule(node)
|
63
|
-
elsif node.
|
63
|
+
elsif node.is_a? Model::Schema
|
64
64
|
format_schema(node)
|
65
|
-
elsif node.
|
65
|
+
elsif node.is_a? Model::SubtypeConstraint
|
66
66
|
format_subtype_constraint(node)
|
67
|
-
elsif node.
|
67
|
+
elsif node.is_a? Model::Type
|
68
68
|
format_type(node)
|
69
|
-
elsif node.
|
69
|
+
elsif node.is_a? Model::Unique
|
70
70
|
format_unique(node)
|
71
|
-
elsif node.
|
71
|
+
elsif node.is_a? Model::Variable
|
72
72
|
format_variable(node)
|
73
|
-
elsif node.
|
73
|
+
elsif node.is_a? Model::Where
|
74
74
|
format_where(node)
|
75
|
-
elsif node.
|
75
|
+
elsif node.is_a? Model::Expressions::AggregateInitializer
|
76
76
|
format_expressions_aggregate_initializer(node)
|
77
|
-
elsif node.
|
77
|
+
elsif node.is_a? Model::Expressions::AggregateItem
|
78
78
|
format_expressions_aggregate_item(node)
|
79
|
-
elsif node.
|
79
|
+
elsif node.is_a? Model::Expressions::AttributeReference
|
80
80
|
format_expressions_attribute_reference(node)
|
81
|
-
elsif node.
|
81
|
+
elsif node.is_a? Model::Expressions::BinaryExpression
|
82
82
|
format_expressions_binary_expression(node)
|
83
|
-
elsif node.
|
83
|
+
elsif node.is_a? Model::Expressions::Call
|
84
84
|
format_expressions_call(node)
|
85
|
-
elsif node.
|
85
|
+
elsif node.is_a? Model::Expressions::EntityConstructor
|
86
86
|
format_expressions_entity_constructor(node)
|
87
|
-
elsif node.
|
87
|
+
elsif node.is_a? Model::Expressions::GroupReference
|
88
88
|
format_expressions_group_reference(node)
|
89
|
-
elsif node.
|
89
|
+
elsif node.is_a? Model::Expressions::IndexReference
|
90
90
|
format_expressions_index_reference(node)
|
91
|
-
elsif node.
|
91
|
+
elsif node.is_a? Model::Expressions::Interval
|
92
92
|
format_expressions_interval(node)
|
93
|
-
elsif node.
|
93
|
+
elsif node.is_a? Model::Expressions::QueryExpression
|
94
94
|
format_expressions_query_expression(node)
|
95
|
-
elsif node.
|
95
|
+
elsif node.is_a? Model::Expressions::SimpleReference
|
96
96
|
format_expressions_simple_reference(node)
|
97
|
-
elsif node.
|
97
|
+
elsif node.is_a? Model::Expressions::UnaryExpression
|
98
98
|
format_expressions_unary_expression(node)
|
99
|
-
elsif node.
|
99
|
+
elsif node.is_a? Model::Literals::Binary
|
100
100
|
format_literals_binary(node)
|
101
|
-
elsif node.
|
101
|
+
elsif node.is_a? Model::Literals::Integer
|
102
102
|
format_literals_integer(node)
|
103
|
-
elsif node.
|
103
|
+
elsif node.is_a? Model::Literals::Logical
|
104
104
|
format_literals_logical(node)
|
105
|
-
elsif node.
|
105
|
+
elsif node.is_a? Model::Literals::Real
|
106
106
|
format_literals_real(node)
|
107
|
-
elsif node.
|
107
|
+
elsif node.is_a? Model::Literals::String
|
108
108
|
format_literals_string(node)
|
109
|
-
elsif node.
|
109
|
+
elsif node.is_a? Model::Statements::Alias
|
110
110
|
format_statements_alias(node)
|
111
|
-
elsif node.
|
111
|
+
elsif node.is_a? Model::Statements::Assignment
|
112
112
|
format_statements_assignment(node)
|
113
|
-
elsif node.
|
113
|
+
elsif node.is_a? Model::Statements::Call
|
114
114
|
format_statements_call(node)
|
115
|
-
elsif node.
|
115
|
+
elsif node.is_a? Model::Statements::Case
|
116
116
|
format_statements_case(node)
|
117
|
-
elsif node.
|
117
|
+
elsif node.is_a? Model::Statements::CaseAction
|
118
118
|
format_statements_case_action(node)
|
119
|
-
elsif node.
|
119
|
+
elsif node.is_a? Model::Statements::Compound
|
120
120
|
format_statements_compound(node)
|
121
|
-
elsif node.
|
121
|
+
elsif node.is_a? Model::Statements::Escape
|
122
122
|
format_statements_escape(node)
|
123
|
-
elsif node.
|
123
|
+
elsif node.is_a? Model::Statements::If
|
124
124
|
format_statements_if(node)
|
125
|
-
elsif node.
|
125
|
+
elsif node.is_a? Model::Statements::Null
|
126
126
|
format_statements_null(node)
|
127
|
-
elsif node.
|
127
|
+
elsif node.is_a? Model::Statements::Repeat
|
128
128
|
format_statements_repeat(node)
|
129
|
-
elsif node.
|
129
|
+
elsif node.is_a? Model::Statements::Return
|
130
130
|
format_statements_return(node)
|
131
|
-
elsif node.
|
131
|
+
elsif node.is_a? Model::Statements::Skip
|
132
132
|
format_statements_skip(node)
|
133
|
-
elsif node.
|
133
|
+
elsif node.is_a? Model::Types::Aggregate
|
134
134
|
format_types_aggregate(node)
|
135
|
-
elsif node.
|
135
|
+
elsif node.is_a? Model::Types::Array
|
136
136
|
format_types_array(node)
|
137
|
-
elsif node.
|
137
|
+
elsif node.is_a? Model::Types::Bag
|
138
138
|
format_types_bag(node)
|
139
|
-
elsif node.
|
139
|
+
elsif node.is_a? Model::Types::Binary
|
140
140
|
format_types_binary(node)
|
141
|
-
elsif node.
|
141
|
+
elsif node.is_a? Model::Types::Boolean
|
142
142
|
format_types_boolean(node)
|
143
|
-
elsif node.
|
143
|
+
elsif node.is_a? Model::Types::Enumeration
|
144
144
|
format_types_enumeration(node)
|
145
|
-
elsif node.
|
145
|
+
elsif node.is_a? Model::Types::GenericEntity
|
146
146
|
format_types_generic_entity(node)
|
147
|
-
elsif node.
|
147
|
+
elsif node.is_a? Model::Types::Generic
|
148
148
|
format_types_generic(node)
|
149
|
-
elsif node.
|
149
|
+
elsif node.is_a? Model::Types::Integer
|
150
150
|
format_types_integer(node)
|
151
|
-
elsif node.
|
151
|
+
elsif node.is_a? Model::Types::List
|
152
152
|
format_types_list(node)
|
153
|
-
elsif node.
|
153
|
+
elsif node.is_a? Model::Types::Logical
|
154
154
|
format_types_logical(node)
|
155
|
-
elsif node.
|
155
|
+
elsif node.is_a? Model::Types::Number
|
156
156
|
format_types_number(node)
|
157
|
-
elsif node.
|
157
|
+
elsif node.is_a? Model::Types::Real
|
158
158
|
format_types_real(node)
|
159
|
-
elsif node.
|
159
|
+
elsif node.is_a? Model::Types::Select
|
160
160
|
format_types_select(node)
|
161
|
-
elsif node.
|
161
|
+
elsif node.is_a? Model::Types::Set
|
162
162
|
format_types_set(node)
|
163
|
-
elsif node.
|
163
|
+
elsif node.is_a? Model::Types::String
|
164
164
|
format_types_string(node)
|
165
165
|
else
|
166
166
|
puts node.class
|
@@ -509,8 +509,7 @@ module Expressir
|
|
509
509
|
[
|
510
510
|
*if node.schemas and node.schemas.length > 0
|
511
511
|
node.schemas.map{|node| format(node)}
|
512
|
-
end
|
513
|
-
*format_scope_remarks(node)
|
512
|
+
end
|
514
513
|
].join("\n")
|
515
514
|
end
|
516
515
|
|
@@ -627,7 +626,8 @@ module Expressir
|
|
627
626
|
[
|
628
627
|
'END_SCHEMA',
|
629
628
|
';'
|
630
|
-
].join('')
|
629
|
+
].join(''),
|
630
|
+
*format_scope_remarks(node)
|
631
631
|
].join("\n")
|
632
632
|
end
|
633
633
|
|
@@ -773,11 +773,11 @@ module Expressir
|
|
773
773
|
|
774
774
|
def format_expressions_binary_expression(node)
|
775
775
|
[
|
776
|
-
*if node.operand1.
|
776
|
+
*if node.operand1.is_a? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand1.operator] > OPERATOR_PRECEDENCE[node.operator]
|
777
777
|
'('
|
778
778
|
end,
|
779
779
|
format(node.operand1),
|
780
|
-
*if node.operand1.
|
780
|
+
*if node.operand1.is_a? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand1.operator] > OPERATOR_PRECEDENCE[node.operator]
|
781
781
|
')'
|
782
782
|
end,
|
783
783
|
' ',
|
@@ -806,11 +806,11 @@ module Expressir
|
|
806
806
|
when Model::Expressions::BinaryExpression::XOR then 'XOR'
|
807
807
|
end,
|
808
808
|
' ',
|
809
|
-
*if node.operand2.
|
809
|
+
*if node.operand2.is_a? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand2.operator] > OPERATOR_PRECEDENCE[node.operator]
|
810
810
|
'('
|
811
811
|
end,
|
812
812
|
format(node.operand2),
|
813
|
-
*if node.operand2.
|
813
|
+
*if node.operand2.is_a? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand2.operator] > OPERATOR_PRECEDENCE[node.operator]
|
814
814
|
')'
|
815
815
|
end,
|
816
816
|
].join('')
|
@@ -911,11 +911,11 @@ module Expressir
|
|
911
911
|
if node.operator == Model::Expressions::UnaryExpression::NOT
|
912
912
|
' '
|
913
913
|
end,
|
914
|
-
*if node.operand.
|
914
|
+
*if node.operand.is_a? Model::Expressions::BinaryExpression
|
915
915
|
'('
|
916
916
|
end,
|
917
917
|
format(node.operand),
|
918
|
-
*if node.operand.
|
918
|
+
*if node.operand.is_a? Model::Expressions::BinaryExpression
|
919
919
|
')'
|
920
920
|
end
|
921
921
|
].join('')
|
@@ -1442,25 +1442,13 @@ module Expressir
|
|
1442
1442
|
str.split("\n").map{|x| "#{INDENT}#{x}"}.join("\n")
|
1443
1443
|
end
|
1444
1444
|
|
1445
|
-
def format_remark_ref(node)
|
1446
|
-
[
|
1447
|
-
*if node.class.method_defined? :parent and node.parent.class.method_defined? :id and node.parent != node
|
1448
|
-
[
|
1449
|
-
format_remark_ref(node.parent),
|
1450
|
-
'.'
|
1451
|
-
].join('')
|
1452
|
-
end,
|
1453
|
-
node.id,
|
1454
|
-
].join('')
|
1455
|
-
end
|
1456
|
-
|
1457
1445
|
def format_remark(node, remark)
|
1458
1446
|
if remark.include?("\n")
|
1459
1447
|
[
|
1460
1448
|
[
|
1461
1449
|
'(*',
|
1462
1450
|
'"',
|
1463
|
-
|
1451
|
+
node.path,
|
1464
1452
|
'"',
|
1465
1453
|
].join(''),
|
1466
1454
|
remark,
|
@@ -1470,7 +1458,7 @@ module Expressir
|
|
1470
1458
|
[
|
1471
1459
|
'--',
|
1472
1460
|
'"',
|
1473
|
-
|
1461
|
+
node.path,
|
1474
1462
|
'"',
|
1475
1463
|
' ',
|
1476
1464
|
remark
|
@@ -1479,7 +1467,7 @@ module Expressir
|
|
1479
1467
|
end
|
1480
1468
|
|
1481
1469
|
def format_remarks(node)
|
1482
|
-
if node.class.method_defined? :remarks
|
1470
|
+
if node.class.method_defined? :remarks
|
1483
1471
|
node.remarks.map do |remark|
|
1484
1472
|
format_remark(node, remark)
|
1485
1473
|
end
|
@@ -1491,9 +1479,7 @@ module Expressir
|
|
1491
1479
|
def format_scope_remarks(node)
|
1492
1480
|
[
|
1493
1481
|
*format_remarks(node),
|
1494
|
-
*
|
1495
|
-
node.children.select{|x| x.parent == node}.flat_map{|x| format_scope_remarks(x)}
|
1496
|
-
end
|
1482
|
+
*node.children.select{|x| !x.is_a? Model::EnumerationItem or node.is_a? Model::Type}.flat_map{|x| format_scope_remarks(x)}
|
1497
1483
|
]
|
1498
1484
|
end
|
1499
1485
|
end
|
@@ -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
|
@@ -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
|
@@ -14,7 +14,7 @@ require "set"
|
|
14
14
|
# > method of gaining this information is multi-pass parsing: the first pass collects the identifiers from their
|
15
15
|
# > declarations, so that subsequent passes are then able to distinguish a veriable_ref from a function_ref,
|
16
16
|
# > for example.
|
17
|
-
#
|
17
|
+
# - such multi-pass parsing is not implemented yet
|
18
18
|
# - xxxRef - merged to SimpleReference
|
19
19
|
# - entityConstructor, functionCall - merged to Call
|
20
20
|
#
|
@@ -44,11 +44,10 @@ module Expressir
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def visit(ctx)
|
47
|
-
|
48
|
-
attach_source(ctx,
|
49
|
-
|
50
|
-
|
51
|
-
result
|
47
|
+
node = super(ctx)
|
48
|
+
attach_source(ctx, node)
|
49
|
+
attach_remarks(ctx, node)
|
50
|
+
node
|
52
51
|
end
|
53
52
|
|
54
53
|
def visit_if(ctx, default = nil)
|
@@ -84,7 +83,7 @@ module Expressir
|
|
84
83
|
end
|
85
84
|
|
86
85
|
def get_tokens(ctx)
|
87
|
-
start_index, stop_index = if ctx.
|
86
|
+
start_index, stop_index = if ctx.is_a? ::ExpressParser::SyntaxContext
|
88
87
|
[0, @tokens.size - 1]
|
89
88
|
else
|
90
89
|
[ctx.start.token_index, ctx.stop.token_index]
|
@@ -94,7 +93,7 @@ module Expressir
|
|
94
93
|
end
|
95
94
|
|
96
95
|
def get_head_tokens(ctx)
|
97
|
-
start_index, stop_index = if ctx.
|
96
|
+
start_index, stop_index = if ctx.is_a? ::ExpressParser::SchemaDeclContext
|
98
97
|
start_index = ctx.start.token_index
|
99
98
|
stop_index = if ctx.schema_body.interface_specification.length > 0
|
100
99
|
ctx.schema_body.interface_specification.last.stop.token_index
|
@@ -124,25 +123,30 @@ module Expressir
|
|
124
123
|
end
|
125
124
|
end
|
126
125
|
|
127
|
-
def attach_parent(node)
|
128
|
-
if node.class.method_defined? :attach_parent_to_children
|
129
|
-
node.attach_parent_to_children
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
126
|
def find_remark_target(node, path)
|
134
|
-
|
135
|
-
target_node
|
127
|
+
target_node = node.find(path)
|
128
|
+
return target_node if target_node
|
136
129
|
|
137
|
-
if
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
current_node = current_node.parent
|
142
|
-
target_node = current_node.find_or_create(path)
|
143
|
-
end
|
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
|
144
134
|
|
145
|
-
|
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
|
146
150
|
end
|
147
151
|
|
148
152
|
def attach_remarks(ctx, node)
|
@@ -767,7 +771,7 @@ module Expressir
|
|
767
771
|
id = visit_if(ctx__entity_head__entity_id)
|
768
772
|
abstract = (ctx__entity_head__subsuper__supertype_constraint__abstract_entity_declaration || ctx__entity_head__subsuper__supertype_constraint__abstract_supertype_declaration) && true
|
769
773
|
supertype_expression = visit_if(ctx__entity_head__subsuper__supertype_constraint__abstract_supertype_declaration || ctx__entity_head__subsuper__supertype_constraint__supertype_rule)
|
770
|
-
subtype_of = visit_if(ctx__entity_head__subsuper__subtype_declaration)
|
774
|
+
subtype_of = visit_if(ctx__entity_head__subsuper__subtype_declaration, [])
|
771
775
|
attributes = [
|
772
776
|
*visit_if_map_flatten(ctx__entity_body__explicit_attr),
|
773
777
|
*visit_if(ctx__entity_body__derive_clause),
|
@@ -967,11 +971,11 @@ module Expressir
|
|
967
971
|
parameters = visit_if_map_flatten(ctx__function_head__formal_parameter)
|
968
972
|
return_type = visit_if(ctx__function_head__parameter_type)
|
969
973
|
declarations = visit_if_map(ctx__algorithm_head__declaration)
|
970
|
-
types = declarations.select{|x| x.
|
971
|
-
entities = declarations.select{|x| x.
|
972
|
-
subtype_constraints = declarations.select{|x| x.
|
973
|
-
functions = declarations.select{|x| x.
|
974
|
-
procedures = declarations.select{|x| x.
|
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}
|
975
979
|
constants = visit_if(ctx__algorithm_head__constant_decl, [])
|
976
980
|
variables = visit_if(ctx__algorithm_head__local_decl, [])
|
977
981
|
statements = visit_if_map(ctx__stmt)
|
@@ -1595,11 +1599,11 @@ module Expressir
|
|
1595
1599
|
id = visit_if(ctx__procedure_head__procedure_id)
|
1596
1600
|
parameters = visit_if_map_flatten(ctx__procedure_head__procedure_head_parameter)
|
1597
1601
|
declarations = visit_if_map(ctx__algorithm_head__declaration)
|
1598
|
-
types = declarations.select{|x| x.
|
1599
|
-
entities = declarations.select{|x| x.
|
1600
|
-
subtype_constraints = declarations.select{|x| x.
|
1601
|
-
functions = declarations.select{|x| x.
|
1602
|
-
procedures = declarations.select{|x| x.
|
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}
|
1603
1607
|
constants = visit_if(ctx__algorithm_head__constant_decl, [])
|
1604
1608
|
variables = visit_if(ctx__algorithm_head__local_decl, [])
|
1605
1609
|
statements = visit_if_map(ctx__stmt)
|
@@ -1837,20 +1841,16 @@ module Expressir
|
|
1837
1841
|
ctx__resource_ref = ctx.resource_ref
|
1838
1842
|
ctx__rename_id = ctx.rename_id
|
1839
1843
|
|
1840
|
-
|
1841
|
-
|
1842
|
-
ref = visit(ctx__resource_ref)
|
1843
|
-
id = visit(ctx__rename_id)
|
1844
|
+
ref = visit_if(ctx__resource_ref)
|
1845
|
+
id = visit_if(ctx__rename_id)
|
1844
1846
|
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
visit(ctx__resource_ref)
|
1851
|
-
end
|
1847
|
+
if id
|
1848
|
+
Model::RenamedRef.new({
|
1849
|
+
ref: ref,
|
1850
|
+
id: id
|
1851
|
+
})
|
1852
1852
|
else
|
1853
|
-
|
1853
|
+
ref
|
1854
1854
|
end
|
1855
1855
|
end
|
1856
1856
|
|
@@ -1888,11 +1888,11 @@ module Expressir
|
|
1888
1888
|
id = visit_if(ctx__rule_head__rule_id)
|
1889
1889
|
applies_to = visit_if_map(ctx__rule_head__entity_ref)
|
1890
1890
|
declarations = visit_if_map(ctx__algorithm_head__declaration)
|
1891
|
-
types = declarations.select{|x| x.
|
1892
|
-
entities = declarations.select{|x| x.
|
1893
|
-
subtype_constraints = declarations.select{|x| x.
|
1894
|
-
functions = declarations.select{|x| x.
|
1895
|
-
procedures = declarations.select{|x| x.
|
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
1896
|
constants = visit_if(ctx__algorithm_head__constant_decl, [])
|
1897
1897
|
variables = visit_if(ctx__algorithm_head__local_decl, [])
|
1898
1898
|
statements = visit_if_map(ctx__stmt)
|
@@ -1953,12 +1953,12 @@ module Expressir
|
|
1953
1953
|
interfaces = visit_if_map(ctx__schema_body__interface_specification)
|
1954
1954
|
constants = visit_if(ctx__schema_body__constant_decl, [])
|
1955
1955
|
declarations = visit_if_map(ctx__schema_body__schema_body_declaration)
|
1956
|
-
types = declarations.select{|x| x.
|
1957
|
-
entities = declarations.select{|x| x.
|
1958
|
-
subtype_constraints = declarations.select{|x| x.
|
1959
|
-
functions = declarations.select{|x| x.
|
1960
|
-
procedures = declarations.select{|x| x.
|
1961
|
-
rules = declarations.select{|x| x.
|
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}
|
1962
1962
|
|
1963
1963
|
Model::Schema.new({
|
1964
1964
|
id: id,
|