expressir 0.2.5 → 0.2.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cross_rubies +30 -0
- data/.github/workflows/rake.yml +14 -15
- data/.github/workflows/release.yml +24 -16
- data/.gitignore +3 -1
- data/Gemfile +0 -2
- data/Rakefile +2 -8
- data/expressir.gemspec +7 -4
- data/ext/express-parser/express_parser.cpp +12 -10
- data/ext/express-parser/extconf.rb +48 -25
- data/lib/expressir/express_exp/formatter.rb +74 -23
- data/lib/expressir/express_exp/parser.rb +20 -2
- data/lib/expressir/express_exp/visitor.rb +201 -96
- data/lib/expressir/model.rb +3 -0
- data/lib/expressir/model/attribute.rb +3 -1
- data/lib/expressir/model/constant.rb +3 -1
- data/lib/expressir/model/entity.rb +12 -19
- data/lib/expressir/model/enumeration_item.rb +3 -1
- data/lib/expressir/model/expressions/aggregate_initializer.rb +2 -2
- data/lib/expressir/model/expressions/aggregate_item.rb +1 -1
- data/lib/expressir/model/expressions/attribute_reference.rb +1 -1
- data/lib/expressir/model/expressions/binary_expression.rb +1 -1
- data/lib/expressir/model/expressions/call.rb +2 -2
- data/lib/expressir/model/expressions/entity_constructor.rb +2 -2
- data/lib/expressir/model/expressions/group_reference.rb +1 -1
- data/lib/expressir/model/expressions/index_reference.rb +1 -1
- data/lib/expressir/model/expressions/interval.rb +1 -1
- data/lib/expressir/model/expressions/query_expression.rb +5 -3
- data/lib/expressir/model/expressions/simple_reference.rb +1 -1
- data/lib/expressir/model/expressions/unary_expression.rb +1 -1
- data/lib/expressir/model/function.rb +32 -38
- data/lib/expressir/model/identifier.rb +1 -0
- data/lib/expressir/model/informal_proposition.rb +13 -0
- data/lib/expressir/model/interface.rb +2 -2
- data/lib/expressir/model/literals/binary.rb +1 -1
- data/lib/expressir/model/literals/integer.rb +1 -1
- data/lib/expressir/model/literals/logical.rb +1 -1
- data/lib/expressir/model/literals/real.rb +1 -1
- data/lib/expressir/model/literals/string.rb +1 -1
- data/lib/expressir/model/model_element.rb +67 -0
- data/lib/expressir/model/parameter.rb +3 -1
- data/lib/expressir/model/procedure.rb +33 -39
- data/lib/expressir/model/renamed_ref.rb +1 -1
- data/lib/expressir/model/repository.rb +3 -3
- data/lib/expressir/model/rule.rb +35 -38
- data/lib/expressir/model/schema.rb +35 -46
- data/lib/expressir/model/scope.rb +49 -3
- data/lib/expressir/model/statements/alias.rb +4 -2
- data/lib/expressir/model/statements/assignment.rb +1 -1
- data/lib/expressir/model/statements/call.rb +2 -2
- data/lib/expressir/model/statements/case.rb +2 -2
- data/lib/expressir/model/statements/case_action.rb +2 -2
- data/lib/expressir/model/statements/compound.rb +2 -2
- data/lib/expressir/model/statements/escape.rb +1 -1
- data/lib/expressir/model/statements/if.rb +3 -3
- data/lib/expressir/model/statements/null.rb +1 -1
- data/lib/expressir/model/statements/repeat.rb +4 -2
- data/lib/expressir/model/statements/return.rb +1 -1
- data/lib/expressir/model/statements/skip.rb +1 -1
- data/lib/expressir/model/subtype_constraint.rb +3 -1
- data/lib/expressir/model/type.rb +13 -3
- data/lib/expressir/model/types/aggregate.rb +3 -1
- data/lib/expressir/model/types/array.rb +1 -1
- data/lib/expressir/model/types/bag.rb +1 -1
- data/lib/expressir/model/types/binary.rb +1 -1
- data/lib/expressir/model/types/boolean.rb +1 -1
- data/lib/expressir/model/types/enumeration.rb +3 -3
- data/lib/expressir/model/types/generic.rb +3 -1
- data/lib/expressir/model/types/generic_entity.rb +3 -1
- data/lib/expressir/model/types/integer.rb +1 -1
- data/lib/expressir/model/types/list.rb +1 -1
- data/lib/expressir/model/types/logical.rb +1 -1
- data/lib/expressir/model/types/number.rb +1 -1
- data/lib/expressir/model/types/real.rb +1 -1
- data/lib/expressir/model/types/select.rb +3 -3
- data/lib/expressir/model/types/set.rb +1 -1
- data/lib/expressir/model/types/string.rb +1 -1
- data/lib/expressir/model/unique.rb +4 -2
- data/lib/expressir/model/variable.rb +3 -1
- data/lib/expressir/model/where.rb +3 -1
- data/lib/expressir/version.rb +1 -1
- data/original/examples/syntax/remark.exp +64 -20
- data/original/examples/syntax/remark_formatted.exp +63 -24
- data/original/examples/syntax/simple.exp +3 -0
- data/original/examples/syntax/source.exp +16 -0
- data/original/examples/syntax/syntax.exp +194 -181
- data/original/examples/syntax/syntax_formatted.exp +354 -787
- data/rakelib/cross-ruby.rake +308 -0
- data/spec/expressir/express_exp/head_source_spec.rb +38 -0
- data/spec/expressir/express_exp/parse_multiple_spec.rb +32 -0
- data/spec/expressir/express_exp/parse_remark_spec.rb +122 -56
- data/spec/expressir/express_exp/parse_syntax_spec.rb +1619 -1569
- data/spec/expressir/express_exp/source_spec.rb +29 -0
- data/spec/expressir/model/model_element_spec.rb +59 -0
- data/spec/expressir/model/{find_spec.rb → scope_spec.rb} +20 -7
- metadata +45 -21
data/lib/expressir/model.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'expressir/model/model_element'
|
2
|
+
|
1
3
|
require 'expressir/model/scope'
|
2
4
|
require 'expressir/model/identifier'
|
3
5
|
|
@@ -6,6 +8,7 @@ require 'expressir/model/constant'
|
|
6
8
|
require 'expressir/model/entity'
|
7
9
|
require 'expressir/model/enumeration_item'
|
8
10
|
require 'expressir/model/function'
|
11
|
+
require 'expressir/model/informal_proposition'
|
9
12
|
require 'expressir/model/interface'
|
10
13
|
require 'expressir/model/parameter'
|
11
14
|
require 'expressir/model/procedure'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
|
-
class Attribute
|
3
|
+
class Attribute < ModelElement
|
4
4
|
include Identifier
|
5
5
|
|
6
6
|
EXPLICIT = :EXPLICIT
|
@@ -15,6 +15,8 @@ module Expressir
|
|
15
15
|
|
16
16
|
def initialize(options = {})
|
17
17
|
@id = options[:id]
|
18
|
+
@remarks = options.fetch(:remarks, [])
|
19
|
+
@source = options[:source]
|
18
20
|
|
19
21
|
@kind = options[:kind]
|
20
22
|
@supertype_attribute = options[:supertype_attribute]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
|
-
class Constant
|
3
|
+
class Constant < ModelElement
|
4
4
|
include Identifier
|
5
5
|
|
6
6
|
attr_accessor :type
|
@@ -8,6 +8,8 @@ module Expressir
|
|
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
|
@type = options[:type]
|
13
15
|
@expression = options[:expression]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
|
-
class Entity
|
3
|
+
class Entity < ModelElement
|
4
4
|
include Scope
|
5
5
|
include Identifier
|
6
6
|
|
@@ -10,35 +10,28 @@ module Expressir
|
|
10
10
|
attr_accessor :attributes
|
11
11
|
attr_accessor :unique
|
12
12
|
attr_accessor :where
|
13
|
+
attr_accessor :informal_propositions
|
13
14
|
|
14
15
|
def initialize(options = {})
|
15
16
|
@id = options[:id]
|
17
|
+
@remarks = options.fetch(:remarks, [])
|
18
|
+
@source = options[:source]
|
16
19
|
|
17
20
|
@abstract = options[:abstract]
|
18
21
|
@supertype_expression = options[:supertype_expression]
|
19
22
|
@subtype_of = options[:subtype_of]
|
20
|
-
@attributes = options
|
21
|
-
@unique = options
|
22
|
-
@where = options
|
23
|
-
|
24
|
-
|
25
|
-
def explicit_attributes
|
26
|
-
@attributes.select{|x| x.kind == Expressir::Model::Attribute::EXPLICIT}
|
27
|
-
end
|
28
|
-
|
29
|
-
def derived_attributes
|
30
|
-
@attributes.select{|x| x.kind == Expressir::Model::Attribute::DERIVED}
|
31
|
-
end
|
32
|
-
|
33
|
-
def inverse_attributes
|
34
|
-
@attributes.select{|x| x.kind == Expressir::Model::Attribute::INVERSE}
|
23
|
+
@attributes = options.fetch(:attributes, [])
|
24
|
+
@unique = options.fetch(:unique, [])
|
25
|
+
@where = options.fetch(:where, [])
|
26
|
+
@informal_propositions = options.fetch(:informal_propositions, [])
|
35
27
|
end
|
36
28
|
|
37
29
|
def children
|
38
30
|
items = []
|
39
|
-
items.push(*@attributes)
|
40
|
-
items.push(*@unique)
|
41
|
-
items.push(*@where)
|
31
|
+
items.push(*@attributes)
|
32
|
+
items.push(*@unique)
|
33
|
+
items.push(*@where)
|
34
|
+
items.push(*@informal_propositions)
|
42
35
|
items
|
43
36
|
end
|
44
37
|
end
|
@@ -1,10 +1,12 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
|
-
class EnumerationItem
|
3
|
+
class EnumerationItem < ModelElement
|
4
4
|
include Identifier
|
5
5
|
|
6
6
|
def initialize(options = {})
|
7
7
|
@id = options[:id]
|
8
|
+
@remarks = options.fetch(:remarks, [])
|
9
|
+
@source = options[:source]
|
8
10
|
end
|
9
11
|
end
|
10
12
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Expressions
|
4
|
-
class AggregateInitializer
|
4
|
+
class AggregateInitializer < ModelElement
|
5
5
|
attr_accessor :items
|
6
6
|
|
7
7
|
def initialize(options = {})
|
8
|
-
@items = options
|
8
|
+
@items = options.fetch(:items, [])
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Expressions
|
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
|
10
|
+
@parameters = options.fetch(:parameters, [])
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Expressions
|
4
|
-
class EntityConstructor
|
4
|
+
class EntityConstructor < ModelElement
|
5
5
|
attr_accessor :entity
|
6
6
|
attr_accessor :parameters
|
7
7
|
|
8
8
|
def initialize(options = {})
|
9
9
|
@entity = options[:entity]
|
10
|
-
@parameters = options
|
10
|
+
@parameters = options.fetch(:parameters, [])
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -1,17 +1,19 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Expressions
|
4
|
-
class QueryExpression
|
4
|
+
class QueryExpression < ModelElement
|
5
5
|
include Scope
|
6
6
|
include Identifier
|
7
7
|
|
8
|
-
attr_accessor :
|
8
|
+
attr_accessor :aggregate_source
|
9
9
|
attr_accessor :expression
|
10
10
|
|
11
11
|
def initialize(options = {})
|
12
12
|
@id = options[:id]
|
13
|
-
|
13
|
+
@remarks = options.fetch(:remarks, [])
|
14
14
|
@source = options[:source]
|
15
|
+
|
16
|
+
@aggregate_source = options[:aggregate_source]
|
15
17
|
@expression = options[:expression]
|
16
18
|
end
|
17
19
|
|
@@ -1,60 +1,54 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
|
-
class Function
|
3
|
+
class Function < ModelElement
|
4
4
|
include Scope
|
5
5
|
include Identifier
|
6
6
|
|
7
7
|
attr_accessor :parameters
|
8
8
|
attr_accessor :return_type
|
9
|
-
attr_accessor :
|
9
|
+
attr_accessor :types
|
10
|
+
attr_accessor :entities
|
11
|
+
attr_accessor :subtype_constraints
|
12
|
+
attr_accessor :functions
|
13
|
+
attr_accessor :procedures
|
10
14
|
attr_accessor :constants
|
11
15
|
attr_accessor :variables
|
12
16
|
attr_accessor :statements
|
13
17
|
|
14
18
|
def initialize(options = {})
|
15
19
|
@id = options[:id]
|
20
|
+
@remarks = options.fetch(:remarks, [])
|
21
|
+
@source = options[:source]
|
16
22
|
|
17
|
-
@parameters = options
|
23
|
+
@parameters = options.fetch(:parameters, [])
|
18
24
|
@return_type = options[:return_type]
|
19
|
-
@
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
@
|
27
|
-
end
|
28
|
-
|
29
|
-
def entities
|
30
|
-
@declarations.select{|x| x.instance_of? Expressir::Model::Entity}
|
31
|
-
end
|
32
|
-
|
33
|
-
def subtype_constraints
|
34
|
-
@declarations.select{|x| x.instance_of? Expressir::Model::SubtypeConstraint}
|
35
|
-
end
|
36
|
-
|
37
|
-
def functions
|
38
|
-
@declarations.select{|x| x.instance_of? Expressir::Model::Function}
|
39
|
-
end
|
40
|
-
|
41
|
-
def procedures
|
42
|
-
@declarations.select{|x| x.instance_of? Expressir::Model::Procedure}
|
25
|
+
@types = options.fetch(:types, [])
|
26
|
+
@entities = options.fetch(:entities, [])
|
27
|
+
@subtype_constraints = options.fetch(:subtype_constraints, [])
|
28
|
+
@functions = options.fetch(:functions, [])
|
29
|
+
@procedures = options.fetch(:procedures, [])
|
30
|
+
@constants = options.fetch(:constants, [])
|
31
|
+
@variables = options.fetch(:variables, [])
|
32
|
+
@statements = options.fetch(:statements, [])
|
43
33
|
end
|
44
34
|
|
45
35
|
def children
|
46
36
|
items = []
|
47
|
-
items.push(*@parameters)
|
48
|
-
items.push(*@
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end)
|
56
|
-
items.push(*@
|
57
|
-
items.push(*@
|
37
|
+
items.push(*@parameters)
|
38
|
+
items.push(*@types)
|
39
|
+
items.push(*@types.flat_map do |x|
|
40
|
+
if x.type.instance_of? Expressir::Model::Types::Enumeration
|
41
|
+
x.type.items
|
42
|
+
else
|
43
|
+
[]
|
44
|
+
end
|
45
|
+
end)
|
46
|
+
items.push(*@entities)
|
47
|
+
items.push(*@subtype_constraints)
|
48
|
+
items.push(*@functions)
|
49
|
+
items.push(*@procedures)
|
50
|
+
items.push(*@constants)
|
51
|
+
items.push(*@variables)
|
58
52
|
items
|
59
53
|
end
|
60
54
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
|
-
class Interface
|
3
|
+
class Interface < ModelElement
|
4
4
|
USE = :USE
|
5
5
|
REFERENCE = :REFERENCE
|
6
6
|
|
@@ -11,7 +11,7 @@ module Expressir
|
|
11
11
|
def initialize(options = {})
|
12
12
|
@kind = options[:kind]
|
13
13
|
@schema = options[:schema]
|
14
|
-
@items = options
|
14
|
+
@items = options.fetch(:items, [])
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|