Parsing/RPN to infix conversion: Difference between revisions

m
→‎{{header|REXX}}: aligned statements.
m (→‎{{header|REXX}}: added/changed whitespace and comments, used a template for the output section.)
m (→‎{{header|REXX}}: aligned statements.)
Line 3,403:
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
pop: pop= #; #= # - 1; return @.pop
push: #= # + 1; @.#= arg(1); return
/*──────────────────────────────────────────────────────────────────────────────────────*/
stack2str: $=; do j=1 for #; _ = @.j; y= left(_, 1)
Line 3,413:
return space($)
/*──────────────────────────────────────────────────────────────────────────────────────*/
toInfix: parse arg rpn; say copies('─', 80 - 1); say 'RPN: ' space(rpn)
 
do N=1 for words(RPN) /*process each of the RPN tokens.*/
Line 3,429:
end /*N*/
 
return space( substr( pop(), 2) )</lang>
{{out|output|text=&nbsp; when using the default inputs: &nbsp; &nbsp; &nbsp; [Output is very similar to AWK's output.]}}
<pre>