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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3cb0411bb21bb99550cde9115cb53218b956d7fa107779b8e318446114fa6f3e
4
- data.tar.gz: 1aad75a31f459f8a6b3c2390b073ff507c27d5ec56b5bf017d91c5f14ff41bce
3
+ metadata.gz: a4fd757c1bc075fe247ba612bf8e3670d6fc03711c332fa297d881513deda678
4
+ data.tar.gz: 1a6a5a2d27345d274d8559ea2b0c8a3cc3551db9012da35123f3ad0ce140c22d
5
5
  SHA512:
6
- metadata.gz: b25b44e6d18de63b49db47effbf77661d1ae1556e5b61745be03bd3a813bda3afe7218815af54132ac59ffee4e32314d6bdb7ff993ca4255da7b713ac64633cd
7
- data.tar.gz: dbede4204b904eb0f9969da284facdc0b91827878e87430dfa10d45bccc3e7a9fa373fa78cf26d63c7d6f96f38f604d074dbc622fb5fe01ca19b5bc08d881733
6
+ metadata.gz: 28573ad987c775b85a49c31cd74d2bd13b7344c66f8c7d937d1db80a286fd6d3c9ecbb149ef50d7ffc44ce0e4bf516b3f1f935c0edf0e7c4b1b773061a4e7dd1
7
+ data.tar.gz: d34ab516d686fcb3428e901625c07b00cd30bd9d67eb43d124b44358e04cc2a3de1abb0dd2adfd89eb9bfcec7f0870227fc5fe28717d07cdaca0b599fc7df36d
@@ -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
@@ -13,6 +13,8 @@ class Kalculator
13
13
  rule(/</) { :LT }
14
14
  rule(/<=/) { :LTE }
15
15
  rule(/==/) { :EQ }
16
+ rule(/AND/) { :AND }
17
+ rule(/OR/) { :OR }
16
18
  rule(/\d+/) { |t| [:NUMBER, t.to_i] }
17
19
  rule(/\.\d+/) { |t| [:NUMBER, t.to_f] }
18
20
  rule(/\d+\.\d+/) { |t| [:NUMBER, t.to_f] }
@@ -1,6 +1,6 @@
1
1
  class Kalculator
2
2
  class Parser < RLTK::Parser
3
- #Left 200 '&&' '||'.
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] }
@@ -1,3 +1,3 @@
1
1
  class Kalculator
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
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.0
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-14 00:00:00.000000000 Z
11
+ date: 2018-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rltk