expressir 0.2.8-x64-mingw32 → 0.2.13-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +1 -7
  3. data/exe/format +20 -0
  4. data/expressir.gemspec +3 -2
  5. data/lib/expressir/express_exp/2.4/express_parser.so +0 -0
  6. data/lib/expressir/express_exp/2.5/express_parser.so +0 -0
  7. data/lib/expressir/express_exp/2.6/express_parser.so +0 -0
  8. data/lib/expressir/express_exp/2.7/express_parser.so +0 -0
  9. data/lib/expressir/express_exp/3.0/express_parser.so +0 -0
  10. data/lib/expressir/express_exp/formatter.rb +147 -110
  11. data/lib/expressir/express_exp/hyperlink_formatter.rb +25 -0
  12. data/lib/expressir/express_exp/parser.rb +14 -1
  13. data/lib/expressir/express_exp/schema_head_formatter.rb +14 -0
  14. data/lib/expressir/express_exp/visitor.rb +197 -111
  15. data/lib/expressir/model.rb +3 -1
  16. data/lib/expressir/model/attribute.rb +5 -1
  17. data/lib/expressir/model/constant.rb +5 -1
  18. data/lib/expressir/model/entity.rb +14 -20
  19. data/lib/expressir/model/enumeration_item.rb +5 -1
  20. data/lib/expressir/model/expressions/aggregate_initializer.rb +4 -2
  21. data/lib/expressir/model/expressions/aggregate_item.rb +3 -1
  22. data/lib/expressir/model/expressions/attribute_reference.rb +3 -1
  23. data/lib/expressir/model/expressions/binary_expression.rb +3 -1
  24. data/lib/expressir/model/expressions/call.rb +4 -2
  25. data/lib/expressir/model/expressions/entity_constructor.rb +4 -2
  26. data/lib/expressir/model/expressions/group_reference.rb +3 -1
  27. data/lib/expressir/model/expressions/index_reference.rb +3 -1
  28. data/lib/expressir/model/expressions/interval.rb +3 -1
  29. data/lib/expressir/model/expressions/query_expression.rb +5 -2
  30. data/lib/expressir/model/expressions/simple_reference.rb +3 -1
  31. data/lib/expressir/model/expressions/unary_expression.rb +3 -1
  32. data/lib/expressir/model/function.rb +28 -39
  33. data/lib/expressir/model/identifier.rb +1 -3
  34. data/lib/expressir/model/informal_proposition.rb +15 -0
  35. data/lib/expressir/model/interface.rb +4 -2
  36. data/lib/expressir/model/literals/binary.rb +3 -1
  37. data/lib/expressir/model/literals/integer.rb +3 -1
  38. data/lib/expressir/model/literals/logical.rb +3 -1
  39. data/lib/expressir/model/literals/real.rb +3 -1
  40. data/lib/expressir/model/literals/string.rb +3 -1
  41. data/lib/expressir/model/model_element.rb +140 -0
  42. data/lib/expressir/model/parameter.rb +5 -1
  43. data/lib/expressir/model/procedure.rb +29 -40
  44. data/lib/expressir/model/renamed_ref.rb +3 -1
  45. data/lib/expressir/model/repository.rb +5 -5
  46. data/lib/expressir/model/rule.rb +33 -41
  47. data/lib/expressir/model/schema.rb +44 -46
  48. data/lib/expressir/model/statements/alias.rb +6 -3
  49. data/lib/expressir/model/statements/assignment.rb +3 -1
  50. data/lib/expressir/model/statements/call.rb +4 -2
  51. data/lib/expressir/model/statements/case.rb +4 -2
  52. data/lib/expressir/model/statements/case_action.rb +4 -2
  53. data/lib/expressir/model/statements/compound.rb +4 -2
  54. data/lib/expressir/model/statements/escape.rb +1 -1
  55. data/lib/expressir/model/statements/if.rb +5 -3
  56. data/lib/expressir/model/statements/null.rb +1 -1
  57. data/lib/expressir/model/statements/repeat.rb +6 -3
  58. data/lib/expressir/model/statements/return.rb +3 -1
  59. data/lib/expressir/model/statements/skip.rb +1 -1
  60. data/lib/expressir/model/subtype_constraint.rb +5 -2
  61. data/lib/expressir/model/type.rb +11 -4
  62. data/lib/expressir/model/types/aggregate.rb +5 -1
  63. data/lib/expressir/model/types/array.rb +3 -1
  64. data/lib/expressir/model/types/bag.rb +3 -1
  65. data/lib/expressir/model/types/binary.rb +3 -1
  66. data/lib/expressir/model/types/boolean.rb +1 -1
  67. data/lib/expressir/model/types/enumeration.rb +5 -3
  68. data/lib/expressir/model/types/generic.rb +5 -1
  69. data/lib/expressir/model/types/generic_entity.rb +5 -1
  70. data/lib/expressir/model/types/integer.rb +1 -1
  71. data/lib/expressir/model/types/list.rb +3 -1
  72. data/lib/expressir/model/types/logical.rb +1 -1
  73. data/lib/expressir/model/types/number.rb +1 -1
  74. data/lib/expressir/model/types/real.rb +3 -1
  75. data/lib/expressir/model/types/select.rb +5 -3
  76. data/lib/expressir/model/types/set.rb +3 -1
  77. data/lib/expressir/model/types/string.rb +3 -1
  78. data/lib/expressir/model/unique.rb +6 -2
  79. data/lib/expressir/model/variable.rb +5 -1
  80. data/lib/expressir/model/where.rb +5 -1
  81. data/lib/expressir/version.rb +1 -1
  82. data/original/examples/syntax/hyperlink.exp +8 -0
  83. data/original/examples/syntax/hyperlink_formatted.exp +19 -0
  84. data/original/examples/syntax/remark.exp +63 -20
  85. data/original/examples/syntax/remark_formatted.exp +62 -24
  86. data/original/examples/syntax/simple.exp +3 -0
  87. data/original/examples/syntax/source.exp +16 -0
  88. data/original/examples/syntax/syntax.exp +201 -190
  89. data/original/examples/syntax/syntax_formatted.exp +370 -799
  90. data/spec/expressir/express_exp/{format_remark_spec.rb → formatter/remark_spec.rb} +2 -2
  91. data/spec/expressir/express_exp/{format_syntax_spec.rb → formatter/syntax_spec.rb} +2 -2
  92. data/spec/expressir/express_exp/hyperlink_formatter_spec.rb +24 -0
  93. data/spec/expressir/express_exp/parser/head_source_spec.rb +38 -0
  94. data/spec/expressir/express_exp/parser/multiple_spec.rb +32 -0
  95. data/spec/expressir/express_exp/{parse_remark_spec.rb → parser/remark_spec.rb} +120 -55
  96. data/spec/expressir/express_exp/{source_spec.rb → parser/source_spec.rb} +3 -6
  97. data/spec/expressir/express_exp/parser/syntax_spec.rb +3080 -0
  98. data/spec/expressir/express_exp/schema_head_formatter_spec.rb +36 -0
  99. data/spec/expressir/model/{find_spec.rb → model_element/find_spec.rb} +26 -8
  100. data/spec/expressir/model/model_element/hash_spec.rb +66 -0
  101. metadata +38 -13
  102. data/lib/expressir/model/scope.rb +0 -32
  103. data/spec/expressir/express_exp/ap233_spec.rb +0 -22
  104. data/spec/expressir/express_exp/find_spec.rb +0 -28
  105. data/spec/expressir/express_exp/parse_syntax_spec.rb +0 -3003
@@ -1,65 +1,63 @@
1
1
  module Expressir
2
2
  module Model
3
- class Schema
4
- include Scope
3
+ class Schema < ModelElement
5
4
  include Identifier
6
5
 
6
+ attr_accessor :head_source
7
+
7
8
  attr_accessor :version
8
9
  attr_accessor :interfaces
9
10
  attr_accessor :constants
10
- attr_accessor :declarations
11
+ attr_accessor :types
12
+ attr_accessor :entities
13
+ attr_accessor :subtype_constraints
14
+ attr_accessor :functions
15
+ attr_accessor :procedures
16
+ attr_accessor :rules
11
17
 
12
18
  def initialize(options = {})
13
19
  @id = options[:id]
14
- @version = options[:version]
15
- @interfaces = options[:interfaces]
16
- @constants = options[:constants]
17
- @declarations = options[:declarations]
18
- end
19
-
20
- def use_interfaces
21
- @interfaces.select{|x| x.kind == Expressir::Model::Interface::USE}
22
- end
23
-
24
- def reference_interfaces
25
- @interfaces.select{|x| x.kind == Expressir::Model::Interface::REFERENCE}
26
- end
27
-
28
- def types
29
- @declarations.select{|x| x.instance_of? Expressir::Model::Type}
30
- end
20
+ @remarks = options.fetch(:remarks, [])
21
+ @source = options[:source]
22
+ @head_source = options[:head_source]
31
23
 
32
- def entities
33
- @declarations.select{|x| x.instance_of? Expressir::Model::Entity}
34
- end
35
-
36
- def subtype_constraints
37
- @declarations.select{|x| x.instance_of? Expressir::Model::SubtypeConstraint}
38
- end
39
-
40
- def functions
41
- @declarations.select{|x| x.instance_of? Expressir::Model::Function}
42
- end
43
-
44
- def procedures
45
- @declarations.select{|x| x.instance_of? Expressir::Model::Procedure}
46
- end
24
+ @version = options[:version]
25
+ @interfaces = options.fetch(:interfaces, [])
26
+ @constants = options.fetch(:constants, [])
27
+ @types = options.fetch(:types, [])
28
+ @entities = options.fetch(:entities, [])
29
+ @subtype_constraints = options.fetch(:subtype_constraints, [])
30
+ @functions = options.fetch(:functions, [])
31
+ @procedures = options.fetch(:procedures, [])
32
+ @rules = options.fetch(:rules, [])
47
33
 
48
- def rules
49
- @declarations.select{|x| x.instance_of? Expressir::Model::Rule}
34
+ super
50
35
  end
51
36
 
52
- def children
37
+ def children(item_ids = nil)
53
38
  items = []
54
- items.push(*@constants) if @constants
55
- items.push(*@declarations.flat_map do |x|
56
- [
57
- x,
58
- *if x.instance_of? Expressir::Model::Type and x.type.instance_of? Expressir::Model::Types::Enumeration
59
- x.type.items
39
+ unless item_ids and item_ids.length > 0
40
+ items.push(*@interfaces.flat_map do |interface|
41
+ schema = parent.schemas.find{|y| interface.schema.id == y.id}
42
+ interface_item_ids = if interface.items
43
+ # TODO: support renamed references
44
+ interface.items.select{|x| x.is_a? Model::Expressions::SimpleReference}.map{|x| x.id}
60
45
  end
61
- ]
62
- end) if @declarations
46
+ schema_items = schema&.children(interface_item_ids) || []
47
+ schema_items
48
+ end)
49
+ end
50
+ items.push(*@constants)
51
+ items.push(*@types)
52
+ items.push(*@types.flat_map{|x| x.type.is_a?(Expressir::Model::Types::Enumeration) ? x.type.items : []})
53
+ items.push(*@entities)
54
+ items.push(*@subtype_constraints)
55
+ items.push(*@functions)
56
+ items.push(*@procedures)
57
+ items.push(*@rules)
58
+ if item_ids and item_ids.length > 0
59
+ items = items.select{|x| item_ids.include?(x.id)}
60
+ end
63
61
  items
64
62
  end
65
63
  end
@@ -1,8 +1,7 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Statements
4
- class Alias
5
- include Scope
4
+ class Alias < ModelElement
6
5
  include Identifier
7
6
 
8
7
  attr_accessor :expression
@@ -10,9 +9,13 @@ module Expressir
10
9
 
11
10
  def initialize(options = {})
12
11
  @id = options[:id]
12
+ @remarks = options.fetch(:remarks, [])
13
+ @source = options[:source]
13
14
 
14
15
  @expression = options[:expression]
15
- @statements = options[:statements]
16
+ @statements = options.fetch(:statements, [])
17
+
18
+ super
16
19
  end
17
20
 
18
21
  def children
@@ -1,13 +1,15 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Statements
4
- class Assignment
4
+ class Assignment < ModelElement
5
5
  attr_accessor :ref
6
6
  attr_accessor :expression
7
7
 
8
8
  def initialize(options = {})
9
9
  @ref = options[:ref]
10
10
  @expression = options[:expression]
11
+
12
+ super
11
13
  end
12
14
  end
13
15
  end
@@ -1,13 +1,15 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Statements
4
- class Call
4
+ class Call < ModelElement
5
5
  attr_accessor :ref
6
6
  attr_accessor :parameters
7
7
 
8
8
  def initialize(options = {})
9
9
  @ref = options[:ref]
10
- @parameters = options[:parameters]
10
+ @parameters = options.fetch(:parameters, [])
11
+
12
+ super
11
13
  end
12
14
  end
13
15
  end
@@ -1,15 +1,17 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Statements
4
- class Case
4
+ class Case < ModelElement
5
5
  attr_accessor :expression
6
6
  attr_accessor :actions
7
7
  attr_accessor :otherwise_statement
8
8
 
9
9
  def initialize(options = {})
10
10
  @expression = options[:expression]
11
- @actions = options[:actions]
11
+ @actions = options.fetch(:actions, [])
12
12
  @otherwise_statement = options[:otherwise_statement]
13
+
14
+ super
13
15
  end
14
16
  end
15
17
  end
@@ -1,13 +1,15 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Statements
4
- class CaseAction
4
+ class CaseAction < ModelElement
5
5
  attr_accessor :labels
6
6
  attr_accessor :statement
7
7
 
8
8
  def initialize(options = {})
9
- @labels = options[:labels]
9
+ @labels = options.fetch(:labels, [])
10
10
  @statement = options[:statement]
11
+
12
+ super
11
13
  end
12
14
  end
13
15
  end
@@ -1,11 +1,13 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Statements
4
- class Compound
4
+ class Compound < ModelElement
5
5
  attr_accessor :statements
6
6
 
7
7
  def initialize(options = {})
8
- @statements = options[:statements]
8
+ @statements = options.fetch(:statements, [])
9
+
10
+ super
9
11
  end
10
12
  end
11
13
  end
@@ -1,7 +1,7 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Statements
4
- class Escape
4
+ class Escape < ModelElement
5
5
  end
6
6
  end
7
7
  end
@@ -1,15 +1,17 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Statements
4
- class If
4
+ class If < ModelElement
5
5
  attr_accessor :expression
6
6
  attr_accessor :statements
7
7
  attr_accessor :else_statements
8
8
 
9
9
  def initialize(options = {})
10
10
  @expression = options[:expression]
11
- @statements = options[:statements]
12
- @else_statements = options[:else_statements]
11
+ @statements = options.fetch(:statements, [])
12
+ @else_statements = options.fetch(:else_statements, [])
13
+
14
+ super
13
15
  end
14
16
  end
15
17
  end
@@ -1,7 +1,7 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Statements
4
- class Null
4
+ class Null < ModelElement
5
5
  end
6
6
  end
7
7
  end
@@ -1,8 +1,7 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Statements
4
- class Repeat
5
- include Scope
4
+ class Repeat < ModelElement
6
5
  include Identifier
7
6
 
8
7
  attr_accessor :bound1
@@ -14,13 +13,17 @@ module Expressir
14
13
 
15
14
  def initialize(options = {})
16
15
  @id = options[:id]
16
+ @remarks = options.fetch(:remarks, [])
17
+ @source = options[:source]
17
18
 
18
19
  @bound1 = options[:bound1]
19
20
  @bound2 = options[:bound2]
20
21
  @increment = options[:increment]
21
22
  @while_expression = options[:while_expression]
22
23
  @until_expression = options[:until_expression]
23
- @statements = options[:statements]
24
+ @statements = options.fetch(:statements, [])
25
+
26
+ super
24
27
  end
25
28
 
26
29
  def children
@@ -1,11 +1,13 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Statements
4
- class Return
4
+ class Return < ModelElement
5
5
  attr_accessor :expression
6
6
 
7
7
  def initialize(options = {})
8
8
  @expression = options[:expression]
9
+
10
+ super
9
11
  end
10
12
  end
11
13
  end
@@ -1,7 +1,7 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Statements
4
- class Skip
4
+ class Skip < ModelElement
5
5
  end
6
6
  end
7
7
  end
@@ -1,7 +1,6 @@
1
1
  module Expressir
2
2
  module Model
3
- class SubtypeConstraint
4
- include Scope
3
+ class SubtypeConstraint < ModelElement
5
4
  include Identifier
6
5
 
7
6
  attr_accessor :applies_to
@@ -11,11 +10,15 @@ module Expressir
11
10
 
12
11
  def initialize(options = {})
13
12
  @id = options[:id]
13
+ @remarks = options.fetch(:remarks, [])
14
+ @source = options[:source]
14
15
 
15
16
  @applies_to = options[:applies_to]
16
17
  @abstract = options[:abstract]
17
18
  @total_over = options[:total_over]
18
19
  @supertype_expression = options[:supertype_expression]
20
+
21
+ super
19
22
  end
20
23
 
21
24
  def children
@@ -1,22 +1,29 @@
1
1
  module Expressir
2
2
  module Model
3
- class Type
4
- include Scope
3
+ class Type < ModelElement
5
4
  include Identifier
6
5
 
7
6
  attr_accessor :type
8
7
  attr_accessor :where
8
+ attr_accessor :informal_propositions
9
9
 
10
10
  def initialize(options = {})
11
11
  @id = options[:id]
12
+ @remarks = options.fetch(:remarks, [])
13
+ @source = options[:source]
12
14
 
13
15
  @type = options[:type]
14
- @where = options[:where]
16
+ @where = options.fetch(:where, [])
17
+ @informal_propositions = options.fetch(:informal_propositions, [])
18
+
19
+ super
15
20
  end
16
21
 
17
22
  def children
18
23
  items = []
19
- items.push(*@where) if @where
24
+ items.push(*@type.is_a?(Expressir::Model::Types::Enumeration) ? @type.items : [])
25
+ items.push(*@where)
26
+ items.push(*@informal_propositions)
20
27
  items
21
28
  end
22
29
  end
@@ -1,15 +1,19 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Types
4
- class Aggregate
4
+ class Aggregate < ModelElement
5
5
  include Identifier
6
6
 
7
7
  attr_accessor :base_type
8
8
 
9
9
  def initialize(options = {})
10
10
  @id = options[:id]
11
+ @remarks = options.fetch(:remarks, [])
12
+ @source = options[:source]
11
13
 
12
14
  @base_type = options[:base_type]
15
+
16
+ super
13
17
  end
14
18
  end
15
19
  end
@@ -1,7 +1,7 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Types
4
- class Array
4
+ class Array < ModelElement
5
5
  attr_accessor :bound1
6
6
  attr_accessor :bound2
7
7
  attr_accessor :optional
@@ -14,6 +14,8 @@ module Expressir
14
14
  @optional = options[:optional]
15
15
  @unique = options[:unique]
16
16
  @base_type = options[:base_type]
17
+
18
+ super
17
19
  end
18
20
  end
19
21
  end
@@ -1,7 +1,7 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Types
4
- class Bag
4
+ class Bag < ModelElement
5
5
  attr_accessor :bound1
6
6
  attr_accessor :bound2
7
7
  attr_accessor :base_type
@@ -10,6 +10,8 @@ module Expressir
10
10
  @bound1 = options[:bound1]
11
11
  @bound2 = options[:bound2]
12
12
  @base_type = options[:base_type]
13
+
14
+ super
13
15
  end
14
16
  end
15
17
  end