6 votes 6 votes Consider the following code $x = (y + 5) + (^*z) * 10 - x /3 $ Which of the following correctly identified by lexical analysis after scanning the above code? 5 Identifiers 3 literals 4 Identifiers 6 literals Compiler Design compiler-design lexical-analysis + – Mk Utkarsh asked Oct 22, 2018 Mk Utkarsh 1.9k views answer comment Share Follow See all 17 Comments See all 17 17 Comments reply Ashwani Kumar 2 commented Oct 22, 2018 reply Follow Share 4 identifier, 3 literals 0 votes 0 votes Shubhanshu commented Oct 22, 2018 reply Follow Share Ashwini are u considering x as two literals? 0 votes 0 votes Mk Utkarsh commented Oct 22, 2018 reply Follow Share Ashwani Kumar 2 why considering x as 2 identifiers? 0 votes 0 votes anonymous commented Oct 22, 2018 reply Follow Share Why will be only 3 literals? 0 votes 0 votes Mk Utkarsh commented Oct 22, 2018 reply Follow Share $5,10,3$ 0 votes 0 votes anonymous commented Oct 22, 2018 reply Follow Share So, The answer should be 3 identifiers and 3 literals. 0 votes 0 votes Ashwani Kumar 2 commented Oct 22, 2018 reply Follow Share Constant literals: 5, 10, 3 Identifiers: x, y, z x should be counted once... 0 votes 0 votes Mk Utkarsh commented Oct 22, 2018 reply Follow Share answer given is 4 Identifiers 0 votes 0 votes manisha11 commented Oct 22, 2018 reply Follow Share I think it should be 3,3 0 votes 0 votes anonymous commented Oct 22, 2018 reply Follow Share What is the number of tokens here ??? 0 votes 0 votes manisha11 commented Oct 22, 2018 reply Follow Share 18 (if we don't count *z as one, I am unsure about that) 0 votes 0 votes Mk Utkarsh commented Oct 22, 2018 reply Follow Share manisha11 *z is not one token $18$ is correct 0 votes 0 votes manisha11 commented Oct 22, 2018 reply Follow Share Okay and what if it is x += y? we will count that as 3/4? 1 votes 1 votes Mk Utkarsh commented Oct 22, 2018 reply Follow Share $3,$ += counted as single assignment operator 0 votes 0 votes manisha11 commented Oct 22, 2018 reply Follow Share Thanks a lot! 0 votes 0 votes I_am_winner commented Oct 23, 2018 reply Follow Share what will be answer for this acc to me it is 3 identifier 3 literals 18 tokens please verify 0 votes 0 votes Sanandan commented Oct 3, 2020 reply Follow Share 3 literals , 3 identifiers 0 votes 0 votes Please log in or register to add a comment.
1 votes 1 votes x=(y+5)+(∗z)∗10−x/3 Here, Identifiers are X, Y, Z. Literals are constant numbers 5, 10, 3. Wheras the rest are operators. So, answer is 3 Identifiers and 3 Literals. Refer this, https://www.cse.iitk.ac.in/users/karkare/cs335/lectures/04LexicalAanalysis.pdf muthu kumar answered Nov 11, 2018 muthu kumar comment Share Follow See all 0 reply Please log in or register to add a comment.