103 views

retagged | 103 views
+3

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.}

0
why dont you treat  x= in x=/*exam*/ as 2 tokens

as x= is not in any comment.
+1

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 /*.

+1
thanks got this concept:)
0

@MiNiPanda, f110 is collectively a lexeme, but not 2 lexemes

therefore totally 16 only

0

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
yes....

why?

just simply remove the comments only.

if any multiple white spaces , then replace with single white space.
0
I tried printing the x value but it gave compilation error :/
0
i am also getting compilation error.

+1 vote