math_engine 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,6 +12,10 @@ class MathEngine
12
12
  def expression(node)
13
13
  node.left.evaluate(self)
14
14
  end
15
+
16
+ def parenthesised_expression(node)
17
+ expression(node)
18
+ end
15
19
 
16
20
  def identifier(node)
17
21
  @context.get node.value
@@ -22,6 +22,7 @@ class MathEngine
22
22
 
23
23
  class LiteralNumberNode < Node ; end
24
24
  class ExpressionNode < Node ; end
25
+ class ParenthesisedExpressionNode < Node ; end
25
26
  class IdentifierNode < Node ; end
26
27
  class AssignmentNode < Node ; end
27
28
 
@@ -82,7 +82,7 @@ class MathEngine
82
82
 
83
83
  expect_current :open_parenthesis, "number, variable or open_parenthesis"
84
84
  next!
85
- result = expression
85
+ result = MathEngine::ParenthesisedExpressionNode.new(expression)
86
86
  expect_current :close_parenthesis
87
87
  next!
88
88
  result
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: math_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-10 00:00:00.000000000 Z
12
+ date: 2012-11-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: lexr
@@ -51,13 +51,13 @@ extra_rdoc_files:
51
51
  - README.md
52
52
  files:
53
53
  - README.md
54
+ - lib/nodes.rb
55
+ - lib/lexer.rb
54
56
  - lib/context.rb
55
57
  - lib/errors.rb
56
- - lib/evaluators/calculate.rb
57
- - lib/evaluators/finders.rb
58
- - lib/lexer.rb
59
58
  - lib/math_engine.rb
60
- - lib/nodes.rb
59
+ - lib/evaluators/finders.rb
60
+ - lib/evaluators/calculate.rb
61
61
  - lib/parser.rb
62
62
  homepage: http://www.brightbits.co.uk
63
63
  licenses: []
@@ -75,7 +75,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
75
75
  version: '0'
76
76
  segments:
77
77
  - 0
78
- hash: 2720302256799733350
78
+ hash: -1839538838728425454
79
79
  required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  none: false
81
81
  requirements: