Parsing/Shunting-yard algorithm: Difference between revisions
Content deleted Content added
m →{{header|Icon}} and {{header|Unicon}}: fix bug in tail code simplification |
|||
Line 505: | Line 505: | ||
if token == ("("|")") then stop("Unbalanced parenthesis") |
if token == ("("|")") then stop("Unbalanced parenthesis") |
||
else { |
else { |
||
rpn ||:= |
rpn ||:= token || " " |
||
printf(pat,"",rpn,list2string(ostack)) |
printf(pat,"",rpn,list2string(ostack)) |
||
} |
} |
||
Line 537: | Line 537: | ||
^ : 3 4 2 * 1 5 - 2 : [ ^ / + ] |
^ : 3 4 2 * 1 5 - 2 : [ ^ / + ] |
||
3 : 3 4 2 * 1 5 - 2 : [ ^ ^ / + ] |
3 : 3 4 2 * 1 5 - 2 : [ ^ ^ / + ] |
||
: 3 4 2 * 1 5 - 2 3 ^ : [ / + ] |
: 3 4 2 * 1 5 - 2 3 ^ : [ ^ / + ] |
||
: 3 4 2 * 1 5 - 2 3 ^ |
: 3 4 2 * 1 5 - 2 3 ^ ^ : [ / + ] |
||
: 3 4 2 * 1 5 - 2 3 ^ ^ / : [ + ] |
|||
: 3 4 2 * 1 5 - 2 3 ^ ^ / + : [ ] |
|||
RPN = "3 4 2 * 1 5 - 2 3 ^ ^ / + "</pre> |
|||
=={{header|Python}}== |
=={{header|Python}}== |