kalculator 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kalculator/evaluator.rb +8 -0
- data/lib/kalculator/lexer.rb +2 -0
- data/lib/kalculator/parser.rb +4 -1
- data/lib/kalculator/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4fd757c1bc075fe247ba612bf8e3670d6fc03711c332fa297d881513deda678
|
4
|
+
data.tar.gz: 1a6a5a2d27345d274d8559ea2b0c8a3cc3551db9012da35123f3ad0ce140c22d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28573ad987c775b85a49c31cd74d2bd13b7344c66f8c7d937d1db80a286fd6d3c9ecbb149ef50d7ffc44ce0e4bf516b3f1f935c0edf0e7c4b1b773061a4e7dd1
|
7
|
+
data.tar.gz: d34ab516d686fcb3428e901625c07b00cd30bd9d67eb43d124b44358e04cc2a3de1abb0dd2adfd89eb9bfcec7f0870227fc5fe28717d07cdaca0b599fc7df36d
|
data/lib/kalculator/evaluator.rb
CHANGED
@@ -44,6 +44,14 @@ class Kalculator
|
|
44
44
|
evaluate(left) == evaluate(right)
|
45
45
|
end
|
46
46
|
|
47
|
+
def and(_, left, right)
|
48
|
+
evaluate(left) && evaluate(right)
|
49
|
+
end
|
50
|
+
|
51
|
+
def or(_, left, right)
|
52
|
+
evaluate(left) || evaluate(right)
|
53
|
+
end
|
54
|
+
|
47
55
|
def boolean(_, boolean)
|
48
56
|
boolean
|
49
57
|
end
|
data/lib/kalculator/lexer.rb
CHANGED
data/lib/kalculator/parser.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Kalculator
|
2
2
|
class Parser < RLTK::Parser
|
3
|
-
|
3
|
+
left :AND, :OR
|
4
4
|
left :GT, :GTE, :LT, :LTE, :EQ
|
5
5
|
left :PLUS, :SUB
|
6
6
|
left :MUL, :DIV
|
@@ -30,6 +30,9 @@ class Kalculator
|
|
30
30
|
clause('expression LTE expression') { |e0, _, e1| [:<=, e0, e1] }
|
31
31
|
clause('expression EQ expression') { |e0, _, e1| [:==, e0, e1] }
|
32
32
|
|
33
|
+
clause('expression AND expression') { |e0, _, e1| [:and, e0, e1] }
|
34
|
+
clause('expression OR expression') { |e0, _, e1| [:or, e0, e1] }
|
35
|
+
|
33
36
|
clause('expression PLUS expression') { |e0, _, e1| [:+, e0, e1] }
|
34
37
|
clause('expression SUB expression') { |e0, _, e1| [:-, e0, e1] }
|
35
38
|
clause('expression MUL expression') { |e0, _, e1| [:*, e0, e1] }
|
data/lib/kalculator/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kalculator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Ries
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rltk
|