LEXICAL ANALYSIS
CONSTRUCTION OF A LEXICAL ANALYZER
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
Turing Machine
|
|
Linear Bounded Automata
|
|
Push Down Automata
|
|
Finite Automata
|
Detailed explanation-1: -CFG and PDA are equivalent in power: a CFG generates a context-free language and a PDA recognizes a context-free language. and the equivalent PDA to be used to implement its compiler. A language is context-free iff some pushdown automaton recognizes it.
Detailed explanation-2: -Any context-free grammar can be converted into a pushdown automaton that recognizes the same language, and vice versa. Theorem. A language is context-free if and only if some pushdown automaton recognizes it. This theorem has two directions.
Detailed explanation-3: -A pushdown automaton is computationally equivalent to a ‘restricted’ Turing Machine (TM) with two tapes which is restricted in the following manner-On the first tape, the TM can only read the input and move from left to right (it cannot make changes). On the second tape, it can only ‘push’ and ‘pop’ data.
Detailed explanation-4: -Definition: A language is context-free if there exists a context-free grammar that can generate it. Theorem A language is context-free if and only if it is accepted by a pushdown automaton.
Detailed explanation-5: -Formally, the set of all context-free languages is identical to the set of languages accepted by pushdown automata (PDA). Parser algorithms for context-free languages include the CYK algorithm and Earley’s Algorithm.