3 votes 3 votes Compiler Design made-easy-test-series compiler-design lexical-analysis + – Deepanshu asked Aug 9, 2018 retagged Mar 4, 2019 by Aditi Singh Deepanshu 780 views answer comment Share Follow See all 10 Comments See all 10 10 Comments reply MiNiPanda commented Aug 9, 2018 reply Follow Share When we write like f1/*gate oat z; x=/*exam*/10; Comments are not categorized as tokens. The blue /* marks the beginning of a comment. Now the lexical analyzer will be waiting for the end of the comment i.e. */. If not found then it will treat the remaining part as a comment only. But in the next line we see there is a */ by seeing which the analyzer marks an end to the comment and start counting from the next token i.e. 10. 1.main 2.( 3.) 4.{ 5.int 6.x 7. , 8. y 9. ; 10. f1 /*gate oat z; x=/*exam*/ 11. 10 12. ; 13. y 14.= 15.20 16. ; 17.} 5 votes 5 votes Deepanshu commented Aug 9, 2018 i reshown by Deepanshu Aug 9, 2018 reply Follow Share why dont you treat x= in x=/*exam*/ as 2 tokens as x= is not in any comment. 0 votes 0 votes MiNiPanda commented Aug 9, 2018 reply Follow Share See once we have written /*.. anything after that will be marked as comment be it in the same or different line.. since x=/* exam is enclosed within the blue and green coloured /* ,*/ so they we will be treated as part of the comment. See this Comments here are indicated by blue color. In the first main() once we have ended the comment using */ from the very next character it is out of the comment zone. While in the 2nd main() i have not given */ so there is no end to the comment. Everything is in blue after /*. 2 votes 2 votes Deepanshu commented Aug 9, 2018 reply Follow Share thanks got this concept:) 1 votes 1 votes Shaik Masthan commented Aug 9, 2018 reply Follow Share @MiNiPanda, f110 is collectively a lexeme, but not 2 lexemes therefore totally 16 only 1 votes 1 votes MiNiPanda commented Aug 9, 2018 reply Follow Share Shaik Masthan If there is a line like int x=2/*random comment random...*/11; then you are saying value of x is 211 as 211 is collectively one lexeme and it is a numeric constant? 0 votes 0 votes Shaik Masthan commented Aug 9, 2018 reply Follow Share yes.... why? just simply remove the comments only. if any multiple white spaces , then replace with single white space. 0 votes 0 votes MiNiPanda commented Aug 9, 2018 reply Follow Share I tried printing the x value but it gave compilation error :/ 0 votes 0 votes Shaik Masthan commented Aug 9, 2018 reply Follow Share i am also getting compilation error. 0 votes 0 votes robinofautumn commented Dec 30, 2022 reply Follow Share I am getting 17. Is it correct? 0 votes 0 votes Please log in or register to add a comment.