3 votes 3 votes Which of the following phases update the symbol table ? Lexical analysis, syntax analysis and semantic analysis . Please also tell what kind of updates a phase performs if it updates symbol table. Compiler Design compiler-design symbol-table + – Xylene asked Aug 8, 2017 Xylene 1.5k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes In Lexical analysis symbol table created to store keywords inside it to get all information about their values and their properties. Syntax analysis or parsing is the second phase of a compiler. lexical analyzer cannot check the syntax of a given sentence due to the limitations of the regular expressions. Regular expressions cannot check balancing tokens, such as parenthesis. Therefore, this phase uses context-free grammar (CFG), which is recognized by push-down automata. CFG, on the other hand, is a superset of Regular Grammar, In Semantic analysis ,fill in information about the symbol later during semantic analysis when more information about the variable is known. as Code generation uses the symbol table to output assembler directives of the appropriate size and type. for more information read this:- https://web.cs.wpi.edu/~kal/courses/cs4533/module5/myst.html learner_geek answered Aug 8, 2017 edited Aug 8, 2017 by learner_geek learner_geek comment Share Follow See all 4 Comments See all 4 4 Comments reply Xylene commented Aug 8, 2017 reply Follow Share I read that symbol table is updated in analysis phase which includes lexical , syntax and semantic analysis and this information is used in synthesis phase. Still confused. 0 votes 0 votes saxena0612 commented Aug 8, 2017 reply Follow Share From my point of view the question you asked is all about updation that in semantics analysis the table is again updated after the lexical phase generation because the semantics checks the type and other attributes like scope etc and thus again store it in table for future reference.Though in lexical phase symbol table is first generated for the program. https://stackoverflow.com/questions/9703227/symbol-table-population-after-parsing-compiler-building See this for reference . Read the very first comment its quite good actually! 0 votes 0 votes Xylene commented Aug 8, 2017 reply Follow Share I don't understand how semantic phase updates the symbol table. It just uses the symbol table right ? What updates will semantic phase perform? 0 votes 0 votes shivangi5 commented Sep 4, 2017 reply Follow Share semantic phase would perform the following. Variable not declared multiple times Variable declared before assigned Variable assigned before referenced Assignment compatible with declared type Operations on variables compatible with type 0 votes 0 votes Please log in or register to add a comment.