"> Implementation -- Parsers

Implementation--
Parsers


There are two levels of parsers built into SimPlan. One is a statement type parser used by the slicing mechanism to identify the type of each statement for building the symbol table, flow control list and slice list. The other is an expression parser/evaluator used in the simulation to calculate values for variables from expressions.


The statement level parser:

The statement level parser is part of the slicing mechanism. It helps identify which statements require entries in the Symbol Table, Flow Control List and Slice List. It keys off of certain parts of each statement to identify the statement type. The statement type keys, in order of precedence, are:

        Statement Type:             Key:
        ---------------             ----
        Close Program Block         "]"
        Open Program Block          "["
        Assertion                   "{"
        Assignment                  " := "
        Declaration                 "declare "
        Conditional Transfer        "if "
        Loop                        "while "
        Unconditional Transfer      "goto "
        Skip                        "skip" or solitary " ;"
        
Only one key should be used in any one line of code. If more than one key is used in a single line of code, the results are unpredictable causing a corrupt Flow Control List and Slice List.


The expression parser/evaluators:

The expression parser/evaluators are part of the simulation phase. They are used to calculate truth values for conditions in "if" and "while" statements and values for other expressions. One deals solely with boolean expressions; the other deals with arithmetic expressions. The standard operator precedence is used:

        Arithmetic expressions
        ----------------------
        values of constants
        substitution of values for variables
        evaluation of expressions in parens.
        evaluation of unary minus
        evaluation of * and integer division
        evaluation of + and binary -

        Boolean expressions
        -------------------
        values of truth value constants
        substitution of truth values for variables
        evaluation of expressions in parens.
        evaluation of relational operators and the accompanying arithmetic expressions
        evaluation of NOT
        evaluation of AND
        evaluation of OR
        
See the language syntax and operational semantics for more details.


Related include files:


Return ...


Andrew Tompkins
Beaverton, OR 97006
Last rev: 17 JUL 03
URL:
http://home.comcast.net/~andytom/simplan.docs/control/parsers.html

Valid XHTML 1.0!