Vectorized LR parsing of computer programs
First Claim
1. In a machine-effected method of operating a parser portion of a compiler for parsing a computer program in an input stream, said computer program being written in a predetermined programming language having a given grammar, including the machine-executed steps of:
- automatically generating a parser state table means having a plurality of state indicating entries, one entry means for indicating each possible state of the parser, each of said state indicating entries including a declaration of said predetermined programming language in said given grammar;
automatically generating a linearized vector table means having an input table including a given plurality of input entries respectively related to the parser state table means entries such that one or more of the input entries relate to a one of the state indicating entries, respectively, and an output table having a predetermined plurality of output entries, arranged said output entries to be identically addressable within the output table as the input entries are respectively addressed within the input table, said predetermined plurality of being equal to said given plurality; and
parsing the computer program in the input stream using the established parser state table means and said linearized table means.
11 Assignments
0 Petitions
Accused Products
Abstract
A parser for parsing computer programs in a compiler has parsing tables arranged as linear vectors. In a reduction portion of the parser, a production table and a lookahead set table have paired entries at identical address offsets such that a one-to-one relationship exists between each lookahead set in the lookahead set table and the representation of the lookahead set in the lookahead set table. In a read transition portion of the parser, an entrance symbol table has entries paired with transition state representations and each pair being at an identical address offset in the respective tables. For a reduction or read transition operation, the lookahead set table or the entrance symbol table is scanned to find the appropriate entry. Once the appropriate entry is found, the production table or the transition state table is addressed using the offset of the appropriate entry found during the scanning process.
97 Citations
11 Claims
-
1. In a machine-effected method of operating a parser portion of a compiler for parsing a computer program in an input stream, said computer program being written in a predetermined programming language having a given grammar, including the machine-executed steps of:
-
automatically generating a parser state table means having a plurality of state indicating entries, one entry means for indicating each possible state of the parser, each of said state indicating entries including a declaration of said predetermined programming language in said given grammar; automatically generating a linearized vector table means having an input table including a given plurality of input entries respectively related to the parser state table means entries such that one or more of the input entries relate to a one of the state indicating entries, respectively, and an output table having a predetermined plurality of output entries, arranged said output entries to be identically addressable within the output table as the input entries are respectively addressed within the input table, said predetermined plurality of being equal to said given plurality; and parsing the computer program in the input stream using the established parser state table means and said linearized table means. - View Dependent Claims (2, 3, 4, 5)
-
-
6. In a machine-effected method of parsing a computer program in an input stream having tokens in the input stream that represent a sequence of structure of the computer program, during said parsing, sequentially creating parser states that respectively indicate status of the syntactical analysis for verifying structure and specification of the computer program expressions, one of said parsing states being a current parser state that indicates a current parsing step, including the machine-executed steps of:
-
generating first look tables, each of said first look tables including entries in said first look tables for identifying the parser states; linear vector parsing means including generating an input means and generating input indicia in said input means such that each of the input indicia are in respective vectors, generating addresses for the input means having addresses respectively addressable from the first look tables, generating an output means including generating output indicia in said output means respectively in the same vectors as the input indicia; and parsing the computer program of the input stream including detecting a current parser state in the first look tables, then scanning the input indicia identifiable with the current parser state and then taking the output indicia in the respective vectors of the input indicia for reading a predetermined token from the input stream. - View Dependent Claims (7, 8, 9, 10)
-
-
11. In apparatus for parsing a computer program, including, in combination:
-
state means for indicating a current parser state; reduction means for reducing program expressions and including a production table having a first number of productions and a lookahead set table having a second number of lookahead set entries, said second number being equal to said first number, each of the productions being paired with a respective one of the lookahead set entries and each respective paired lookahead set and production having an identical offset address in the respective tables in the reduction means; read transition means for identifying read transitions in the computer program parsing and including an entrance symbol table having a second number of entrance symbols for entering respective ones of the parser states and a transition state table having a second number of representations of transition states, each of the entrance symbols being paired with a respective one of the transition states and being at an address offset in the entrance symbol table identical to the address offset of the respective paired representation of transition states; and parse loop means connected to the state means, to the reduction means and to the read transition means for activating either the reduction means or the read transition means for each state indicated in the state means and including changing the state indicated in the state means only when the transition means is used.
-
Specification