GATE / CS ARCHIVE

GATE CSE 2018 / QUESTION 8

Compiler phase ordering

Compiler Design · Compiler Phases, Linking & Loading · Full GATE CSE 2018 paper

GATE 2018, Q8 1 mark · MCQ
Report issue

Compiler Phases, Linking & Loading

Question 8, GATE 2018: Choose the false claim: A CFGs can specify lexical and syntactic rules; B type checking precedes parsing; C high-level code can translate to different intermediate representations; D function arguments can be passed on the program stack.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Method

Parsing identifies constructs such as expressions, declarations and function calls. Type checking applies rules to those constructs and their symbol-table information, so the conventional dependency is syntax before semantic type checking. A compiler may interleave actions during parsing, but that does not establish the blanket claim in B. Regular token languages are also context-free, which is why A is expressively valid even though practical lexers usually use regular expressions.

Solution

Parsing supplies the syntactic structure on which conventional type checking operates, so saying type checking is performed before parsing is false, B. CFGs can express regular lexical rules as well as syntax, multiple intermediate representations are possible, and stack argument passing is standard.

Original paper, page 5 · Answer key