5 votes 5 votes void main() { i/*nt*/a=10; return; } Number of tokens in above code:? Compiler Design compiler-design compiler-tokenization + – rahul sharma 5 asked Oct 9, 2017 • edited Oct 9, 2017 by rahul sharma 5 rahul sharma 5 5.6k views answer comment Share Follow See all 6 Comments See all 6 6 Comments reply saxena0612 commented Oct 9, 2017 reply Follow Share 12 ! ia will be counted as an identifier.! 0 votes 0 votes sunil sarode commented Oct 9, 2017 reply Follow Share we will not consider comment. void | main |( | ) | { | i | a |= | 10 | ; | return | ; | } | 13 2 votes 2 votes rahul sharma 5 commented Oct 9, 2017 reply Follow Share There is not space between comment and a.I have updated the question to make it clear.Please check will it be 12 or 13? 0 votes 0 votes sunil sarode commented Oct 10, 2017 reply Follow Share lexical analysis will remove the white space (if any)after each line,so do not worry about space. https://stackoverflow.com/questions/40246721/what-is-the-number-of-tokens-in-the-following-code-snippet 0 votes 0 votes Rupendra Choudhary commented Oct 10, 2017 reply Follow Share Hello saxena , i think it should be 13 .. i and a would be count as 2 tokens...as comment between them is like space which is not allowed in identifier name ... 0 votes 0 votes rahul sharma 5 commented Oct 11, 2017 reply Follow Share @ sunil sarode Comment will be ignored by lexical analyzer,then why i and a will be seprate tokens?Shouldnt it count as 1 token? 0 votes 0 votes Please log in or register to add a comment.
Best answer 7 votes 7 votes this is my answer. Comments act as white space for separating tokens. Page 57 in C standard. Hira Thakur answered Oct 10, 2017 • selected Dec 31, 2018 by Arjun Hira Thakur comment Share Follow See all 0 reply Please log in or register to add a comment.