expressir 0.2.9-x64-mingw32 → 0.2.14-x64-mingw32

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