Arithmetic Evaluator/Go: Difference between revisions

(→‎Library: remove non-working error case)
imported>Katsumi
 
Line 3:
This is an operator precedence parser. The number format used in calculation can be changed with the line "type Number int".
 
<langsyntaxhighlight lang="go">package main
 
import (
Line 228:
}
}
</syntaxhighlight>
</lang>
 
Example
Line 243:
</pre>
 
== External links ==
* [http[wp://en.wikipedia.org/wiki/Operator-precedence_parser#Pseudo-code Wikipedia:precedence parser|Operator-precedence parser]]
 
=Library=
Shown here is use of the package go/parser in the standard library. For the Go 1 release, there is a parser in the standard library, but not an evaluator. Evaluation is relatively easy though, once you have a parse tree.
Anonymous user