Re: pp, pitanje
"Crafting a compiler"
ch.17 Syntatic Error Recovery and Repair
> Data je gramatika LL(1):
> S -> E $
> E’ -> epsilon
> E -> T E’
> T-> id
> E’-> + T E
> T-> ( E )
> Neka je ulazna sentenca id ) ... $. Kako bi se izvršio oporavak od
> greške i koji bi se problem tu pojavio?
Sequence of stack moves that occurs is:
S' => E$ => TE'$ => idE'$ => E'$ => $
and error is detected. The last move occurs because ')' in Follow(E'). Now,
since only $ is left on the stack, the only repair operation possible is to
delete all remaining input up to the endmarker. This is rather extreme
action, especially since the language being generated is insert-corectable.
[ ... ovo iznad ti objasnjava sta je problem ... sada objasnjava razliku
izmedju 'strong' LL(1) parsera i 'full' LL(1) parsera ... ]
Strong LL(1) parser predict a production A -> epsilon, with a lookahead
symbol a if 'a' in Follow(A). Weather is actually valid is determined after
the prediction. In contrast, full LL(1) parsers do not make any prediction
unless the lookahead symbol is known to be valid.
[ ... da skratim 'full' parseri zahtevaju mnogo vece tabele od 'strong'
parsera ali imaju 'immediate error detection property' ... 'strong' parseri
se koriste u praksi ...]
.... As an alternative [ alternativa 'full' parserima ], we can buffer the
parse moves and semantic routine calls induced by a lookahead symbol. If
symbol is eventualy shifted, we know it is legal. We can then clear the
buffered parse moves and perform the buffered semantic routine calls. If we
cannot shift the lookahead, we use the buffered parse moves to restore the
parse stack to the configuration that existed when the illegal lookahead was
first used.
In general, for LL(1) parsers, we buffer on stack predictions that are made
until succesful shift occurs, at which point the buffer stack can be
cleared. To undo predictions, right-hand sides on the parse stack are
replaced by the left-hand side from which they were predicted. Thus, in the
preciding example, we buffer the move 'predict E -> epsilon'. When we
discover that ')' is illegal, we can use this buffer to undo the prediction,
replacing $ with E'$.
[ ... sada mozes da nastavis dalje sa parsiranjem ... ako ignorises ')' ...
ima jos o ovome ali mislim da je ovo dovoljno za ovaj odgovor ... ]
- References:
- pp, pitanje
- From: Bratislav Milic <zverko@eunet.yu>
- pp, pitanje
Previous by date: pp, pitanje
Next by date: OS
Previous by thread: pp, pitanje Next by thread: prevodioci... po ko zna koji put...
Previous by thread: pp, pitanje Next by thread: prevodioci... po ko zna koji put...