basic_math_parser 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 18307c524b4545e94035783d72ecc7e0b08341c0d8ff9b168892a8b2c27cea06
4
- data.tar.gz: 83ae85573f2cc5e8857714cdb91002ce9edcfde78291344e86331cdf5a587c25
3
+ metadata.gz: 85a86b2cf7041356eb22499e68b700a775e93c823b9ef407aae8cb2d280f711e
4
+ data.tar.gz: 2cd56f0f2fe0fc347f5d36f7dd772900f4ac9f07c6e5182bf976142ec96957d3
5
5
  SHA512:
6
- metadata.gz: 6eefaeb1d946fae1da4fefe1b4e2e9803e992dd7bca0a5c666bac8f5b9fd6bcf5a190aeff4495c510adeaf5ec56addea9d738cfbcfd237fa371bef3ccc2e5995
7
- data.tar.gz: 2f6c00c0d59411b1e80e30efc8230e90fa051441a44a487e52f61a069616dbff9eb61b614a4798f6197d1ce2e731f96f09c5c8e453d2a0640fa2f617f54d5943
6
+ metadata.gz: ffe283c33e0ca2baf8aaf78d455b0c33d8ae8f6e3daa2a5ce69de01a67167ac0197cf0ef564a24459066cbb70b296e2700c94f353fcb57135ec358c2fab842b6
7
+ data.tar.gz: 59e467fb49cf8e2a8ceaba4695685b206d9e389a7c8a8ab81ce45ef19571db104159df9145056643f155ca6d8632dd9f6e28f43301417483d2266fc5dc57e32a
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # BasicMathParser
2
2
 
3
- BasicMathParser is an simple expression parser bulit based on the postfix expression parsing.
3
+ BasicMathParser is an simple expression parser built based on the postfix expression parsing.
4
4
 
5
5
  ## Installation
6
6
 
@@ -12,12 +12,23 @@ If bundler is not being used to manage dependencies, install the gem by executin
12
12
 
13
13
  $ gem install basic_math_parser
14
14
 
15
- ## Example
15
+ ## Examples
16
16
 
17
- To parse an expression:
17
+ To parse an expression:
18
+ ```
19
+ BasicMathParser.evaluate("3+5")
20
+ # => 8.0
21
+ ```
22
+ BasicMathParser will support Order precedence and use of parentheses to group expressions, by this Proper evaluation is ensured.
23
+ ```
24
+ BasicMathParser.evaluate("(10 + 5) / 5")
25
+ # => 3.0
18
26
 
19
- BasicMathParser.evaluate("3+5")
20
- => 8.0
27
+ BasicMathParser.evaluate("10 + 5 / 5")
28
+ # => 11.0
29
+ ```
30
+
31
+ **Supported operations:** `+`, `-`, `/`, `*`, `%`, `^`, `(` , `)`
21
32
 
22
33
  ## Development
23
34
 
@@ -7,14 +7,12 @@ Gem::Specification.new do |spec|
7
7
  spec.version = BasicMathParser::VERSION
8
8
  spec.authors = ["srkrishna412"]
9
9
  spec.email = ["srkrishna412@gmail.com"]
10
-
10
+ spec.licenses = ['AGPLv3']
11
11
  spec.summary = "Evalute a basic arithmetic expression"
12
- spec.description = "Evalute a basic arithmetic expression"
12
+ spec.description = "Evalute a basic arithmetic expression using postfix parsing approach."
13
13
  spec.homepage = "https://gitlab.com/srkrishna/basic_math_parser"
14
14
  spec.required_ruby_version = ">= 2.6.0"
15
15
 
16
- # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
17
-
18
16
  spec.metadata["homepage_uri"] = spec.homepage
19
17
  spec.metadata["source_code_uri"] = "https://gitlab.com/srkrishna/basic_math_parser"
20
18
  spec.metadata["changelog_uri"] = "https://gitlab.com/srkrishna/basic_math_parser/-/blob/main/CHANGELOG.md"
@@ -4,7 +4,7 @@ class Tokenizer
4
4
  RULES = {
5
5
  /\d+\.\d+|\d+|\.\d+/ => :number,
6
6
  /[\/+\-*^%\()]/ => :op,
7
- /\d+[a-zA-z]+|[a-zA-z]+\d+|[a-zA-z]+/ => :variable
7
+ /\d+[a-zA-z]+|[a-zA-z]+\d+|[a-zA-z]+|[`~^$#@!<>=_-]+/ => :variable,
8
8
  }
9
9
 
10
10
  def initialize
@@ -29,7 +29,7 @@ class Tokenizer
29
29
  def find_token(regex, type)
30
30
  token = @buffer.scan(regex)
31
31
 
32
- raise BasicMathParser::ParseError.for('variable are not unsupported', info: {variable: token} ) if token && type == :variable
32
+ raise BasicMathParser::ParseError.for('Expression contains unsupported Symbol/character!', info: {variable: token} ) if token && type == :variable
33
33
 
34
34
  @tokens << Token.new(type, token) if token
35
35
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BasicMathParser
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: basic_math_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - srkrishna412
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-16 00:00:00.000000000 Z
11
+ date: 2022-06-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Evalute a basic arithmetic expression
13
+ description: Evalute a basic arithmetic expression using postfix parsing approach.
14
14
  email:
15
15
  - srkrishna412@gmail.com
16
16
  executables: []
@@ -36,7 +36,8 @@ files:
36
36
  - lib/basic_math_parser/version.rb
37
37
  - sig/basic_math_parser.rbs
38
38
  homepage: https://gitlab.com/srkrishna/basic_math_parser
39
- licenses: []
39
+ licenses:
40
+ - AGPLv3
40
41
  metadata:
41
42
  homepage_uri: https://gitlab.com/srkrishna/basic_math_parser
42
43
  source_code_uri: https://gitlab.com/srkrishna/basic_math_parser