Friday, January 8, 2010

Table (Parser)

One last thing is needed before the Parser can be implemented is the Table, so named because it contains a list of the all operators and the precedence priority used in the conversion to the RPN format. However, it is also a good place to list all the commands and have them in one place, so there is only one table to search through or use during source recreation.

Eventually the Table will have many fields in it, but these will be added as needed. But for now, for the Parser, the fields that are needed are:

    string – the characters of the entry
    type – the type of the entry
    data type – data type of the entry
    code – a code for the entry
    two flag – command can have two words or operator can have two characters flag

The type is the same as used for the token, except here the possible values used by the parser are:

    COMMAND
    OPERATOR
    INTFUNC
    REMARK

There will eventually be entries for CONSTANT, DEFFUNC, VARIABLE, ARRAY, GENFUNC, SUBROUTINE, etc. These entries won't contain string values so the parser will not search these. The purpose is for the Run Time and Recreator because the entries will contain function pointers to the Run Time and Recreator routines to handle these different program elements.

The need for a two word flag for commands and two character flag for operators has been previously explained in posts Parsing Identifiers and Parsing Operators. Since only commands need the two word flag and operators need the two character flag, there is only a need to have one flag, so it will be called the two flag.

No comments:

Post a Comment

All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)