procedure PARSEGRAPH (top, flag.)
var t, top : pointer; var flag: boolean;
// top points initially to the start symbol and later to the current goal
// flag is a boolean which is set true if parsing is successful
// sym is initialized to contain the first input token
t := top;
loop
if TAG(t) //true implies terminal symbol
then if SYMBOL(t) = sym // match token with terminal
then flag:= true; call NEXT() // get next token
else flag:= (SYMBOL(t) = 'empty') // match empty string
endif
else PARSEGRAPH (SYMBOL(t), flag) //parse nonterminal
endif
if flag // true implies successful passage through node
thent: = FOLLOW(t)
else t: = OTHER(t)
endif
until t = nil repeat
end PARSEGRAPH