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. |
ELENA 3.3 : |
||
<lang elena>import system'routines. |
<lang elena>import system'routines. |
||
import extensions. |
import extensions. |
||
Line 1,147: | Line 1,147: | ||
} |
} |
||
operatorState |
operatorState : ch |
||
[ |
[ |
||
ch => |
ch => |
||
$40 [ // ( |
$40 [ // ( |
||
^ |
^ self newBracket; gotoStarting |
||
]; |
]; |
||
! [ |
! [ |
||
^ |
^ self newToken; append:ch; gotoToken |
||
]. |
]. |
||
] |
] |
||
tokenState |
tokenState : ch |
||
[ |
[ |
||
ch => |
ch => |
||
$41 [ // ) |
$41 [ // ) |
||
^ |
^ self closeBracket; gotoToken |
||
]; |
]; |
||
$42 [ // * |
$42 [ // * |
||
^ |
^ self newProduct; gotoOperator |
||
]; |
]; |
||
$43 [ // + |
$43 [ // + |
||
^ |
^ self newSummary; gotoOperator |
||
]; |
]; |
||
$45 [ // - |
$45 [ // - |
||
^ |
^ self newDifference; gotoOperator |
||
]; |
]; |
||
$47 [ // / |
$47 [ // / |
||
^ |
^ self newFraction; gotoOperator |
||
]; |
]; |
||
! [ |
! [ |
||
^ |
^ self append:ch |
||
]. |
]. |
||
] |
] |
||
startState |
startState : ch |
||
[ |
[ |
||
ch => |
ch => |
||
$40 [ // ( |
$40 [ // ( |
||
^ |
^ self newBracket; gotoStarting |
||
]; |
]; |
||
$45 [ // - |
$45 [ // - |
||
^ |
^ self newToken; append literal:"0"; newDifference; gotoOperator |
||
]; |
]; |
||
! [ |
! [ |
||
^ |
^ self newToken; append:ch; gotoToken |
||
]. |
]. |
||
] |
] |
||
class Scope |
class Scope |