Wednesday, February 2, 2011

C++ Tokens

Tip- The parser separates tokens from the input stream by creating the longest token possible using the input characters in a left-to-right scan

Details - A token is the smallest element of a C++ program that is meaningful to the compiler.
The parser separates tokens from the input stream by creating the longest token possible using the input characters in a left-to-right scan. Consider this code fragment:

a = i+++j;
what does it mean?

a = i + (++j)
or
a = (i++) + j

Because the parser creates the longest token possible from the input stream, it chooses the second interpretation, making the tokens i++, +, and j.

You can write funny looking code with the parser’s blessing. Try it. Love it.

Reference   -

Posted By : Ajesh P.S

No comments:

Post a Comment