aboutsummaryrefslogtreecommitdiff
path: root/calc.y
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2018-06-06 02:33:41 +0200
committerDimitri Sokolyuk <demon@dim13.org>2018-06-06 02:33:41 +0200
commit798a774484d6703bc94d3cfd9103e4cc5165dfa8 (patch)
tree4679431d89553619c7a4241b84db29859114a89b /calc.y
parent5ded4927cdd84f327a75ccdf17b32658d974b035 (diff)
....
Diffstat (limited to 'calc.y')
-rw-r--r--calc.y6
1 files changed, 3 insertions, 3 deletions
diff --git a/calc.y b/calc.y
index bac526c..43c691c 100644
--- a/calc.y
+++ b/calc.y
@@ -38,6 +38,7 @@ line
yylex.(*yyLex).ok = true
}
| WORD '=' exp { reg[$1] = $3 }
+ | error
;
exp
@@ -53,13 +54,12 @@ exp
| '-' exp %prec UMINUS { $$ = -$2 }
| '(' exp ')' { $$ = $2 }
| '|' exp '|' { $$ = math.Abs($2) }
- | error { $$ = math.NaN() }
;
%%
-func Parse(input string) (float64, bool) {
+func Parse(input string) (float64, bool, error) {
l := lex(input)
yyParse(l)
- return l.result, l.ok
+ return l.result, l.ok, l.err
}