Anonymous user
Arithmetic evaluation: Difference between revisions
→{{header|Elena}}
Line 937:
=={{header|Elena}}==
<lang elena>#define std'basic'*.
#define std'patterns'*.
#define sys'io'*.
#define std'dictionary'*.
#subject parse_order.
#class Token
Line 968 ⟶ 964:
]
#method numeric =
}
Line 1,078 ⟶ 1,074:
]
#method append
[
#var aCode := Int32Value::aChar.
#if control if:(aCode == 41)
[
Line 1,092 ⟶ 1,090:
[ #shift EOF. ^ $self. ].
theParser evaluate:
]
Line 1,113 ⟶ 1,111:
#method evaluate : aChar
[
#if (
[
theToken := SubExpression.
Line 1,146 ⟶ 1,144:
#role Operator
{
#method evaluate
[
#if Control if:(
[
theToken := (Token += aChar).
Line 1,156 ⟶ 1,154:
#shift.
]
| if:(
[
theToken := SubExpression.
Line 1,169 ⟶ 1,167:
#method numeric = theTopNode numeric.
#method evaluate
[
#if Control if:(
[
theToken += aChar.
]
| if:(
[
theTopNode := theTopNode + ProductNode.
Line 1,181 ⟶ 1,179:
#shift Operator.
]
| if:(
[
theTopNode := theTopNode + FractionNode.
Line 1,187 ⟶ 1,185:
#shift Operator.
]
| if:(
[
theTopNode := theTopNode + SummaryNode.
Line 1,193 ⟶ 1,191:
#shift Operator.
]
| if:(
[
theTopNode := theTopNode + DifferenceNode.
Line 1,199 ⟶ 1,197:
#shift Operator.
]
| if:(
[
theToken := SubExpression.
|