Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please help me in this project Store tokens in symbol table based on the above table. Should properly handle the comments enclosed in /* and
please help me in this project
Store tokens in symbol table based on the above table. Should properly handle the comments enclosed in /* and / or following // . Should properly handle the white spaces (blanks, tabs or newlines). Print all data stored in the symbol table just before exiting. If the input to your compiler contains something other than the lexemes mentioned in the table above, then it should generate and display the error with: - The line number - The unrecognized lexeme in the source code and - A meaningful error message For Syntax Analysis, if the input contains a legal expression involving operators + and and parenthesis (and), your compiler should accept it and display "Compiled Successfully". othewise give out error message with correct line number and a meaningful error message: Use the CFG and the Parsing Table given below for Syntax Analysis of the input. SLR (1) Parsing Table Action State id + - ) Goto T 2 F sa E-> E->ETIT T- SFF F9E) id s5 3 0 1 SE 1 accept 12 s6 2 57 12 14 12 14 14 GAN 55 54 00 8 2 3 r6 r6 r6 a r6 6 9 55 55 54 54 3 10 7 8 9 56 s11 ri r1 r3 s7 13 r5 10 11 w 13 15 15 int int Code and test a compiler in java that should perform following actions: Read input source code from the following file: "input.txt" . Give user the option to perform Lexical Analysis only or Lexical and Syntax Analysis both. (in case of Lexical and Syntax Analysis both, take one line input from the screen) Recognize following tokens for the lexemes in the input: Keywords: int char, string, if, else, do, while. Identifiers (id): letter followed by zero or more letters or digits. String Literal: (sl): anything that is surrounded by double quotes, for example "Hi" Int value (in): example: 155 Relational Operators (ro): = and > Arithmetic Operators (ao): +,-./ Other Operators (oo): assignment: 5parenthesis: (), braces: (. ), line terminator:;. Lexeme Token Name Attribute Store in Symbol Value Table or Not 0 yes char char 1 yes string string 2 yes if if 3 yes else else 4 yes do do 5 yes while while 6 yes any identifier id (next value) yes any string value in si (next value) yes double quotes any int value (next value) yes > no > + no no no . 8 8 8 8 8 8 8 8 aa aa a a no no = no no no no no Upon recognizing a token, should print the lexeme, the token name and the attribute value based on the above table Sample Input Source Code for Lexical Analysis only: int vall - 21; // to store a value int vala; int total; string purpose. "Calculation"; " to store calculation if (val > 10 ) { val2 = 5; } else { val2 . 10; } total - (vali + valz) vali; Sample Symbol Table: Attribute Value Token Name Type Value 0 int 1 char 2 string 3 4 5 6 7 else do while id in vall 8 9 Calculation Sample Input Source Code for Lexical Analysis and Syntax Analysis both: (val2 + vall).val3 Token Name Type Value int Sample Symbol Table: Attribute Value 0 1 2 3 4 5 6 7 char string if else do while id id id 8 9 val2 vall val3 Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started