expressir 0.2.5 → 0.2.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/.cross_rubies +30 -0
  3. data/.github/workflows/rake.yml +14 -15
  4. data/.github/workflows/release.yml +24 -16
  5. data/.gitignore +3 -1
  6. data/Gemfile +0 -2
  7. data/Rakefile +2 -8
  8. data/expressir.gemspec +7 -4
  9. data/ext/express-parser/express_parser.cpp +12 -10
  10. data/ext/express-parser/extconf.rb +48 -25
  11. data/lib/expressir/express_exp/formatter.rb +74 -23
  12. data/lib/expressir/express_exp/parser.rb +20 -2
  13. data/lib/expressir/express_exp/visitor.rb +201 -96
  14. data/lib/expressir/model.rb +3 -0
  15. data/lib/expressir/model/attribute.rb +3 -1
  16. data/lib/expressir/model/constant.rb +3 -1
  17. data/lib/expressir/model/entity.rb +12 -19
  18. data/lib/expressir/model/enumeration_item.rb +3 -1
  19. data/lib/expressir/model/expressions/aggregate_initializer.rb +2 -2
  20. data/lib/expressir/model/expressions/aggregate_item.rb +1 -1
  21. data/lib/expressir/model/expressions/attribute_reference.rb +1 -1
  22. data/lib/expressir/model/expressions/binary_expression.rb +1 -1
  23. data/lib/expressir/model/expressions/call.rb +2 -2
  24. data/lib/expressir/model/expressions/entity_constructor.rb +2 -2
  25. data/lib/expressir/model/expressions/group_reference.rb +1 -1
  26. data/lib/expressir/model/expressions/index_reference.rb +1 -1
  27. data/lib/expressir/model/expressions/interval.rb +1 -1
  28. data/lib/expressir/model/expressions/query_expression.rb +5 -3
  29. data/lib/expressir/model/expressions/simple_reference.rb +1 -1
  30. data/lib/expressir/model/expressions/unary_expression.rb +1 -1
  31. data/lib/expressir/model/function.rb +32 -38
  32. data/lib/expressir/model/identifier.rb +1 -0
  33. data/lib/expressir/model/informal_proposition.rb +13 -0
  34. data/lib/expressir/model/interface.rb +2 -2
  35. data/lib/expressir/model/literals/binary.rb +1 -1
  36. data/lib/expressir/model/literals/integer.rb +1 -1
  37. data/lib/expressir/model/literals/logical.rb +1 -1
  38. data/lib/expressir/model/literals/real.rb +1 -1
  39. data/lib/expressir/model/literals/string.rb +1 -1
  40. data/lib/expressir/model/model_element.rb +67 -0
  41. data/lib/expressir/model/parameter.rb +3 -1
  42. data/lib/expressir/model/procedure.rb +33 -39
  43. data/lib/expressir/model/renamed_ref.rb +1 -1
  44. data/lib/expressir/model/repository.rb +3 -3
  45. data/lib/expressir/model/rule.rb +35 -38
  46. data/lib/expressir/model/schema.rb +35 -46
  47. data/lib/expressir/model/scope.rb +49 -3
  48. data/lib/expressir/model/statements/alias.rb +4 -2
  49. data/lib/expressir/model/statements/assignment.rb +1 -1
  50. data/lib/expressir/model/statements/call.rb +2 -2
  51. data/lib/expressir/model/statements/case.rb +2 -2
  52. data/lib/expressir/model/statements/case_action.rb +2 -2
  53. data/lib/expressir/model/statements/compound.rb +2 -2
  54. data/lib/expressir/model/statements/escape.rb +1 -1
  55. data/lib/expressir/model/statements/if.rb +3 -3
  56. data/lib/expressir/model/statements/null.rb +1 -1
  57. data/lib/expressir/model/statements/repeat.rb +4 -2
  58. data/lib/expressir/model/statements/return.rb +1 -1
  59. data/lib/expressir/model/statements/skip.rb +1 -1
  60. data/lib/expressir/model/subtype_constraint.rb +3 -1
  61. data/lib/expressir/model/type.rb +13 -3
  62. data/lib/expressir/model/types/aggregate.rb +3 -1
  63. data/lib/expressir/model/types/array.rb +1 -1
  64. data/lib/expressir/model/types/bag.rb +1 -1
  65. data/lib/expressir/model/types/binary.rb +1 -1
  66. data/lib/expressir/model/types/boolean.rb +1 -1
  67. data/lib/expressir/model/types/enumeration.rb +3 -3
  68. data/lib/expressir/model/types/generic.rb +3 -1
  69. data/lib/expressir/model/types/generic_entity.rb +3 -1
  70. data/lib/expressir/model/types/integer.rb +1 -1
  71. data/lib/expressir/model/types/list.rb +1 -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 +1 -1
  75. data/lib/expressir/model/types/select.rb +3 -3
  76. data/lib/expressir/model/types/set.rb +1 -1
  77. data/lib/expressir/model/types/string.rb +1 -1
  78. data/lib/expressir/model/unique.rb +4 -2
  79. data/lib/expressir/model/variable.rb +3 -1
  80. data/lib/expressir/model/where.rb +3 -1
  81. data/lib/expressir/version.rb +1 -1
  82. data/original/examples/syntax/remark.exp +64 -20
  83. data/original/examples/syntax/remark_formatted.exp +63 -24
  84. data/original/examples/syntax/simple.exp +3 -0
  85. data/original/examples/syntax/source.exp +16 -0
  86. data/original/examples/syntax/syntax.exp +194 -181
  87. data/original/examples/syntax/syntax_formatted.exp +354 -787
  88. data/rakelib/cross-ruby.rake +308 -0
  89. data/spec/expressir/express_exp/head_source_spec.rb +38 -0
  90. data/spec/expressir/express_exp/parse_multiple_spec.rb +32 -0
  91. data/spec/expressir/express_exp/parse_remark_spec.rb +122 -56
  92. data/spec/expressir/express_exp/parse_syntax_spec.rb +1619 -1569
  93. data/spec/expressir/express_exp/source_spec.rb +29 -0
  94. data/spec/expressir/model/model_element_spec.rb +59 -0
  95. data/spec/expressir/model/{find_spec.rb → scope_spec.rb} +20 -7
  96. metadata +45 -21
@@ -1,7 +1,7 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Statements
4
- class Alias
4
+ class Alias < ModelElement
5
5
  include Scope
6
6
  include Identifier
7
7
 
@@ -10,9 +10,11 @@ module Expressir
10
10
 
11
11
  def initialize(options = {})
12
12
  @id = options[:id]
13
+ @remarks = options.fetch(:remarks, [])
14
+ @source = options[:source]
13
15
 
14
16
  @expression = options[:expression]
15
- @statements = options[:statements]
17
+ @statements = options.fetch(:statements, [])
16
18
  end
17
19
 
18
20
  def children
@@ -1,7 +1,7 @@
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
 
@@ -1,13 +1,13 @@
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
11
  end
12
12
  end
13
13
  end
@@ -1,14 +1,14 @@
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
13
  end
14
14
  end
@@ -1,12 +1,12 @@
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
11
  end
12
12
  end
@@ -1,11 +1,11 @@
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
9
  end
10
10
  end
11
11
  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,15 @@
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
13
  end
14
14
  end
15
15
  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,7 +1,7 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Statements
4
- class Repeat
4
+ class Repeat < ModelElement
5
5
  include Scope
6
6
  include Identifier
7
7
 
@@ -14,13 +14,15 @@ module Expressir
14
14
 
15
15
  def initialize(options = {})
16
16
  @id = options[:id]
17
+ @remarks = options.fetch(:remarks, [])
18
+ @source = options[:source]
17
19
 
18
20
  @bound1 = options[:bound1]
19
21
  @bound2 = options[:bound2]
20
22
  @increment = options[:increment]
21
23
  @while_expression = options[:while_expression]
22
24
  @until_expression = options[:until_expression]
23
- @statements = options[:statements]
25
+ @statements = options.fetch(:statements, [])
24
26
  end
25
27
 
26
28
  def children
@@ -1,7 +1,7 @@
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 = {})
@@ -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,6 +1,6 @@
1
1
  module Expressir
2
2
  module Model
3
- class SubtypeConstraint
3
+ class SubtypeConstraint < ModelElement
4
4
  include Scope
5
5
  include Identifier
6
6
 
@@ -11,6 +11,8 @@ module Expressir
11
11
 
12
12
  def initialize(options = {})
13
13
  @id = options[:id]
14
+ @remarks = options.fetch(:remarks, [])
15
+ @source = options[:source]
14
16
 
15
17
  @applies_to = options[:applies_to]
16
18
  @abstract = options[:abstract]
@@ -1,22 +1,32 @@
1
1
  module Expressir
2
2
  module Model
3
- class Type
3
+ class Type < ModelElement
4
4
  include Scope
5
5
  include Identifier
6
6
 
7
7
  attr_accessor :type
8
8
  attr_accessor :where
9
+ attr_accessor :informal_propositions
9
10
 
10
11
  def initialize(options = {})
11
12
  @id = options[:id]
13
+ @remarks = options.fetch(:remarks, [])
14
+ @source = options[:source]
12
15
 
13
16
  @type = options[:type]
14
- @where = options[:where]
17
+ @where = options.fetch(:where, [])
18
+ @informal_propositions = options.fetch(:informal_propositions, [])
15
19
  end
16
20
 
17
21
  def children
18
22
  items = []
19
- items.push(*@where) if @where
23
+ items.push(*[
24
+ *if @type.instance_of? Expressir::Model::Types::Enumeration
25
+ @type.items
26
+ end
27
+ ])
28
+ items.push(*@where)
29
+ items.push(*@informal_propositions)
20
30
  items
21
31
  end
22
32
  end
@@ -1,13 +1,15 @@
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]
13
15
  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
@@ -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
@@ -1,7 +1,7 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Types
4
- class Binary
4
+ class Binary < ModelElement
5
5
  attr_accessor :width
6
6
  attr_accessor :fixed
7
7
 
@@ -1,7 +1,7 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Types
4
- class Boolean
4
+ class Boolean < ModelElement
5
5
  end
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Types
4
- class Enumeration
4
+ class Enumeration < ModelElement
5
5
  attr_accessor :extensible
6
6
  attr_accessor :items
7
7
  attr_accessor :extension_type
@@ -9,9 +9,9 @@ module Expressir
9
9
 
10
10
  def initialize(options = {})
11
11
  @extensible = options[:extensible]
12
- @items = options[:items]
12
+ @items = options.fetch(:items, [])
13
13
  @extension_type = options[:extension_type]
14
- @extension_items = options[:extension_items]
14
+ @extension_items = options.fetch(:extension_items, [])
15
15
  end
16
16
  end
17
17
  end
@@ -1,11 +1,13 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Types
4
- class Generic
4
+ class Generic < ModelElement
5
5
  include Identifier
6
6
 
7
7
  def initialize(options = {})
8
8
  @id = options[:id]
9
+ @remarks = options.fetch(:remarks, [])
10
+ @source = options[:source]
9
11
  end
10
12
  end
11
13
  end
@@ -1,11 +1,13 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Types
4
- class GenericEntity
4
+ class GenericEntity < ModelElement
5
5
  include Identifier
6
6
 
7
7
  def initialize(options = {})
8
8
  @id = options[:id]
9
+ @remarks = options.fetch(:remarks, [])
10
+ @source = options[:source]
9
11
  end
10
12
  end
11
13
  end
@@ -1,7 +1,7 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Types
4
- class Integer
4
+ class Integer < ModelElement
5
5
  end
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Types
4
- class List
4
+ class List < ModelElement
5
5
  attr_accessor :bound1
6
6
  attr_accessor :bound2
7
7
  attr_accessor :unique
@@ -1,7 +1,7 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Types
4
- class Logical
4
+ class Logical < ModelElement
5
5
  end
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Types
4
- class Number
4
+ class Number < ModelElement
5
5
  end
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Types
4
- class Real
4
+ class Real < ModelElement
5
5
  attr_accessor :precision
6
6
 
7
7
  def initialize(options = {})
@@ -1,7 +1,7 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Types
4
- class Select
4
+ class Select < ModelElement
5
5
  attr_accessor :extensible
6
6
  attr_accessor :generic_entity
7
7
  attr_accessor :items
@@ -11,9 +11,9 @@ module Expressir
11
11
  def initialize(options = {})
12
12
  @extensible = options[:extensible]
13
13
  @generic_entity = options[:generic_entity]
14
- @items = options[:items]
14
+ @items = options.fetch(:items, [])
15
15
  @extension_type = options[:extension_type]
16
- @extension_items = options[:extension_items]
16
+ @extension_items = options.fetch(:extension_items, [])
17
17
  end
18
18
  end
19
19
  end
@@ -1,7 +1,7 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Types
4
- class Set
4
+ class Set < ModelElement
5
5
  attr_accessor :bound1
6
6
  attr_accessor :bound2
7
7
  attr_accessor :base_type
@@ -1,7 +1,7 @@
1
1
  module Expressir
2
2
  module Model
3
3
  module Types
4
- class String
4
+ class String < ModelElement
5
5
  attr_accessor :width
6
6
  attr_accessor :fixed
7
7