Compiler Writing

Bottom-Up Parsing (Compiler Writing) Part 11

LALR(l) Parsers In this subsection we present a parsing technique known as LALR(\) parsing. This method of parsing is similar to but more powerful than the SLR{ 1) method because it uses lookahead information which can be obtained, for example, from the construction process given in the previous subsection. Although an LALR( 1) parser is […]

Bottom-Up Parsing (Compiler Writing) Part 12

Representation and Optimization of LR Parsers Thus far in this topic we have represented the F and G functions by two-dimensional matrices. Such representations are very efficient from a table-lookup standpoint. Since parsers for typical programming languages contain hundreds of states, the space requirements for storing the matrices can be very considerable. It has been […]

Bottom-Up Parsing (Compiler Writing) Part 13

Error Detection and Recovery in LR Parsers Acceptable error recovery, which often involves some error repair, has been difficult to incorporate within LR, SLR, and LALR parsers. This section outlines some of the approaches to error detection and recovery, concentrating on recent efforts in implementing error-repair strategies based upon the context surrounding the error point […]

Bottom-Up Parsing (Compiler Writing) Part 14

COMPARISON OF PARSING METHODS Throughout the last two topics we have presented several parsing methods Each method is usually associated with a class of grammars. All parsing methods. That is, the time taken to parse a given input string is proportional to the number of tokens in that string. This section briefly compares most of […]

Symbol-Table-Handling Techniques (Compiler Writing) Part 1

Symbol tables (also called identifier tables and name tables) assist two important functions in the translation process: in checking for semantic (i.e., context-sensitive) correctness and aiding in the proper generation of code. Both of these functions are achieved by inserting into, and retrieving from the symbol table, attributes of the variables used in the source […]

Symbol-Table-Handling Techniques (Compiler Writing) Part 2

Ordered Symbol Tables In this and the following two subsections, we describe symbol-table organizations in which the table position of a variable’s set of attributes is based on the variable’s name. In such circumstances, an insertion must be accompanied by a lookup procedure which determines where in the symbol table the variable’s attributes should be […]

Symbol-Table-Handling Techniques (Compiler Writing) Part 3

Hash Symbol Tables The best search methods for the symbol-table organizations we have discussed so far have had an average length of search requiring on the order of log2« comparisons. In this section we investigate an organization in which the search time is essentially independent of the number of records in the table (i.e., the […]

Symbol-Table-Handling Techniques (Compiler Writing) Part 4

SYMBOL-TABLE ORGANIZATIONS FOR BLOCK-STRUCTURED LANGUAGES In this section we concentrate on the problems of symbol-table handling when compiling block-structured languages. By a block-structured language we mean a language in which a module can contain nested submodules and each submodule can have its own set of locally declared variables. A variable declared within a module A […]

Run-Time Storage Organization and Management (Compiler Writing) Part 1

Thus far we have concentrated on those parts of the compiler that are responsible for recognizing the syntactic correctness of a program. In the remainder of the text, the synthesis part of the compilation process is highlighted. Before we can begin to consider the generation of code for the constituent parts of a program (as […]

Run-Time Storage Organization and Management (Compiler Writing) Part 2

Run-Time Address Calculation We are now in a position to formalize a procedure for run-time address calculation in our dynamic storage-allocation model. Given a variable with a tuple address of (BL, ON) that is accessible in a block at level LEV, the address ADDR of the variable is found as follows: where abp means the […]