Definition (declaration) of identifiers

116 views 10:43 am 0 Comments July 26, 2023

compiler: * Associates attributes with identifiers used in a program * For instance, a type attribute is usually associated with each identifier A symbol table is a necessary component Definition (declaration) of identifiers appears once in a program + Use of identifiers may appear in many places of the program text * Identifiers and attributes are entered by the analysis phases → When processing a definition (declaration) of an identifier + In simple languages with only global variables and implicit declarations: • The scanner can enter an identifier into a symbol table if it is not already there ✓ In block-structured languages with scopes and explicit declarations: The parser and/or semantic analyzer enter identifiers and corresponding attributes * Symbol table information is used by the analysis and synthesis phases + To verify that used identifiers have been defined (declared) * To verify that expressions and assignments are semantically correct – type checking → To generate intermediate or target code Symbol Tables, Hashing and Hash Tables-1 From your past knowledge and after reading the above slide, answer Q(1-3) 1- Symbol Table is used for a) Checking Type compatibility b) Storage allocation c) checking duplicate identifiers errors d) all above 2- Symbol table is filled during the a) Lexical b) Syntax c) Semantic d) Intermediate code optimization e) object code generation 3- The access time of the symbol table will be linear if it is implemented by a) linear list b) binary search tree Mid exam LT I Jan, 2022, _phase. 4- Which of the following statements may not produce executable code when compiled? a) Declaration (int I;) b) Assignment statement (I=3+6;) c) print statement (print (I); ) d) Structural statement ( for, while, if ) 5- The output of a lexical analyzer is a) a parse tree b) intermediate code. c) machine code d) a stream of tokens such as token table. Compiler Design-O Malammed Madawwar c) at the same speed d) may be faster or slower Name: 6- Relative to the program translated by a compiler, the same program when interpreted runs a) faster b) slower 1 من 4 7-Which of the following comparisons between static and dynamic type checking is incorrect? a) Dynamic type checking slows down the execution b) Dynamic type checking offers more flexibility to the programmers. c) In contrast to static type checking, dynamic type checking may cause failure in runtime due to type errors. d) Unlike static type checking, dynamic type checking is done durin

Tags: , , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *