Parsing/Shunting-yard algorithm: Difference between revisions

Content added Content deleted
(Added Algol 68)
m (use named params)
Line 2,463: Line 2,463:
string res = "", sep = "", top
string res = "", sep = "", top
sequence stack = {}
sequence stack = {}
--sequence ops = split(infix) -- (only works if () properly spaced)
sequence ops = split(substitute_all(infix,{"(",")"},{" ( "," ) "}),' ',no_empty:=1,limit:=0)
sequence ops = split(substitute_all(infix,{"(",")"},{" ( "," ) "}),' ',0,1)
printf(1,"Infix input: %-30s%s", {infix,iff(show_workings?'\n':'\t')})
printf(1,"Infix input: %-30s%s", {infix,iff(show_workings?'\n':'\t')})
for i=1 to length(ops) do
for i=1 to length(ops) do