keisan 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +6 -0
  5. data/Gemfile +4 -0
  6. data/MIT-LICENSE +19 -0
  7. data/README.md +188 -0
  8. data/Rakefile +6 -0
  9. data/bin/console +10 -0
  10. data/bin/setup +8 -0
  11. data/keisan.gemspec +31 -0
  12. data/lib/keisan.rb +118 -0
  13. data/lib/keisan/ast/arithmetic_operator.rb +9 -0
  14. data/lib/keisan/ast/bitwise_and.rb +21 -0
  15. data/lib/keisan/ast/bitwise_operator.rb +9 -0
  16. data/lib/keisan/ast/bitwise_or.rb +21 -0
  17. data/lib/keisan/ast/bitwise_xor.rb +21 -0
  18. data/lib/keisan/ast/boolean.rb +15 -0
  19. data/lib/keisan/ast/builder.rb +141 -0
  20. data/lib/keisan/ast/exponent.rb +25 -0
  21. data/lib/keisan/ast/function.rb +19 -0
  22. data/lib/keisan/ast/indexing.rb +16 -0
  23. data/lib/keisan/ast/list.rb +10 -0
  24. data/lib/keisan/ast/literal.rb +6 -0
  25. data/lib/keisan/ast/logical_and.rb +21 -0
  26. data/lib/keisan/ast/logical_greater_than.rb +17 -0
  27. data/lib/keisan/ast/logical_greater_than_or_equal_to.rb +17 -0
  28. data/lib/keisan/ast/logical_less_than.rb +17 -0
  29. data/lib/keisan/ast/logical_less_than_or_equal_to.rb +17 -0
  30. data/lib/keisan/ast/logical_operator.rb +9 -0
  31. data/lib/keisan/ast/logical_or.rb +21 -0
  32. data/lib/keisan/ast/node.rb +9 -0
  33. data/lib/keisan/ast/null.rb +12 -0
  34. data/lib/keisan/ast/number.rb +15 -0
  35. data/lib/keisan/ast/operator.rb +50 -0
  36. data/lib/keisan/ast/parent.rb +15 -0
  37. data/lib/keisan/ast/plus.rb +49 -0
  38. data/lib/keisan/ast/string.rb +15 -0
  39. data/lib/keisan/ast/times.rb +36 -0
  40. data/lib/keisan/ast/unary_bitwise_not.rb +9 -0
  41. data/lib/keisan/ast/unary_identity.rb +9 -0
  42. data/lib/keisan/ast/unary_inverse.rb +9 -0
  43. data/lib/keisan/ast/unary_logical_not.rb +9 -0
  44. data/lib/keisan/ast/unary_minus.rb +9 -0
  45. data/lib/keisan/ast/unary_operator.rb +13 -0
  46. data/lib/keisan/ast/unary_plus.rb +9 -0
  47. data/lib/keisan/ast/variable.rb +16 -0
  48. data/lib/keisan/calculator.rb +30 -0
  49. data/lib/keisan/context.rb +36 -0
  50. data/lib/keisan/exceptions.rb +19 -0
  51. data/lib/keisan/function.rb +15 -0
  52. data/lib/keisan/functions/default_registry.rb +58 -0
  53. data/lib/keisan/functions/rand.rb +22 -0
  54. data/lib/keisan/functions/registry.rb +50 -0
  55. data/lib/keisan/functions/sample.rb +20 -0
  56. data/lib/keisan/parser.rb +211 -0
  57. data/lib/keisan/parsing/argument.rb +6 -0
  58. data/lib/keisan/parsing/arithmetic_operator.rb +6 -0
  59. data/lib/keisan/parsing/bitwise_and.rb +9 -0
  60. data/lib/keisan/parsing/bitwise_not.rb +9 -0
  61. data/lib/keisan/parsing/bitwise_not_not.rb +9 -0
  62. data/lib/keisan/parsing/bitwise_operator.rb +6 -0
  63. data/lib/keisan/parsing/bitwise_or.rb +9 -0
  64. data/lib/keisan/parsing/bitwise_xor.rb +9 -0
  65. data/lib/keisan/parsing/boolean.rb +11 -0
  66. data/lib/keisan/parsing/component.rb +6 -0
  67. data/lib/keisan/parsing/divide.rb +9 -0
  68. data/lib/keisan/parsing/element.rb +6 -0
  69. data/lib/keisan/parsing/exponent.rb +9 -0
  70. data/lib/keisan/parsing/function.rb +12 -0
  71. data/lib/keisan/parsing/group.rb +11 -0
  72. data/lib/keisan/parsing/indexing.rb +14 -0
  73. data/lib/keisan/parsing/list.rb +10 -0
  74. data/lib/keisan/parsing/logical_and.rb +9 -0
  75. data/lib/keisan/parsing/logical_greater_than.rb +9 -0
  76. data/lib/keisan/parsing/logical_greater_than_or_equal_to.rb +9 -0
  77. data/lib/keisan/parsing/logical_less_than.rb +9 -0
  78. data/lib/keisan/parsing/logical_less_than_or_equal_to.rb +9 -0
  79. data/lib/keisan/parsing/logical_not.rb +9 -0
  80. data/lib/keisan/parsing/logical_not_not.rb +9 -0
  81. data/lib/keisan/parsing/logical_operator.rb +6 -0
  82. data/lib/keisan/parsing/logical_or.rb +9 -0
  83. data/lib/keisan/parsing/minus.rb +9 -0
  84. data/lib/keisan/parsing/null.rb +6 -0
  85. data/lib/keisan/parsing/number.rb +10 -0
  86. data/lib/keisan/parsing/operator.rb +13 -0
  87. data/lib/keisan/parsing/plus.rb +9 -0
  88. data/lib/keisan/parsing/round_group.rb +6 -0
  89. data/lib/keisan/parsing/square_group.rb +6 -0
  90. data/lib/keisan/parsing/string.rb +10 -0
  91. data/lib/keisan/parsing/times.rb +9 -0
  92. data/lib/keisan/parsing/unary_minus.rb +9 -0
  93. data/lib/keisan/parsing/unary_operator.rb +9 -0
  94. data/lib/keisan/parsing/unary_plus.rb +9 -0
  95. data/lib/keisan/parsing/variable.rb +11 -0
  96. data/lib/keisan/token.rb +25 -0
  97. data/lib/keisan/tokenizer.rb +41 -0
  98. data/lib/keisan/tokens/arithmetic_operator.rb +29 -0
  99. data/lib/keisan/tokens/bitwise_operator.rb +29 -0
  100. data/lib/keisan/tokens/boolean.rb +20 -0
  101. data/lib/keisan/tokens/comma.rb +11 -0
  102. data/lib/keisan/tokens/group.rb +28 -0
  103. data/lib/keisan/tokens/logical_operator.rb +38 -0
  104. data/lib/keisan/tokens/null.rb +15 -0
  105. data/lib/keisan/tokens/number.rb +24 -0
  106. data/lib/keisan/tokens/operator.rb +9 -0
  107. data/lib/keisan/tokens/string.rb +15 -0
  108. data/lib/keisan/tokens/word.rb +11 -0
  109. data/lib/keisan/variables/default_registry.rb +20 -0
  110. data/lib/keisan/variables/registry.rb +41 -0
  111. data/lib/keisan/version.rb +3 -0
  112. metadata +238 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5118e044fef1a400782707bed4cff70265f601ed
4
+ data.tar.gz: 54db3071552f280ed42f2b86e714ebb1b8a356da
5
+ SHA512:
6
+ metadata.gz: 1219fa0069d41b5b5295320d82ebb5ec82a9c11c01b94eae5adfafa932cc603db4185fcd47676bb36b45716a276436b8a71ec8aa175d0de2b2058f2b816440eb
7
+ data.tar.gz: aad7604a738e66b385c40dd3cf78a6d2a8c28ebeb8c35e206f35d81d5ae8aed3d8256de70dfd34ff47161d53ef671f1380631588adb20c65086739953d34d8d2
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,6 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ - 2.4.1
6
+ before_install: gem install bundler -v 1.14.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in keisan.gemspec
4
+ gemspec
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2017 Christopher Barry Locke
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,188 @@
1
+ # Keisan
2
+
3
+ [![Build Status](https://travis-ci.org/project-eutopia/keisan.png?branch=master)](https://travis-ci.org/project-eutopia/keisan)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![Hakiri](https://hakiri.io/github/project-eutopia/keisan/master.svg)](https://hakiri.io/github/project-eutopia/keisan)
6
+
7
+ Keisan ([計算, to calculate](https://en.wiktionary.org/wiki/%E8%A8%88%E7%AE%97#Japanese)) is a Ruby library for parsing equations into an abstract syntax tree. This allows for safe evaluation of string representations of mathematical/logical expressions.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'keisan'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install keisan
24
+
25
+ ## Usage
26
+
27
+ ### Calculator class
28
+
29
+ The functionality of `keisan` can be demonstrated by using the `Keisan::Calculator` class. The `evaluate` method evaluates an expression by parsing it into an abstract syntax tree (AST), then evaluating any member functions/variables given.
30
+
31
+ ```ruby
32
+ calculator = Keisan::Calculator.new
33
+ calculator.evaluate("15 + 2 * (1 + 3)")
34
+ #=> 23
35
+ ```
36
+
37
+ ##### Specifying variables
38
+
39
+ Passing in a hash of variable (`name`, `value`) pairs to the `evaluate` method defines variables
40
+
41
+ ```ruby
42
+ calculator.evaluate("3*x + y**2", x: -2.5, y: 3)
43
+ #=> 1.5
44
+ ```
45
+
46
+ It will raise an error if an variable is not defined
47
+
48
+ ```ruby
49
+ calculator.evaluate("x + 1")
50
+ #=> Keisan::Exceptions::UndefinedVariableError: x
51
+ ```
52
+
53
+ ##### Specifying functions
54
+
55
+ Just like variables, functions can be defined by passing a `Proc` object as follows
56
+
57
+ ```ruby
58
+ calculator.evaluate("2*f(1+2) + 4", f: Proc.new {|x| x**2})
59
+ #=> 22
60
+ ```
61
+
62
+ It will raise an error if a function is not defined
63
+
64
+ ```ruby
65
+ calculator.evaluate("f(2) + 1")
66
+ #=> Keisan::Exceptions::UndefinedFunctionError: f
67
+ ```
68
+
69
+ ##### Lists
70
+
71
+ Just like in Ruby, lists can be defined using square brackets, and indexed using square brackets
72
+
73
+ ```ruby
74
+ calculator.evaluate("[2, 3, 5, 8]")
75
+ #=> [2, 3, 5, 8]
76
+ calculator.evaluate("[[1,2,3],[4,5,6],[7,8,9]][1][2]")
77
+ #=> 6
78
+ ```
79
+
80
+ They can also be concatenated using the `+` operator
81
+
82
+ ```ruby
83
+ calculator.evaluate("[3, 5] + [x, x+1]", x: 10)
84
+ #=> [3, 5, 10, 11]
85
+ ```
86
+
87
+ ##### Logical operations
88
+
89
+ `keisan` understands basic boolean logic operators, like `<`, `<=`, `>`, `>=`, `&&`, `||`, `!`, so calculations like the following are possible
90
+
91
+ ```ruby
92
+ calculator.evaluate("1 > 0")
93
+ #=> true
94
+ calculator.evaluate("!!!true")
95
+ #=> false
96
+ calculator.evaluate("x >= 0 && x < 10", x: 5)
97
+ #=> true
98
+ ```
99
+
100
+ There is also a useful ternary `if` function defined
101
+
102
+ ```ruby
103
+ calculator.evaluate("2 + if(1 > 0, 10, 29)")
104
+ #=> 12
105
+ ```
106
+
107
+ ##### Bitwise operations
108
+
109
+ The basic bitwise operations, NOT `~`, OR `|`, XOR `^`, and AND `&` are also available for use
110
+
111
+ ```ruby
112
+ calculator.evaluate("2 + 12 & 7")
113
+ #=> 6
114
+ ```
115
+
116
+ ##### String
117
+
118
+ `keisan` also can parse in strings, and access the characters by index
119
+
120
+ ```ruby
121
+ calculator.evaluate("'hello'[1]")
122
+ #=> "e"
123
+ ```
124
+
125
+ ##### Builtin variables and functions
126
+
127
+ `keisan` includes all standard methods given by the Ruby `Math` class.
128
+
129
+ ```ruby
130
+ calculator.evaluate("log10(1000)")
131
+ #=> 3.0
132
+ ```
133
+
134
+ Furthermore, the following builtin constants are defined
135
+
136
+ ```ruby
137
+ calculator.evaluate("pi")
138
+ #=> 3.141592653589793
139
+ calculator.evaluate("e")
140
+ #=> 2.718281828459045
141
+ calculator.evaluate("i")
142
+ #=> (0+1i)
143
+ ```
144
+
145
+ This allows for simple calculations like
146
+
147
+ ```ruby
148
+ calculator.evaluate("e**(i*pi)+1")
149
+ => (0.0+0.0i)
150
+ ```
151
+
152
+ ### Adding custom variables and functions
153
+
154
+ The `Keisan::Calculator` class has a single `Keisan::Context` object in its `context` attribute. This class is used to store local variables and functions. As an example of pre-defining some variables and functions, see the following
155
+
156
+ ```ruby
157
+ calculator.define_variable!("x", 5)
158
+ #=> 5
159
+ calculator.evaluate("x + 1")
160
+ #=> 6
161
+ calculator.evaluate("x + 1", x: 10)
162
+ #=> 11
163
+ calculator.evaluate("x + 1")
164
+ #=> 6
165
+ ```
166
+
167
+ Notice how when passing variable values directly to the `evaluate` method, it only shadows the value of 5 for that specific calculation. The same thing works for functions
168
+
169
+ ```ruby
170
+ calculator.define_function!("f", Proc.new {|x| 3*x})
171
+ #=> #<Keisan::Function:0x005570f935ecc8 @function_proc=#<Proc:0x005570f935ecf0@(pry):6>, @name="f">
172
+ calculator.evaluate("f(2)")
173
+ #=> 6
174
+ calculator.evaluate("f(2)", f: Proc.new {|x| 10*x})
175
+ #=> 20
176
+ calculator.evaluate("f(2)")
177
+ #=> 6
178
+ ```
179
+
180
+ ## Development
181
+
182
+ After checking out the repository, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
183
+
184
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
185
+
186
+ ## Contributing
187
+
188
+ Bug reports and pull requests are welcome on GitHub at https://github.com/project-eutopia/keisan. If there is any functionality you would like (e.g. new functions), feel free to open a [new issue](https://github.com/project-eutopia/keisan/issues/new).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "keisan"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ require "pry"
10
+ Pry.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'keisan/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "keisan"
8
+ spec.version = Keisan::VERSION
9
+ spec.authors = ["Christopher Locke"]
10
+ spec.email = ["project.eutopia@gmail.com"]
11
+
12
+ spec.summary = %q{An equation parser and evaluator}
13
+ spec.description = %q{A library for parsing equations into an abstract syntax tree for evaluation}
14
+ spec.homepage = "https://github.com/project-eutopia/keisan"
15
+ spec.licenses = %w(MIT)
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.required_ruby_version = '>= 2.4.0'
23
+
24
+ spec.add_dependency "activesupport", ">= 4.2.2"
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.14"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rspec", "~> 3.0"
29
+ spec.add_development_dependency "pry"
30
+ spec.add_development_dependency "pry-stack_explorer"
31
+ end
@@ -0,0 +1,118 @@
1
+ require "cmath"
2
+ require "active_support"
3
+ require "active_support/core_ext"
4
+
5
+ require "keisan/version"
6
+ require "keisan/exceptions"
7
+
8
+ require "keisan/function"
9
+ require "keisan/functions/registry"
10
+ require "keisan/functions/default_registry"
11
+ require "keisan/variables/registry"
12
+ require "keisan/variables/default_registry"
13
+ require "keisan/context"
14
+
15
+ require "keisan/ast/node"
16
+
17
+ require "keisan/ast/literal"
18
+ require "keisan/ast/number"
19
+ require "keisan/ast/string"
20
+ require "keisan/ast/null"
21
+ require "keisan/ast/boolean"
22
+ require "keisan/ast/variable"
23
+
24
+ require "keisan/ast/parent"
25
+ require "keisan/ast/unary_operator"
26
+ require "keisan/ast/unary_plus"
27
+ require "keisan/ast/unary_minus"
28
+ require "keisan/ast/unary_inverse"
29
+ require "keisan/ast/unary_bitwise_not"
30
+ require "keisan/ast/unary_logical_not"
31
+ require "keisan/ast/unary_identity"
32
+ require "keisan/ast/operator"
33
+ require "keisan/ast/arithmetic_operator"
34
+ require "keisan/ast/plus"
35
+ require "keisan/ast/times"
36
+ require "keisan/ast/exponent"
37
+ require "keisan/ast/function"
38
+ require "keisan/ast/bitwise_operator"
39
+ require "keisan/ast/bitwise_and"
40
+ require "keisan/ast/bitwise_or"
41
+ require "keisan/ast/bitwise_xor"
42
+ require "keisan/ast/logical_operator"
43
+ require "keisan/ast/logical_and"
44
+ require "keisan/ast/logical_or"
45
+ require "keisan/ast/logical_less_than"
46
+ require "keisan/ast/logical_greater_than"
47
+ require "keisan/ast/logical_less_than_or_equal_to"
48
+ require "keisan/ast/logical_greater_than_or_equal_to"
49
+ require "keisan/ast/function"
50
+ require "keisan/ast/list"
51
+ require "keisan/ast/indexing"
52
+
53
+ require "keisan/ast/builder"
54
+
55
+ require "keisan/token"
56
+ require "keisan/tokens/comma"
57
+ require "keisan/tokens/group"
58
+ require "keisan/tokens/number"
59
+ require "keisan/tokens/operator"
60
+ require "keisan/tokens/string"
61
+ require "keisan/tokens/null"
62
+ require "keisan/tokens/boolean"
63
+ require "keisan/tokens/arithmetic_operator"
64
+ require "keisan/tokens/logical_operator"
65
+ require "keisan/tokens/bitwise_operator"
66
+ require "keisan/tokens/word"
67
+
68
+ require "keisan/tokenizer"
69
+
70
+ require "keisan/parsing/component"
71
+
72
+ require "keisan/parsing/element"
73
+ require "keisan/parsing/number"
74
+ require "keisan/parsing/string"
75
+ require "keisan/parsing/null"
76
+ require "keisan/parsing/boolean"
77
+ require "keisan/parsing/variable"
78
+ require "keisan/parsing/function"
79
+ require "keisan/parsing/group"
80
+ require "keisan/parsing/round_group"
81
+ require "keisan/parsing/square_group"
82
+ require "keisan/parsing/list"
83
+ require "keisan/parsing/indexing"
84
+ require "keisan/parsing/argument"
85
+
86
+ require "keisan/parsing/unary_operator"
87
+ require "keisan/parsing/unary_plus"
88
+ require "keisan/parsing/unary_minus"
89
+
90
+ require "keisan/parsing/operator"
91
+ require "keisan/parsing/arithmetic_operator"
92
+ require "keisan/parsing/plus"
93
+ require "keisan/parsing/minus"
94
+ require "keisan/parsing/times"
95
+ require "keisan/parsing/divide"
96
+ require "keisan/parsing/exponent"
97
+ require "keisan/parsing/bitwise_operator"
98
+ require "keisan/parsing/bitwise_and"
99
+ require "keisan/parsing/bitwise_or"
100
+ require "keisan/parsing/bitwise_xor"
101
+ require "keisan/parsing/bitwise_not"
102
+ require "keisan/parsing/bitwise_not_not"
103
+ require "keisan/parsing/logical_operator"
104
+ require "keisan/parsing/logical_less_than"
105
+ require "keisan/parsing/logical_greater_than"
106
+ require "keisan/parsing/logical_less_than_or_equal_to"
107
+ require "keisan/parsing/logical_greater_than_or_equal_to"
108
+ require "keisan/parsing/logical_and"
109
+ require "keisan/parsing/logical_or"
110
+ require "keisan/parsing/logical_not"
111
+ require "keisan/parsing/logical_not_not"
112
+
113
+ require "keisan/parser"
114
+
115
+ require "keisan/calculator"
116
+
117
+ module Keisan
118
+ end
@@ -0,0 +1,9 @@
1
+ module Keisan
2
+ module AST
3
+ class ArithmeticOperator < Operator
4
+ def associativity
5
+ :left
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,21 @@
1
+ module Keisan
2
+ module AST
3
+ class BitwiseAnd < BitwiseOperator
4
+ def self.priority
5
+ 31
6
+ end
7
+
8
+ def arity
9
+ 2..Float::INFINITY
10
+ end
11
+
12
+ def symbol
13
+ :"&"
14
+ end
15
+
16
+ def blank_value
17
+ ~0
18
+ end
19
+ end
20
+ end
21
+ end