predicator 0.3.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +2 -0
- data/.rubocop.yml +46 -0
- data/.travis.yml +3 -2
- data/HISTORY.md +31 -0
- data/README.md +33 -12
- data/Rakefile +14 -5
- data/lib/predicator.rb +18 -4
- data/lib/predicator/ast.rb +190 -0
- data/lib/predicator/context.rb +7 -12
- data/lib/predicator/evaluator.rb +153 -0
- data/lib/predicator/lexer.rex +69 -0
- data/lib/predicator/lexer.rex.rb +187 -0
- data/lib/predicator/parser.rb +427 -26
- data/lib/predicator/parser.y +103 -35
- data/lib/predicator/version.rb +1 -1
- data/lib/predicator/visitors.rb +5 -0
- data/lib/predicator/visitors/dot.rb +113 -0
- data/lib/predicator/visitors/each.rb +16 -0
- data/lib/predicator/visitors/instructions.rb +183 -0
- data/lib/predicator/visitors/string.rb +76 -0
- data/lib/predicator/visitors/visitor.rb +100 -0
- data/predicator.gemspec +10 -2
- metadata +67 -28
- data/lib/predicator/generated_parser.rb +0 -307
- data/lib/predicator/lexer.rb +0 -117
- data/lib/predicator/predicates/and.rb +0 -20
- data/lib/predicator/predicates/between.rb +0 -23
- data/lib/predicator/predicates/equal.rb +0 -9
- data/lib/predicator/predicates/false.rb +0 -13
- data/lib/predicator/predicates/greater_than.rb +0 -9
- data/lib/predicator/predicates/greater_than_or_equal.rb +0 -9
- data/lib/predicator/predicates/less_than.rb +0 -9
- data/lib/predicator/predicates/less_than_or_equal.rb +0 -9
- data/lib/predicator/predicates/not.rb +0 -20
- data/lib/predicator/predicates/not_equal.rb +0 -9
- data/lib/predicator/predicates/or.rb +0 -20
- data/lib/predicator/predicates/relation.rb +0 -17
- data/lib/predicator/predicates/true.rb +0 -13
- data/lib/predicator/variable.rb +0 -26
@@ -0,0 +1,76 @@
|
|
1
|
+
module Predicator
|
2
|
+
module Visitors
|
3
|
+
class String < Visitor
|
4
|
+
private
|
5
|
+
|
6
|
+
def terminal node
|
7
|
+
node.left.to_s
|
8
|
+
end
|
9
|
+
|
10
|
+
def visit_STRING node
|
11
|
+
"'#{node.left}'"
|
12
|
+
end
|
13
|
+
|
14
|
+
def visit_ARRAY node
|
15
|
+
contents = node.left.map{ |item| visit item }.join(", ")
|
16
|
+
"[#{contents}]"
|
17
|
+
end
|
18
|
+
|
19
|
+
def visit_NOT node
|
20
|
+
"!#{visit node.left}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def visit_GROUP node
|
24
|
+
"(#{visit node.left})"
|
25
|
+
end
|
26
|
+
|
27
|
+
def visit_EQ node
|
28
|
+
[visit(node.left), " = ", visit(node.right)].join
|
29
|
+
end
|
30
|
+
|
31
|
+
def visit_GT node
|
32
|
+
[visit(node.left), " > ", visit(node.right)].join
|
33
|
+
end
|
34
|
+
|
35
|
+
def visit_LT node
|
36
|
+
[visit(node.left), " < ", visit(node.right)].join
|
37
|
+
end
|
38
|
+
|
39
|
+
def visit_AND node
|
40
|
+
[visit(node.left), " and ", visit(node.right)].join
|
41
|
+
end
|
42
|
+
|
43
|
+
def visit_OR node
|
44
|
+
[visit(node.left), " or ", visit(node.right)].join
|
45
|
+
end
|
46
|
+
|
47
|
+
def visit_BETWEEN node
|
48
|
+
[visit(node.left), " between ", visit(node.middle), " and ", visit(node.right)].join
|
49
|
+
end
|
50
|
+
|
51
|
+
def visit_IN node
|
52
|
+
[visit(node.left), " in ", visit(node.right)].join
|
53
|
+
end
|
54
|
+
|
55
|
+
def visit_NOTIN node
|
56
|
+
[visit(node.left), " not in ", visit(node.right)].join
|
57
|
+
end
|
58
|
+
|
59
|
+
def visit_STRSTARTSWITH node
|
60
|
+
[visit(node.left), " starts with ", visit(node.right)].join
|
61
|
+
end
|
62
|
+
|
63
|
+
def visit_STRENDSWITH node
|
64
|
+
[visit(node.left), " ends with ", visit(node.right)].join
|
65
|
+
end
|
66
|
+
|
67
|
+
def visit_DATEAGO node
|
68
|
+
visit(node.left) + " ago"
|
69
|
+
end
|
70
|
+
|
71
|
+
def visit_DATEFROMNOW node
|
72
|
+
visit(node.left) + " from now"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
module Predicator
|
2
|
+
module Visitors
|
3
|
+
class Visitor
|
4
|
+
DISPATCH_CACHE = Hash.new { |h,k|
|
5
|
+
h[k] = "visit_#{k}"
|
6
|
+
}
|
7
|
+
|
8
|
+
def accept node
|
9
|
+
visit node
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def visit node
|
15
|
+
send DISPATCH_CACHE[node.type], node
|
16
|
+
end
|
17
|
+
|
18
|
+
def visit_children node
|
19
|
+
node.children.each {|child| visit child}
|
20
|
+
end
|
21
|
+
|
22
|
+
def terminal node; end
|
23
|
+
|
24
|
+
def visit_ARRAY node
|
25
|
+
node.left.each{ |item| visit item }
|
26
|
+
end
|
27
|
+
|
28
|
+
visit_children_methods = %w(
|
29
|
+
visit_EQ visit_GT visit_LT
|
30
|
+
visit_NOT visit_GROUP visit_BOOL
|
31
|
+
visit_IN visit_NOTIN visit_BETWEEN
|
32
|
+
visit_DATEAGO visit_DATEFROMNOW
|
33
|
+
visit_AND visit_OR
|
34
|
+
visit_STRSTARTSWITH visit_STRENDSWITH
|
35
|
+
)
|
36
|
+
visit_children_methods.each do |method_name|
|
37
|
+
define_method method_name do |node|
|
38
|
+
visit_children node
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
%w( visit_INTEQ visit_STREQ visit_DATEQ ).each do |method_name|
|
43
|
+
define_method method_name do |node|
|
44
|
+
visit_EQ node
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
%w( visit_INTGT visit_STRGT visit_DATGT ).each do |method_name|
|
49
|
+
define_method method_name do |node|
|
50
|
+
visit_GT node
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
%w( visit_INTLT visit_STRLT visit_DATLT ).each do |method_name|
|
55
|
+
define_method method_name do |node|
|
56
|
+
visit_LT node
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
%w( visit_INTIN visit_STRIN ).each do |method_name|
|
61
|
+
define_method method_name do |node|
|
62
|
+
visit_IN node
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
%w( visit_INTNOTIN visit_STRNOTIN ).each do |method_name|
|
67
|
+
define_method method_name do |node|
|
68
|
+
visit_NOTIN node
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
%w( visit_INTBETWEEN visit_DATBETWEEN ).each do |method_name|
|
73
|
+
define_method method_name do |node|
|
74
|
+
visit_BETWEEN node
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
terminal_methods = %w(
|
79
|
+
visit_TRUE visit_FALSE
|
80
|
+
visit_DATE visit_DURATION
|
81
|
+
visit_INTEGER visit_STRING visit_VARIABLE
|
82
|
+
visit_BLANK visit_PRESENT
|
83
|
+
)
|
84
|
+
terminal_methods.each do |method_name|
|
85
|
+
define_method method_name do |node|
|
86
|
+
terminal node
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
array_methods = %w(
|
91
|
+
visit_INTARRAY visit_STRARRAY
|
92
|
+
)
|
93
|
+
array_methods.each do |method_name|
|
94
|
+
define_method method_name do |node|
|
95
|
+
visit_ARRAY node
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
data/predicator.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["JohnnyT"]
|
10
10
|
spec.email = ["ubergeek3141@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{
|
13
|
-
spec.homepage = "https://github.com/
|
12
|
+
spec.summary = %q{A secure, non-evaling condition (boolean predicate) engine for end users}
|
13
|
+
spec.homepage = "https://github.com/riddler/predicator/tree/master/impl/rb"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(bin|test|spec|features)/}) }
|
@@ -18,9 +18,17 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename f }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
22
|
+
spec.metadata["changelog_uri"] = "https://github.com/riddler/predicator/blob/master/impl/rb/HISTORY.md"
|
23
|
+
spec.metadata["source_code_uri"] = "https://github.com/riddler/predicator/tree/master/impl/rb"
|
24
|
+
spec.metadata["bug_tracker_uri"] = "https://github.com/riddler/predicator/issues"
|
25
|
+
|
21
26
|
spec.add_development_dependency "bundler"
|
22
27
|
spec.add_development_dependency "coveralls"
|
23
28
|
spec.add_development_dependency "minitest", "= 5.4.2"
|
29
|
+
spec.add_development_dependency "minitest-focus"
|
30
|
+
spec.add_development_dependency "oedipus_lex"
|
31
|
+
spec.add_development_dependency "pry-nav"
|
24
32
|
spec.add_development_dependency "racc"
|
25
33
|
spec.add_development_dependency "rake"
|
26
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: predicator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JohnnyT
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,48 @@ dependencies:
|
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 5.4.2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest-focus
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: oedipus_lex
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry-nav
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
55
97
|
- !ruby/object:Gem::Dependency
|
56
98
|
name: racc
|
57
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,7 +122,7 @@ dependencies:
|
|
80
122
|
- - ">="
|
81
123
|
- !ruby/object:Gem::Version
|
82
124
|
version: '0'
|
83
|
-
description:
|
125
|
+
description:
|
84
126
|
email:
|
85
127
|
- ubergeek3141@gmail.com
|
86
128
|
executables: []
|
@@ -88,6 +130,7 @@ extensions: []
|
|
88
130
|
extra_rdoc_files: []
|
89
131
|
files:
|
90
132
|
- ".gitignore"
|
133
|
+
- ".rubocop.yml"
|
91
134
|
- ".travis.yml"
|
92
135
|
- CODE_OF_CONDUCT.md
|
93
136
|
- Gemfile
|
@@ -96,32 +139,30 @@ files:
|
|
96
139
|
- README.md
|
97
140
|
- Rakefile
|
98
141
|
- lib/predicator.rb
|
142
|
+
- lib/predicator/ast.rb
|
99
143
|
- lib/predicator/context.rb
|
100
|
-
- lib/predicator/
|
101
|
-
- lib/predicator/lexer.
|
144
|
+
- lib/predicator/evaluator.rb
|
145
|
+
- lib/predicator/lexer.rex
|
146
|
+
- lib/predicator/lexer.rex.rb
|
102
147
|
- lib/predicator/parser.rb
|
103
148
|
- lib/predicator/parser.y
|
104
|
-
- lib/predicator/predicates/and.rb
|
105
|
-
- lib/predicator/predicates/between.rb
|
106
|
-
- lib/predicator/predicates/equal.rb
|
107
|
-
- lib/predicator/predicates/false.rb
|
108
|
-
- lib/predicator/predicates/greater_than.rb
|
109
|
-
- lib/predicator/predicates/greater_than_or_equal.rb
|
110
|
-
- lib/predicator/predicates/less_than.rb
|
111
|
-
- lib/predicator/predicates/less_than_or_equal.rb
|
112
|
-
- lib/predicator/predicates/not.rb
|
113
|
-
- lib/predicator/predicates/not_equal.rb
|
114
|
-
- lib/predicator/predicates/or.rb
|
115
|
-
- lib/predicator/predicates/relation.rb
|
116
|
-
- lib/predicator/predicates/true.rb
|
117
|
-
- lib/predicator/variable.rb
|
118
149
|
- lib/predicator/version.rb
|
150
|
+
- lib/predicator/visitors.rb
|
151
|
+
- lib/predicator/visitors/dot.rb
|
152
|
+
- lib/predicator/visitors/each.rb
|
153
|
+
- lib/predicator/visitors/instructions.rb
|
154
|
+
- lib/predicator/visitors/string.rb
|
155
|
+
- lib/predicator/visitors/visitor.rb
|
119
156
|
- predicator.gemspec
|
120
|
-
homepage: https://github.com/
|
157
|
+
homepage: https://github.com/riddler/predicator/tree/master/impl/rb
|
121
158
|
licenses:
|
122
159
|
- MIT
|
123
|
-
metadata:
|
124
|
-
|
160
|
+
metadata:
|
161
|
+
allowed_push_host: https://rubygems.org
|
162
|
+
changelog_uri: https://github.com/riddler/predicator/blob/master/impl/rb/HISTORY.md
|
163
|
+
source_code_uri: https://github.com/riddler/predicator/tree/master/impl/rb
|
164
|
+
bug_tracker_uri: https://github.com/riddler/predicator/issues
|
165
|
+
post_install_message:
|
125
166
|
rdoc_options: []
|
126
167
|
require_paths:
|
127
168
|
- lib
|
@@ -136,10 +177,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
177
|
- !ruby/object:Gem::Version
|
137
178
|
version: '0'
|
138
179
|
requirements: []
|
139
|
-
|
140
|
-
|
141
|
-
signing_key:
|
180
|
+
rubygems_version: 3.0.6
|
181
|
+
signing_key:
|
142
182
|
specification_version: 4
|
143
|
-
summary:
|
183
|
+
summary: A secure, non-evaling condition (boolean predicate) engine for end users
|
144
184
|
test_files: []
|
145
|
-
has_rdoc:
|
@@ -1,307 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# DO NOT MODIFY!!!!
|
3
|
-
# This file is automatically generated by Racc 1.4.14
|
4
|
-
# from Racc grammer file "".
|
5
|
-
#
|
6
|
-
|
7
|
-
require 'racc/parser.rb'
|
8
|
-
module Predicator
|
9
|
-
class GeneratedParser < Racc::Parser
|
10
|
-
##### State transition tables begin ###
|
11
|
-
|
12
|
-
racc_action_table = [
|
13
|
-
9, 31, 32, 7, 8, 14, 15, 16, 17, 18,
|
14
|
-
9, 43, 6, 7, 8, 14, 15, 16, 17, 18,
|
15
|
-
9, 44, 6, 7, 8, 14, 15, 16, 17, 18,
|
16
|
-
9, nil, 6, 7, 8, 14, 15, 16, 17, 18,
|
17
|
-
9, nil, 6, 7, 8, 14, 15, 16, 17, 18,
|
18
|
-
20, 21, 6, 19, nil, nil, 20, 21, nil, 22,
|
19
|
-
nil, nil, 42, 23, 28, 27, 26, 25, 24, 14,
|
20
|
-
15, 16, 17, 18, 14, 15, 16, 17, 18, 14,
|
21
|
-
15, 16, 17, 18, 14, 15, 16, 17, 18, 14,
|
22
|
-
15, 16, 17, 18, 14, 15, 16, 17, 18, 14,
|
23
|
-
15, 16, 17, 18, 14, 15, 16, 17, 18 ]
|
24
|
-
|
25
|
-
racc_action_check = [
|
26
|
-
0, 18, 19, 0, 0, 0, 0, 0, 0, 0,
|
27
|
-
6, 31, 0, 6, 6, 6, 6, 6, 6, 6,
|
28
|
-
9, 35, 6, 9, 9, 9, 9, 9, 9, 9,
|
29
|
-
20, nil, 9, 20, 20, 20, 20, 20, 20, 20,
|
30
|
-
21, nil, 20, 21, 21, 21, 21, 21, 21, 21,
|
31
|
-
29, 29, 21, 1, nil, nil, 1, 1, nil, 5,
|
32
|
-
nil, nil, 29, 5, 5, 5, 5, 5, 5, 22,
|
33
|
-
22, 22, 22, 22, 23, 23, 23, 23, 23, 24,
|
34
|
-
24, 24, 24, 24, 25, 25, 25, 25, 25, 26,
|
35
|
-
26, 26, 26, 26, 27, 27, 27, 27, 27, 28,
|
36
|
-
28, 28, 28, 28, 44, 44, 44, 44, 44 ]
|
37
|
-
|
38
|
-
racc_action_pointer = [
|
39
|
-
-2, 53, nil, nil, nil, 47, 8, nil, nil, 18,
|
40
|
-
nil, nil, nil, nil, nil, nil, nil, nil, -12, 2,
|
41
|
-
28, 38, 62, 67, 72, 77, 82, 87, 92, 47,
|
42
|
-
nil, 0, nil, nil, nil, 18, nil, nil, nil, nil,
|
43
|
-
nil, nil, nil, nil, 97, nil ]
|
44
|
-
|
45
|
-
racc_action_default = [
|
46
|
-
-26, -26, -1, -2, -3, -26, -26, -12, -13, -26,
|
47
|
-
-17, -18, -19, -20, -21, -22, -23, -24, -26, -26,
|
48
|
-
-26, -26, -26, -26, -26, -26, -26, -26, -26, -26,
|
49
|
-
-16, -26, 46, -14, -15, -26, -6, -7, -8, -9,
|
50
|
-
-10, -11, -5, -25, -26, -4 ]
|
51
|
-
|
52
|
-
racc_goto_table = [
|
53
|
-
35, 36, 37, 38, 39, 40, 41, 1, nil, nil,
|
54
|
-
nil, nil, nil, 29, nil, nil, 30, nil, nil, nil,
|
55
|
-
nil, nil, 45, nil, nil, nil, nil, 33, 34 ]
|
56
|
-
|
57
|
-
racc_goto_check = [
|
58
|
-
5, 5, 5, 5, 5, 5, 5, 1, nil, nil,
|
59
|
-
nil, nil, nil, 1, nil, nil, 1, nil, nil, nil,
|
60
|
-
nil, nil, 5, nil, nil, nil, nil, 1, 1 ]
|
61
|
-
|
62
|
-
racc_goto_pointer = [
|
63
|
-
nil, 7, nil, nil, nil, -22, nil, nil, nil, nil ]
|
64
|
-
|
65
|
-
racc_goto_default = [
|
66
|
-
nil, nil, 2, 3, 4, 5, 10, 11, 12, 13 ]
|
67
|
-
|
68
|
-
racc_reduce_table = [
|
69
|
-
0, 0, :racc_error,
|
70
|
-
1, 23, :_reduce_none,
|
71
|
-
1, 23, :_reduce_none,
|
72
|
-
1, 23, :_reduce_none,
|
73
|
-
5, 23, :_reduce_4,
|
74
|
-
3, 23, :_reduce_none,
|
75
|
-
3, 24, :_reduce_6,
|
76
|
-
3, 24, :_reduce_7,
|
77
|
-
3, 24, :_reduce_8,
|
78
|
-
3, 24, :_reduce_9,
|
79
|
-
3, 24, :_reduce_10,
|
80
|
-
3, 24, :_reduce_11,
|
81
|
-
1, 25, :_reduce_12,
|
82
|
-
1, 25, :_reduce_13,
|
83
|
-
3, 26, :_reduce_14,
|
84
|
-
3, 26, :_reduce_15,
|
85
|
-
2, 26, :_reduce_16,
|
86
|
-
1, 27, :_reduce_none,
|
87
|
-
1, 27, :_reduce_none,
|
88
|
-
1, 28, :_reduce_none,
|
89
|
-
1, 28, :_reduce_none,
|
90
|
-
1, 30, :_reduce_21,
|
91
|
-
1, 31, :_reduce_22,
|
92
|
-
1, 31, :_reduce_23,
|
93
|
-
1, 31, :_reduce_24,
|
94
|
-
3, 29, :_reduce_25 ]
|
95
|
-
|
96
|
-
racc_reduce_n = 26
|
97
|
-
|
98
|
-
racc_shift_n = 46
|
99
|
-
|
100
|
-
racc_token_table = {
|
101
|
-
false => 0,
|
102
|
-
:error => 1,
|
103
|
-
:tBANG => 2,
|
104
|
-
:tAND => 3,
|
105
|
-
:tOR => 4,
|
106
|
-
:tTRUE => 5,
|
107
|
-
:tFALSE => 6,
|
108
|
-
:tSTRING => 7,
|
109
|
-
:tFLOAT => 8,
|
110
|
-
:tINTEGER => 9,
|
111
|
-
:tDATE => 10,
|
112
|
-
:tIDENTIFIER => 11,
|
113
|
-
:tBETWEEN => 12,
|
114
|
-
:tDOT => 13,
|
115
|
-
:tLPAREN => 14,
|
116
|
-
:tRPAREN => 15,
|
117
|
-
:tEQ => 16,
|
118
|
-
:tNEQ => 17,
|
119
|
-
:tLEQ => 18,
|
120
|
-
:tGEQ => 19,
|
121
|
-
:tLT => 20,
|
122
|
-
:tGT => 21 }
|
123
|
-
|
124
|
-
racc_nt_base = 22
|
125
|
-
|
126
|
-
racc_use_result_var = false
|
127
|
-
|
128
|
-
Racc_arg = [
|
129
|
-
racc_action_table,
|
130
|
-
racc_action_check,
|
131
|
-
racc_action_default,
|
132
|
-
racc_action_pointer,
|
133
|
-
racc_goto_table,
|
134
|
-
racc_goto_check,
|
135
|
-
racc_goto_default,
|
136
|
-
racc_goto_pointer,
|
137
|
-
racc_nt_base,
|
138
|
-
racc_reduce_table,
|
139
|
-
racc_token_table,
|
140
|
-
racc_shift_n,
|
141
|
-
racc_reduce_n,
|
142
|
-
racc_use_result_var ]
|
143
|
-
|
144
|
-
Racc_token_to_s_table = [
|
145
|
-
"$end",
|
146
|
-
"error",
|
147
|
-
"tBANG",
|
148
|
-
"tAND",
|
149
|
-
"tOR",
|
150
|
-
"tTRUE",
|
151
|
-
"tFALSE",
|
152
|
-
"tSTRING",
|
153
|
-
"tFLOAT",
|
154
|
-
"tINTEGER",
|
155
|
-
"tDATE",
|
156
|
-
"tIDENTIFIER",
|
157
|
-
"tBETWEEN",
|
158
|
-
"tDOT",
|
159
|
-
"tLPAREN",
|
160
|
-
"tRPAREN",
|
161
|
-
"tEQ",
|
162
|
-
"tNEQ",
|
163
|
-
"tLEQ",
|
164
|
-
"tGEQ",
|
165
|
-
"tLT",
|
166
|
-
"tGT",
|
167
|
-
"$start",
|
168
|
-
"predicate",
|
169
|
-
"relation_predicate",
|
170
|
-
"boolean_predicate",
|
171
|
-
"logical_predicate",
|
172
|
-
"value",
|
173
|
-
"scalar",
|
174
|
-
"variable",
|
175
|
-
"string",
|
176
|
-
"literal" ]
|
177
|
-
|
178
|
-
Racc_debug_parser = false
|
179
|
-
|
180
|
-
##### State transition tables end #####
|
181
|
-
|
182
|
-
# reduce 0 omitted
|
183
|
-
|
184
|
-
# reduce 1 omitted
|
185
|
-
|
186
|
-
# reduce 2 omitted
|
187
|
-
|
188
|
-
# reduce 3 omitted
|
189
|
-
|
190
|
-
module_eval(<<'.,.,', 'parser.y', 13)
|
191
|
-
def _reduce_4(val, _values)
|
192
|
-
Predicator::Predicates::Between.new val[0], val[2], val[4]
|
193
|
-
end
|
194
|
-
.,.,
|
195
|
-
|
196
|
-
# reduce 5 omitted
|
197
|
-
|
198
|
-
module_eval(<<'.,.,', 'parser.y', 17)
|
199
|
-
def _reduce_6(val, _values)
|
200
|
-
Predicator::Predicates::Equal.new val[0], val[2]
|
201
|
-
end
|
202
|
-
.,.,
|
203
|
-
|
204
|
-
module_eval(<<'.,.,', 'parser.y', 18)
|
205
|
-
def _reduce_7(val, _values)
|
206
|
-
Predicator::Predicates::GreaterThan.new val[0], val[2]
|
207
|
-
end
|
208
|
-
.,.,
|
209
|
-
|
210
|
-
module_eval(<<'.,.,', 'parser.y', 19)
|
211
|
-
def _reduce_8(val, _values)
|
212
|
-
Predicator::Predicates::LessThan.new val[0], val[2]
|
213
|
-
end
|
214
|
-
.,.,
|
215
|
-
|
216
|
-
module_eval(<<'.,.,', 'parser.y', 20)
|
217
|
-
def _reduce_9(val, _values)
|
218
|
-
Predicator::Predicates::GreaterThanOrEqual.new val[0], val[2]
|
219
|
-
end
|
220
|
-
.,.,
|
221
|
-
|
222
|
-
module_eval(<<'.,.,', 'parser.y', 21)
|
223
|
-
def _reduce_10(val, _values)
|
224
|
-
Predicator::Predicates::LessThanOrEqual.new val[0], val[2]
|
225
|
-
end
|
226
|
-
.,.,
|
227
|
-
|
228
|
-
module_eval(<<'.,.,', 'parser.y', 22)
|
229
|
-
def _reduce_11(val, _values)
|
230
|
-
Predicator::Predicates::NotEqual.new val[0], val[2]
|
231
|
-
end
|
232
|
-
.,.,
|
233
|
-
|
234
|
-
module_eval(<<'.,.,', 'parser.y', 25)
|
235
|
-
def _reduce_12(val, _values)
|
236
|
-
Predicator::Predicates::True.new
|
237
|
-
end
|
238
|
-
.,.,
|
239
|
-
|
240
|
-
module_eval(<<'.,.,', 'parser.y', 26)
|
241
|
-
def _reduce_13(val, _values)
|
242
|
-
Predicator::Predicates::False.new
|
243
|
-
end
|
244
|
-
.,.,
|
245
|
-
|
246
|
-
module_eval(<<'.,.,', 'parser.y', 29)
|
247
|
-
def _reduce_14(val, _values)
|
248
|
-
Predicator::Predicates::And.new [val[0], val[2]]
|
249
|
-
end
|
250
|
-
.,.,
|
251
|
-
|
252
|
-
module_eval(<<'.,.,', 'parser.y', 30)
|
253
|
-
def _reduce_15(val, _values)
|
254
|
-
Predicator::Predicates::Or.new [val[0], val[2]]
|
255
|
-
end
|
256
|
-
.,.,
|
257
|
-
|
258
|
-
module_eval(<<'.,.,', 'parser.y', 31)
|
259
|
-
def _reduce_16(val, _values)
|
260
|
-
Predicator::Predicates::Not.new val[0]
|
261
|
-
end
|
262
|
-
.,.,
|
263
|
-
|
264
|
-
# reduce 17 omitted
|
265
|
-
|
266
|
-
# reduce 18 omitted
|
267
|
-
|
268
|
-
# reduce 19 omitted
|
269
|
-
|
270
|
-
# reduce 20 omitted
|
271
|
-
|
272
|
-
module_eval(<<'.,.,', 'parser.y', 42)
|
273
|
-
def _reduce_21(val, _values)
|
274
|
-
val[0]
|
275
|
-
end
|
276
|
-
.,.,
|
277
|
-
|
278
|
-
module_eval(<<'.,.,', 'parser.y', 45)
|
279
|
-
def _reduce_22(val, _values)
|
280
|
-
val[0].to_f
|
281
|
-
end
|
282
|
-
.,.,
|
283
|
-
|
284
|
-
module_eval(<<'.,.,', 'parser.y', 46)
|
285
|
-
def _reduce_23(val, _values)
|
286
|
-
val[0].to_i
|
287
|
-
end
|
288
|
-
.,.,
|
289
|
-
|
290
|
-
module_eval(<<'.,.,', 'parser.y', 47)
|
291
|
-
def _reduce_24(val, _values)
|
292
|
-
Date.new *val[0]
|
293
|
-
end
|
294
|
-
.,.,
|
295
|
-
|
296
|
-
module_eval(<<'.,.,', 'parser.y', 50)
|
297
|
-
def _reduce_25(val, _values)
|
298
|
-
Predicator::Variable.new val[0], val[2]
|
299
|
-
end
|
300
|
-
.,.,
|
301
|
-
|
302
|
-
def _reduce_none(val, _values)
|
303
|
-
val[0]
|
304
|
-
end
|
305
|
-
|
306
|
-
end # class GeneratedParser
|
307
|
-
end # module Predicator
|