CD - Assignment 1
CD - Assignment 1
Assignment 1
3. Define lexeme, token and pattern. Identify the lexemes that make up the tokens in the
following program segment. Indicate corresponding token and pattern.
4. Construct DFA for following Regular expression. Use firstpos, lastpos and followpos
functions to construct DFA.
(a*|b*)*
5. What is regular expression, give all the algebraic properties of regular expression.
6. Construct NFA for following regular expression using Thompson’s notation and then
convert it into DFA.
a(b | c)*a*c#
(a | b)*abb
method. a+ b* (c |d) f #
Show that the string aa+a* can be generated by the grammar. Construct the parse tree
for the grammar. Is the grammar ambiguous?
15. Apply shift reduce parser for parsing following string using unambiguous
grammar. id - id * id - id
16. Where do we use operator precedence parsing technique? Give the general precedence
table for operating precedence parsing, considering all the generalized rules.
17. Construct a precedence graph, precedence table for operator precedence parser to be
used for parsing a string consisting of id, - , * , $. Parse following string.
$ id - id * id * id $
18. What is left recursion? Eliminate the left recursion from the following grammar.
And Design the FIRST SET and FOLLOW SET for the following grammar
E◊E+T|T
T◊T*F|F
F ◊ ( E ) | id
20. Differentiate SLR, Canonical LR and LALR. Also justify the statement “A class of grammar
that can be parsed using LR methods is a proper subset of the class of grammars that
can be parsed with predictive parser”.
21. Draw the state transition diagram for the unsigned numbers.