Data Structures in Compiler

Token
  • Represented by an integer value or an enumeration literal
  • Sometimes, it is necessary to preserve the string of characters that was scanned
  • For example, name of an identifiers or value of a literal
Syntax Tree
  • Constructed as a pointer-based structure
  • Dynamically allocated as parsing proceeds
  • Nodes have fields containing information collected by the parser and semantic analyzer
 Symbol Table
  • Keeps information associate with all kinds of identifiers:
Constants, variables, functions, parameters, types, fields, etc.
  • Identifiers are entered by the scanner, parser or semantic analyzer
  • Semantic analyzer adds type information and other attributes
  • Code generation and optimization phases use the information in the symbol table
  • Insertion, deletion and search operation needed to efficient because they are frequent
  • Hash table with constant time operations is usually the preferred choice
  • More than one symbol table may be used
Literal Table
  • Stores constant values and string literal in a program
  • One literal table applies globally to the entire program
  • Used by the code generator to:
            Assign addresses for literals
            Enter data definitions in the target code file
  • Avoids the replication of constants and strings
  • Quick insertion and lookup are essential. Deletion is not necessary
Temporary Files
  • Used historically by old compilers due to memory constraints
  • Hold the data of various stages
Share on Google Plus

About Data Sciences by Venu

Hi, My name is Venugopala Chary and I'm Currently working as Associate Professor in Reputed Engineerng College, Hyderabad. I have B.Tech and M.tech in regular from JNTU Hyderabad. I have 11 Years of Teaching Experience for both B.Tech and M.Tech Courses.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment