Following questions have been asked in GATE CS exam.
1. Given the following expression grammar:
E -> E * F | F+E | F
F -> F-F | id
which of the following is true? (GATE CS 2000)
(a) * has higher precedence than +
(b) – has higher precedence than *
(c) + and — have same precedence
(d) + has higher precedence than *
Precedence in a grammar is enforced by making sure that a production rule with higher precedence operator will never produce an expression with operator with lower precedence.
In the given grammar ‘-’ has higher precedence than ‘*’
2. Consider a program P that consists of two source modules M1 and M2 contained in two different files. If M1 contains a reference to a function defined in M2 the reference will be resolved at (GATE CS 2004)
a) Edit time
b) Compile time
c) Link time
d) Load time
Compiler transforms source code into the target language. The target language is generally in binary form known as object code. Typically, an object file can contain three kinds of symbols:
* defined symbols, which allow it to be called by other modules,
* undefined symbols, which call the other modules where these symbols are defined, and
* local symbols, used internally within the object file to facilitate relocation.
When a program comprises multiple object files, the linker combines these files into a unified executable program, resolving the symbols as it goes along.
3. Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar? (GATE CS 2003)
(a) Removing left recursion alone
(b) Factoring the grammar alone
(c) Removing left recursion and factoring the grammar
(d) None of the above
Removing left recursion and factoring the grammar do not suffice to convert an arbitrary CFG to LL(1) grammar.
4. Assume that the SLR parser for a grammar G has n1 states and the LALR parser for G has n2 states. The relationship between nl and n2 is (GATE CS 2003)
(a) n1 is necessarily less than n2
(b) n1 is necessarily equal to n2
(c) n1 is necessarily greater than n2
(d) none of the above
Please see GATE Corner for all previous year paper/solutions/explanations, syllabus, important dates, notes, etc.
Please write comments if you find any of the answers/explanations incorrect, or you want to share more information about the topics discussed above.
- Compiler Theory | Set 1
- Difference between Native compiler and Cross compiler
- Incremental Compiler in Compiler Design
- Automata Theory | Set 1
- Automata Theory | Set 2
- Automata Theory | Set 3
- Automata Theory | Set 4
- Automata Theory | Set 6
- Automata Theory | Set 5
- Introduction to Syntax Analysis in Compiler Design
- Why FIRST and FOLLOW in Compiler Design?
- Runtime Environments in Compiler Design
- Syntax Directed Translation in Compiler Design
- Intermediate Code Generation in Compiler Design
- Peephole Optimization in Compiler Design
- Language Processors: Assembler, Compiler and Interpreter
- Code Optimization in Compiler Design
- Introduction of Object Code in Compiler Design
- Introduction of Compiler Design
- Phases of a Compiler
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.