bool 1.0.14-java → 1.0.15-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bool.rb +5 -5
- data/lib/bool/ast.rb +23 -10
- data/lib/bool/evaluator.rb +1 -1
- data/lib/bool/renderer.rb +4 -4
- data/lib/bool_ext.jar +0 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5342f4b1b2dc7581b554c8d34f81d1b6a1983ce2
|
4
|
+
data.tar.gz: 6d382073a0589287a004c01a168758d091376511
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c3184884662028e84bed61bf4f46070b8b6165fdbb90f3f37d93416bef0766c90ede6e3000f242ea54d766db8a8912621e9abb8afc7211f1fc4b0d0660483e5
|
7
|
+
data.tar.gz: c784bb5129c6c4143574cfeee2fa1bc56dbb47846225f1f180e3864873e84b83e39fe0130c3cabc6e2c5c5b3bf948911d5970ddb48120fa8454219857261a03b
|
data/lib/bool.rb
CHANGED
@@ -7,11 +7,11 @@ require 'bool/renderer'
|
|
7
7
|
|
8
8
|
module Bool
|
9
9
|
class SyntaxError < StandardError
|
10
|
-
attr_reader :
|
10
|
+
attr_reader :token
|
11
11
|
|
12
|
-
def initialize(message,
|
12
|
+
def initialize(message, token)
|
13
13
|
super(message)
|
14
|
-
@
|
14
|
+
@token = token
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -19,9 +19,9 @@ module Bool
|
|
19
19
|
def parse(source)
|
20
20
|
lexer = Java::Bool::Lexer.new(source)
|
21
21
|
parser = Java::Bool::Parser.new(lexer)
|
22
|
-
parser.
|
22
|
+
parser.buildAst()
|
23
23
|
rescue => e
|
24
|
-
raise SyntaxError.new(e.message, e.
|
24
|
+
raise SyntaxError.new(e.message, e.token)
|
25
25
|
end
|
26
26
|
module_function(:parse)
|
27
27
|
else
|
data/lib/bool/ast.rb
CHANGED
@@ -2,22 +2,33 @@ module Bool
|
|
2
2
|
if RUBY_PLATFORM =~ /java/
|
3
3
|
# AST classes defined in bool_ext.jar
|
4
4
|
else
|
5
|
-
class
|
6
|
-
attr_reader :
|
5
|
+
class Token
|
6
|
+
attr_reader :value, :first_line, :last_line, :first_column, :last_column
|
7
7
|
|
8
|
-
def initialize(
|
9
|
-
@
|
8
|
+
def initialize(value, first_line, last_line, first_column, last_column)
|
9
|
+
@value, @first_line, @last_line, @first_column, @last_column = value, first_line, last_line, first_column, last_column
|
10
10
|
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Node
|
14
|
+
attr_reader :token
|
15
|
+
|
16
|
+
def initialize(token)
|
17
|
+
@token = token
|
18
|
+
end
|
19
|
+
end
|
11
20
|
|
21
|
+
class Var < Node
|
12
22
|
def accept(visitor, arg)
|
13
23
|
visitor.visit_var(self, arg)
|
14
24
|
end
|
15
25
|
end
|
16
26
|
|
17
|
-
class And
|
27
|
+
class And < Node
|
18
28
|
attr_reader :left, :right
|
19
29
|
|
20
|
-
def initialize(left, right)
|
30
|
+
def initialize(token, left, right)
|
31
|
+
super(token)
|
21
32
|
@left, @right = left, right
|
22
33
|
end
|
23
34
|
|
@@ -26,10 +37,11 @@ module Bool
|
|
26
37
|
end
|
27
38
|
end
|
28
39
|
|
29
|
-
class Or
|
40
|
+
class Or < Node
|
30
41
|
attr_reader :left, :right
|
31
42
|
|
32
|
-
def initialize(left, right)
|
43
|
+
def initialize(token, left, right)
|
44
|
+
super(token)
|
33
45
|
@left, @right = left, right
|
34
46
|
end
|
35
47
|
|
@@ -38,10 +50,11 @@ module Bool
|
|
38
50
|
end
|
39
51
|
end
|
40
52
|
|
41
|
-
class Not
|
53
|
+
class Not < Node
|
42
54
|
attr_reader :operand
|
43
55
|
|
44
|
-
def initialize(operand)
|
56
|
+
def initialize(token, operand)
|
57
|
+
super(token)
|
45
58
|
@operand = operand
|
46
59
|
end
|
47
60
|
|
data/lib/bool/evaluator.rb
CHANGED
data/lib/bool/renderer.rb
CHANGED
@@ -9,19 +9,19 @@ module Bool
|
|
9
9
|
|
10
10
|
else
|
11
11
|
def visit_var(node, vars)
|
12
|
-
node.
|
12
|
+
node.token.value
|
13
13
|
end
|
14
14
|
|
15
15
|
def visit_and(node, vars)
|
16
|
-
"(
|
16
|
+
"(#{render(node.left)} #{node.token.value} #{render(node.right)})"
|
17
17
|
end
|
18
18
|
|
19
19
|
def visit_or(node, vars)
|
20
|
-
"(
|
20
|
+
"(#{render(node.left)} #{node.token.value} #{render(node.right)})"
|
21
21
|
end
|
22
22
|
|
23
23
|
def visit_not(node, vars)
|
24
|
-
"
|
24
|
+
"#{node.token.value}#{render(node.operand)}"
|
25
25
|
end
|
26
26
|
|
27
27
|
private
|
data/lib/bool_ext.jar
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.15
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Aslak Hellesøy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
68
|
version: '0'
|
69
69
|
requirements: []
|
70
70
|
rubyforge_project:
|
71
|
-
rubygems_version: 2.0.0
|
71
|
+
rubygems_version: 2.0.0
|
72
72
|
signing_key:
|
73
73
|
specification_version: 4
|
74
74
|
summary: Boolean expression evaluator
|