expressir 0.2.11 → 0.2.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/format +27 -0
- data/expressir.gemspec +1 -0
- data/lib/expressir/express_exp/formatter.rb +90 -100
- data/lib/expressir/express_exp/hyperlink_formatter.rb +27 -0
- data/lib/expressir/express_exp/parser.rb +7 -1
- data/lib/expressir/express_exp/schema_head_formatter.rb +12 -0
- data/lib/expressir/express_exp/visitor.rb +67 -99
- data/lib/expressir/model.rb +2 -2
- 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/{renamed_ref.rb → interface_item.rb} +4 -2
- data/lib/expressir/model/interfaced_item.rb +23 -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/repository.rb +2 -2
- data/lib/expressir/model/rule.rb +4 -9
- data/lib/expressir/model/schema.rb +45 -12
- 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 +23 -0
- data/original/examples/syntax/hyperlink_formatted.exp +51 -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 +28 -0
- data/spec/expressir/express_exp/{parse_multiple_spec.rb → parser/multiple_spec.rb} +6 -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} +98 -60
- data/spec/expressir/express_exp/schema_head_formatter_spec.rb +40 -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 +33 -14
- data/lib/expressir/model/scope.rb +0 -71
- data/spec/expressir/express_exp/ap233_spec.rb +0 -22
- data/spec/expressir/express_exp/head_source_spec.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47487a0a54ea6a8564ad87e6ac763fd7afd9110fb3cb4580462ca13c77c78aa5
|
4
|
+
data.tar.gz: cfea2dad62fc18754207e704204d79867a3090bee07a9fb89b7c033a2630845e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0afc309ae992b8fdb501a77db6073aa9a569af0822e25d295ea2b15bd579088d5c7c15877364a58db0bee9ce4feae95b785cf47816df12f66dd72b792ddb685
|
7
|
+
data.tar.gz: 05e78f10274be40d47bad5d5bfac785c4d5aecd027d06fec1421c5ba1623c8f69aa5dcdfc53c13c39cd766b45302dfcc87c521ec74d2847f941db65d9f094646
|
data/exe/format
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "expressir/express_exp/parser"
|
4
|
+
require "expressir/express_exp/hyperlink_formatter"
|
5
|
+
|
6
|
+
input_files = [
|
7
|
+
# basic test
|
8
|
+
# '../iso-10303-stepmod/data/resources/action_schema/action_schema_annotated.exp',
|
9
|
+
# '../iso-10303-stepmod/data/resources/basic_attribute_schema/basic_attribute_schema_annotated.exp',
|
10
|
+
# '../iso-10303-stepmod/data/resources/support_resource_schema/support_resource_schema_annotated.exp',
|
11
|
+
# cyclic reference test
|
12
|
+
# '../iso-10303-stepmod/data/resources/product_property_definition_schema/product_property_definition_schema_annotated.exp',
|
13
|
+
# '../iso-10303-stepmod/data/resources/product_property_representation_schema/product_property_representation_schema_annotated.exp'
|
14
|
+
# renamed reference test
|
15
|
+
'../iso-10303-stepmod/ballots/ballots/ap210_wg12/express/resources/mathematical_functions_schema.exp',
|
16
|
+
'../iso-10303-stepmod/data/resources/iso13584_expressions_schema/iso13584_expressions_schema.exp',
|
17
|
+
# all valid iso-10303-stepmod files (takes 10 min)
|
18
|
+
# *`bundle exec ../stepmod-utils/exe/stepmod-find-express-files ../iso-10303-stepmod`.strip.split("\n").map{|file| File.exists?(file.sub(/\.exp$/, '_annotated.exp')) ? file.sub(/\.exp$/, '_annotated.exp') : file}
|
19
|
+
]
|
20
|
+
|
21
|
+
repo = Expressir::ExpressExp::Parser.from_files(input_files)
|
22
|
+
# schema = repo.schemas.find{|x| x.id == 'action_schema'}
|
23
|
+
# schema = repo.schemas.find{|x| x.id == 'product_property_definition_schema'}
|
24
|
+
schema = repo.schemas.find{|x| x.id == 'mathematical_functions_schema'}
|
25
|
+
result = Expressir::ExpressExp::HyperlinkFormatter.format(schema)
|
26
|
+
|
27
|
+
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"
|
@@ -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::InterfaceItem
|
54
|
+
format_interface_item(node)
|
55
|
+
elsif node.is_a? Model::Parameter
|
54
56
|
format_parameter(node)
|
55
|
-
elsif node.
|
57
|
+
elsif node.is_a? Model::Procedure
|
56
58
|
format_procedure(node)
|
57
|
-
elsif node.
|
58
|
-
format_renamed_ref(node)
|
59
|
-
elsif node.instance_of? Model::Repository
|
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
|
@@ -419,6 +419,20 @@ module Expressir
|
|
419
419
|
].join('')
|
420
420
|
end
|
421
421
|
|
422
|
+
def format_interface_item(node)
|
423
|
+
[
|
424
|
+
format(node.ref),
|
425
|
+
*if node.id
|
426
|
+
[
|
427
|
+
' ',
|
428
|
+
'AS',
|
429
|
+
' ',
|
430
|
+
node.id
|
431
|
+
]
|
432
|
+
end
|
433
|
+
].join('')
|
434
|
+
end
|
435
|
+
|
422
436
|
def format_parameter(node)
|
423
437
|
[
|
424
438
|
*if node.var
|
@@ -495,22 +509,11 @@ module Expressir
|
|
495
509
|
].join("\n")
|
496
510
|
end
|
497
511
|
|
498
|
-
def format_renamed_ref(node)
|
499
|
-
[
|
500
|
-
format(node.ref),
|
501
|
-
' ',
|
502
|
-
'AS',
|
503
|
-
' ',
|
504
|
-
node.id
|
505
|
-
].join('')
|
506
|
-
end
|
507
|
-
|
508
512
|
def format_repository(node)
|
509
513
|
[
|
510
514
|
*if node.schemas and node.schemas.length > 0
|
511
515
|
node.schemas.map{|node| format(node)}
|
512
|
-
end
|
513
|
-
*format_scope_remarks(node)
|
516
|
+
end
|
514
517
|
].join("\n")
|
515
518
|
end
|
516
519
|
|
@@ -627,7 +630,8 @@ module Expressir
|
|
627
630
|
[
|
628
631
|
'END_SCHEMA',
|
629
632
|
';'
|
630
|
-
].join('')
|
633
|
+
].join(''),
|
634
|
+
*format_scope_remarks(node)
|
631
635
|
].join("\n")
|
632
636
|
end
|
633
637
|
|
@@ -773,11 +777,11 @@ module Expressir
|
|
773
777
|
|
774
778
|
def format_expressions_binary_expression(node)
|
775
779
|
[
|
776
|
-
*if node.operand1.
|
780
|
+
*if node.operand1.is_a? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand1.operator] > OPERATOR_PRECEDENCE[node.operator]
|
777
781
|
'('
|
778
782
|
end,
|
779
783
|
format(node.operand1),
|
780
|
-
*if node.operand1.
|
784
|
+
*if node.operand1.is_a? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand1.operator] > OPERATOR_PRECEDENCE[node.operator]
|
781
785
|
')'
|
782
786
|
end,
|
783
787
|
' ',
|
@@ -806,11 +810,11 @@ module Expressir
|
|
806
810
|
when Model::Expressions::BinaryExpression::XOR then 'XOR'
|
807
811
|
end,
|
808
812
|
' ',
|
809
|
-
*if node.operand2.
|
813
|
+
*if node.operand2.is_a? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand2.operator] > OPERATOR_PRECEDENCE[node.operator]
|
810
814
|
'('
|
811
815
|
end,
|
812
816
|
format(node.operand2),
|
813
|
-
*if node.operand2.
|
817
|
+
*if node.operand2.is_a? Model::Expressions::BinaryExpression and OPERATOR_PRECEDENCE[node.operand2.operator] > OPERATOR_PRECEDENCE[node.operator]
|
814
818
|
')'
|
815
819
|
end,
|
816
820
|
].join('')
|
@@ -911,11 +915,11 @@ module Expressir
|
|
911
915
|
if node.operator == Model::Expressions::UnaryExpression::NOT
|
912
916
|
' '
|
913
917
|
end,
|
914
|
-
*if node.operand.
|
918
|
+
*if node.operand.is_a? Model::Expressions::BinaryExpression
|
915
919
|
'('
|
916
920
|
end,
|
917
921
|
format(node.operand),
|
918
|
-
*if node.operand.
|
922
|
+
*if node.operand.is_a? Model::Expressions::BinaryExpression
|
919
923
|
')'
|
920
924
|
end
|
921
925
|
].join('')
|
@@ -1442,25 +1446,13 @@ module Expressir
|
|
1442
1446
|
str.split("\n").map{|x| "#{INDENT}#{x}"}.join("\n")
|
1443
1447
|
end
|
1444
1448
|
|
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
1449
|
def format_remark(node, remark)
|
1458
1450
|
if remark.include?("\n")
|
1459
1451
|
[
|
1460
1452
|
[
|
1461
1453
|
'(*',
|
1462
1454
|
'"',
|
1463
|
-
|
1455
|
+
node.path,
|
1464
1456
|
'"',
|
1465
1457
|
].join(''),
|
1466
1458
|
remark,
|
@@ -1470,7 +1462,7 @@ module Expressir
|
|
1470
1462
|
[
|
1471
1463
|
'--',
|
1472
1464
|
'"',
|
1473
|
-
|
1465
|
+
node.path,
|
1474
1466
|
'"',
|
1475
1467
|
' ',
|
1476
1468
|
remark
|
@@ -1479,7 +1471,7 @@ module Expressir
|
|
1479
1471
|
end
|
1480
1472
|
|
1481
1473
|
def format_remarks(node)
|
1482
|
-
if node.class.method_defined? :remarks
|
1474
|
+
if node.class.method_defined? :remarks
|
1483
1475
|
node.remarks.map do |remark|
|
1484
1476
|
format_remark(node, remark)
|
1485
1477
|
end
|
@@ -1491,9 +1483,7 @@ module Expressir
|
|
1491
1483
|
def format_scope_remarks(node)
|
1492
1484
|
[
|
1493
1485
|
*format_remarks(node),
|
1494
|
-
*
|
1495
|
-
node.children.select{|x| x.parent == node}.flat_map{|x| format_scope_remarks(x)}
|
1496
|
-
end
|
1486
|
+
*node.children.select{|x| !x.is_a? Model::EnumerationItem or node.is_a? Model::Type}.flat_map{|x| format_scope_remarks(x)}
|
1497
1487
|
]
|
1498
1488
|
end
|
1499
1489
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Expressir
|
2
|
+
module ExpressExp
|
3
|
+
module HyperlinkFormatter
|
4
|
+
def format_expressions_simple_reference(node)
|
5
|
+
return node.id if node.parent.is_a? Model::Expressions::AttributeReference
|
6
|
+
|
7
|
+
# skip hyperlink if target node can't be found
|
8
|
+
target_node = if node.parent.is_a? Model::InterfaceItem
|
9
|
+
node.find("#{node.parent.parent.schema.id}.#{node.parent.ref.id}")
|
10
|
+
else
|
11
|
+
node.find(node.id)
|
12
|
+
end
|
13
|
+
return node.id unless target_node
|
14
|
+
|
15
|
+
# skip hyperlink for implicit scopes
|
16
|
+
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
|
17
|
+
|
18
|
+
# skip hyperlink if this node and target node are in the same main item
|
19
|
+
node_path_parts = node.path.split(".")
|
20
|
+
target_node_path_parts = target_node.path.split(".")
|
21
|
+
return node.id if node_path_parts[0..1] == target_node_path_parts[0..1]
|
22
|
+
|
23
|
+
"{{{<<express:#{target_node.path},#{node.id}>>}}}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -34,15 +34,21 @@ module Expressir
|
|
34
34
|
visitor = Visitor.new(parser.tokens)
|
35
35
|
repo = visitor.visit(parse_tree)
|
36
36
|
|
37
|
+
repo.schemas.each{|schema| schema.file = file}
|
38
|
+
|
37
39
|
repo
|
38
40
|
end
|
39
41
|
|
40
42
|
def self.from_files(files)
|
41
43
|
schemas = files.map{|file| self.from_file(file).schemas}.flatten
|
42
44
|
|
43
|
-
Model::Repository.new({
|
45
|
+
repo = Model::Repository.new({
|
44
46
|
schemas: schemas
|
45
47
|
})
|
48
|
+
|
49
|
+
repo.schemas.each{|schema| schema.parent = repo}
|
50
|
+
|
51
|
+
repo
|
46
52
|
end
|
47
53
|
|
48
54
|
# deprecated
|