Arithmetic evaluation: Difference between revisions

Content added Content deleted
(→‎{{header|Java}}: code cleanup, consistent indentation)
Line 1,061: Line 1,061:


=={{header|Elena}}==
=={{header|Elena}}==
ELENA 3.2 :
ELENA 3.3 :
<lang elena>import system'routines.
<lang elena>import system'routines.
import extensions.
import extensions.
Line 1,147: Line 1,147:
}
}


operatorState = (:ch)
operatorState : ch
[
[
ch =>
ch =>
$40 [ // (
$40 [ // (
^ closure newBracket; gotoStarting
^ self newBracket; gotoStarting
];
];
! [
! [
^ closure newToken; append:ch; gotoToken
^ self newToken; append:ch; gotoToken
].
].
].
]


tokenState = (:ch)
tokenState : ch
[
[
ch =>
ch =>
$41 [ // )
$41 [ // )
^ closure closeBracket; gotoToken
^ self closeBracket; gotoToken
];
];
$42 [ // *
$42 [ // *
^ closure newProduct; gotoOperator
^ self newProduct; gotoOperator
];
];
$43 [ // +
$43 [ // +
^ closure newSummary; gotoOperator
^ self newSummary; gotoOperator
];
];
$45 [ // -
$45 [ // -
^ closure newDifference; gotoOperator
^ self newDifference; gotoOperator
];
];
$47 [ // /
$47 [ // /
^ closure newFraction; gotoOperator
^ self newFraction; gotoOperator
];
];
! [
! [
^ closure append:ch
^ self append:ch
].
].
].
]


startState = (:ch)
startState : ch
[
[
ch =>
ch =>
$40 [ // (
$40 [ // (
^ closure newBracket; gotoStarting
^ self newBracket; gotoStarting
];
];
$45 [ // -
$45 [ // -
^ closure newToken; append literal:"0"; newDifference; gotoOperator
^ self newToken; append literal:"0"; newDifference; gotoOperator
];
];
! [
! [
^ closure newToken; append:ch; gotoToken
^ self newToken; append:ch; gotoToken
].
].
].
]


class Scope
class Scope