LLk-Parsing - COT 4210 Top-down Parsing with LL(k) Grammars...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
COT 4210 Top-down Parsing with LL(k) Grammars Fall 2001 Deterministic Top-down Parsing A top-down parsing algorithm is one that attempts to simulate a left-most derivation of the input. Algorithms of this kind use a stack to hold the unexpanded sentential form produced at each step of the parse. At the beginning of a parse, the stack is initialized with the start symbol of the underlying grammar. Parsing proceeds using two pieces of information to make a decision as to what action the parser should take. The lookahead is a string composed of the next k tokens in the input stream, where k 1 is a bound on the length of the lookahead string; a token is essentially a terminal symbol of the underlying grammar, but more precisely it is a lexical category such as identifier or reserved word , real literal , etc. In addition to the lookahead, the parser uses information in the parse stack, usually only the top symbol of the stack is needed. Figure 1 illustrates a conceptual model of top- down parsing. Figure 1. Conceptual Model of Top-down Parsing Algorithms Top-down parsing algorithms may use a technique known as back-tracking when the parser reaches a configuration where the parse cannot complete successfully. Recursive descent is an example of such an algorithm. The idea is that the parser “backs up” or “back tracks” to a previous parsing configuration where an alternative action is possible. It then takes one of the alternative actions and continues. Back tracking may occur
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

LLk-Parsing - COT 4210 Top-down Parsing with LL(k) Grammars...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online