0% found this document useful (0 votes)
54 views3 pages

Automata Theory & Compiler Design Exam

This document outlines the examination structure for the Automata Theory and Compiler Design course at GITAM University, including instructions and sections for answering questions. It consists of multiple sections with various questions related to regular languages, finite automata, parsing techniques, and lexical analysis. The exam is designed for students in their VI semester and has a total of 30 marks.

Uploaded by

HARI
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views3 pages

Automata Theory & Compiler Design Exam

This document outlines the examination structure for the Automata Theory and Compiler Design course at GITAM University, including instructions and sections for answering questions. It consists of multiple sections with various questions related to regular languages, finite automata, parsing techniques, and lexical analysis. The exam is designed for students in their VI semester and has a total of 30 marks.

Uploaded by

HARI
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

[Apr-24]

GITAM (Deemed to be University)


[CSEN3061]
GST/GSS/GSB/GSHS Degree Examination
VI Semester
AUTOMATA THEORY AND COMPILER DESIGN
(Effective from the admitted batch 2021-22)
Time: 2 Hours Max. Marks: 30
-----------------------------------------------------------------------------------------------------
Instructions: All parts of the unit must be answered in one place only.
----------------------------------------------------------------------------------------------------
Section-A
1. Answer all questions: (51=5)
a) List out the closure properties of regular language.
b) Define PDA using the seven tuples
c) Illustrate the importance of Lexical Analyzer
d) List out the different types of Parsing techniques
e) Describe two advantages of using intermediate code
representation during compilation.
Section-B
Answer the following: (55=25)
UNIT-I
2. a) Let P and Q be two regular expressions over Σ. If P does not
contain ∈, then the following equation in R, namely R=Q+RP
has a unique solution given by R=QP*.
b) Applying this theory determine regular expression of below finite
Automata.
OR
3. a) Design a finite automaton that accept odd number of 0’s and
even number of 1’s.
b) Show that W1=00011, W2=01001 are accepted by the designed
machine.
UNIT-II
4. a) Demonstrate Regular grammar is a subset of CFG.
b) Transfer following CFG in CNF
S → x | xD
D → xCC | ε
C → Dx | y
OR
5. a) Design a PDA that accepts any language in the form of L=a nbn.
b) Represent the designed PDA using 7 tuples
UNIT-III
6. a) Let a HLL code is “void main ()”. Make use of LB (Lex Begin)
and FW (Forward) pointers to find out lexeme.
b) Design a pattern that recognizes any relational operators during
the Lexical Analysis phase.
OR
7. a) Let a variable is declared in the program like “int num=10;”.
Find out different lex, token associated with this.
b) Demonstrate the procedure of lexical analyzer in recognition of
tokens.
UNIT-IV
8. Design a parse table for the below grammar using LL (1) parser.
S→E
T → FT ′
E→TE′
T′→∗T|/T|ε
E′→+E|−E|ε
F → id | num
OR
9. Design state transition diagram and parse table for the below
grammar using LR (0) parser.
SXX
XbX|a
UNIT-V
10. Translate the following expression: (a + b) * (c + d) + (a + b + c)
into i) Quadruples ii) Triples iii) Indirect triples

OR
11. Convert the following expression into syntax tree and three address
code: h=(b-(a+b)/d)-c+6.

[VI/124]

Common questions

Powered by AI

The primary parsing techniques are top-down parsing (including LL parsing) and bottom-up parsing (including LR parsing). Top-down parsing constructs the parse tree from the top down, predicting and ensuring that the input abides by the grammar, while bottom-up parsing works from the leaves up to the root, focusing on reducing the input string back to the start grammar symbol. The choice impacts how efficiently the parse tree is constructed, error recovery, and how grammar rules are applied and resolved .

An LL(1) parsing table is designed by computing the FIRST and FOLLOW sets for each grammar production, then populating the table using these sets to predict which production to use based on the current input token. This method helps synchronize input symbols with grammar rules, allowing the parsing algorithm to backtrack minimally. It is useful for early syntax error detection because it predicts illegal tokens or grammar violations as soon as they occur, enhancing error recovery .

A finite automaton for this problem would consist of four states: q0 (start state, even 0s, even 1s), q1 (odd 0s, even 1s), q2 (even 0s, odd 1s), and q3 (odd 0s, odd 1s). The transitions depend on the input: reading '0' causes transitions between even and odd 0 states, and reading '1' causes transitions between even and odd 1 states. The accepting state is q1. This structure ensures that only strings with an odd number of 0s and even number of 1s are accepted .

To convert the given CFG to CNF, where each rule produces two non-terminals or a terminal, first eliminate ε-productions and unit productions. Then convert the rules to binary form using intermediary non-terminals. For example, S → xD can become S → XA where X → x and A → D. The CNF helps streamline parsing algorithms like CYK by simplifying CFGs to a standardized, binary form .

Closure properties of regular languages include union, concatenation, and star (Kleene closure). These properties are foundational in automata theory because they allow for constructing complex regular languages from simpler ones. The operations ensure that the set of regular languages is closed under these operations, meaning if one or more regular languages undergo these operations, the result is also a regular language .

The unique solution for R=Q+RP when P does not contain ε is R=QP*. This is significant as it demonstrates that under specific conditions, infinite sequences (expressed by P*) can be expressed compactly in finite automata terms, leading to a deterministic construction of the automaton that accepts the language described. It illustrates the power and limitations of regular expressions in processing regular languages .

One advantage of using intermediate code representation is platform independence; it allows code to be easily translated into the target machine code for different hardware platforms. Another advantage is simplification of optimization processes. Since intermediate code is usually in a form closer to assembly language and not too high-level, it facilitates various optimizations before final code generation, leading to better performance .

The lexical analyzer is the first phase of the compiler, responsible for scanning the source code and converting it into tokens, which are the atomic units of syntax. It improves efficiency by removing whitespace and comments and allows for fast error detection by identifying syntax errors and illegal tokens early in the compilation process. This streamlined tokenization enables subsequent parsing phases to function more efficiently .

A PDA is formally defined with seven tuples (Q, Σ, Γ, δ, q0, Z0, F) where Q is a finite set of states, Σ is the input alphabet, Γ is the stack alphabet, δ is the transition function, q0 is the start state, Z0 is the start stack symbol, and F is the set of accepting states. This formalism is crucial as it provides a structured way to model context-free languages, which are more powerful than regular languages and can describe more complex language constructs essential for programming languages and parsers .

In lexical analysis, the LB and FW pointers are used to identify lexemes. LB marks the start of a potential lexeme, while FW scans ahead to determine the lexeme's end. For example, in parsing "void main ()", LB points to 'v' and FW moves until it identifies "void" as a keyword. This pointer-based method is crucial for efficient scanning and tokenization, helping to precisely extract and categorize lexemes from the source code .

You might also like