Lexical analysis
Question 1 |
The number of tokens in the following C statement is
C
printf("i = %d, &i = %x", i, &i);
3 | |
26 | |
10 | |
21 |
Discuss it
In a C source program, the basic element recognized by the compiler is the “token.” A token is source-program text that the compiler does not break down into component elements. There are 6 types of C tokens : identifiers, keywords, constants, operators, string literals and other separators. There are total 10 tokens in the above printf statement. Below are tokens in above program.
printf ( "i = %d, &i = %x" , i , & i ) ;
Question 2 |
parsing of the program | |
the code generation | |
the lexical analysis of the program | |
dataflow analysis |
Discuss it
Question 3 |
The lexical analysis for a modern computer language such as Java needs the power of which one of the following machine models in a necessary and sufficient sense?
Finite state automata | |
Deterministic pushdown automata | |
Non-Deterministic pushdown automata | |
Turing Machine |
Discuss it
In lexical analysis finite automata is used to produce tokens in the form of identifiers, keywords and constants from the input program. In the process of pattern recognition, it used to search keywords by using string-matching algorithms. See https://www.geeksforgeeks.org/automata-theory-set-3/
Question 4 |
printf("i=%d, &i=%x", i, &i);
are 11.
(III) Symbol table can be implementation by using array and hash table but not tree.
Which of the following statement(s) is/are correct?Only (I) | |
Only (II) and (III) | |
All (I), (II), and (III) | |
None of these |
Discuss it
printf("i=%d, &i=%x", i, &i);
are 10.
(III) Symbol table can be implementation by using array, hash table, tree and linked lists.
So, option (D) is correct.Question 5 |
Context-free grammar can be used to specify both lexical and syntax rules. | |
Type checking is done before parsing. | |
High-level language programs can be translated to different Intermediate Representations. | |
Arguments to a function can be passed using the program stack. |
Discuss it
Question 6 |
T1T2T3 | |
T1T1T3 | |
T2T1T3 | |
T3T3 |
Discuss it
Question 7 |

(1) | |
(2) | |
(3) | |
(4) |
Discuss it
Question 8 |
A parse tree | |
Intermediate code | |
Machine code | |
A stream of tokens |
Discuss it
Question 9 |
Only I | |
Only II | |
Both I and II | |
Neither I nor II |
Discuss it
Question 10 |
Only I | |
Only II | |
Both I and II | |
Neither I nor II |
Discuss it