S
Stefan Ram
Mr. X. said:there are two stacks :
For this approach (I do not know whether this is the same as a
»polish stack«), you might read the paragraph starting with
»I gave each symbol in the syntax table a particular code«
at
http://www.woz.org/letters/general/03.html
. Also see the English text at the end of
http://groups.google.com/[email protected]
. The classical reference is
Sequential Formula Translation
K. Samelson and F. L. Bauer
Communications of the ACM
Volume 3, Issue 2 (February 1960)
Pages: 76 - 83
ISSN:0001-0782
. I have implemented such a stack pair once in Java.
The support code is rather large and unpublished yet.
But the two core methods for the stack pair are given below.
public static void acceptOperator
( final OperatorToken operatorToken,
final de.dclj.ram.notation.bauer.notation.PlacementHint placementHint,
final OperatorStack operatorStack,
final DesignationStack designationStack )
{ int rightPriority;
if( placementHint instanceof OperatorMustBePrefixPlacementHint )
{ rightPriority = getOperatorRightPriorityInPrefixContext( operatorToken ); }
else
{ rightPriority = getOperatorRightPriorityInInfixContext( operatorToken ); }
while( isReducible( operatorStack, rightPriority ))
{ OperatorToken operator = operatorStack.pop();
operator.reduce( placementHint, operatorStack, designationStack ); }
operatorStack.accept( operatorToken ); }
public static void acceptLiteral
( final LiteralToken literalToken,
final de.dclj.ram.notation.bauer.notation.PlacementHint placementHint,
final OperatorStack operatorStack,
final DesignationStack designationStack )
{ designationStack.accept( literalToken.value() ); }}