4 votes 4 votes The number of tokens in the following expression is? + * * * < = & > { - + + + } ( >> ) + & & Compiler Design compiler-design lexical-analysis + – vaishali jhalani asked Nov 22, 2016 vaishali jhalani 1.4k views answer comment Share Follow See 1 comment See all 1 1 comment reply PallabiC commented Feb 18, 2017 reply Follow Share As ++ is used to increment the value we are taking it as single token. But In this case * is used as multiplication operation.That's why 3 separate tokens. Am I right? 0 votes 0 votes Please log in or register to add a comment.
17 votes 17 votes + * * * < = & > { - ++ + } ( >> ) + & & Totally 17 Prajwal Bhat answered Nov 22, 2016 Prajwal Bhat comment Share Follow See all 4 Comments See all 4 4 Comments reply Vishal Goyal commented Apr 11, 2017 reply Follow Share & & are two tokens na why did you take it as one token 0 votes 0 votes nailwalhimanshu commented Oct 4, 2017 reply Follow Share We have taken && as one token because it stands for logical AND in C. 0 votes 0 votes gabbar commented Nov 3, 2017 reply Follow Share 17 or 18 ? 0 votes 0 votes reboot commented Aug 22, 2020 reply Follow Share @nailwalhimanshu but isn’t their space between both &s ? 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes 17 tokens in total kmr_ndrsh answered Dec 3, 2016 kmr_ndrsh comment Share Follow See all 0 reply Please log in or register to add a comment.
–1 votes –1 votes Ans is 16.. + ** * < = & > { - ++ + } ( >> ) + & & I think longest match rule is applied. vaishali jhalani answered Nov 22, 2016 vaishali jhalani comment Share Follow See all 8 Comments See all 8 8 Comments reply Prajwal Bhat commented Nov 22, 2016 reply Follow Share AFAIK It should be 17 3 votes 3 votes sudsho commented Nov 22, 2016 reply Follow Share @vaishali ** is not defined in C....they are 2 separate tokens 2 votes 2 votes Sri commented Dec 9, 2016 reply Follow Share I have a doubt. Can't we just divide "<=" to "<" and "=" as separate tokens? 0 votes 0 votes sudsho commented Dec 9, 2016 reply Follow Share u can divide...but lexical analyser will not..it follows longest matching rule... 2 votes 2 votes sh!va commented Dec 9, 2016 reply Follow Share If it was C++, then ++ will be counted as signle token? 0 votes 0 votes sudsho commented Dec 9, 2016 reply Follow Share @sh!va yes...we pre define the regular expressions for lexical analyser based on our compiler..if it's C or C++ then all identifiers,keywords etc will be treated the same and tokens will be generated regarding them...since ++ is define in C it will be treated as single token following longest match...but +++ will be treated like ++ as one token and next + as one token.. 1 votes 1 votes Karthik Akula commented Dec 10, 2016 reply Follow Share longest match rule if i wanna try to search your name i will type m & ot wills how all names start with m then i type ma then iw ill show name starts wil ma so it goes & finally i will type marco and it will show name with marco. so it will not show other m name which does not have arco after . so longest match. same happens with destination network address matching of a packet with network address of routes in routing table. 1 votes 1 votes LeenSharma commented Apr 24, 2017 reply Follow Share Answer should be 17.Arjun sir can u please clarify why we are taking *** as 2 tokens not as 3. 2 votes 2 votes Please log in or register to add a comment.