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 +4 -4
- data/lib/eqn.rb +5 -0
- data/lib/eqn.treetop +1 -1
- data/lib/eqn/parser.rb +5 -7
- data/lib/eqn/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a298576c822eca16cdaf7281ec1344ea37f19a4
|
4
|
+
data.tar.gz: 3408ed487ad7cae4ff268559d1e71bf769221d90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2898eec4da5863b38c44460eb4d4fd980f4e71b9f481a92f5f09d14581399c313525dc324b3a5e2bf55768073e5b300c97687be4e8355132301d8ac1e4d9f1b0
|
7
|
+
data.tar.gz: 372020127e6141058da57c09fdccde57d8332a930dc0a59d9b76621b8f033d7b4b2f602d495af541dc8a1d311081d2e6610753fb95173bd52cea84efcf39dfff
|
data/lib/eqn.rb
CHANGED
data/lib/eqn.treetop
CHANGED
data/lib/eqn/parser.rb
CHANGED
@@ -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 =
|
8
|
+
tree = parser.parse(data)
|
11
9
|
|
12
10
|
# Raise any errors.
|
13
|
-
raise ParseError, "Parse error at offset: #{
|
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
|
22
|
+
root_node.elements.each(&method(:clean_tree))
|
25
23
|
root_node
|
26
24
|
end
|
27
25
|
end
|
data/lib/eqn/version.rb
CHANGED