expressir 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/expressir/express_exp/formatter.rb +1444 -0
- data/lib/expressir/express_exp/visitor.rb +288 -280
- data/lib/expressir/model.rb +13 -42
- data/lib/expressir/model/{derived.rb → attribute.rb} +13 -4
- data/lib/expressir/model/constant.rb +2 -1
- data/lib/expressir/model/entity.rb +22 -17
- data/lib/expressir/model/enumeration_item.rb +2 -1
- data/lib/expressir/model/expressions/aggregate_initializer.rb +9 -9
- data/lib/expressir/model/expressions/aggregate_item.rb +15 -0
- data/lib/expressir/model/expressions/{attribute_qualifier.rb → attribute_reference.rb} +3 -1
- data/lib/expressir/model/expressions/binary_expression.rb +40 -0
- data/lib/expressir/model/expressions/{function_call.rb → call.rb} +3 -3
- data/lib/expressir/model/expressions/entity_constructor.rb +11 -11
- data/lib/expressir/model/expressions/{group_qualifier.rb → group_reference.rb} +3 -1
- data/lib/expressir/model/expressions/{index_qualifier.rb → index_reference.rb} +3 -1
- data/lib/expressir/model/expressions/interval.rb +17 -17
- data/lib/expressir/model/expressions/query_expression.rb +26 -0
- data/lib/expressir/model/expressions/simple_reference.rb +13 -0
- data/lib/expressir/model/expressions/{expression.rb → unary_expression.rb} +7 -3
- data/lib/expressir/model/function.rb +14 -6
- data/lib/expressir/model/{reference.rb → interface.rb} +6 -1
- data/lib/expressir/model/literals/logical.rb +4 -0
- data/lib/expressir/model/parameter.rb +4 -3
- data/lib/expressir/model/procedure.rb +14 -6
- data/lib/expressir/model/repository.rb +1 -1
- data/lib/expressir/model/rule.rb +16 -8
- data/lib/expressir/model/schema.rb +22 -6
- data/lib/expressir/model/statements/alias.rb +3 -2
- data/lib/expressir/model/statements/{procedure_call.rb → call.rb} +3 -3
- data/lib/expressir/model/statements/case.rb +2 -2
- data/lib/expressir/model/statements/case_action.rb +2 -2
- data/lib/expressir/model/statements/repeat.rb +3 -2
- data/lib/expressir/model/subtype_constraint.rb +6 -5
- data/lib/expressir/model/type.rb +3 -2
- data/lib/expressir/model/types/aggregate.rb +2 -1
- data/lib/expressir/model/types/generic.rb +2 -1
- data/lib/expressir/model/types/generic_entity.rb +2 -1
- data/lib/expressir/model/unique.rb +2 -1
- data/lib/expressir/model/{local.rb → variable.rb} +3 -2
- data/lib/expressir/model/where.rb +2 -1
- data/lib/expressir/version.rb +1 -1
- data/original/examples/syntax/remark.exp +126 -108
- data/original/examples/syntax/remark_formatted.exp +172 -0
- data/original/examples/syntax/syntax.exp +287 -277
- data/original/examples/syntax/syntax_formatted.exp +1176 -0
- data/spec/expressir/express_exp/format_remark_spec.rb +28 -0
- data/spec/expressir/express_exp/format_syntax_spec.rb +28 -0
- data/spec/expressir/express_exp/{remark_spec.rb → parse_remark_spec.rb} +80 -36
- data/spec/expressir/express_exp/parse_syntax_spec.rb +2998 -0
- metadata +22 -46
- data/lib/expressir/model/explicit.rb +0 -19
- data/lib/expressir/model/expressions/aggregate_element.rb +0 -15
- data/lib/expressir/model/expressions/qualified_ref.rb +0 -15
- data/lib/expressir/model/expressions/query.rb +0 -25
- data/lib/expressir/model/inverse.rb +0 -19
- data/lib/expressir/model/operators/addition.rb +0 -8
- data/lib/expressir/model/operators/and.rb +0 -8
- data/lib/expressir/model/operators/andor.rb +0 -8
- data/lib/expressir/model/operators/combine.rb +0 -8
- data/lib/expressir/model/operators/equal.rb +0 -8
- data/lib/expressir/model/operators/exponentiation.rb +0 -8
- data/lib/expressir/model/operators/greater_than.rb +0 -8
- data/lib/expressir/model/operators/greater_than_or_equal.rb +0 -8
- data/lib/expressir/model/operators/in.rb +0 -8
- data/lib/expressir/model/operators/instance_equal.rb +0 -8
- data/lib/expressir/model/operators/instance_not_equal.rb +0 -8
- data/lib/expressir/model/operators/integer_division.rb +0 -8
- data/lib/expressir/model/operators/less_than.rb +0 -8
- data/lib/expressir/model/operators/less_than_or_equal.rb +0 -8
- data/lib/expressir/model/operators/like.rb +0 -8
- data/lib/expressir/model/operators/modulo.rb +0 -8
- data/lib/expressir/model/operators/multiplication.rb +0 -8
- data/lib/expressir/model/operators/not.rb +0 -8
- data/lib/expressir/model/operators/not_equal.rb +0 -8
- data/lib/expressir/model/operators/oneof.rb +0 -8
- data/lib/expressir/model/operators/or.rb +0 -8
- data/lib/expressir/model/operators/real_division.rb +0 -8
- data/lib/expressir/model/operators/subtraction.rb +0 -8
- data/lib/expressir/model/operators/unary_minus.rb +0 -8
- data/lib/expressir/model/operators/unary_plus.rb +0 -8
- data/lib/expressir/model/operators/xor.rb +0 -8
- data/lib/expressir/model/ref.rb +0 -11
- data/lib/expressir/model/use.rb +0 -13
- data/spec/expressir/express_exp/syntax_spec.rb +0 -2992
@@ -1,13 +1,17 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Expressions
|
4
|
-
class
|
4
|
+
class UnaryExpression
|
5
|
+
MINUS = :MINUS
|
6
|
+
NOT = :NOT
|
7
|
+
PLUS = :PLUS
|
8
|
+
|
5
9
|
attr_accessor :operator
|
6
|
-
attr_accessor :
|
10
|
+
attr_accessor :operand
|
7
11
|
|
8
12
|
def initialize(options = {})
|
9
13
|
@operator = options[:operator]
|
10
|
-
@
|
14
|
+
@operand = options[:operand]
|
11
15
|
end
|
12
16
|
end
|
13
17
|
end
|
@@ -6,8 +6,10 @@ module Expressir
|
|
6
6
|
attr_accessor :return_type
|
7
7
|
attr_accessor :declarations
|
8
8
|
attr_accessor :constants
|
9
|
-
attr_accessor :
|
9
|
+
attr_accessor :variables
|
10
10
|
attr_accessor :statements
|
11
|
+
|
12
|
+
attr_accessor :parent
|
11
13
|
attr_accessor :remarks
|
12
14
|
|
13
15
|
def initialize(options = {})
|
@@ -16,9 +18,8 @@ module Expressir
|
|
16
18
|
@return_type = options[:return_type]
|
17
19
|
@declarations = options[:declarations]
|
18
20
|
@constants = options[:constants]
|
19
|
-
@
|
21
|
+
@variables = options[:variables]
|
20
22
|
@statements = options[:statements]
|
21
|
-
@remarks = options[:remarks]
|
22
23
|
end
|
23
24
|
|
24
25
|
def types
|
@@ -41,12 +42,19 @@ module Expressir
|
|
41
42
|
@declarations.select{|x| x.instance_of? Expressir::Model::Procedure}
|
42
43
|
end
|
43
44
|
|
44
|
-
def
|
45
|
+
def children
|
45
46
|
items = []
|
46
47
|
items.push(*@parameters) if @parameters
|
47
|
-
items.push(*@declarations
|
48
|
+
items.push(*@declarations.flat_map do |x|
|
49
|
+
[
|
50
|
+
x,
|
51
|
+
*if x.instance_of? Expressir::Model::Type and x.type.instance_of? Expressir::Model::Types::Enumeration
|
52
|
+
x.type.items
|
53
|
+
end
|
54
|
+
]
|
55
|
+
end) if @declarations
|
48
56
|
items.push(*@constants) if @constants
|
49
|
-
items.push(*@
|
57
|
+
items.push(*@variables) if @variables
|
50
58
|
items
|
51
59
|
end
|
52
60
|
end
|
@@ -1,10 +1,15 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
|
-
class
|
3
|
+
class Interface
|
4
|
+
USE = :USE
|
5
|
+
REFERENCE = :REFERENCE
|
6
|
+
|
7
|
+
attr_accessor :kind
|
4
8
|
attr_accessor :schema
|
5
9
|
attr_accessor :items
|
6
10
|
|
7
11
|
def initialize(options = {})
|
12
|
+
@kind = options[:kind]
|
8
13
|
@schema = options[:schema]
|
9
14
|
@items = options[:items]
|
10
15
|
end
|
@@ -1,16 +1,17 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
class Parameter
|
4
|
+
attr_accessor :var
|
4
5
|
attr_accessor :id
|
5
6
|
attr_accessor :type
|
6
|
-
|
7
|
+
|
8
|
+
attr_accessor :parent
|
7
9
|
attr_accessor :remarks
|
8
10
|
|
9
11
|
def initialize(options = {})
|
12
|
+
@var = options[:var]
|
10
13
|
@id = options[:id]
|
11
14
|
@type = options[:type]
|
12
|
-
@var = options[:var]
|
13
|
-
@remarks = options[:remarks]
|
14
15
|
end
|
15
16
|
end
|
16
17
|
end
|
@@ -5,8 +5,10 @@ module Expressir
|
|
5
5
|
attr_accessor :parameters
|
6
6
|
attr_accessor :declarations
|
7
7
|
attr_accessor :constants
|
8
|
-
attr_accessor :
|
8
|
+
attr_accessor :variables
|
9
9
|
attr_accessor :statements
|
10
|
+
|
11
|
+
attr_accessor :parent
|
10
12
|
attr_accessor :remarks
|
11
13
|
|
12
14
|
def initialize(options = {})
|
@@ -14,9 +16,8 @@ module Expressir
|
|
14
16
|
@parameters = options[:parameters]
|
15
17
|
@declarations = options[:declarations]
|
16
18
|
@constants = options[:constants]
|
17
|
-
@
|
19
|
+
@variables = options[:variables]
|
18
20
|
@statements = options[:statements]
|
19
|
-
@remarks = options[:remarks]
|
20
21
|
end
|
21
22
|
|
22
23
|
def types
|
@@ -39,12 +40,19 @@ module Expressir
|
|
39
40
|
@declarations.select{|x| x.instance_of? Expressir::Model::Procedure}
|
40
41
|
end
|
41
42
|
|
42
|
-
def
|
43
|
+
def children
|
43
44
|
items = []
|
44
45
|
items.push(*@parameters) if @parameters
|
45
|
-
items.push(*@declarations
|
46
|
+
items.push(*@declarations.flat_map do |x|
|
47
|
+
[
|
48
|
+
x,
|
49
|
+
*if x.instance_of? Expressir::Model::Type and x.type.instance_of? Expressir::Model::Types::Enumeration
|
50
|
+
x.type.items
|
51
|
+
end
|
52
|
+
]
|
53
|
+
end) if @declarations
|
46
54
|
items.push(*@constants) if @constants
|
47
|
-
items.push(*@
|
55
|
+
items.push(*@variables) if @variables
|
48
56
|
items
|
49
57
|
end
|
50
58
|
end
|
data/lib/expressir/model/rule.rb
CHANGED
@@ -5,9 +5,11 @@ module Expressir
|
|
5
5
|
attr_accessor :applies_to
|
6
6
|
attr_accessor :declarations
|
7
7
|
attr_accessor :constants
|
8
|
-
attr_accessor :
|
9
|
-
attr_accessor :where
|
8
|
+
attr_accessor :variables
|
10
9
|
attr_accessor :statements
|
10
|
+
attr_accessor :where
|
11
|
+
|
12
|
+
attr_accessor :parent
|
11
13
|
attr_accessor :remarks
|
12
14
|
|
13
15
|
def initialize(options = {})
|
@@ -15,10 +17,9 @@ module Expressir
|
|
15
17
|
@applies_to = options[:applies_to]
|
16
18
|
@declarations = options[:declarations]
|
17
19
|
@constants = options[:constants]
|
18
|
-
@
|
19
|
-
@where = options[:where]
|
20
|
+
@variables = options[:variables]
|
20
21
|
@statements = options[:statements]
|
21
|
-
@
|
22
|
+
@where = options[:where]
|
22
23
|
end
|
23
24
|
|
24
25
|
def types
|
@@ -41,11 +42,18 @@ module Expressir
|
|
41
42
|
@declarations.select{|x| x.instance_of? Expressir::Model::Procedure}
|
42
43
|
end
|
43
44
|
|
44
|
-
def
|
45
|
+
def children
|
45
46
|
items = []
|
46
|
-
items.push(*@declarations
|
47
|
+
items.push(*@declarations.flat_map do |x|
|
48
|
+
[
|
49
|
+
x,
|
50
|
+
*if x.instance_of? Expressir::Model::Type and x.type.instance_of? Expressir::Model::Types::Enumeration
|
51
|
+
x.type.items
|
52
|
+
end
|
53
|
+
]
|
54
|
+
end) if @declarations
|
47
55
|
items.push(*@constants) if @constants
|
48
|
-
items.push(*@
|
56
|
+
items.push(*@variables) if @variables
|
49
57
|
items.push(*@where) if @where
|
50
58
|
items
|
51
59
|
end
|
@@ -6,7 +6,7 @@ module Expressir
|
|
6
6
|
attr_accessor :interfaces
|
7
7
|
attr_accessor :constants
|
8
8
|
attr_accessor :declarations
|
9
|
-
|
9
|
+
|
10
10
|
attr_accessor :remarks
|
11
11
|
|
12
12
|
def initialize(options = {})
|
@@ -15,8 +15,14 @@ module Expressir
|
|
15
15
|
@interfaces = options[:interfaces]
|
16
16
|
@constants = options[:constants]
|
17
17
|
@declarations = options[:declarations]
|
18
|
-
|
19
|
-
|
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}
|
20
26
|
end
|
21
27
|
|
22
28
|
def types
|
@@ -39,11 +45,21 @@ module Expressir
|
|
39
45
|
@declarations.select{|x| x.instance_of? Expressir::Model::Procedure}
|
40
46
|
end
|
41
47
|
|
42
|
-
def
|
48
|
+
def rules
|
49
|
+
@declarations.select{|x| x.instance_of? Expressir::Model::Rule}
|
50
|
+
end
|
51
|
+
|
52
|
+
def children
|
43
53
|
items = []
|
44
54
|
items.push(*@constants) if @constants
|
45
|
-
items.push(*@declarations
|
46
|
-
|
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
|
60
|
+
end
|
61
|
+
]
|
62
|
+
end) if @declarations
|
47
63
|
items
|
48
64
|
end
|
49
65
|
end
|
@@ -5,16 +5,17 @@ module Expressir
|
|
5
5
|
attr_accessor :id
|
6
6
|
attr_accessor :expression
|
7
7
|
attr_accessor :statements
|
8
|
+
|
9
|
+
attr_accessor :parent
|
8
10
|
attr_accessor :remarks
|
9
11
|
|
10
12
|
def initialize(options = {})
|
11
13
|
@id = options[:id]
|
12
14
|
@expression = options[:expression]
|
13
15
|
@statements = options[:statements]
|
14
|
-
@remarks = options[:remarks]
|
15
16
|
end
|
16
17
|
|
17
|
-
def
|
18
|
+
def children
|
18
19
|
items = []
|
19
20
|
items.push(self)
|
20
21
|
items
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Statements
|
4
|
-
class
|
5
|
-
attr_accessor :
|
4
|
+
class Call
|
5
|
+
attr_accessor :ref
|
6
6
|
attr_accessor :parameters
|
7
7
|
|
8
8
|
def initialize(options = {})
|
9
|
-
@
|
9
|
+
@ref = options[:ref]
|
10
10
|
@parameters = options[:parameters]
|
11
11
|
end
|
12
12
|
end
|
@@ -2,12 +2,12 @@ module Expressir
|
|
2
2
|
module Model
|
3
3
|
module Statements
|
4
4
|
class Case
|
5
|
-
attr_accessor :
|
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
11
|
@actions = options[:actions]
|
12
12
|
@otherwise_statement = options[:otherwise_statement]
|
13
13
|
end
|
@@ -2,11 +2,11 @@ module Expressir
|
|
2
2
|
module Model
|
3
3
|
module Statements
|
4
4
|
class CaseAction
|
5
|
-
attr_accessor :
|
5
|
+
attr_accessor :labels
|
6
6
|
attr_accessor :statement
|
7
7
|
|
8
8
|
def initialize(options = {})
|
9
|
-
@
|
9
|
+
@labels = options[:labels]
|
10
10
|
@statement = options[:statement]
|
11
11
|
end
|
12
12
|
end
|
@@ -9,6 +9,8 @@ module Expressir
|
|
9
9
|
attr_accessor :while_expression
|
10
10
|
attr_accessor :until_expression
|
11
11
|
attr_accessor :statements
|
12
|
+
|
13
|
+
attr_accessor :parent
|
12
14
|
attr_accessor :remarks
|
13
15
|
|
14
16
|
def initialize(options = {})
|
@@ -19,10 +21,9 @@ module Expressir
|
|
19
21
|
@while_expression = options[:while_expression]
|
20
22
|
@until_expression = options[:until_expression]
|
21
23
|
@statements = options[:statements]
|
22
|
-
@remarks = options[:remarks]
|
23
24
|
end
|
24
25
|
|
25
|
-
def
|
26
|
+
def children
|
26
27
|
items = []
|
27
28
|
items.push(self)
|
28
29
|
items
|
@@ -3,18 +3,19 @@ module Expressir
|
|
3
3
|
class SubtypeConstraint
|
4
4
|
attr_accessor :id
|
5
5
|
attr_accessor :applies_to
|
6
|
-
attr_accessor :
|
6
|
+
attr_accessor :abstract
|
7
7
|
attr_accessor :total_over
|
8
|
-
attr_accessor :
|
8
|
+
attr_accessor :supertype_expression
|
9
|
+
|
10
|
+
attr_accessor :parent
|
9
11
|
attr_accessor :remarks
|
10
12
|
|
11
13
|
def initialize(options = {})
|
12
14
|
@id = options[:id]
|
13
15
|
@applies_to = options[:applies_to]
|
14
|
-
@
|
16
|
+
@abstract = options[:abstract]
|
15
17
|
@total_over = options[:total_over]
|
16
|
-
@
|
17
|
-
@remarks = options[:remarks]
|
18
|
+
@supertype_expression = options[:supertype_expression]
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
data/lib/expressir/model/type.rb
CHANGED
@@ -4,16 +4,17 @@ module Expressir
|
|
4
4
|
attr_accessor :id
|
5
5
|
attr_accessor :type
|
6
6
|
attr_accessor :where
|
7
|
+
|
8
|
+
attr_accessor :parent
|
7
9
|
attr_accessor :remarks
|
8
10
|
|
9
11
|
def initialize(options = {})
|
10
12
|
@id = options[:id]
|
11
13
|
@type = options[:type]
|
12
14
|
@where = options[:where]
|
13
|
-
@remarks = options[:remarks]
|
14
15
|
end
|
15
16
|
|
16
|
-
def
|
17
|
+
def children
|
17
18
|
items = []
|
18
19
|
items.push(*@where) if @where
|
19
20
|
items
|
@@ -4,12 +4,13 @@ module Expressir
|
|
4
4
|
class Aggregate
|
5
5
|
attr_accessor :label
|
6
6
|
attr_accessor :base_type
|
7
|
+
|
8
|
+
attr_accessor :parent
|
7
9
|
attr_accessor :remarks
|
8
10
|
|
9
11
|
def initialize(options = {})
|
10
12
|
@label = options[:label]
|
11
13
|
@base_type = options[:base_type]
|
12
|
-
@remarks = options[:remarks]
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|