Bracket Matching by yt

with text_io;use text_io;procedure a is
x,p:natural:=0;s:string:=get_line;begin
for i in s'range loop
x:=character'pos(s(i));if(x+1)mod 4<2 then
s(p+1):=s(i);p:=p+2;elsif
x/6/=character'pos(s(p))/6 then
put_line("failed at: "&s(i..s'last));a;end if;p:=p-1;end loop;if p=0 then
put_line("yes");a;end if;put_line("failed at: EOL");a;end;

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page