10 votes 10 votes a = 1+1+1+ 1+1+1 1+1; as far as i think, it will pass the lexical phase.. it should b syntax error.. correct ?? Compiler Design compiler-design lexical-analysis + – shubhams3 asked Mar 22, 2016 shubhams3 1.0k views answer comment Share Follow See all 2 Comments See all 2 2 Comments reply Arjun commented Mar 22, 2016 reply Follow Share yes.. All are valid tokens. 3 votes 3 votes shubhams3 commented Mar 22, 2016 reply Follow Share Tokens r valid, but d code will not compile. I think d error will b in syntax analyzer phase.. No grammar will b available to construct parse tree of given string. 1 votes 1 votes Please log in or register to add a comment.
Best answer 14 votes 14 votes Yes, It will pass the lexical phase. There is a specific rule in "integer constant creation" that you can not have a blank space between a number. In the above line after 5th 1, "1 1", cause an error. This error is a grammatical error. Hence It will be not pass syntax analysis. Hence syntax error will be generated and reported at compile time. rude answered Mar 22, 2016 selected May 19, 2016 by Arjun rude comment Share Follow See all 6 Comments See all 6 6 Comments reply shubhams3 commented Mar 22, 2016 reply Follow Share In Lexical analysis phase, it removes all the white spaces and comments. so white space between 1 should also be removed, also LA phase makes use of Regular expressions to identify tokens, so it makes sense what you are saying. Still confusing. I think there are conflicts between answers. If there is any example of such question over internet or any other text book you guys know, then please do share. Thanks. 0 votes 0 votes Arjun commented Mar 22, 2016 reply Follow Share There is a specific rule in "integer constant creation" that you can not have a blank space between a number https://gcc.gnu.org/onlinedocs/cpp/Tokenization.html 1 votes 1 votes shubhams3 commented Mar 23, 2016 reply Follow Share Thanks.. this solved the confusion. 1 votes 1 votes rude commented Apr 5, 2016 reply Follow Share @Arjun Sir, Is my answer is not correct? Why did I get a down vote for this? :( :( 0 votes 0 votes Arjun commented Apr 5, 2016 reply Follow Share yes, its not correct. 1 1 should be two valid tokens in C. 0 votes 0 votes rude commented May 19, 2016 reply Follow Share @Arjun sir, yeah i got my mistake. Now I have edited it. I think now its correct. Thx. 0 votes 0 votes Please log in or register to add a comment.
2 votes 2 votes Yes , this error will be generated at the time of syntax analyzer . you cant make a parse tree for this rishu_18 answered Mar 22, 2016 rishu_18 comment Share Follow See all 0 reply Please log in or register to add a comment.