Question

7. Lexical analyzer, is the first phase in compiler, Of what use is this to the whole compilation and 14 marks) what are the
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Question 7:

Lexical analyzer is the first phase of the compiler that is used to convert source code into stream of tokens which is passed to the next phase syntax analyzer.

For example: int x = 5;

will be converted to [int,keyword][x,identifier][assignment][5,constant][terminator]

Lexical analyzer uses the concept of regular languages such as regular expressions, finite automata, regular grammar,etc.

Question 8:

Let D be the set of digits, and N be the set of non-vowel upper case letter

D = {0,1,2,3,4,5,6,7,8,9}

N = {B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z}

Regular expression:

(0+1+2+3+4+5+6+7+8+9)(a+b)(B+C+D+F+G+H+J+K+L+M+N+P+Q+R+S+T+V+W+X+Y+Z)

or

D(a+b)N

Question 9:

The language can be represented as:

S ={epsilon, ab, aabb, aaabbb, aaaabbbb,....} = {anbn, n>=0}

Context free grammar:

The regular expression cannot be constructed for the this language as this is not a regular language.

Question 10:

Regular expression is:

Corresponding NFA is:

Add a comment
Know the answer?
Add Answer to:
7. Lexical analyzer, is the first phase in compiler, Of what use is this to the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 12. Use the following SDT to convert an infix expression (9*3+2) to it post-fix equivalent. Semantic...

    12. Use the following SDT to convert an infix expression (9*3+2) to it post-fix equivalent. Semantic rules Production (print(")) ) (priot ()) () (print (num.lval)) E E+T T TP- [5 marks F num 13. Briefly explain the relevance of DAG and TAC at the Intermediate code generation phase. Give an example of DAG(Directed Acyclic Graph) with its equivalent TAC(Three-Address Code). [6 marks 14. Parser table is very important in predictive parsing; construct a parser table for the following CFG: S...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT