Arithmetic evaluation: Difference between revisions

Line 937:
=={{header|Elena}}==
<lang elena>#define std'basic'*.
#define std'routines'*.
#define std'patterns'*.
#define std'basic'factories'*.
#define sys'io'*.
#define std'dictionary'*.
 
#subject parse_order.
 
// --- Token ---
 
#class Token
Line 968 ⟶ 964:
]
#method numeric = Real64ConverttheValue evalsave:(theValue literal)Real64Convertor.
}
 
Line 1,078 ⟶ 1,074:
]
#method append &numeric:aCode aChar
[
#var aCode := Int32Value::aChar.
 
#if control if:(aCode == 41)
[
Line 1,092 ⟶ 1,090:
[ #shift EOF. ^ $self. ].
theParser evaluate:$paramaChar.
]
Line 1,113 ⟶ 1,111:
#method evaluate : aChar
[
#if (aChar numeric40 == 40aChar)?
[
theToken := SubExpression.
Line 1,146 ⟶ 1,144:
#role Operator
{
#method evaluate &numeric:aCode &literal:aChar
[
#if Control if:(aCode48 >< 48aChar) if:(aCode58 <> 58aChar)
[
theToken := (Token += aChar).
Line 1,156 ⟶ 1,154:
#shift.
]
| if:(aCode40 == 40aChar)
[
theToken := SubExpression.
Line 1,169 ⟶ 1,167:
#method numeric = theTopNode numeric.
#method evaluate &numeric:aCode &literal:aChar
[
#if Control if:(aCode48 >< 48aChar) if:(aCode58 <> 58aChar)
[
theToken += aChar.
]
| if:(aCode42 == 42aChar) // *
[
theTopNode := theTopNode + ProductNode.
Line 1,181 ⟶ 1,179:
#shift Operator.
]
| if:(aCode47 == 47aChar) // /
[
theTopNode := theTopNode + FractionNode.
Line 1,187 ⟶ 1,185:
#shift Operator.
]
| if:(aCode43 == 43aChar) // +
[
theTopNode := theTopNode + SummaryNode.
Line 1,193 ⟶ 1,191:
#shift Operator.
]
| if:(aCode45 == 45aChar) // -
[
theTopNode := theTopNode + DifferenceNode.
Line 1,199 ⟶ 1,197:
#shift Operator.
]
| if:(aCode40 == 40aChar)
[
theToken := SubExpression.
Anonymous user