Anonymous user
Arithmetic evaluation: Difference between revisions
m
→{{header|Tailspin}}: readability fix
m (→{{header|Tailspin}}: slightly more readable) |
m (→{{header|Tailspin}}: readability fix) |
||
Line 5,980:
=={{header|Tailspin}}==
<lang tailspin>
templates
when <[](1)> do $(1) !
otherwise [ { left: $(1), op: $(2), right: $(3)}, $(4..last)...] -> #
end leftAssociate
composer parseArithmetic
(<WS>?) <addition|multiplication|term> (<WS>?)
rule addition: [<multiplication|term> <addedTerm>+ ] ->
rule addedTerm: (<WS>?) <'[+-]'> (<WS>?) <multiplication|term>
rule multiplication: [<term> <multipliedTerm>+] ->
rule multipliedTerm: (<WS>?) <'[*/]'> (<WS>?) <term>
rule term: <INT|parentheses>
|