Preview

Symbol Table

Better Essays
Open Document
Open Document
1792 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Symbol Table
SYMBOL TABLES
A compiler uses a symbol table to keep track of scope and binding information about names. The symbol table is searched every time a name is encountered in the source text. Changes to the symbol table occur if a new name or new information about an existing name is discovered. A symbol table mechanism must allow us to add new entries and find existing entries. The two symbol table mechanisms are linear lists and hash tables. Each scheme is evaluated on the basis of time required to add n entries and make e inquiries. A linear list is the simplest to implement, but its performance is poor when n and e are large. Hashing schemes provide better performance for greater programming effort and space overhead. It is useful for a compiler to be able to grow the symbol table dynamically at compile time. If the symbol table is fixed when the compiler is written, the size must be chosen large enough to handle any source program that might be presented. SYMBOL-TABLE ENTRIES Each entry in the symbol table is for the declaration of a name. The format of entries does have to be uniform, because the information saved about a same depends on the usage of time. Each entry can be implemented as a record consisting of a sequence of consecutive words of memory. To keep symbol table entries uniform, it may be convenient for some of the information about a name to be kept outside the table entry, with only a pointer to this information stored in the record. Information is entered into the symbol table at various times. Keywords are entered initially. The lexical analyzer looks up sequences of letters and digits in the symbol table to determine if a reserved keyword or a name has been collected. With this approach, keywords must be in the symbol table before lexical analysis begins. Alternatively, if lexical analyzer intercepts reserved keywords, they should be entered into the symbol table with a warning of their possible

You May Also Find These Documents Helpful

  • Satisfactory Essays

    This week learning assignment is based on Unit 8 Chapter 6 reading of the textbook about the elements of a computing system that focus on the selections relevant for supporting programs with symbols.…

    • 288 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Nt1310 Unit 3 Quiz

    • 6337 Words
    • 26 Pages

    What is the primary purpose of the __P() macro? Choice 1 The __P() macro has no function, and merely obfuscates library function declarat ions. It should be removed from further releases of the C library. Choice 2 The __P() macro provides forward compatibility for C++ compilers, which do not r ecognize Standard C prototypes. Choice 3 Identifiers that begin with two underscores are reserved for C library implement ations. It is impossible to determine the purpose of the macro from the context given. Choice 4 The __P() macro provides backward compatibility for K&R C compilers, which do no t recognize Standard C prototypes. Choice 5 The __P() macro serves primarily to differentiate library functions from applica tion-specific functions. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /*question number 68*/ Which one of the following is NOT a valid identifier? Choice 1 __ident Choice 2 auto [Ans] Choice 3 bigNumber Choice 4 g42277 Choice 5 peaceful_in_space - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /*question number 69*/ /* Read an arbitrarily long string. */ Code: int read_long_string (const char ** const buf) { char * p = NULL; const char * fwd = NULL; size_t len = 0; assert(buf); do { p = realloc(p, len += 256); if (!p) return 0; if (!fwd) fwd = p; else fwd = strchr(p, '\0'); } while (fgets(fwd, 256, stdin)); *buf =…

    • 6337 Words
    • 26 Pages
    Good Essays
  • Good Essays

    Keyword that tells the compiler that the data type of the identifier is a number.…

    • 703 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Homework Week 2

    • 743 Words
    • 3 Pages

    A compiler translates one computer language into another. It also pics up errors in the program being put together.…

    • 743 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    This paper will describe the variable naming rules of three different programming languages. These three languages are Visual Basic, Python, and Java. Each of these languages has different rules that apply to them and some similarities. I will describe the rules and the similarities and differences in the next few paragraphs.…

    • 878 Words
    • 4 Pages
    Good Essays
  • Good Essays

    Unit 16 Ao1

    • 529 Words
    • 3 Pages

    Programs need to store data at some time during the execution of processes. Data is held in variables which are names containers for each piece of data. Each variable must be given a name so it can be referred to again and again throughout the program. It should be something that is recognisable because for example variable 1 would be soon forgotten in a substantial piece of code. Variable names cannot be the same as code words such as print or run.…

    • 529 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Comp 220

    • 1463 Words
    • 6 Pages

    Pointers also have the requirement that the pointer type must be of the same data type as the variable, or the data that it points to or holds the address of. The power of pointers also hints at the potential complexity of their use, which is why this lab is focused almost entirely on several different aspects and uses of pointers. The lab also introduces pointer arrays and pointers to pointers.…

    • 1463 Words
    • 6 Pages
    Good Essays
  • Good Essays

    What uses keywords plus special symbols to find the exact information you want by eliminating results that are too general or too broad?…

    • 1566 Words
    • 7 Pages
    Good Essays
  • Good Essays

    It allows you to search for an item and its variations by entering the root of the term. An example would be: color, colour.…

    • 310 Words
    • 2 Pages
    Good Essays
  • Better Essays

    ii. The optional keyword static is used to declare a special kind of variable called a class variable. Class variables will be discussed in another lecture.…

    • 939 Words
    • 4 Pages
    Better Essays
  • Satisfactory Essays

    Is3110 Chapter 1

    • 789 Words
    • 4 Pages

    | 2. The determination of database requirements is part of a process known as systems development.…

    • 789 Words
    • 4 Pages
    Satisfactory Essays
  • Better Essays

    In addition, assembly language allows programmers to utilize symbolic addresses to replace numeric memory addresses in binary bits to execute a command or input data. Computer specialist can link symbolic labels to an instruction or piece of data in the program. In other words, the symbolic label turns into a permanent tag for the instruction or piece of data disregarding where it populates in the program or where it relocates in the memory. However, machine language is more complicated. To perform an instruction or input data in the memory in a specific location, the computer specialist must specify the direct address. For example, “In machine language, to jump to the instruction stored in memory location 18, you must specify directly to address 18 (write JUMP…

    • 2002 Words
    • 9 Pages
    Better Essays
  • Satisfactory Essays

    Week 3

    • 754 Words
    • 4 Pages

    7. A field identified in a table as holding the unique identifier of the table's records is called the (Points : 1)…

    • 754 Words
    • 4 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Miss

    • 274 Words
    • 2 Pages

    * It is like a library that contains all categories of identifiers that makes it easier and reduces number of codes. It is used as a prefix before the local name.…

    • 274 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    residences

    • 735 Words
    • 8 Pages

    iPads, iPhones, and iPods are only allowed to download apps from the iTunes App Store, and while apps are available from other sources, using them requires an unauthorized change to the device's software called a(n) ____.…

    • 735 Words
    • 8 Pages
    Satisfactory Essays

Related Topics