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

Class LRtable

Known Subclasses:
LALRtable1, LR1table, SLRtable

Class for construction of a LR table
Method Summary
  __init__(self, cfgr, operators, noconflicts, expect)
  add_action(self, i, a, action, j)
Set (action,j) for state i and symbol a or raise conflict error.
  make_action_goto(self)
make action[i,X] and goto[i,X] All pairs (i,s) not in action and goto dictionaries are 'error'
  resolve_shift_reduce(self, i, a, s, r)
Operators precedence resolution or standard option: shift
  rules_precedence(self)
Rule precedence obtained as the precedence of the right most terminal.

Instance Variable Summary
  gr: a context-free grammar
  Log: Log report for LR table construction
  operators: operators

Method Details

__init__(self, cfgr, operators=None, noconflicts=1, expect=0)
(Constructor)

Parameters:
cfgr - a context-free grammar
operators - operators
noconflicts - if 0 LRtable conflicts are not resolved, unless for spcecial operator rules
           (type=integer)
expect - exact number of expected LR shift/reduce conflicts
           (type=integer)

add_action(self, i, a, action, j)

Set (action,j) for state i and symbol a or raise conflict error. Conficts are resolved using the following rules:
  • shift/reduce: if precedence/assoc information is available
try to use it; otherwise conflict is resolved in favor of shift
  • reduce/reduce: choosing the production rule listed first

make_action_goto(self)

make action[i,X] and goto[i,X] All pairs (i,s) not in action and goto dictionaries are 'error'

resolve_shift_reduce(self, i, a, s, r)

Operators precedence resolution or standard option: shift

s: rule for shift r: rule for reduce

rules_precedence(self)

Rule precedence obtained as the precedence of the right most terminal.

Instance Variable Details

gr

a context-free grammar

Log

Log report for LR table construction

operators

operators

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