bool 1.0.14-x86-mingw32 → 1.0.15-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f365bbde23267a870cb7f05c696787293a88b96
4
- data.tar.gz: 940ab326bdcb11bef45de6d42be4d1bc011d3699
3
+ metadata.gz: 2df0ea05c2e275a61f5341860764c7e9387d18d2
4
+ data.tar.gz: fb5c0739fb9e9c92efc563f812426f6b77f7bdef
5
5
  SHA512:
6
- metadata.gz: 4f2a9b8f313932c408b8ee20d89f788bd87dc703d49fbe7b0fe74333e567ed64fad26e153e255c992ebc8a414a0977558399f1fa826a8dfa02750e351244403a
7
- data.tar.gz: 17499c9ce63ebf61498da90b1d34b8c8c17e3a1a69ab628dd6aa127400a88fee7fe907052290dceb1c0ae637f8f52d2ec9911dd3175c9e7df604a881483c708b
6
+ metadata.gz: 259fb206d764d09eddec8db7d6fd23c5c76d038ad4cdd5a6ca714650cb1d6d01389fa7f67a5beb41f023b4f4e2daa991c2956cc89c4a6a5ab979ee4f3f664737
7
+ data.tar.gz: 385849b9ce8af844d542299f172618c4a13729c2dc4580564f33c031bce1316b5bac0e03f7a6424216e7356d8c23e19983889f9781ab6faf7efc4ea5c2dcdce0
@@ -7,11 +7,11 @@ require 'bool/renderer'
7
7
 
8
8
  module Bool
9
9
  class SyntaxError < StandardError
10
- attr_reader :first_line, :last_line, :first_column, :last_column
10
+ attr_reader :token
11
11
 
12
- def initialize(message, first_line, last_line, first_column, last_column)
12
+ def initialize(message, token)
13
13
  super(message)
14
- @first_line, @last_line, @first_column, @last_column = first_line, last_line, first_column, last_column
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.parseExpr()
22
+ parser.buildAst()
23
23
  rescue => e
24
- raise SyntaxError.new(e.message, e.line, e.line, e.column, e.column)
24
+ raise SyntaxError.new(e.message, e.token)
25
25
  end
26
26
  module_function(:parse)
27
27
  else
@@ -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 Var
6
- attr_reader :name
5
+ class Token
6
+ attr_reader :value, :first_line, :last_line, :first_column, :last_column
7
7
 
8
- def initialize(name)
9
- @name = name
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
 
@@ -9,7 +9,7 @@ module Bool
9
9
 
10
10
  else
11
11
  def visit_var(node, vars)
12
- !!vars.index(node.name)
12
+ !!vars.index(node.token.value)
13
13
  end
14
14
 
15
15
  def visit_and(node, vars)
@@ -9,19 +9,19 @@ module Bool
9
9
 
10
10
  else
11
11
  def visit_var(node, vars)
12
- node.name
12
+ node.token.value
13
13
  end
14
14
 
15
15
  def visit_and(node, vars)
16
- "(" + render(node.left) + " && " + render(node.right) + ")"
16
+ "(#{render(node.left)} #{node.token.value} #{render(node.right)})"
17
17
  end
18
18
 
19
19
  def visit_or(node, vars)
20
- "(" + render(node.left) + " || " + render(node.right) + ")"
20
+ "(#{render(node.left)} #{node.token.value} #{render(node.right)})"
21
21
  end
22
22
 
23
23
  def visit_not(node, vars)
24
- "!" + render(node.operand)
24
+ "#{node.token.value}#{render(node.operand)}"
25
25
  end
26
26
 
27
27
  private
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.14
4
+ version: 1.0.15
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - Aslak Hellesøy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-16 00:00:00.000000000 Z
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.rc.2
71
+ rubygems_version: 2.0.0
72
72
  signing_key:
73
73
  specification_version: 4
74
74
  summary: Boolean expression evaluator