Package nltk_lite :: Package draw :: Module cfg :: Class CFGEditor
[show private | hide private]
[frames | no frames]

Type CFGEditor

object --+
         |
        CFGEditor


A dialog window for creating and editing context free grammars. CFGEditor places the following restrictions on what CFGs can be edited:
Method Summary
  __init__(self, parent, cfg, set_cfg_callback)
  _analyze(self, *e)
Replace -> with arrows, and colorize the entire buffer.
  _analyze_line(self, linenum)
Colorize a given line.
  _analyze_token(self, match, linenum)
Given a line number and a regexp match for a token on that line, colorize the token.
  _apply(self, *e)
  _cancel(self, *e)
  _check_analyze(self, *e)
Check if we've moved to a new line.
  _clear_tags(self, linenum)
Remove all tags (except arrow and sel) from the given line of the text widget used for editing the productions.
  _destroy(self, *e)
  _help(self, *e)
  _init_bindings(self)
  _init_buttons(self)
  _init_nonterminal_tag(self, tag, foreground)
  _init_prodframe(self)
  _init_startframe(self)
  _mark_error(self, linenum, line)
Mark the location of an error in a line.
  _ok(self, *e)
  _parse_productions(self)
Parse the current contents of the textwidget buffer, to create a list of productions.
  _replace_arrows(self, *e)
Replace any '->' text strings with arrows (char \256, in symbol font).
  _reset(self, *e)
Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Variable Summary
str ARROW = '\xde'
SRE_Pattern _ARROW_RE = \s*(->|(Þ))\s*
tuple _BOLD = ('helvetica', -12, 'bold')
SRE_Pattern _LHS_RE = (^\s*\w+\s*)(->|(Þ))
SRE_Pattern _PRODUCTION_RE = (^\s*\w+\s*)(->|(Þ))\s*((\w+|'[\w ]*'|"...
SRE_Pattern _TOKEN_RE = \w+|->|'[\w ]+'|"[\w ]+"|(Þ)

Method Details

_analyze(self, *e)

Replace -> with arrows, and colorize the entire buffer.

_analyze_line(self, linenum)

Colorize a given line.

_analyze_token(self, match, linenum)

Given a line number and a regexp match for a token on that line, colorize the token. Note that the regexp match gives us the token's text, start index (on the line), and end index (on the line).

_check_analyze(self, *e)

Check if we've moved to a new line. If we have, then remove all colorization from the line we moved to, and re-colorize the line that we moved from.

_clear_tags(self, linenum)

Remove all tags (except arrow and sel) from the given line of the text widget used for editing the productions.

_mark_error(self, linenum, line)

Mark the location of an error in a line.

_parse_productions(self)

Parse the current contents of the textwidget buffer, to create a list of productions.

_replace_arrows(self, *e)

Replace any '->' text strings with arrows (char \256, in symbol font). This searches the whole buffer, but is fast enough to be done anytime they press '>'.

Class Variable Details

ARROW

Type:
str
Value:
'\xde'                                                                 

_ARROW_RE

Type:
SRE_Pattern
Value:
\s*(->|(Þ))\s*                                                         

_BOLD

Type:
tuple
Value:
('helvetica', -12, 'bold')                                             

_LHS_RE

Type:
SRE_Pattern
Value:
(^\s*\w+\s*)(->|(Þ))                                                   

_PRODUCTION_RE

Type:
SRE_Pattern
Value:
(^\s*\w+\s*)(->|(Þ))\s*((\w+|'[\w ]*'|"[\w ]*"|\|)\s*)*$               

_TOKEN_RE

Type:
SRE_Pattern
Value:
\w+|->|'[\w ]+'|"[\w ]+"|(Þ)                                           

Generated by Epydoc 2.1 on Tue Sep 5 09:37:21 2006 http://epydoc.sf.net