First time here? Checkout the FAQ!
+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.
asked in Compiler Design by Loyal (4.4k points) 3 21 74 | 62 views

1 Answer

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:-


answered by Loyal (3k points) 14 42
edited by
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.

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.
See this for reference . Read the very first comment its quite good actually!

I don't understand how semantic phase updates the symbol table. It just uses the symbol table right ? What updates will semantic phase perform?
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

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
Top Users Oct 2017
  1. Arjun

    23678 Points

  2. Bikram

    17268 Points

  3. Habibkhan

    8950 Points

  4. srestha

    6446 Points

  5. Debashish Deka

    5478 Points

  6. jothee

    5128 Points

  7. Sachin Mittal 1

    4882 Points

  8. joshi_nitish

    4486 Points

  9. sushmita

    4032 Points

  10. Rishi yadav

    3974 Points

Recent Badges

Popular Question RISHI GUPTA 1
Popular Question Hira Thakur
Notable Question amaity
Notable Question srestha
Nice Answer Madhab
Renewal Madhab
Popular Question sourabh
Notable Question K ANKITH KUMAR
Great Answer saloni
Resurrection saloni
27,406 questions
35,255 answers
33,454 users