0% found this document useful (0 votes)
30 views3 pages

bc210424835 cs606 Assignment 1 Solution

Uploaded by

ordinary.girl166
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views3 pages

bc210424835 cs606 Assignment 1 Solution

Uploaded by

ordinary.girl166
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

CS606 Compiler Construction

Assignment # 01

Student Id: bc210424835


Student Name: Maham Ameer

Question No 01 Marks (20)

Consider the following stream of characters as input to the lexical analyzer (i.e., scanner);

for (int i = 0; i < 10; i++) {


if (i % 2 == 0) {
cout << "Even number: " << i << endl;
} else {
cout << "Odd number: " << i << endl;
}
}

You are required to find the tokens produced by lexical analyzer and write them along with their
types (types are given below) in the following sample table.

No. Token Type

1. for Keyword

2. ( Symbol

3. int Keyword

4. i Identifier

5. = Symbol
6. 0 Integer

7. ; Symbol

8. i Identifier

9. < Symbol

10. 10 Integer

11. ; Symbol

12. i Identifier

13. ++ Symbol

14. ) Symbol

15. { Symbol

16. if Keyword

17. ( Symbol

18. i Identifier

19. % Symbol

20. 2 Integer

21. == Symbol

22. 0 Integer

23. ) Symbol

24. { Symbol

25. cout identifier

26. << Symbol

27. “Even number:” String

28. << Symbol

29. i Identifier
30. << Symbol

31. endl Identifier

32. ; Symbol

33. } Symbol

34. else Keyword

35. { Symbol

36. cout Identifier

37. << Symbol

38. “Odd number:” String

39. << Symbol

40. i Identifier

41. << Symbol

42. endl Identifier

43. ; Symbol

44. } Symbol

45. } Symbol

You might also like