Home | Trees | Indices | Help |
|
---|
|
??-158 --+ | ??-159 --+ | Category
A Category
is a wrapper for feature dictionaries,
intended for use in parsing. It can act as a
Nonterminal
.
A Category
acts like a dictionary, except in the
following ways:
repr()
representation of a Category, the head goes
to the left, on the outside of the brackets. Subclasses of
Category
may change the feature name that is designated
as the head, which is _head by default.
Categories can contain any kind of object as their values, and can be recursive and even re-entrant. Categories are not necessarily "categories all the way down"; they can contain plain dictionaries as their values, and converting inner dictionaries to categories would probably lead to messier code for no gain.
Because Categories can contain any kind of object, they do not try to keep control over what their inner objects do. If you freeze a Category but mutate its inner objects, undefined behavior will occur.
|
|||
|
|||
|
|||
|
|||
bool
|
|
||
|
|||
|
|||
|
|||
bool
|
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Category
|
|
||
str or None
|
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
|||
|
|
|||
headname = 'head'
|
|||
yaml_tag = '!parse.Category'
|
|||
_PARSE_RE = {'name': re.compile(r'\s*([^\s\(\)"\'=,\[\]/\?]+)\
|
|
|
Compare Categories for equality. This relies on Python's built-in __eq__ for dictionaries, which is fairly thorough in checking for recursion and reentrance.
|
Freezing a Category memoizes its hash value, to make comparisons on it faster. After freezing, the Category and all its values are immutable.
|
|
|
|
|
|
|
Helper function that parses a Category.
|
Helper function that parses a feature value. Currently supports: None, bools, integers, variables, strings, nested feature structures.
|
Parse a
where
|
|
_PARSE_RE
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Wed May 16 22:47:25 2007 | http://epydoc.sourceforge.net |