eqn 1.6.1 → 1.6.2

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
  SHA1:
3
- metadata.gz: a04c182e84dafb070744df14445241b94a232e0a
4
- data.tar.gz: 124f04f06e496e94e589a766f18cef67c5f2ed13
3
+ metadata.gz: 7a298576c822eca16cdaf7281ec1344ea37f19a4
4
+ data.tar.gz: 3408ed487ad7cae4ff268559d1e71bf769221d90
5
5
  SHA512:
6
- metadata.gz: be2664a0662c2237af3b3ab6d23446d5cf267345edc122270ee5553474ea82589f7430b38c0afbfb12f8c031d9e170fab2b28ebcd70774f40a72a5586825b3aa
7
- data.tar.gz: 50ae4a06be0cc9d955207521bd8f09c8ef58c61461ffda847e901e6c85d9d41535c937ed0da03d01d15539272b829fd11d0b839322423faa3e7bb0cfacf953d0
6
+ metadata.gz: 2898eec4da5863b38c44460eb4d4fd980f4e71b9f481a92f5f09d14581399c313525dc324b3a5e2bf55768073e5b300c97687be4e8355132301d8ac1e4d9f1b0
7
+ data.tar.gz: 372020127e6141058da57c09fdccde57d8332a930dc0a59d9b76621b8f033d7b4b2f602d495af541dc8a1d311081d2e6610753fb95173bd52cea84efcf39dfff
data/lib/eqn.rb CHANGED
@@ -1,2 +1,7 @@
1
1
  require 'treetop'
2
+
3
+ # Load the parser from the Treetop grammar.
4
+ Treetop.load(File.join(__dir__, 'eqn.treetop'))
5
+
6
+ # Load eqn classes.
2
7
  Dir.glob File.join(__dir__, 'eqn', '**', '*.rb'), &method(:require)
@@ -126,4 +126,4 @@ grammar Eqn
126
126
  rule space
127
127
  ("\s" / "\t")*
128
128
  end
129
- end
129
+ end
@@ -1,16 +1,14 @@
1
1
  module Eqn
2
2
  class Parser
3
- # Load the Treetop grammar from the grammar.
4
- Treetop.load(File.join(File.dirname(__dir__), 'eqn.treetop'))
5
- @@parser = EqnParser.new
6
-
7
3
  class << self
8
4
  def parse(data)
5
+ parser = EqnParser.new
6
+
9
7
  # Pass the data over to the parser instance.
10
- tree = @@parser.parse(data.downcase)
8
+ tree = parser.parse(data)
11
9
 
12
10
  # Raise any errors.
13
- raise ParseError, "Parse error at offset: #{@@parser.index}" + @@parser.failure_reason if tree.nil?
11
+ raise ParseError, "Parse error at offset: #{parser.index} -- #{parser.failure_reason}" if tree.nil?
14
12
 
15
13
  # Remove extraneous nodes and return tree.
16
14
  clean_tree(tree)
@@ -21,7 +19,7 @@ module Eqn
21
19
  def clean_tree(root_node)
22
20
  return if root_node.elements.nil?
23
21
  root_node.elements.delete_if { |node| node.class == Treetop::Runtime::SyntaxNode }
24
- root_node.elements.each { |node| clean_tree(node) }
22
+ root_node.elements.each(&method(:clean_tree))
25
23
  root_node
26
24
  end
27
25
  end
@@ -1,3 +1,3 @@
1
1
  module Eqn
2
- VERSION = '1.6.1'.freeze
2
+ VERSION = '1.6.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eqn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Schneider