Page 1 of 1

Task 1: For the following sample program find all the tokens. Note that a lexical Analyzer is responsible for 1. Scan In

Posted: Sun Jul 03, 2022 10:00 am
by answerhappygod
Task 1: For the following sample program find all thetokens.Note that a lexical Analyzer is responsible for1. Scan Input2. Remove WS, NL, ...3. Identify Tokens4. Create Symbol Table (ST)
in python5. Insert Tokens into ST6. Generate Errors7. Send Tokens to Parser
Fig 1: Lexical Analyzer
Input:int a, b, c;float d, e;a = b = 5;c = 6;if ( a > b){
Page 4 of
c = a - b;e = d - 2.0;}else{d = e + 6.0;b = a + c;}Output:Keywords: int, float, if, elseIdentifiers: a, b, c, d, eMath Operators: +, -, =Logical Operators: >Numerical Values: 5, 6, 2.0, 6.0Others: , ; ( ) { }