Arithmetic evaluation: Difference between revisions

m
→‎Icon and Unicon: header simplification
m (whitespace/cleanup)
m (→‎Icon and Unicon: header simplification)
Line 951:
Left _ -> error "Did not parse"</lang>
 
== {{header|Icon}} and {{header|Unicon }}==
{{works with|Unicon}}
A compact recursive descent parser using Hanson's device. This program
* handles left and right associativity and different precedences
Line 963 ⟶ 964:
* Notice that the code looks remarkably like a typical grammar, rather than being an opaque cryptic solution
* Does not rely on any library to silently solve 1/2 the problem; in fact, this code would probably suit being put into a library almost verbatim
==={{header|Icon}}===
{{works with|Unicon}}
<lang Icon>procedure main() #: simple arithmetical parser / evaluator
write("Usage: Input expression = Abstract Syntax Tree = Value, ^Z to end.")
Anonymous user