Module parser :: Class Yappy
[show private | hide private]
[frames | no frames]

Class Yappy

LRparser --+
           |
          Yappy

Known Subclasses:
Yappy_grammar

A basic class for parsing.
Method Summary
  __init__(self, tokenize, grammar, table, no_table, tabletype, noconflicts, expect, **args)
@param tokenize: same as for L{Lexer}...
  input(self, str, context, lexer)
Reads from stdin or string and retuns parsed result
  inputfile(self, FileName, context)
Reads input from file
  parse_tree(self)
To be defined using output
  test(self)
A test for each class
    Inherited from LRparser
  __str__(self)
Return the LR parsing table showing for each state the action and goto function
  gsrules(self, rulestr, **sym)
Transforms a string in a grammar description
  parse_grammar(self, st, context, args)
Transforms a string into a grammar description
  parsing(self, tokens, context)
LR Parsing Algorithm (aho86:_compil, page 218)

Instance Variable Summary
  lex: a Lexer object
    Inherited from LRparser
  ACTION: Action function
  cfgr: context free grammar
  context: computational context
  GOTO: Goto function
  nonterminals: grammar nonterminals
  output: list of grammar rules used for parsing tokens (right derivation in reverse)
  rules: grammar rules
  stack: LR stack with pairs (state,token)
  table: LR parsing table
  terminals: grammar terminals
  tokens: tokens to be parsed

Method Details

__init__(self, tokenize, grammar, table='YappyTab', no_table=1, tabletype=<class parser.LALRtable at 0x3009c900>, noconflicts=1, expect=0, **args)
(Constructor)

@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
Overrides:
parser.LRparser.__init__

input(self, str=None, context={}, lexer=0)

Reads from stdin or string and retuns parsed result
Parameters:
str - String to be parsed. If not given, reads from stdin.
context - some initial computational context
lexer - if 1 only lexical analisys is performed
Returns:
a tuple (parsed result,context) or only the parsed result

inputfile(self, FileName, context={})

Reads input from file

parse_tree(self)

To be defined using output

test(self)

A test for each class

Instance Variable Details

lex

a Lexer object

Generated by Epydoc 2.1 on Wed Jul 19 10:36:01 2006 http://epydoc.sf.net