Logo Search packages:      
Sourcecode: gadfly version File versions  Download package

gadfly::kjParser::ParserObj Class Reference

List of all members.

Detailed Description

the parse class:
      Based loosely on Aho+Ullman, Principles of Compiler Design, Ch.6.
       except that they don't describe how to handle boundary
       conditions, I made them up myself.

      Note: This could be implemented using just functions; it's implemented
       as a class to facilitate diagnostics and debugging in case of
       failures of various sorts.

    a parse accepts
      a rule list

      a lexically analysed stream with methods
        stream.getmember()  returns the current token on the stream
        stream.next()  moves on to next token
        stream.more()     returns false if current token is the last token

      and a FSM (finite state machine) with methods
          the nonterminal at which to start parsing
          the initial state to start at
          the final state to go to upon successful parse
          returns either
             (TERMFLAG, 0)
                if Current_State is terminal (final or reduction).
             (NOMATCHFLAG, 0)
                if Current_State is nonterminal, but the Current_Token
                and Next_Token do not lead to a valid state in the FSM
             (MOVETOFLAG, Next_State)
                if Current_State is nonterminal and Current_Token,
                Next_token map to Next_State from Current_State.
             (REDUCEFLAG, Rulenum)
                if Current_State indicates a reduction at Current_Token
                for rule Rule number Rule

       and a Stack with methods (replaced with dictionary)
             (init: {-1:0} )
          Stack.Top() returns top of stack (no pop)
             ( Stack[Stack[-1]] )
             ( Stack[-1]=Stack[-1]+1; Stack[Stack[-1]]=Object )
             ( Stack[-1]=0 )
             ( Stack[-1] == 0 )
             ( Stack[-1] = Stack[-1]-1 )
          stack contents created by Parser will be of form (State,Value)
          where Value was inserted at FSM state State.
          Value of form either (KEYFLAG, Name)
                               (NontermName, reductionvalue)
                            or (TerminalName, value)

       and an optional parameter Evaluate which if 0 indicates that
          rules should be evaluated, otherwise indicates that rules
          should just be reduced and the reduction structure should
          be used as the result of the rule

    rule objects must support methods
          pops off the elements corresponding to the body of the Rule
          from the stack and returns (NewStack,Red) where NewStack is
          the stack minus the body and Red is the result of evaluating the
          reduction function on this instance of the rule.
          the nonterminal at the head of the rule

Definition at line 588 of file kjParser.py.

Public Member Functions

def __init__
def DoOneReduction
def GO
def GotoState
def ParseError
def StackDump

Public Attributes


The documentation for this class was generated from the following file:

Generated by  Doxygen 1.6.0   Back to index