calc_wsalasg 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/parser.rb +12 -13
- 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: f3d0a671c693d5d2f1d9a928f62bbc590dec757f
|
4
|
+
data.tar.gz: ccd8c57622cfadd89842b4da442eadc17f5e3003
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62aaabb31b5b0a4c0e80f57db4bde67fd89fc63458de76c9c0a8f4c765f59a073f03631282264d4b63522223714e7c91d094da1caf935bc45087dd3f19cf8102
|
7
|
+
data.tar.gz: 861cb39c7f3d3643c1b45a7c35c0fd57d90bc3bfbb2232b3c6bc0a108e8e8194aa2936fbce3849935394ac1c5a40ccf19605522ed38c0fa1cc3fd02dcd678ac3
|
data/lib/parser.rb
CHANGED
@@ -45,24 +45,23 @@ class Parser
|
|
45
45
|
return e
|
46
46
|
end
|
47
47
|
|
48
|
-
def Term()
|
49
|
-
|
48
|
+
def Term()
|
50
49
|
RestTerm(Storable())
|
51
50
|
end
|
52
51
|
|
53
52
|
def RestTerm(e)
|
54
53
|
|
55
|
-
t
|
54
|
+
t = @scan.getToken
|
56
55
|
|
57
|
-
if t.
|
58
|
-
return
|
56
|
+
if t.type == :times
|
57
|
+
return RestTerm (TimesNode.new(e,Storable()))
|
59
58
|
end
|
60
59
|
|
61
60
|
if t.type == :divide
|
62
61
|
return RestTerm (DivideNode.new(e,Storable()))
|
63
62
|
end
|
64
63
|
|
65
|
-
@scan.
|
64
|
+
@scan.putBackToken
|
66
65
|
|
67
66
|
return e
|
68
67
|
end
|
@@ -71,14 +70,14 @@ class Parser
|
|
71
70
|
|
72
71
|
result = Factor()
|
73
72
|
|
74
|
-
t
|
73
|
+
t = @scan.getToken
|
75
74
|
|
76
75
|
if t.type == :keyword then
|
77
|
-
if t.lex == "
|
76
|
+
if t.lex == "S" then
|
78
77
|
return StoreNode.new(result)
|
79
78
|
end
|
80
79
|
puts "Expected s found: ", t.lex
|
81
|
-
raise
|
80
|
+
raise ParseError.new
|
82
81
|
end
|
83
82
|
|
84
83
|
@scan.putBackToken
|
@@ -89,8 +88,8 @@ class Parser
|
|
89
88
|
|
90
89
|
t = @scan.getToken
|
91
90
|
|
92
|
-
if t.type == :
|
93
|
-
return
|
91
|
+
if t.type == :number then
|
92
|
+
return NumNode.new(t.lex.to_i)
|
94
93
|
end
|
95
94
|
|
96
95
|
if t.type == :keyword then
|
@@ -99,7 +98,7 @@ class Parser
|
|
99
98
|
end
|
100
99
|
|
101
100
|
puts "Expeected R found: " + t.lex
|
102
|
-
|
101
|
+
raise ParseError.new
|
103
102
|
end
|
104
103
|
|
105
104
|
if t.type == :lparen then
|
@@ -116,7 +115,7 @@ class Parser
|
|
116
115
|
end
|
117
116
|
|
118
117
|
puts "Expected number, R, ( found: " + t.type.to_s
|
119
|
-
raise ParseError.new
|
118
|
+
raise ParseError.new # "Parse Error"
|
120
119
|
end
|
121
120
|
end
|
122
121
|
|