4 votes 4 votes Is the given answer correct? Compiler Design made-easy-test-series compiler-design compiler-tokenization lexical-analysis + – Lucky sunda asked Jan 6, 2017 • edited Mar 6, 2019 by adeebafatima1 Lucky sunda 1.7k views answer comment Share Follow See all 3 Comments See all 3 3 Comments reply saurabh rai commented Feb 7, 2017 i edited by saurabh rai Feb 7, 2017 reply Follow Share it is 34 "printf("%d%d%d,a,b,c")" is 14 tokens 1 votes 1 votes bad_engineer commented Feb 7, 2017 reply Follow Share 21???? 0 votes 0 votes Ashwani Kumar 2 commented Feb 7, 2017 i reshown by Ashwani Kumar 2 Feb 7, 2017 reply Follow Share I also write 21 but made easy people counted each token of that statement individually I think their solution is wrong..!! 0 votes 0 votes Please log in or register to add a comment.
Best answer 7 votes 7 votes Total 34 "printf("%d%d%d,a,b,c")" will be considered as "printf(" % d % d % d , a , b , c ")" NOT as 1 token but as 14 token Smriti012 answered Feb 7, 2017 • selected Feb 7, 2017 by saurabh rai Smriti012 comment Share Follow See all 14 Comments See all 14 14 Comments reply Ashwani Kumar 2 commented Feb 7, 2017 reply Follow Share I got it.. It will work like this..For this statement "printf ( " is one token and at the end ")" is also a token... total=34 Thanks..!! 2 votes 2 votes bad_engineer commented Feb 7, 2017 reply Follow Share I didnt understood what are those 14 tokens can you specify??? 0 votes 0 votes smartmeet commented Feb 7, 2017 reply Follow Share Tokens should be like this, int main ( ) int a , b , c ; a + c ; etc. and i think "____" should be considered as one Token only! So total should be 21 0 votes 0 votes bad_engineer commented Feb 7, 2017 reply Follow Share exactly but someone here is saying "_________" it is 14 tokens 0 votes 0 votes saurabh rai commented Feb 7, 2017 reply Follow Share @smartmeet u make it this ans wrong ? 0 votes 0 votes Ashwani Kumar 2 commented Feb 7, 2017 reply Follow Share @bad_engineer @smartmeet Initially i also counted as 21 but.. When lexical analyzer scans this statement it firstly see " and will map to the corressponding DFA or regular expression and will terminate when it reaches " and thus making " printf ( " as a token Am i right ..?? 0 votes 0 votes smartmeet commented Feb 7, 2017 reply Follow Share yes, I think you are right..it searches for next " 0 votes 0 votes Smriti012 commented Feb 7, 2017 reply Follow Share @Ashwani Kumar At first attempt i also got 21 ....so I thought over it... n got my mistake... 0 votes 0 votes bad_engineer commented Feb 7, 2017 reply Follow Share yup me too understood my mistake 0 votes 0 votes akankshadewangan24 commented Apr 24, 2017 reply Follow Share what is the no. of token in following printf("%d %d",a); 7 right "printf("%d %d",a);" no. of token is 9 right? correct me if i am wrong 0 votes 0 votes LeenSharma commented Apr 24, 2017 reply Follow Share akankshadewangan24 0 votes 0 votes srestha commented Apr 24, 2017 reply Follow Share Where do u got that concept of 6 token? Any reference? 0 votes 0 votes LeenSharma commented Apr 25, 2017 reply Follow Share srestha may be i am wrong here but i think anything come between " " is a token.Please correct me i am wrong. 0 votes 0 votes srestha commented Apr 25, 2017 reply Follow Share yes, then how u divide inside "...." and considered it separately? Even in the selected ans of this question also considered 14 token, how? 0 votes 0 votes Please log in or register to add a comment.
10 votes 10 votes Yes 34 is correct. Gate Mission 1 answered Jan 6, 2017 Gate Mission 1 comment Share Follow See 1 comment See all 1 1 comment reply Lucky sunda commented Jan 6, 2017 reply Follow Share Thanku very much :) 1 votes 1 votes Please log in or register to add a comment.
0 votes 0 votes Tokens: 1:: int 2:: main 3,4:: ( ) 5,6::{ } 7::int 8,9,10:: a,a,a 11,12,13:: b,b,b 14,15,16::c,c,c 17-24::=,,,,,;;; 25-30:: %%%ddd 31:: = 32:: + 33:: "printf(" 34:: ")" Source: http://www.personal.kent.edu/~rmuhamma/Compilers/MyCompiler/chapter3.htm Coreect me if I'm wrong! smartmeet answered Feb 7, 2017 smartmeet comment Share Follow See all 0 reply Please log in or register to add a comment.