Module parser :: Class Yappy_grammar
[hide private]
[frames] | no frames]

Class Yappy_grammar

source code

LRparser --+    
           |    
       Yappy --+
               |
              Yappy_grammar

A parser for grammar rules. See test() for an example.

Instance Methods [hide private]
 
__init__(self, no_table=1, table='yappypar.tab', tabletype=<class parser.LR1table at 0x15c9ad0>, **args)
@param tokenize: same as for L{Lexer} @param grammar: if a string C{parse_grammar} is called
source code
 
OPVRule(self, arg, context) source code
 
OPRule(self, arg, context) source code
 
OPSEMRule(self, arg, context) source code
 
OPSEMRule1(self, arg, context) source code
 
RHRule(self, arg, context) source code
 
RHSRule(self, arg, context) source code
 
MULTIRule(self, arg, context) source code
 
RULERule(self, arg, context) source code
 
GRule(self, args, context) source code
 
test(self)
A test for each class
source code

Inherited from Yappy: input, inputfile, parse_tree

Inherited from LRparser: __str__, gsrules, parse_grammar, parsing

Instance Variables [hide private]

Inherited from Yappy: lex

Inherited from LRparser: ACTION, GOTO, cfgr, context, nonterminals, output, rules, stack, table, terminals, tokens

Method Details [hide private]

__init__(self, no_table=1, table='yappypar.tab', tabletype=<class parser.LR1table at 0x15c9ad0>, **args)
(Constructor)

source code 

      @param tokenize: same as for L{Lexer}
      @param grammar: if a string C{parse_grammar} is called

      @param table: and no_table, tabletype same as for L{LRparser}

      @param **args: dictionary where:
      - key C{tmpdir} is the directory
where the parse table used by the Yappy Grammar is stored;
  -  key  C{usrdir} is the directory where the user tables are stored
  -  key  C{nosemrules} if 1 semantic actions are not applied
      

Parameters:
  • grammar - is a list for productions; each production is a tuple (LeftHandside,RightHandside,SemFunc,Prec?) with LeftHandside nonterminal, RightHandside list of symbols, SemFunc syntax-direct semantics, if present Prec (PRECEDENCE,ASSOC) for ambiguous rules

    First production is for start symbol

  • table_shelve - file where parser is saved
  • tabletype - type of LR table: SLR, LR1, LALR
  • no_table - if 0 table_shelve is created anyway
  • operators - precedence and associativity for operators
  • noconflicts - if 0 LRtable conflicts are not resolved, unless spcecial operator rules
  • expect - exact number of expected LR shift/reduce conflicts
  • args - extra arguments; key nosemrules if 1 no semantic rules are applied
Overrides: LRparser.__init__
(inherited documentation)

test(self)

source code 

A test for each class

Overrides: Yappy.test
(inherited documentation)