Machine-translated by Google. Questions are authored in English.
Top

Syntax Analysis and Parsing Questions and Answers

91.

Which of the following is a Parser generating tool ?

Exam Year(s)

MH SET - 2018, SET Exam - 2018,

Answer: D

The parser generating tool is yacc.

yacc (Yet Another Compiler-Compiler) takes a grammar specification with actions and generates an LALR parser in C. It is usually used together with lex.

lex generates lexical analysers (scanners), not parsers. vi is a text editor and ls is the Unix command that lists directory contents.

Please log in or register to report this question.

92.

The syntax of expression in a language can be characterised by :

(i) a table giving associativity and precedence
(ii) a grammar for expression
(iii) expression are always to be written in infix notation
(iv) use of terminal per precedence level

Exam Year(s)

MH SET - 2021, SET Exam - 2021,

Answer: A

The syntax of expressions can be characterised by (i) and (ii), so the answer is (i) and (ii).

One way is a table listing each operator's precedence and associativity; the other is a grammar for expressions, where precedence is built into the structure of the productions. Both fix how an expression such as a - b * c is grouped.

Statement (iii) is false: expressions can be written in prefix or postfix notation as well as infix. Statement (iv) is also wrong as worded: an expression grammar uses one nonterminal per precedence level, not one terminal. Options containing (iii) or (iv) are therefore wrong.

Please log in or register to report this question.

93.

The grammar S \(\rightarrow\) aSa/bS/d is :

Exam Year(s)

MH SET - 2021, SET Exam - 2021,

Answer: D

The grammar is both LL(1) and LR(1).

The three alternatives of S begin with different terminals: FIRST(aSa) = {a}, FIRST(bS) = {b}, FIRST(d) = {d}. These sets are disjoint and no alternative derives the empty string, so a parser can always choose the production from one token of lookahead. The grammar is LL(1).

Every LL(1) grammar is also LR(1), since an LR(1) parser has at least as much information when it decides. So the grammar is both, which rules out the three options that deny one of the two.

Please log in or register to report this question.

Answer: C

The false statement is A uses canonical reduction to check the syntactic errors.

A top-down parser starts from the start symbol and expands non-terminals to generate a derivation of the input (a leftmost derivation), so statement A is true.

Canonical reduction belongs to bottom-up parsing: a bottom-up parser reduces the input string step by step to the start symbol, tracing a rightmost derivation in reverse, which is the canonical reduction sequence. So B's two statements are true and the one assigning canonical reduction to the top-down parser is false.

Please log in or register to report this question.

Loading…

Other Subjects

Tags: Syntax Analysis and Parsing Questions and Answers || Syntax Analysis and Parsing MCQ Questions and Answers || Syntax Analysis and Parsing GK Questions and Answers || Syntax Analysis and Parsing GK MCQ Questions || Syntax Analysis and Parsing Multiple Choice Questions and Answers || Syntax Analysis and Parsing GK || GK on Syntax Analysis and Parsing || Compiler Design Questions and Answers || Compiler Design MCQ Questions and Answers || Compiler Design GK Questions and Answers || GK on Compiler Design