GATE CSE
First time here? Checkout the FAQ!
x
+2 votes
34 views
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 Active (1.8k points)   | 34 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:-

                                                                        https://web.cs.wpi.edu/~kal/courses/cs4533/module5/myst.html

answered by Active (2.4k points)  
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.

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!

I don't understand how semantic phase updates the symbol table. It just uses the symbol table right ? What updates will semantic phase perform?


Top Users Aug 2017
  1. ABKUNDAN

    4670 Points

  2. Bikram

    4556 Points

  3. akash.dinkar12

    3420 Points

  4. rahul sharma 5

    3118 Points

  5. manu00x

    2864 Points

  6. makhdoom ghaya

    2450 Points

  7. just_bhavana

    2136 Points

  8. Tesla!

    2042 Points

  9. stblue

    1930 Points

  10. joshi_nitish

    1686 Points


24,969 questions
32,072 answers
74,565 comments
30,147 users