Initial commit of PyBison (version 0.1.8)

parents
Version 0.1.7:
2004-04-30:
- Added scientific calculator example (calc1)
- Added support for error-handling rules
- Added support for rule handlers to raise errors
Version 0.1.6:
2004-04-30:
- Added ANSI C parser to examples
Version 0.1.5:
2004-04-30:
- Added XML support - can now export and import parse trees to/from
XML strings or xml.dom.minidom objects
Version 0.1.4:
2004-04-29:
- Improved the layout and usability of python parser files generated
by the bison2py utility, particularly with the '-c' option enabled
- fixed the 'template' example, so that it actually works if used as is
- tidied up and fleshed out the walkthrough document
Version 0.1.3:
2004-04-28:
- java example:
- replaced grammar file with an adapted version of one
from the GNU gcj compiler source - the damn thing works now!
- fixed lex script
- core - added support for a 'debug' flag keyword argument to Parser.run(),
which causes the bison-generated parser to haemorrhage out all manner of
detailed debug info
- various other fixes and tidy-ups
Version 0.1.2:
2004-04-25:
- moved pure-python code from bison.pyx (now renamed to bison_.pyx),
into a new file 'bison.py'.
- patched by Eugene Oden to fix bug in processing legacy rules files
in cases where rules contained character literals
- added '-c' option to bison2py utility, which causes the generation
of handler code as separate node classes instead of methods
Version 0.1.1:
2004-04-23:
- changed call signature for user target callbacks, to a much faster and
more convenient form
- fixed several fatal bugs
- added java parser example
Version 0.1.0:
2004-04-23:
- first release
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
PyBison was designed and written by David McNab <david@freenet.org.nz>.
---------------------
Ideas for the class model were borrowed from the PLY Python Parser
Builder toolkit - http://systems.cs.uchicago.edu/ply/
----------------------
The javaparser.l and javaparser.y files in the examples/ directory
are based (almost verbatim) on scripts written by
Professor Dave Binkley
(http://www.cs.loyola.edu/~binkley/)
at the Department of Computer Science at Loyola College in Maryland
(http://www.cs.loyola.edu/)
(permission pending)
INSTALL file for PyBison
1. Prerequisites
You will need:
- Python 2.2 or later, with development headers and libraries
- GNU bison (or yacc) - www.gnu.org or gnuwin32.sf.net
- GNU flex (or lex) - ditto
- The Pyrex Python/C wrapper creation framework:
- http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/
- A standard C compiler and linker
2. Installing
- Crack the tarball somewhere convenient (eg your home directory)
- cd into the top level directory of this package
- become root, and type 'python setup.py install'
With all going well, you should see a bunch of harmless warning messages
from the compilation of bison.c, but no errors.
The following commands will verify if the installation succeeded:
$ which bison2py
/usr/bin/bison2py
$ python -c "import bison"
$
#@+leo-ver=4
#@+node:@file Makefile
#all: java-grammar
PY_INCLUDE=/usr/include/python2.3
all: module doco
module:
python setup.py build
install:
python setup.py install
doco:
epydoc -n "PyBison API Reference" -o doc/api build/lib*/bison.py
clean:
rm -rf *~ *.output tokens.h *.tab.* *.yy.c java-grammar new.* *.o *.so dummy build *.pxi *-lexer.c
rm -rf *-parser.y *-parser.c *-parser.h pybison.c pybison.h
rm -rf bison.c bison.h
rm -rf *.pyc
rm -rf tmp.*
rm -f src/pyrex/bison_.pxi src/pyrex/bison_.c src/pyrex/bison_.h
#@-node:@file Makefile
#@-leo
Welcome to PyBison
Bringing GNU Bison/Flex's raw speed and power to Python
1) What is PyBison?
PyBison is a framework which effectively 'wraps' Bison and Flex into a Python
class structure.
You define a parser class, define tokens and precedences as attributes,
and parse targets as methods with rules in the docstrings,
then instantiate and run.
Black Magick happens in the background, whereupon you get callbacks each
time yyparse() resolves a parse target.
2) There are already parsers for Python. Why re-invent the wheel?
I looked at all the Python-based parsing frameworks.
IMO, the best one was PLY - a pure-python lexx/yacc implementation
(which I have borrowed from heavily in designing PyBison's OO model).
But PLY suffers some major limitations:
* usage of 'named groups' regular expressions in the lexer creates
a hard limit of 100 tokens - not enough to comfortably handle major
languages
* pure-python implementation is a convenience, but incurs a cruel
performance penalty
* the parser engine is SLR, not full LALR(1)
The other frameworks utilise a fiddly script syntax -
3) How do I use this?
Refer to the INSTALL file for setting up.
Refer to the examples and the doco for usage.
/* Body color */
body { background: #ffffff; color: #000000; }
/* Tables */
table.summary, table.details, table.index
{ background: #e8f0f8; color: #000000; }
tr.summary, tr.details, tr.index
{ background: #70b0f0; color: #000000;
text-align: left; font-size: 120%; }
tr.group { background: #c0e0f8; color: #000000;
text-align: left; font-size: 120%;
font-style: italic; }
/* Documentation page titles */
h2.module { margin-top: 0.2em; }
h2.class { margin-top: 0.2em; }
/* Headings */
h1.heading { font-size: +140%; font-style: italic;
font-weight: bold; }
h2.heading { font-size: +125%; font-style: italic;
font-weight: bold; }
h3.heading { font-size: +110%; font-style: italic;
font-weight: normal; }
/* Base tree */
pre.base-tree { font-size: 80%; margin: 0; }
/* Details Sections */
table.func-details { background: #e8f0f8; color: #000000;
border: 2px groove #c0d0d0;
padding: 0 1em 0 1em; margin: 0.4em 0 0 0; }
h3.func-detail { background: transparent; color: #000000;
margin: 0 0 1em 0; }
table.var-details { background: #e8f0f8; color: #000000;
border: 2px groove #c0d0d0;
padding: 0 1em 0 1em; margin: 0.4em 0 0 0; }
h3.var-details { background: transparent; color: #000000;
margin: 0 0 1em 0; }
/* Function signatures */
.sig { background: transparent; color: #000000;
font-weight: bold; }
.sig-name { background: transparent; color: #006080; }
.sig-arg, .sig-kwarg, .sig-vararg
{ background: transparent; color: #008060; }
.sig-default { background: transparent; color: #602000; }
.summary-sig { background: transparent; color: #000000; }
.summary-sig-name { background: transparent; color: #204080; }
.summary-sig-arg, .summary-sig-kwarg, .summary-sig-vararg
{ background: transparent; color: #008060; }
/* Doctest blocks */
.py-src { background: transparent; color: #000000; }
.py-prompt { background: transparent; color: #005050;
font-weight: bold;}
.py-string { background: transparent; color: #006030; }
.py-comment { background: transparent; color: #003060; }
.py-keyword { background: transparent; color: #600000; }
.py-output { background: transparent; color: #404040; }
pre.doctestblock { background: #f4faff; color: #000000;
padding: .5em; margin: 1em;
border: 1px solid #708890; }
table pre.doctestblock
{ background: #dce4ec; color: #000000;
padding: .5em; margin: 1em;
border: 1px solid #708890; }
/* Variable values */
pre.variable { background: #dce4ec; color: #000000;
padding: .5em; margin: 0;
border: 1px solid #708890; }
.variable-linewrap { background: transparent; color: #604000; }
.variable-ellipsis { background: transparent; color: #604000; }
.variable-quote { background: transparent; color: #604000; }
.re { background: transparent; color: #000000; }
.re-char { background: transparent; color: #006030; }
.re-op { background: transparent; color: #600000; }
.re-group { background: transparent; color: #003060; }
.re-ref { background: transparent; color: #404040; }
/* Navigation bar */
table.navbar { background: #a0c0ff; color: #0000ff;
border: 2px groove #c0d0d0; }
th.navbar { background: #a0c0ff; color: #0000ff; }
th.navselect { background: #70b0ff; color: #000000; }
.nomargin { margin: 0; }
/* Links */
a:link { background: transparent; color: #0000ff; }
a:visited { background: transparent; color: #204080; }
a.navbar:link { background: transparent; color: #0000ff;
text-decoration: none; }
a.navbar:visited { background: transparent; color: #204080;
text-decoration: none; }
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<title> PyBison API Reference </title>
</head>
<frameset cols="20%,80%">
<frameset rows="30%,70%">
<frame src="public/toc.html" name="moduleListFrame">
<frame src="public/toc-everything.html" name="moduleFrame">
</frameset>
<frame src="public/bison-module.html" name="mainFrame">
</frameset>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>__builtin__.object</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<font size="-1"><b class="breadcrumbs">
Module&nbsp;__builtin__ ::
Class&nbsp;object
</b></font></br>
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[show&nbsp;private&nbsp;|&nbsp;<a href="../public/__builtin__.object-class.html">hide&nbsp;private</a>]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="__builtin__.object-class.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<!-- =========== START OF CLASS DESCRIPTION =========== -->
<h2 class="class">Class object</h2>
<dl><dt><b>Known Subclasses:</b></dt>
<dd>
<a href="bison.BisonParser-class.html"><code>BisonParser</code></a>,
<a href="__builtin__.type-class.html"><code>type</code></a></dd></dl>
<hr/>
The most base type
<hr/>
<!-- =========== START OF METHOD SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Method Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__init__" class="summary-sig-name"><code>__init__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__init__(...) initializes x; see x.__class__.__doc__ for
signature</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__delattr__" class="summary-sig-name"><code>__delattr__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__delattr__('name') &lt;==&gt; del x.name</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__getattribute__" class="summary-sig-name"><code>__getattribute__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__getattribute__('name') &lt;==&gt; x.name</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__hash__" class="summary-sig-name"><code>__hash__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__hash__() &lt;==&gt; hash(x)</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__reduce__" class="summary-sig-name"><code>__reduce__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
helper for pickle</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__reduce_ex__" class="summary-sig-name"><code>__reduce_ex__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
helper for pickle</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__repr__" class="summary-sig-name"><code>__repr__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__repr__() &lt;==&gt; repr(x)</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__setattr__" class="summary-sig-name"><code>__setattr__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__setattr__('name', value) &lt;==&gt; x.name = value</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__str__" class="summary-sig-name"><code>__str__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__str__() &lt;==&gt; str(x)</td></tr>
<tr bgcolor="#e8f0f8" class="group">
<th colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;Inherited from type</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__new__" class="summary-sig-name"><code>__new__</code></a>(<span class=summary-sig-arg>T</span>,
<span class=summary-sig-arg>S</span>,
<span class="summary-sig-vararg">...</span>)</span></code>
<br />
T.__new__(S, ...) -&gt; a new object with type S, a subtype of T</td></tr>
</table><br />
<!-- =========== START OF CLASS VARIABLE SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Class Variable Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>type</code></font></td>
<td><a name="__class__"></a><b><code>__class__</code></b> = <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
</table><br />
<!-- =========== START OF METHOD DETAILS =========== -->
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="details">
<th colspan="2">Method Details</th></tr>
</table>
<a name="__init__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-vararg">...</span>)</span>
<br /><i>(Constructor)</i>
</h3>
x.__init__(...) initializes x; see x.__class__.__doc__ for
signature
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="__delattr__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__delattr__</span>(<span class="sig-vararg">...</span>)</span>
</h3>
x.__delattr__('name') &lt;==&gt; del x.name
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="__getattribute__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__getattribute__</span>(<span class="sig-vararg">...</span>)</span>
</h3>
x.__getattribute__('name') &lt;==&gt; x.name
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="__hash__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__hash__</span>(<span class=sig-arg>x</span>)</span>
<br /><i>(Hashing function)</i>
</h3>
x.__hash__() &lt;==&gt; hash(x)
<dl><dt></dt><dd>
<dl><dt><b>Returns:</b></dt>
<dd>
<pre class="literalblock">
hash(x)
</pre>
</dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="__reduce__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__reduce__</span>(<span class="sig-vararg">...</span>)</span>
</h3>
helper for pickle
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="__reduce_ex__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__reduce_ex__</span>(<span class="sig-vararg">...</span>)</span>
</h3>
helper for pickle
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="__repr__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__repr__</span>(<span class=sig-arg>x</span>)</span>
<br /><i>(Representation operator)</i>
</h3>
x.__repr__() &lt;==&gt; repr(x)
<dl><dt></dt><dd>
<dl><dt><b>Returns:</b></dt>
<dd>
<pre class="literalblock">
repr(x)
</pre>
</dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="__setattr__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__setattr__</span>(<span class="sig-vararg">...</span>)</span>
</h3>
x.__setattr__('name', value) &lt;==&gt; x.name = value
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="__str__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__str__</span>(<span class=sig-arg>x</span>)</span>
<br /><i>(Informal representation operator)</i>
</h3>
x.__str__() &lt;==&gt; str(x)
<dl><dt></dt><dd>
<dl><dt><b>Returns:</b></dt>
<dd>
<pre class="literalblock">
str(x)
</pre>
</dd>
</dl>
</dd></dl>
</td></tr></table>
<br />
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sun Jun 27 12:36:56 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>__builtin__.type</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<font size="-1"><b class="breadcrumbs">
Module&nbsp;__builtin__ ::
Class&nbsp;type
</b></font></br>
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[show&nbsp;private&nbsp;|&nbsp;<a href="../public/__builtin__.type-class.html">hide&nbsp;private</a>]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="__builtin__.type-class.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<!-- =========== START OF CLASS DESCRIPTION =========== -->
<h2 class="class">Class type</h2>
<pre class="base-tree">
<a href="__builtin__.object-class.html"><code>object</code></a> --+
|
<b>type</b>
</pre><br />
<hr/>
type(object) -&gt; the object's type type(name, bases, dict) -&gt; a
new type
<hr/>
<!-- =========== START OF METHOD SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Method Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__call__" class="summary-sig-name"><code>__call__</code></a>(<span class=summary-sig-arg>x</span>,
<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__call__(...) &lt;==&gt; x(...)</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__cmp__" class="summary-sig-name"><code>__cmp__</code></a>(<span class=summary-sig-arg>x</span>,
<span class=summary-sig-arg>y</span>)</span></code>
<br />
x.__cmp__(y) &lt;==&gt; cmp(x,y)</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__delattr__" class="summary-sig-name"><code>__delattr__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__delattr__('name') &lt;==&gt; del x.name</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__getattribute__" class="summary-sig-name"><code>__getattribute__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__getattribute__('name') &lt;==&gt; x.name</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__hash__" class="summary-sig-name"><code>__hash__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__hash__() &lt;==&gt; hash(x)</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__new__" class="summary-sig-name"><code>__new__</code></a>(<span class=summary-sig-arg>T</span>,
<span class=summary-sig-arg>S</span>,
<span class="summary-sig-vararg">...</span>)</span></code>
<br />
T.__new__(S, ...) -&gt; a new object with type S, a subtype of T</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__repr__" class="summary-sig-name"><code>__repr__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__repr__() &lt;==&gt; repr(x)</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__setattr__" class="summary-sig-name"><code>__setattr__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__setattr__('name', value) &lt;==&gt; x.name = value</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">list of immediate subclasses</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__subclasses__" class="summary-sig-name"><code>__subclasses__</code></a>()</span></code>
<br />
__subclasses__() -&gt; list of immediate subclasses</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">list</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#mro" class="summary-sig-name"><code>mro</code></a>()</span></code>
<br />
return a type's method resolution order</td></tr>
<tr bgcolor="#e8f0f8" class="group">
<th colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;Inherited from object</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__init__" class="summary-sig-name"><code>__init__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__init__(...) initializes x; see x.__class__.__doc__ for
signature</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__reduce__" class="summary-sig-name"><code>__reduce__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
helper for pickle</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__reduce_ex__" class="summary-sig-name"><code>__reduce_ex__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
helper for pickle</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__str__" class="summary-sig-name"><code>__str__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__str__() &lt;==&gt; str(x)</td></tr>
</table><br />
<!-- =========== START OF CLASS VARIABLE SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Class Variable Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>type</code></font></td>
<td><a name="__base__"></a><b><code>__base__</code></b> = <a href="__builtin__.object-class.html"><code>__builtin__.object</code></a></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>tuple</code></font></td>
<td><b><a href="__builtin__.type-class.html#__bases__"><code>__bases__</code></a></b> = <span title="(&lt;type 'object'&gt;,)"><code>(&lt;type&nbsp;'object'&gt;,) </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>int</code></font></td>
<td><b><a href="__builtin__.type-class.html#__basicsize__"><code>__basicsize__</code></a></b> = <span title="420">420&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>int</code></font></td>
<td><b><a href="__builtin__.type-class.html#__dictoffset__"><code>__dictoffset__</code></a></b> = <span title="132">132&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>int</code></font></td>
<td><b><a href="__builtin__.type-class.html#__flags__"><code>__flags__</code></a></b> = <span title="21995">21995&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>int</code></font></td>
<td><b><a href="__builtin__.type-class.html#__itemsize__"><code>__itemsize__</code></a></b> = <span title="20">20&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>tuple</code></font></td>
<td><b><a href="__builtin__.type-class.html#__mro__"><code>__mro__</code></a></b> = <span title="(&lt;type 'type'&gt;, &lt;type 'object'&gt;)"><code>(&lt;type&nbsp;'type'&gt;,&nbsp;&lt;type&nbsp;'object'&gt;) </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>str</code></font></td>
<td><b><a href="__builtin__.type-class.html#__name__"><code>__name__</code></a></b> = <span title="'type'"><code><span class="variable-quote">'</span>type<span class="variable-quote">'</span> </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>int</code></font></td>
<td><b><a href="__builtin__.type-class.html#__weakrefoffset__"><code>__weakrefoffset__</code></a></b> = <span title="184">184&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
</table><br />
<!-- =========== START OF METHOD DETAILS =========== -->
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="details">
<th colspan="2">Method Details</th></tr>
</table>
<a name="__call__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__call__</span>(<span class=sig-arg>x</span>,
<span class="sig-vararg">...</span>)</span>
<br /><i>(Call operator)</i>
</h3>
x.__call__(...) &lt;==&gt; x(...)
<dl><dt></dt><dd>
<dl><dt><b>Returns:</b></dt>
<dd>
<pre class="literalblock">
x(...)
</pre>
</dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="__cmp__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__cmp__</span>(<span class=sig-arg>x</span>,
<span class=sig-arg>y</span>)</span>
<br /><i>(Comparison operator)</i>
</h3>
x.__cmp__(y) &lt;==&gt; cmp(x,y)
<dl><dt></dt><dd>
<dl><dt><b>Returns:</b></dt>
<dd>
<pre class="literalblock">
cmp(x,y)
</pre>
</dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="__delattr__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__delattr__</span>(<span class="sig-vararg">...</span>)</span>
</h3>
x.__delattr__('name') &lt;==&gt; del x.name
<dl><dt></dt><dd>
<dl><dt><b>Overrides:</b></dt>
<dd><a href="__builtin__.object-class.html#__delattr__"><code>__builtin__.object.__delattr__</code></a></dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="__getattribute__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__getattribute__</span>(<span class="sig-vararg">...</span>)</span>
</h3>
x.__getattribute__('name') &lt;==&gt; x.name
<dl><dt></dt><dd>
<dl><dt><b>Overrides:</b></dt>
<dd><a href="__builtin__.object-class.html#__getattribute__"><code>__builtin__.object.__getattribute__</code></a></dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="__hash__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__hash__</span>(<span class=sig-arg>x</span>)</span>
<br /><i>(Hashing function)</i>
</h3>
x.__hash__() &lt;==&gt; hash(x)
<dl><dt></dt><dd>
<dl><dt><b>Returns:</b></dt>
<dd>
<pre class="literalblock">
hash(x)
</pre>
</dd>
</dl>
<dl><dt><b>Overrides:</b></dt>
<dd><a href="__builtin__.object-class.html#__hash__"><code>__builtin__.object.__hash__</code></a></dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="__new__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__new__</span>(<span class=sig-arg>T</span>,
<span class=sig-arg>S</span>,
<span class="sig-vararg">...</span>)</span>
</h3>
T.__new__(S, ...) -&gt; a new object with type S, a subtype of T
<dl><dt></dt><dd>
<dl><dt><b>Returns:</b></dt>
<dd>
<pre class="literalblock">
a new object with type S, a subtype of T
</pre>
</dd>
</dl>
<dl><dt><b>Overrides:</b></dt>
<dd><a href="__builtin__.type-class.html#__new__"><code>__builtin__.type.__new__</code></a></dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="__repr__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__repr__</span>(<span class=sig-arg>x</span>)</span>
<br /><i>(Representation operator)</i>
</h3>
x.__repr__() &lt;==&gt; repr(x)
<dl><dt></dt><dd>
<dl><dt><b>Returns:</b></dt>
<dd>
<pre class="literalblock">
repr(x)
</pre>
</dd>
</dl>
<dl><dt><b>Overrides:</b></dt>
<dd><a href="__builtin__.object-class.html#__repr__"><code>__builtin__.object.__repr__</code></a></dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="__setattr__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__setattr__</span>(<span class="sig-vararg">...</span>)</span>
</h3>
x.__setattr__('name', value) &lt;==&gt; x.name = value
<dl><dt></dt><dd>
<dl><dt><b>Overrides:</b></dt>
<dd><a href="__builtin__.object-class.html#__setattr__"><code>__builtin__.object.__setattr__</code></a></dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="__subclasses__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__subclasses__</span>()</span>
</h3>
__subclasses__() -&gt; list of immediate subclasses
<dl><dt></dt><dd>
<dl><dt><b>Returns:</b></dt>
<dd>
list of immediate subclasses </dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="mro"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">mro</span>()</span>
</h3>
return a type's method resolution order
<dl><dt></dt><dd>
<dl><dt><b>Returns:</b></dt>
<dd>
list </dd>
</dl>
</dd></dl>
</td></tr></table>
<br />
<!-- =========== START OF CLASS VARIABLE DETAILS =========== -->
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="details">
<th colspan="2">Class Variable Details</th></tr>
</table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="__bases__"></a>
<h3>__bases__</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>tuple</code>
</dd>
<span title="(&lt;type 'object'&gt;,)"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
(&lt;type 'object'&gt;,) </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="__basicsize__"></a>
<h3>__basicsize__</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>int</code>
</dd>
<span title="420"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
420&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="__dictoffset__"></a>
<h3>__dictoffset__</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>int</code>
</dd>
<span title="132"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
132&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="__flags__"></a>
<h3>__flags__</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>int</code>
</dd>
<span title="21995"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
21995&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="__itemsize__"></a>
<h3>__itemsize__</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>int</code>
</dd>
<span title="20"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
20&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="__mro__"></a>
<h3>__mro__</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>tuple</code>
</dd>
<span title="(&lt;type 'type'&gt;, &lt;type 'object'&gt;)"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
(&lt;type 'type'&gt;, &lt;type 'object'&gt;) </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="__name__"></a>
<h3>__name__</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>str</code>
</dd>
<span title="'type'"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
<span class="variable-quote">'</span>type<span class="variable-quote">'</span> </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="__weakrefoffset__"></a>
<h3>__weakrefoffset__</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>int</code>
</dd>
<span title="184"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
184&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<br />
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sun Jun 27 12:36:56 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>bison</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th bgcolor="#70b0f0" class="navselect">&nbsp;&nbsp;&nbsp;Home&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<font size="-1"><b class="breadcrumbs">
Module&nbsp;bison
</b></font></br>
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[show&nbsp;private&nbsp;|&nbsp;<a href="../public/bison-module.html">hide&nbsp;private</a>]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="bison-module.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<!-- =========== START OF MODULE DESCRIPTION =========== -->
<h2 class="module">Module bison</h2>
<p>Wrapper module for interfacing with Bison (yacc)</p>
<p>Written April 2004 by David McNab &lt;david&#64;freenet.org.nz&gt;
Copyright (c) 2004 by David McNab, all rights reserved.</p>
<p>Released under the GNU General Public License, a copy of which should
appear in this distribution in the file called 'COPYING'. If this file is
missing, then you can obtain a copy of the GPL license document from the
GNU website at http://www.gnu.org.</p>
<p>This software is released with no warranty whatsoever. Use it at your
own risk.</p>
If you wish to use this software in a commercial application, and wish
to depart from the GPL licensing requirements, please contact the author
and apply for a commercial license.
<hr/>
<!-- =========== START OF CLASSES =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Classes</th></tr>
<tr><td width="15%">
<b><a href="bison.BisonError-class.html"><code>BisonError</code></a></b></td>
<td>Flags an error to yyparse()</td></tr>
<tr><td width="15%">
<b><a href="bison.BisonNode-class.html"><code>BisonNode</code></a></b></td>
<td>Generic class for wrapping parse targets.</td></tr>
<tr><td width="15%">
<b><a href="bison.BisonParser-class.html"><code>BisonParser</code></a></b></td>
<td>Base parser class</td></tr>
</table><br />
<!-- =========== START OF EXCEPTIONS =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Exceptions</th></tr>
<tr><td width="15%">
<b><a href="bison.ParserSyntaxError-class.html"><code>ParserSyntaxError</code></a></b></td>
<td>&nbsp;</td></tr>
</table><br />
<!-- =========== START OF FUNCTION SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Function Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison-module.html#bisonToPython" class="summary-sig-name"><code>bisonToPython</code></a>(<span class=summary-sig-arg>bisonfileName</span>,
<span class=summary-sig-arg>lexfileName</span>,
<span class=summary-sig-arg>pyfileName</span>,
<span class=summary-sig-arg>generateClasses</span>)</span></code>
<br />
Rips the rules, tokens and precedences from a bison file, and the
verbatim text from a lex file and generates a boilerplate python file
containing a Parser class with handler methods and grammar attributes</td></tr>
</table><br />
<!-- =========== START OF VARIABLE SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Variable Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>SRE_Pattern</code></font></td>
<td><b><a href="bison-module.html#reSpaces"><code>reSpaces</code></a></b> = <span title="&lt;_sre.SRE_Pattern object at 0x4029a2f8&gt;"><code><span class="re"><span class="re-char">\s</span><span class="re-op">+</span></span> </code>
</span></td></tr>
</table><br />
<!-- =========== START OF FUNCTION DETAILS =========== -->
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="details">
<th colspan="2">Function Details</th></tr>
</table>
<a name="bisonToPython"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">bisonToPython</span>(<span class=sig-arg>bisonfileName</span>,
<span class=sig-arg>lexfileName</span>,
<span class=sig-arg>pyfileName</span>,
<span class=sig-arg>generateClasses</span>=<span class=sig-default>0</span>)</span>
</h3>
<p>Rips the rules, tokens and precedences from a bison file, and the
verbatim text from a lex file and generates a boilerplate python file
containing a Parser class with handler methods and grammar
attributes</p>
Arguments:
<ul>
<li>
bisonfileName - name of input bison script
</li>
<li>
lexfileName - name of input flex script
</li>
<li>
pyfileName - name of output python file
</li>
<li>
generateClasses - flag - default 0 - if 1, causes a unique class
to be defined for each parse target, and for the corresponding
target handler method in the main Parser class to use this class
when creating the node.
</li>
</ul>
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<br />
<!-- =========== START OF VARIABLE DETAILS =========== -->
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="details">
<th colspan="2">Variable Details</th></tr>
</table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="reSpaces"></a>
<h3>reSpaces</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>SRE_Pattern</code>
</dd>
<span title="&lt;_sre.SRE_Pattern object at 0x4029a2f8&gt;"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
<span class="re"><span class="re-char">\s</span><span class="re-op">+</span></span> </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<br />
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th bgcolor="#70b0f0" class="navselect">&nbsp;&nbsp;&nbsp;Home&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sun Jun 27 12:36:56 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>bison.BisonError</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<font size="-1"><b class="breadcrumbs">
<a href="bison-module.html">Module&nbsp;bison</a> ::
Class&nbsp;BisonError
</b></font></br>
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[show&nbsp;private&nbsp;|&nbsp;<a href="../public/bison.BisonError-class.html">hide&nbsp;private</a>]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="bison.BisonError-class.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<!-- =========== START OF CLASS DESCRIPTION =========== -->
<h2 class="class">Class BisonError</h2>
<hr/>
<p>Flags an error to yyparse()</p>
You should return this in your actions to notify a syntax error
<hr/>
<!-- =========== START OF METHOD SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Method Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="__init__"></a><span class="summary-sig"><span class="summary-sig-name">__init__</span>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>value</span>)</span></code>
</td></tr>
</table><br />
<!-- =========== START OF CLASS VARIABLE SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Class Variable Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>int</code></font></td>
<td><b><a href="../private/bison.BisonError-class.html#_pyBisonError"><code>_pyBisonError</code></a></b> = <span title="1">1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
</table><br />
<!-- =========== START OF CLASS VARIABLE DETAILS =========== -->
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="details">
<th colspan="2">Class Variable Details</th></tr>
</table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="_pyBisonError"></a>
<h3>_pyBisonError</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>int</code>
</dd>
<span title="1"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<br />
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sun Jun 27 12:36:56 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>bison.BisonNode</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<font size="-1"><b class="breadcrumbs">
<a href="bison-module.html">Module&nbsp;bison</a> ::
Class&nbsp;BisonNode
</b></font></br>
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[show&nbsp;private&nbsp;|&nbsp;<a href="../public/bison.BisonNode-class.html">hide&nbsp;private</a>]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="bison.BisonNode-class.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<!-- =========== START OF CLASS DESCRIPTION =========== -->
<h2 class="class">Class BisonNode</h2>
<hr/>
<p>Generic class for wrapping parse targets.</p>
Arguments:
<ul>
<li>
targetname - the name of the parse target being wrapped.
</li>
<li>
items - optional - a list of items comprising a clause in the
target rule - typically this will only be used by the PyBison
callback mechanism.
</li>
</ul>
Keywords:
<ul>
<li>
any keywords you want (except 'items'), with any type of value.
keywords will be stored as attributes in the constructed object.
</li>
</ul>
<hr/>
<!-- =========== START OF METHOD SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Method Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="__init__"></a><span class="summary-sig"><span class="summary-sig-name">__init__</span>(<span class=summary-sig-arg>self</span>,
<span class="summary-sig-kwarg">**kw</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonNode-class.html#__getitem__" class="summary-sig-name"><code>__getitem__</code></a>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>item</span>)</span></code>
<br />
Retrieves the ith value from this node, or child nodes</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="__getslice__"></a><span class="summary-sig"><span class="summary-sig-name">__getslice__</span>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>fromidx</span>,
<span class=summary-sig-arg>toidx</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="__iter__"></a><span class="summary-sig"><span class="summary-sig-name">__iter__</span>(<span class=summary-sig-arg>self</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="__len__"></a><span class="summary-sig"><span class="summary-sig-name">__len__</span>(<span class=summary-sig-arg>self</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="__repr__"></a><span class="summary-sig"><span class="summary-sig-name">__repr__</span>(<span class=summary-sig-arg>self</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="__str__"></a><span class="summary-sig"><span class="summary-sig-name">__str__</span>(<span class=summary-sig-arg>self</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonNode-class.html#dump" class="summary-sig-name"><code>dump</code></a>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>indent</span>)</span></code>
<br />
For debugging - prints a recursive dump of a parse tree node and its
children</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonNode-class.html#toprettyxml" class="summary-sig-name"><code>toprettyxml</code></a>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>indent</span>,
<span class=summary-sig-arg>newl</span>,
<span class=summary-sig-arg>encoding</span>)</span></code>
<br />
returns a human-readable xml serialisation of this node and its
children</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonNode-class.html#toxml" class="summary-sig-name"><code>toxml</code></a>(<span class=summary-sig-arg>self</span>)</span></code>
<br />
Returns an xml serialisation of this node and its children, as a raw
string</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonNode-class.html#toxmldoc" class="summary-sig-name"><code>toxmldoc</code></a>(<span class=summary-sig-arg>self</span>)</span></code>
<br />
Returns the node and its children as an xml.dom.minidom.Document
object</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonNode-class.html#toxmlelem" class="summary-sig-name"><code>toxmlelem</code></a>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>docobj</span>)</span></code>
<br />
Returns a DOM Element object of this node and its children</td></tr>
</table><br />
<!-- =========== START OF METHOD DETAILS =========== -->
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="details">
<th colspan="2">Method Details</th></tr>
</table>
<a name="__getitem__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__getitem__</span>(<span class=sig-arg>self</span>,
<span class=sig-arg>item</span>)</span>
<br /><i>(Indexing operator)</i>
</h3>
<p>Retrieves the ith value from this node, or child nodes</p>
<p>If the subscript is a single number, it will be used as an index
into this node's children list.</p>
If the subscript is a list or tuple, we recursively fetch the item
by using the first element as an index into this node's children, the
second element as an index into that child node's children, and so
on
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="dump"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">dump</span>(<span class=sig-arg>self</span>,
<span class=sig-arg>indent</span>=<span class=sig-default>0</span>)</span>
</h3>
For debugging - prints a recursive dump of a parse tree node and its
children
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="toprettyxml"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">toprettyxml</span>(<span class=sig-arg>self</span>,
<span class=sig-arg>indent</span>=<span class=sig-default>'&nbsp;&nbsp;'</span>,
<span class=sig-arg>newl</span>=<span class=sig-default>'\n'</span>,
<span class=sig-arg>encoding</span>=<span class=sig-default>None</span>)</span>
</h3>
returns a human-readable xml serialisation of this node and its
children
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="toxml"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">toxml</span>(<span class=sig-arg>self</span>)</span>
</h3>
<p>Returns an xml serialisation of this node and its children, as a raw
string</p>
Called on the toplevel node, the xml is a representation of the
entire parse tree.
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="toxmldoc"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">toxmldoc</span>(<span class=sig-arg>self</span>)</span>
</h3>
Returns the node and its children as an xml.dom.minidom.Document
object
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="toxmlelem"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">toxmlelem</span>(<span class=sig-arg>self</span>,
<span class=sig-arg>docobj</span>)</span>
</h3>
Returns a DOM Element object of this node and its children
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<br />
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sun Jun 27 12:36:56 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>bison.BisonParser</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<font size="-1"><b class="breadcrumbs">
<a href="bison-module.html">Module&nbsp;bison</a> ::
Class&nbsp;BisonParser
</b></font></br>
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[show&nbsp;private&nbsp;|&nbsp;<a href="../public/bison.BisonParser-class.html">hide&nbsp;private</a>]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="bison.BisonParser-class.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<!-- =========== START OF CLASS DESCRIPTION =========== -->
<h2 class="class">Class BisonParser</h2>
<pre class="base-tree">
<a href="__builtin__.object-class.html"><code>object</code></a> --+
|
<b>BisonParser</b>
</pre><br />
<hr/>
<p>Base parser class</p>
You should subclass this, and provide a bunch of methods called
'on_TargetName', where 'TargetName' is the name of each target in your
grammar (.y) file.
<hr/>
<!-- =========== START OF METHOD SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Method Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonParser-class.html#__init__" class="summary-sig-name"><code>__init__</code></a>(<span class=summary-sig-arg>self</span>,
<span class="summary-sig-kwarg">**kw</span>)</span></code>
<br />
Abstract representation of parser</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="__getitem__"></a><span class="summary-sig"><span class="summary-sig-name">__getitem__</span>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>idx</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonParser-class.html#error" class="summary-sig-name"><code>error</code></a>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>value</span>)</span></code>
<br />
Return the result of this method from a handler to notify a syntax
error</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonParser-class.html#loadxml" class="summary-sig-name"><code>loadxml</code></a>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>raw</span>,
<span class=summary-sig-arg>namespace</span>)</span></code>
<br />
Loads a parse tree from raw xml text</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonParser-class.html#loadxmldoc" class="summary-sig-name"><code>loadxmldoc</code></a>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>xmldoc</span>,
<span class=summary-sig-arg>namespace</span>)</span></code>
<br />
Returns a reconstituted parse tree, loaded from an
xml.dom.minidom.Document instance</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonParser-class.html#loadxmlobj" class="summary-sig-name"><code>loadxmlobj</code></a>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>xmlobj</span>,
<span class=summary-sig-arg>namespace</span>)</span></code>
<br />
Returns a node object, being a parse tree, reconstituted from an
xml.dom.minidom.Element object</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonParser-class.html#read" class="summary-sig-name"><code>read</code></a>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>nbytes</span>)</span></code>
<br />
Override this in your subclass, if you desire.</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonParser-class.html#run" class="summary-sig-name"><code>run</code></a>(<span class=summary-sig-arg>self</span>,
<span class="summary-sig-kwarg">**kw</span>)</span></code>
<br />
Runs the parser, and returns the top-most parse target.</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonParser-class.html#toprettyxml" class="summary-sig-name"><code>toprettyxml</code></a>(<span class=summary-sig-arg>self</span>)</span></code>
<br />
Returns a human-readable xml representation of the parse tree</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonParser-class.html#toxml" class="summary-sig-name"><code>toxml</code></a>(<span class=summary-sig-arg>self</span>)</span></code>
<br />
Serialises the parse tree and returns it as a raw xml string</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonParser-class.html#toxmldoc" class="summary-sig-name"><code>toxmldoc</code></a>(<span class=summary-sig-arg>self</span>)</span></code>
<br />
Returns an xml.dom.minidom.Document object containing the parse
tree</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="_error"></a><span class="summary-sig"><span class="summary-sig-name">_error</span>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>linenum</span>,
<span class=summary-sig-arg>msg</span>,
<span class=summary-sig-arg>tok</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="_globals"></a><span class="summary-sig"><span class="summary-sig-name">_globals</span>(<span class=summary-sig-arg>self</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="../private/bison.BisonParser-class.html#_handle" class="summary-sig-name"><code>_handle</code></a>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>targetname</span>,
<span class=summary-sig-arg>option</span>,
<span class=summary-sig-arg>names</span>,
<span class=summary-sig-arg>values</span>)</span></code>
<br />
Callback which receives a target from parser, as a targetname and list
of term names and values.</td></tr>
<tr bgcolor="#e8f0f8" class="group">
<th colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;Inherited from object</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__delattr__" class="summary-sig-name"><code>__delattr__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__delattr__('name') &lt;==&gt; del x.name</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__getattribute__" class="summary-sig-name"><code>__getattribute__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__getattribute__('name') &lt;==&gt; x.name</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__hash__" class="summary-sig-name"><code>__hash__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__hash__() &lt;==&gt; hash(x)</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__reduce__" class="summary-sig-name"><code>__reduce__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
helper for pickle</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__reduce_ex__" class="summary-sig-name"><code>__reduce_ex__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
helper for pickle</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__repr__" class="summary-sig-name"><code>__repr__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__repr__() &lt;==&gt; repr(x)</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__setattr__" class="summary-sig-name"><code>__setattr__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__setattr__('name', value) &lt;==&gt; x.name = value</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__str__" class="summary-sig-name"><code>__str__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__str__() &lt;==&gt; str(x)</td></tr>
<tr bgcolor="#e8f0f8" class="group">
<th colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;Inherited from type</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__new__" class="summary-sig-name"><code>__new__</code></a>(<span class=summary-sig-arg>T</span>,
<span class=summary-sig-arg>S</span>,
<span class="summary-sig-vararg">...</span>)</span></code>
<br />
T.__new__(S, ...) -&gt; a new object with type S, a subtype of T</td></tr>
</table><br />
<!-- =========== START OF CLASS VARIABLE SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Class Variable Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>str</code></font></td>
<td><b><a href="bison.BisonParser-class.html#bisonCFile"><code>bisonCFile</code></a></b> = <span title="'tmp.tab.c'"><code><span class="variable-quote">'</span>tmp.tab.c<span class="variable-quote">'</span> </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>str</code></font></td>
<td><b><a href="bison.BisonParser-class.html#bisonCFile1"><code>bisonCFile1</code></a></b> = <span title="'tmp.bison.c'"><code><span class="variable-quote">'</span>tmp.bison.c<span class="variable-quote">'</span> </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>list</code></font></td>
<td><b><a href="bison.BisonParser-class.html#bisonCmd"><code>bisonCmd</code></a></b> = <span title="['bison', '-d', '-v', '-t']"><code>['bison',&nbsp;'-d',&nbsp;'-v',&nbsp;'-t'] </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>NoneType</code></font></td>
<td><b><a href="bison.BisonParser-class.html#bisonEngineLibName"><code>bisonEngineLibName</code></a></b> = <span title="None">None&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>str</code></font></td>
<td><b><a href="bison.BisonParser-class.html#bisonFile"><code>bisonFile</code></a></b> = <span title="'tmp.y'"><code><span class="variable-quote">'</span>tmp.y<span class="variable-quote">'</span> </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>str</code></font></td>
<td><b><a href="bison.BisonParser-class.html#bisonHFile"><code>bisonHFile</code></a></b> = <span title="'tmp.tab.h'"><code><span class="variable-quote">'</span>tmp.tab.h<span class="variable-quote">'</span> </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>str</code></font></td>
<td><b><a href="bison.BisonParser-class.html#bisonHFile1"><code>bisonHFile1</code></a></b> = <span title="'tokens.h'"><code><span class="variable-quote">'</span>tokens.h<span class="variable-quote">'</span> </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>classobj</code></font></td>
<td><a name="defaultNodeClass"></a><b><code>defaultNodeClass</code></b> = <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>NoneType</code></font></td>
<td><b><a href="bison.BisonParser-class.html#file"><code>file</code></a></b> = <span title="None">None&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>str</code></font></td>
<td><b><a href="bison.BisonParser-class.html#flexCFile"><code>flexCFile</code></a></b> = <span title="'lex.yy.c'"><code><span class="variable-quote">'</span>lex.yy.c<span class="variable-quote">'</span> </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>str</code></font></td>
<td><b><a href="bison.BisonParser-class.html#flexCFile1"><code>flexCFile1</code></a></b> = <span title="'tmp.lex.c'"><code><span class="variable-quote">'</span>tmp.lex.c<span class="variable-quote">'</span> </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>list</code></font></td>
<td><b><a href="bison.BisonParser-class.html#flexCmd"><code>flexCmd</code></a></b> = <span title="['flex']"><code>['flex'] </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>str</code></font></td>
<td><b><a href="bison.BisonParser-class.html#flexFile"><code>flexFile</code></a></b> = <span title="'tmp.l'"><code><span class="variable-quote">'</span>tmp.l<span class="variable-quote">'</span> </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>int</code></font></td>
<td><b><a href="bison.BisonParser-class.html#keepfiles"><code>keepfiles</code></a></b> = <span title="0">0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>NoneType</code></font></td>
<td><b><a href="bison.BisonParser-class.html#last"><code>last</code></a></b> = <span title="None">None&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>NoneType</code></font></td>
<td><b><a href="bison.BisonParser-class.html#lasterror"><code>lasterror</code></a></b> = <span title="None">None&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>int</code></font></td>
<td><b><a href="bison.BisonParser-class.html#verbose"><code>verbose</code></a></b> = <span title="0">0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
</table><br />
<!-- =========== START OF METHOD DETAILS =========== -->
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="details">
<th colspan="2">Method Details</th></tr>
</table>
<a name="__init__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__init__</span>(<span class=sig-arg>self</span>,
<span class="sig-kwarg">**kw</span>)</span>
<br /><i>(Constructor)</i>
</h3>
<p>Abstract representation of parser</p>
Keyword arguments:
<ul>
<li>
read - a callable accepting an int arg (nbytes) and returning a
string, default is this class' read() method
</li>
<li>
file - a file object, or string of a pathname to open as a file,
defaults to sys.stdin. Note that you can leave this blank, and pass
a file keyword argument to the .run() method.
</li>
<li>
verbose - set to 1 to enable verbose output messages, default
0
</li>
<li>
keepfiles - if non-zero, keeps any files generated in the course
of building the parser engine; by default, all these files get
deleted upon a successful engine build
</li>
<li>
defaultNodeClass - the class to use for creating parse nodes,
default is self.defaultNodeClass (in this base class,
BisonNode)
</li>
</ul>
<dl><dt></dt><dd>
<dl><dt><b>Overrides:</b></dt>
<dd><a href="__builtin__.object-class.html#__init__"><code>__builtin__.object.__init__</code></a></dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="error"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">error</span>(<span class=sig-arg>self</span>,
<span class=sig-arg>value</span>)</span>
</h3>
Return the result of this method from a handler to notify a syntax
error
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="loadxml"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">loadxml</span>(<span class=sig-arg>self</span>,
<span class=sig-arg>raw</span>,
<span class=sig-arg>namespace</span>=<span class=sig-default>None</span>)</span>
</h3>
<p>Loads a parse tree from raw xml text</p>
<p>Stores it in the '.last' attribute, which is where the root node of
parsed text gets stored</p>
Arguments:
<ul>
<li>
raw - string containing the raw xml
</li>
<li>
namespace - a dict or module object, where the node classes
required for reconstituting the parse tree, can be found
</li>
</ul>
Returns:
<ul>
<li>
root node object of reconstituted parse tree
</li>
</ul>
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="loadxmldoc"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">loadxmldoc</span>(<span class=sig-arg>self</span>,
<span class=sig-arg>xmldoc</span>,
<span class=sig-arg>namespace</span>=<span class=sig-default>None</span>)</span>
</h3>
<p>Returns a reconstituted parse tree, loaded from an
xml.dom.minidom.Document instance</p>
Arguments:
<ul>
<li>
xmldoc - an xml.dom.minidom.Document instance
</li>
<li>
namespace - a dict from which to find the classes needed to
translate the document into a tree of parse nodes
</li>
</ul>
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="loadxmlobj"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">loadxmlobj</span>(<span class=sig-arg>self</span>,
<span class=sig-arg>xmlobj</span>,
<span class=sig-arg>namespace</span>=<span class=sig-default>None</span>)</span>
</h3>
<p>Returns a node object, being a parse tree, reconstituted from an
xml.dom.minidom.Element object</p>
Arguments:
<ul>
<li>
xmlobj - an xml.dom.minidom.Element instance
</li>
<li>
namespace - a namespace from which the node classes needed for
reconstituting the tree, can be found
</li>
</ul>
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="read"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">read</span>(<span class=sig-arg>self</span>,
<span class=sig-arg>nbytes</span>)</span>
</h3>
<p>Override this in your subclass, if you desire.</p>
Arguments:
<ul>
<li>
nbytes - the maximum length of the string which you may return.
DO NOT return a string longer than this, or else Bad Things will
happen.
</li>
</ul>
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="run"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">run</span>(<span class=sig-arg>self</span>,
<span class="sig-kwarg">**kw</span>)</span>
</h3>
<p>Runs the parser, and returns the top-most parse target.</p>
Keywords:
<ul>
<li>
file - either a string, comprising a file to open and read input
from, or a Python file object
</li>
<li>
debug - enables garrulous parser debugging output, default 0
</li>
</ul>
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="toprettyxml"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">toprettyxml</span>(<span class=sig-arg>self</span>)</span>
</h3>
Returns a human-readable xml representation of the parse tree
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="toxml"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">toxml</span>(<span class=sig-arg>self</span>)</span>
</h3>
Serialises the parse tree and returns it as a raw xml string
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="toxmldoc"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">toxmldoc</span>(<span class=sig-arg>self</span>)</span>
</h3>
Returns an xml.dom.minidom.Document object containing the parse
tree
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="_handle"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">_handle</span>(<span class=sig-arg>self</span>,
<span class=sig-arg>targetname</span>,
<span class=sig-arg>option</span>,
<span class=sig-arg>names</span>,
<span class=sig-arg>values</span>)</span>
</h3>
<p>Callback which receives a target from parser, as a targetname and
list of term names and values.</p>
Tries to dispatch to on_TargetName() methods if they exist,
otherwise wraps the target in a BisonNode object
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<br />
<!-- =========== START OF CLASS VARIABLE DETAILS =========== -->
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="details">
<th colspan="2">Class Variable Details</th></tr>
</table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="bisonCFile"></a>
<h3>bisonCFile</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>str</code>
</dd>
<span title="'tmp.tab.c'"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
<span class="variable-quote">'</span>tmp.tab.c<span class="variable-quote">'</span> </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="bisonCFile1"></a>
<h3>bisonCFile1</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>str</code>
</dd>
<span title="'tmp.bison.c'"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
<span class="variable-quote">'</span>tmp.bison.c<span class="variable-quote">'</span> </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="bisonCmd"></a>
<h3>bisonCmd</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>list</code>
</dd>
<span title="['bison', '-d', '-v', '-t']"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
['bison', '-d', '-v', '-t'] </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="bisonEngineLibName"></a>
<h3>bisonEngineLibName</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>NoneType</code>
</dd>
<span title="None"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
None&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="bisonFile"></a>
<h3>bisonFile</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>str</code>
</dd>
<span title="'tmp.y'"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
<span class="variable-quote">'</span>tmp.y<span class="variable-quote">'</span> </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="bisonHFile"></a>
<h3>bisonHFile</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>str</code>
</dd>
<span title="'tmp.tab.h'"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
<span class="variable-quote">'</span>tmp.tab.h<span class="variable-quote">'</span> </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="bisonHFile1"></a>
<h3>bisonHFile1</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>str</code>
</dd>
<span title="'tokens.h'"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
<span class="variable-quote">'</span>tokens.h<span class="variable-quote">'</span> </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="file"></a>
<h3>file</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>NoneType</code>
</dd>
<span title="None"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
None&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="flexCFile"></a>
<h3>flexCFile</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>str</code>
</dd>
<span title="'lex.yy.c'"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
<span class="variable-quote">'</span>lex.yy.c<span class="variable-quote">'</span> </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="flexCFile1"></a>
<h3>flexCFile1</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>str</code>
</dd>
<span title="'tmp.lex.c'"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
<span class="variable-quote">'</span>tmp.lex.c<span class="variable-quote">'</span> </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="flexCmd"></a>
<h3>flexCmd</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>list</code>
</dd>
<span title="['flex']"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
['flex'] </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="flexFile"></a>
<h3>flexFile</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>str</code>
</dd>
<span title="'tmp.l'"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
<span class="variable-quote">'</span>tmp.l<span class="variable-quote">'</span> </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="keepfiles"></a>
<h3>keepfiles</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>int</code>
</dd>
<span title="0"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="last"></a>
<h3>last</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>NoneType</code>
</dd>
<span title="None"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
None&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="lasterror"></a>
<h3>lasterror</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>NoneType</code>
</dd>
<span title="None"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
None&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="verbose"></a>
<h3>verbose</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>int</code>
</dd>
<span title="0"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<br />
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sun Jun 27 12:36:56 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>bison.ParserEngine</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<font size="-1"><b class="breadcrumbs">
<a href="bison-module.html">Module&nbsp;bison</a> ::
Class&nbsp;ParserEngine
</b></font></br>
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[show&nbsp;private&nbsp;|&nbsp;<a href="../public/bison.ParserEngine-class.html">hide&nbsp;private</a>]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="bison.ParserEngine-class.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<!-- =========== START OF CLASS DESCRIPTION =========== -->
<h2 class="class">Class ParserEngine</h2>
<pre class="base-tree">
<a href="__builtin__.object-class.html"><code>object</code></a> --+
|
<b>ParserEngine</b>
</pre><br />
<hr/>
<p>Wraps the interface to the binary bison/lex-generated parser engine
dynamic library.</p>
<p>You shouldn't need to deal with this at all.</p>
Takes care of:
<ul>
<li>
building the library (if the parser rules have changed)
</li>
<li>
loading the library and extracting the parser entry point
</li>
<li>
calling the entry point
</li>
<li>
closing the library
</li>
</ul>
Makes direct calls to the platform-dependent routines in
bisondynlib-[linux|windows].c
<hr/>
<!-- =========== START OF METHOD SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Method Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.ParserEngine-class.html#__init__" class="summary-sig-name"><code>__init__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__init__(...) initializes x; see x.__class__.__doc__ for
signature</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.ParserEngine-class.html#__del__" class="summary-sig-name"><code>__del__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
Clean up and bail</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.ParserEngine-class.html#buildLib" class="summary-sig-name"><code>buildLib</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
Creates the parser engine lib</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.ParserEngine-class.html#closeLib" class="summary-sig-name"><code>closeLib</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
Does the necessary cleanups and closes the parser library</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.ParserEngine-class.html#openCurrentLib" class="summary-sig-name"><code>openCurrentLib</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
Tests if library exists and is current.</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.ParserEngine-class.html#openLib" class="summary-sig-name"><code>openLib</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
Loads the parser engine's dynamic library, and extracts the following
symbols:</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.ParserEngine-class.html#runEngine" class="summary-sig-name"><code>runEngine</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
Runs the binary parser engine, as loaded from the lib</td></tr>
<tr bgcolor="#e8f0f8" class="group">
<th colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;Inherited from object</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__delattr__" class="summary-sig-name"><code>__delattr__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__delattr__('name') &lt;==&gt; del x.name</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__getattribute__" class="summary-sig-name"><code>__getattribute__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__getattribute__('name') &lt;==&gt; x.name</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__hash__" class="summary-sig-name"><code>__hash__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__hash__() &lt;==&gt; hash(x)</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__reduce__" class="summary-sig-name"><code>__reduce__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
helper for pickle</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__reduce_ex__" class="summary-sig-name"><code>__reduce_ex__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
helper for pickle</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__repr__" class="summary-sig-name"><code>__repr__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__repr__() &lt;==&gt; repr(x)</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__setattr__" class="summary-sig-name"><code>__setattr__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__setattr__('name', value) &lt;==&gt; x.name = value</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__str__" class="summary-sig-name"><code>__str__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__str__() &lt;==&gt; str(x)</td></tr>
<tr bgcolor="#e8f0f8" class="group">
<th colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;Inherited from type</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__new__" class="summary-sig-name"><code>__new__</code></a>(<span class=summary-sig-arg>T</span>,
<span class=summary-sig-arg>S</span>,
<span class="summary-sig-vararg">...</span>)</span></code>
<br />
T.__new__(S, ...) -&gt; a new object with type S, a subtype of T</td></tr>
</table><br />
<!-- =========== START OF METHOD DETAILS =========== -->
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="details">
<th colspan="2">Method Details</th></tr>
</table>
<a name="__init__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-vararg">...</span>)</span>
<br /><i>(Constructor)</i>
</h3>
x.__init__(...) initializes x; see x.__class__.__doc__ for
signature
<dl><dt></dt><dd>
<dl><dt><b>Overrides:</b></dt>
<dd><a href="__builtin__.object-class.html#__init__"><code>__builtin__.object.__init__</code></a></dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="__del__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__del__</span>(<span class="sig-vararg">...</span>)</span>
<br /><i>(Destructor)</i>
</h3>
Clean up and bail
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="buildLib"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">buildLib</span>(<span class="sig-vararg">...</span>)</span>
</h3>
<p>Creates the parser engine lib</p>
This consists of:
<ol start="1">
<li>
Ripping the tokens list, precedences, start target, handler
docstrings and lex script from this Parser instance's attribs and
methods
</li>
<li>
Creating bison and lex files
</li>
<li>
Compiling bison/lex files to C
</li>
<li>
Compiling the C files, and link into a dynamic lib
</li>
</ol>
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="closeLib"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">closeLib</span>(<span class="sig-vararg">...</span>)</span>
</h3>
Does the necessary cleanups and closes the parser library
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="openCurrentLib"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">openCurrentLib</span>(<span class="sig-vararg">...</span>)</span>
</h3>
<p>Tests if library exists and is current. If not, builds a fresh
one</p>
Opens the library
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="openLib"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">openLib</span>(<span class="sig-vararg">...</span>)</span>
</h3>
Loads the parser engine's dynamic library, and extracts the
following symbols:
<ul>
<li>
void *do_parse() (runs parser)
</li>
<li>
char *parserHash (contains hash of python parser rules)
</li>
</ul>
<p>Returns lib handle, plus pointer to do_parse() function, as long
ints (which later need to be cast to pointers)</p>
Important note -this is totally linux-specific. If you want windows
support, you'll have to modify these funcs to use glib instead (or
create windows equivalents), in which case I'd greatly appreciate you
sending me a patch.
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="runEngine"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">runEngine</span>(<span class="sig-vararg">...</span>)</span>
</h3>
Runs the binary parser engine, as loaded from the lib
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<br />
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Fri Apr 23 19:00:01 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>bison.ParserSyntaxError</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<font size="-1"><b class="breadcrumbs">
<a href="bison-module.html">Module&nbsp;bison</a> ::
Class&nbsp;ParserSyntaxError
</b></font></br>
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[show&nbsp;private&nbsp;|&nbsp;<a href="../public/bison.ParserSyntaxError-class.html">hide&nbsp;private</a>]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="bison.ParserSyntaxError-class.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<!-- =========== START OF CLASS DESCRIPTION =========== -->
<h2 class="class">Class ParserSyntaxError</h2>
<pre class="base-tree">
<a href="exceptions.Exception-class.html"><code>Exception</code></a> --+
|
<b>ParserSyntaxError</b>
</pre><br />
<hr/>
<!-- =========== START OF METHOD SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Method Summary</th></tr>
<tr bgcolor="#e8f0f8" class="group">
<th colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;Inherited from Exception</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="exceptions.Exception-class.html#__init__" class="summary-sig-name"><code>__init__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="exceptions.Exception-class.html#__getitem__" class="summary-sig-name"><code>__getitem__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="exceptions.Exception-class.html#__str__" class="summary-sig-name"><code>__str__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
</td></tr>
</table><br />
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sun Jun 27 12:36:56 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
/* Body color */
body { background: #ffffff; color: #000000; }
/* Tables */
table.summary, table.details, table.index
{ background: #e8f0f8; color: #000000; }
tr.summary, tr.details, tr.index
{ background: #70b0f0; color: #000000;
text-align: left; font-size: 120%; }
tr.group { background: #c0e0f8; color: #000000;
text-align: left; font-size: 120%;
font-style: italic; }
/* Documentation page titles */
h2.module { margin-top: 0.2em; }
h2.class { margin-top: 0.2em; }
/* Headings */
h1.heading { font-size: +140%; font-style: italic;
font-weight: bold; }
h2.heading { font-size: +125%; font-style: italic;
font-weight: bold; }
h3.heading { font-size: +110%; font-style: italic;
font-weight: normal; }
/* Base tree */
pre.base-tree { font-size: 80%; margin: 0; }
/* Details Sections */
table.func-details { background: #e8f0f8; color: #000000;
border: 2px groove #c0d0d0;
padding: 0 1em 0 1em; margin: 0.4em 0 0 0; }
h3.func-detail { background: transparent; color: #000000;
margin: 0 0 1em 0; }
table.var-details { background: #e8f0f8; color: #000000;
border: 2px groove #c0d0d0;
padding: 0 1em 0 1em; margin: 0.4em 0 0 0; }
h3.var-details { background: transparent; color: #000000;
margin: 0 0 1em 0; }
/* Function signatures */
.sig { background: transparent; color: #000000;
font-weight: bold; }
.sig-name { background: transparent; color: #006080; }
.sig-arg, .sig-kwarg, .sig-vararg
{ background: transparent; color: #008060; }
.sig-default { background: transparent; color: #602000; }
.summary-sig { background: transparent; color: #000000; }
.summary-sig-name { background: transparent; color: #204080; }
.summary-sig-arg, .summary-sig-kwarg, .summary-sig-vararg
{ background: transparent; color: #008060; }
/* Doctest blocks */
.py-src { background: transparent; color: #000000; }
.py-prompt { background: transparent; color: #005050;
font-weight: bold;}
.py-string { background: transparent; color: #006030; }
.py-comment { background: transparent; color: #003060; }
.py-keyword { background: transparent; color: #600000; }
.py-output { background: transparent; color: #404040; }
pre.doctestblock { background: #f4faff; color: #000000;
padding: .5em; margin: 1em;
border: 1px solid #708890; }
table pre.doctestblock
{ background: #dce4ec; color: #000000;
padding: .5em; margin: 1em;
border: 1px solid #708890; }
/* Variable values */
pre.variable { background: #dce4ec; color: #000000;
padding: .5em; margin: 0;
border: 1px solid #708890; }
.variable-linewrap { background: transparent; color: #604000; }
.variable-ellipsis { background: transparent; color: #604000; }
.variable-quote { background: transparent; color: #604000; }
.re { background: transparent; color: #000000; }
.re-char { background: transparent; color: #006030; }
.re-op { background: transparent; color: #600000; }
.re-group { background: transparent; color: #003060; }
.re-ref { background: transparent; color: #404040; }
/* Navigation bar */
table.navbar { background: #a0c0ff; color: #0000ff;
border: 2px groove #c0d0d0; }
th.navbar { background: #a0c0ff; color: #0000ff; }
th.navselect { background: #70b0ff; color: #000000; }
.nomargin { margin: 0; }
/* Links */
a:link { background: transparent; color: #0000ff; }
a:visited { background: transparent; color: #204080; }
a.navbar:link { background: transparent; color: #0000ff;
text-decoration: none; }
a.navbar:visited { background: transparent; color: #204080;
text-decoration: none; }
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>exceptions.Exception</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<font size="-1"><b class="breadcrumbs">
Module&nbsp;exceptions ::
Class&nbsp;Exception
</b></font></br>
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[show&nbsp;private&nbsp;|&nbsp;<a href="../public/exceptions.Exception-class.html">hide&nbsp;private</a>]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="exceptions.Exception-class.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<!-- =========== START OF CLASS DESCRIPTION =========== -->
<h2 class="class">Class Exception</h2>
<dl><dt><b>Known Subclasses:</b></dt>
<dd>
<a href="bison.ParserSyntaxError-class.html"><code>ParserSyntaxError</code></a></dd></dl>
<hr/>
Common base class for all exceptions.
<hr/>
<!-- =========== START OF METHOD SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Method Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="__init__"></a><span class="summary-sig"><span class="summary-sig-name">__init__</span>(<span class="summary-sig-vararg">...</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="__getitem__"></a><span class="summary-sig"><span class="summary-sig-name">__getitem__</span>(<span class="summary-sig-vararg">...</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="__str__"></a><span class="summary-sig"><span class="summary-sig-name">__str__</span>(<span class="summary-sig-vararg">...</span>)</span></code>
</td></tr>
</table><br />
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sun Jun 27 12:36:56 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<title> PyBison API Reference </title>
</head>
<frameset cols="20%,80%">
<frameset rows="30%,70%">
<frame src="toc.html" name="moduleListFrame">
<frame src="toc-everything.html" name="moduleFrame">
</frameset>
<frame src="bison-module.html" name="mainFrame">
</frameset>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Help</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th bgcolor="#70b0f0" class="navselect">&nbsp;&nbsp;&nbsp;Help&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[show&nbsp;private&nbsp;|&nbsp;<a href="../public/help.html">hide&nbsp;private</a>]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="help.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<center><h2> API Documentation </h2></center>
<p> This document contains the API (Application Programming Interface)
documentation for PyBison API Reference. Documentation for the Python
objects defined by the project is divided into separate pages for each
package, module, and class. The API documentation also includes two
pages containing information about the project as a whole: a trees
page, and an index page. </p>
<h2> Object Documentation </h2>
<p>Each <b>Package Documentation</b> page contains:
<ul>
<li> A description of the package. </li>
<li> A list of the modules and sub-packages contained by the
package. </li>
<li> A summary of the classes defined by the package. </li>
<li> A summary of the functions defined by the package. </li>
<li> A summary of the variables defined by the package. </li>
<li> A detailed description of each function defined by the
package. </li>
<li> A detailed description of each variable defined by the
package. </li>
</ul></p>
<p>Each <b>Module Documentation</b> page contains:
<ul>
<li> A description of the module. </li>
<li> A summary of the classes defined by the module. </li>
<li> A summary of the functions defined by the module. </li>
<li> A summary of the variables defined by the module. </li>
<li> A detailed description of each function defined by the
module. </li>
<li> A detailed description of each variable defined by the
module. </li>
</ul></p>
<p>Each <b>Class Documentation</b> page contains:
<ul>
<li> A class inheritance diagram. </li>
<li> A list of known subclasses. </li>
<li> A description of the class. </li>
<li> A summary of the methods defined by the class. </li>
<li> A summary of the instance variables defined by the class. </li>
<li> A summary of the class (static) variables defined by the
class. </li>
<li> A detailed description of each method defined by the
class. </li>
<li> A detailed description of each instance variable defined by the
class. </li>
<li> A detailed description of each class (static) variable defined
by the class. </li>
</ul></p>
<h2> Project Documentation </h2>
<p> The <b>Trees</b> page contains the module and class hierarchies:
<ul>
<li> The <i>module hierarchy</i> lists every package and module, with
modules grouped into packages. At the top level, and within each
package, modules and sub-packages are listed alphabetically. </li>
<li> The <i>class hierarchy</i> lists every class, grouped by base
class. If a class has more than one base class, then it will be
listed under each base class. At the top level, and under each base
class, classes are listed alphabetically. </li>
</ul></p>
<p> The <b>Index</b> page contains indices of terms and
identifiers:
<ul>
<li> The <i>term index</i> lists every term indexed by any object's
documentation. For each term, the index provides links to each
place where the term is indexed. </li>
<li> The <i>identifier index</i> lists the (short) name of every package,
module, class, method, function, variable, and parameter. For each
identifier, the index provides a short description, and a link to
its documentation. </li>
</ul></p>
<h2> The Table of Contents </h2>
<p> The table of contents occupies the two frames on the left side of
the window. The upper-left frame displays the <i>project
contents</i>, and the lower-left frame displays the <i>module
contents</i>: </p>
<center>
<table class="summary" border="1" cellspacing="0" cellpadding="3">
<tr heigh="30%">
<td align="center">
<font size="-1">Project<br>Contents<hr>...</font></td>
<td align="center" rowspan="2" width="70%">
API<br>Documentation<br>Frame<br><br><br>
</td>
</tr>
<tr>
<td align="center">
<font size="-1">Module<br>Contents<hr>&nbsp;<br>...<br>&nbsp;</font>
</td>
</tr>
</table><br>
</center>
<p> The <b>project contents frame</b> contains a list of all packages
and modules that are defined by the project. Clicking on an entry
will display its contents in the module contents frame. Clicking on a
special entry, labeled "Everything," will display the contents of
the entire project. </p>
<p> The <b>module contents frame</b> contains a list of every
submodule, class, type, exception, function, and variable defined by a
module or package. Clicking on an entry will display its
documentation in the API documentation frame. Clicking on the name of
the module, at the top of the frame, will display the documentation
for the module itself. </p>
<p> The "<b>frames</b>" and "<b>no frames</b>" buttons below the top
navigation bar can be used to control whether the table of contents is
displayed or not. </p>
<h2> The Navigation Bar </h2>
<p> A navigation bar is located at the top and bottom of every page.
It indicates what type of page you are currently viewing, and allows
you to go to related pages. The following table describes the labels
on the navigation bar. Note that not some labels (such as
[Parent]) are not displayed on all pages. </p>
<table class="summary" border="1" cellspacing="0" cellpadding="3" width="100%">
<tr class="summary">
<th>Label</th>
<th>Highlighted when...</th>
<th>Links to...</th>
</tr>
<tr><td valign="top"><b>[Parent]</b></td>
<td valign="top"><i>(never highlighted)</i></td>
<td valign="top"> the parent of the current package </td></tr>
<tr><td valign="top"><b>[Package]</b></td>
<td valign="top">viewing a package</td>
<td valign="top">the package containing the current object
</td></tr>
<tr><td valign="top"><b>[Module]</b></td>
<td valign="top">viewing a module</td>
<td valign="top">the module containing the current object
</td></tr>
<tr><td valign="top"><b>[Class]</b></td>
<td valign="top">viewing a class </td>
<td valign="top">the class containing the current object</td></tr>
<tr><td valign="top"><b>[Trees]</b></td>
<td valign="top">viewing the trees page</td>
<td valign="top"> the trees page </td></tr>
<tr><td valign="top"><b>[Index]</b></td>
<td valign="top">viewing the index page</td>
<td valign="top"> the index page </td></tr>
<tr><td valign="top"><b>[Help]</b></td>
<td valign="top">viewing the help page</td>
<td valign="top"> the help page </td></tr>
</table>
<p> The "<b>show private</b>" and "<b>hide private</b>" buttons below
the top navigation bar can be used to control whether documentation
for private objects is displayed. Private objects are usually defined
as objects whose (short) names begin with a single underscore, but do
not end with an underscore. For example, "<code>_x</code>",
"<code>__pprint</code>", and "<code>epydoc.epytext._tokenize</code>"
are private objects; but "<code>re.sub</code>",
"<code>__init__</code>", and "<code>type_</code>" are not. However,
if a module defines the "<code>__all__</code>" variable, then its
contents are used to decide which objects are private. </p>
<p> A timestamp below the bottom navigation bar indicates when each
page was last updated. </p>
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th bgcolor="#70b0f0" class="navselect">&nbsp;&nbsp;&nbsp;Help&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sun Jun 27 12:36:56 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<title> PyBison API Reference </title>
</head>
<frameset cols="20%,80%">
<frameset rows="30%,70%">
<frame src="toc.html" name="moduleListFrame">
<frame src="toc-everything.html" name="moduleFrame">
</frameset>
<frame src="bison-module.html" name="mainFrame">
</frameset>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Index</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th bgcolor="#70b0f0" class="navselect">&nbsp;&nbsp;&nbsp;Index&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[show&nbsp;private&nbsp;|&nbsp;<a href="../public/indices.html">hide&nbsp;private</a>]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="indices.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<br />
<!-- =========== START OF IDENTIFIER INDEX =========== -->
<table class="index" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="index">
<th colspan="2">Identifier Index</th></tr>
<tr><td width="15%"><a href="__builtin__.object-class.html"><code>object</code></a></td>
<td>Class in module <code>__builtin__</code></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__bases__"><code>__bases__</code></a></td>
<td>Variable in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__basicsize__"><code>__basicsize__</code></a></td>
<td>Variable in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__call__"><code>__call__</code></a></td>
<td>Method in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html"><code>type</code></a></td>
<td>Class in module <code>__builtin__</code></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__cmp__"><code>__cmp__</code></a></td>
<td>Method in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.object-class.html#__delattr__"><code>__delattr__</code></a></td>
<td>Method in class <a href="__builtin__.object-class.html"><code>__builtin__.object</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__delattr__"><code>__delattr__</code></a></td>
<td>Method in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__dictoffset__"><code>__dictoffset__</code></a></td>
<td>Variable in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__flags__"><code>__flags__</code></a></td>
<td>Variable in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.object-class.html#__getattribute__"><code>__getattribute__</code></a></td>
<td>Method in class <a href="__builtin__.object-class.html"><code>__builtin__.object</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__getattribute__"><code>__getattribute__</code></a></td>
<td>Method in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#__getitem__"><code>__getitem__</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#__getitem__"><code>__getitem__</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="exceptions.Exception-class.html#__getitem__"><code>__getitem__</code></a></td>
<td>Method in class <a href="exceptions.Exception-class.html"><code>exceptions.Exception</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#__getslice__"><code>__getslice__</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.object-class.html#__hash__"><code>__hash__</code></a></td>
<td>Method in class <a href="__builtin__.object-class.html"><code>__builtin__.object</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__hash__"><code>__hash__</code></a></td>
<td>Method in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.object-class.html#__init__"><code>__init__</code></a></td>
<td>Method in class <a href="__builtin__.object-class.html"><code>__builtin__.object</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonError-class.html#__init__"><code>__init__</code></a></td>
<td>Method in class <a href="bison.BisonError-class.html"><code>bison.BisonError</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#__init__"><code>__init__</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#__init__"><code>__init__</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="exceptions.Exception-class.html#__init__"><code>__init__</code></a></td>
<td>Method in class <a href="exceptions.Exception-class.html"><code>exceptions.Exception</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__itemsize__"><code>__itemsize__</code></a></td>
<td>Variable in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#__iter__"><code>__iter__</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#__len__"><code>__len__</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__mro__"><code>__mro__</code></a></td>
<td>Variable in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__name__"><code>__name__</code></a></td>
<td>Variable in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__new__"><code>__new__</code></a></td>
<td>Method in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__new__"><code>__new__</code></a></td>
<td>Method in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.object-class.html#__reduce__"><code>__reduce__</code></a></td>
<td>Method in class <a href="__builtin__.object-class.html"><code>__builtin__.object</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.object-class.html#__reduce_ex__"><code>__reduce_ex__</code></a></td>
<td>Method in class <a href="__builtin__.object-class.html"><code>__builtin__.object</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.object-class.html#__repr__"><code>__repr__</code></a></td>
<td>Method in class <a href="__builtin__.object-class.html"><code>__builtin__.object</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__repr__"><code>__repr__</code></a></td>
<td>Method in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#__repr__"><code>__repr__</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.object-class.html#__setattr__"><code>__setattr__</code></a></td>
<td>Method in class <a href="__builtin__.object-class.html"><code>__builtin__.object</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__setattr__"><code>__setattr__</code></a></td>
<td>Method in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.object-class.html#__str__"><code>__str__</code></a></td>
<td>Method in class <a href="__builtin__.object-class.html"><code>__builtin__.object</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#__str__"><code>__str__</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="exceptions.Exception-class.html#__str__"><code>__str__</code></a></td>
<td>Method in class <a href="exceptions.Exception-class.html"><code>exceptions.Exception</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__subclasses__"><code>__subclasses__</code></a></td>
<td>Method in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__weakrefoffset__"><code>__weakrefoffset__</code></a></td>
<td>Variable in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="../private/bison.BisonParser-class.html#_error"><code>_error</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="../private/bison.BisonParser-class.html#_globals"><code>_globals</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="../private/bison.BisonParser-class.html#_handle"><code>_handle</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison-module.html"><code>bison</code></a></td>
<td>Module</td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#bisonCFile"><code>bisonCFile</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#bisonCFile1"><code>bisonCFile1</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#bisonCmd"><code>bisonCmd</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#bisonEngineLibName"><code>bisonEngineLibName</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonError-class.html"><code>BisonError</code></a></td>
<td>Class in module <a href="bison-module.html"><code>bison</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#bisonFile"><code>bisonFile</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#bisonHFile"><code>bisonHFile</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#bisonHFile1"><code>bisonHFile1</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html"><code>BisonNode</code></a></td>
<td>Class in module <a href="bison-module.html"><code>bison</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html"><code>BisonParser</code></a></td>
<td>Class in module <a href="bison-module.html"><code>bison</code></a></td></tr>
<tr><td width="15%"><a href="bison-module.html#bisonToPython"><code>bisonToPython</code></a></td>
<td>Function in module <a href="bison-module.html"><code>bison</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html"><code>BisonNode</code></a></td>
<td>Class in module <a href="bison-module.html"><code>bison</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#dump"><code>dump</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#error"><code>error</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="exceptions.Exception-class.html"><code>Exception</code></a></td>
<td>Class in module <code>exceptions</code></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#file"><code>file</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#flexCFile"><code>flexCFile</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#flexCFile1"><code>flexCFile1</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#flexCmd"><code>flexCmd</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#flexFile"><code>flexFile</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#keepfiles"><code>keepfiles</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#last"><code>last</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#lasterror"><code>lasterror</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#loadxml"><code>loadxml</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#loadxmldoc"><code>loadxmldoc</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#loadxmlobj"><code>loadxmlobj</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#mro"><code>mro</code></a></td>
<td>Method in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.object-class.html"><code>object</code></a></td>
<td>Class in module <code>__builtin__</code></td></tr>
<tr><td width="15%"><a href="bison.ParserSyntaxError-class.html"><code>ParserSyntaxError</code></a></td>
<td>Class in module <a href="bison-module.html"><code>bison</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#read"><code>read</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison-module.html#reSpaces"><code>reSpaces</code></a></td>
<td>Variable in module <a href="bison-module.html"><code>bison</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#run"><code>run</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#toprettyxml"><code>toprettyxml</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#toprettyxml"><code>toprettyxml</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#toxml"><code>toxml</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#toxml"><code>toxml</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#toxmldoc"><code>toxmldoc</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#toxmldoc"><code>toxmldoc</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#toxmlelem"><code>toxmlelem</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html"><code>type</code></a></td>
<td>Class in module <code>__builtin__</code></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#verbose"><code>verbose</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
</table>
<br />
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th bgcolor="#70b0f0" class="navselect">&nbsp;&nbsp;&nbsp;Index&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sun Jun 27 12:36:56 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>bison</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<center><font size="+1"><b><a target="mainFrame" href="bison-module.html">bison</a></b></font></center>
<hr>
<!-- =========== START OF CLASSES =========== -->
<font size="+1"><b>Classes</b></font><br />
<a target="mainFrame" href="bison.BisonError-class.html">BisonError</a><br />
<a target="mainFrame" href="bison.BisonNode-class.html">BisonNode</a><br />
<a target="mainFrame" href="bison.BisonParser-class.html">BisonParser</a><br />
<br />
<!-- =========== START OF EXCEPTIONS =========== -->
<font size="+1"><b>Exceptions</b></font><br />
<a target="mainFrame" href="bison.ParserSyntaxError-class.html">ParserSyntaxError</a><br />
<br />
<!-- =========== START OF FUNCTIONS =========== -->
<font size="+1"><b>Functions</b></font><br />
<a target="mainFrame" href="bison-module.html#bisonToPython">bisonToPython</a><br />
<br />
<!-- =========== START OF VARIABLES =========== -->
<font size="+1"><b>Variables</b></font><br />
<a target="mainFrame" href="bison-module.html#reSpaces">reSpaces</a><br />
<br />
<hr>
<font size="-2">[show&nbsp;private&nbsp;|&nbsp;<a href="../public/toc-bison-module.html">hide&nbsp;private</a>]</font>
</body>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Everything</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<center><font size="+1"><b>Everything</b></font></center>
<hr>
<!-- =========== START OF ALL CLASSES =========== -->
<font size="+1"><b>All&nbsp;Classes</b></font><br />
<a target="mainFrame" href="bison.BisonError-class.html">bison.BisonError</a><br />
<a target="mainFrame" href="bison.BisonNode-class.html">bison.BisonNode</a><br />
<a target="mainFrame" href="bison.BisonParser-class.html">bison.BisonParser</a><br />
<br />
<!-- =========== START OF ALL EXCEPTIONS =========== -->
<font size="+1"><b>All&nbsp;Exceptions</b></font><br />
<a target="mainFrame" href="bison.ParserSyntaxError-class.html">bison.ParserSyntaxError</a><br />
<br />
<!-- =========== START OF ALL FUNCTIONS =========== -->
<font size="+1"><b>All&nbsp;Functions</b></font><br />
<a target="mainFrame" href="bison-module.html#bisonToPython">bisonToPython</a><br />
<br />
<!-- =========== START OF ALL VARIABLES =========== -->
<font size="+1"><b>All&nbsp;Variables</b></font><br />
<a target="mainFrame" href="bison-module.html#reSpaces">reSpaces</a><br />
<br />
<hr>
<font size="-2">[show&nbsp;private&nbsp;|&nbsp;<a href="../public/toc-everything.html">hide&nbsp;private</a>]</font>
</body>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Table of Contents</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<center><font size="+1"><b>Table&nbsp;of&nbsp;Contents</b></font></center>
<hr>
<a target="moduleFrame" href="toc-everything.html">Everything</a><br />
<!-- =========== START OF PACKAGES =========== -->
<br /><font size="+1"><b>Packages</b></font><br />
<!-- =========== START OF MODULES =========== -->
<br /><font size="+1"><b>Modules</b></font><br />
<a target="moduleFrame" href="toc-bison-module.html">bison</a><br />
<br /><hr>
<font size="-2">[show&nbsp;private&nbsp;|&nbsp;<a href="../public/toc.html">hide&nbsp;private</a>]</font>
</body>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Module and Class Hierarchies</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th bgcolor="#70b0f0" class="navselect">&nbsp;&nbsp;&nbsp;Trees&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[show&nbsp;private&nbsp;|&nbsp;<a href="../public/trees.html">hide&nbsp;private</a>]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="trees.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<!-- =========== START OF MODULE HIERARCHY =========== -->
<h2>Module Hierarchy</h2>
<ul>
<li> <b><a href="bison-module.html"><code>bison</code></a></b>: <i>Wrapper module for interfacing with Bison (yacc)</i>
</ul>
<!-- =========== START OF CLASS HIERARCHY =========== -->
<h2>Class Hierarchy</h2>
<ul>
<li> <b><a href="__builtin__.object-class.html"><code>__builtin__.object</code></a></b>: <i>
The most base type</i>
<ul>
<li> <b><a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></b>: <i>
Base parser class</i>
<li> <b><a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></b>: <i>
type(object) -&gt; the object's type type(name, bases, dict) -&gt; a
new type</i>
</ul>
<li> <b><a href="bison.BisonError-class.html"><code>bison.BisonError</code></a></b>: <i>
Flags an error to yyparse()</i>
<li> <b><a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></b>: <i>
Generic class for wrapping parse targets.</i>
<li> <b><a href="exceptions.Exception-class.html"><code>exceptions.Exception</code></a></b>: <i>
Common base class for all exceptions.</i>
<ul>
<li> <b><a href="bison.ParserSyntaxError-class.html"><code>bison.ParserSyntaxError</code></a></b>
</ul>
</ul>
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sun Jun 27 12:36:56 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>__builtin__.object</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<font size="-1"><b class="breadcrumbs">
Module&nbsp;__builtin__ ::
Class&nbsp;object
</b></font></br>
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[<a href="../private/__builtin__.object-class.html">show&nbsp;private</a>&nbsp;|&nbsp;hide&nbsp;private]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="__builtin__.object-class.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<!-- =========== START OF CLASS DESCRIPTION =========== -->
<h2 class="class">Class object</h2>
<dl><dt><b>Known Subclasses:</b></dt>
<dd>
<a href="bison.BisonParser-class.html"><code>BisonParser</code></a>,
<a href="__builtin__.type-class.html"><code>type</code></a></dd></dl>
<hr/>
The most base type
<hr/>
<!-- =========== START OF METHOD SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Method Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__init__" class="summary-sig-name"><code>__init__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__init__(...) initializes x; see x.__class__.__doc__ for
signature</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__delattr__" class="summary-sig-name"><code>__delattr__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__delattr__('name') &lt;==&gt; del x.name</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__getattribute__" class="summary-sig-name"><code>__getattribute__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__getattribute__('name') &lt;==&gt; x.name</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__hash__" class="summary-sig-name"><code>__hash__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__hash__() &lt;==&gt; hash(x)</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__reduce__" class="summary-sig-name"><code>__reduce__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
helper for pickle</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__reduce_ex__" class="summary-sig-name"><code>__reduce_ex__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
helper for pickle</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__repr__" class="summary-sig-name"><code>__repr__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__repr__() &lt;==&gt; repr(x)</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__setattr__" class="summary-sig-name"><code>__setattr__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__setattr__('name', value) &lt;==&gt; x.name = value</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__str__" class="summary-sig-name"><code>__str__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__str__() &lt;==&gt; str(x)</td></tr>
<tr bgcolor="#e8f0f8" class="group">
<th colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;Inherited from type</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__new__" class="summary-sig-name"><code>__new__</code></a>(<span class=summary-sig-arg>T</span>,
<span class=summary-sig-arg>S</span>,
<span class="summary-sig-vararg">...</span>)</span></code>
<br />
T.__new__(S, ...) -&gt; a new object with type S, a subtype of T</td></tr>
</table><br />
<!-- =========== START OF CLASS VARIABLE SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Class Variable Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>type</code></font></td>
<td><a name="__class__"></a><b><code>__class__</code></b> = <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
</table><br />
<!-- =========== START OF METHOD DETAILS =========== -->
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="details">
<th colspan="2">Method Details</th></tr>
</table>
<a name="__init__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-vararg">...</span>)</span>
<br /><i>(Constructor)</i>
</h3>
x.__init__(...) initializes x; see x.__class__.__doc__ for
signature
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="__delattr__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__delattr__</span>(<span class="sig-vararg">...</span>)</span>
</h3>
x.__delattr__('name') &lt;==&gt; del x.name
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="__getattribute__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__getattribute__</span>(<span class="sig-vararg">...</span>)</span>
</h3>
x.__getattribute__('name') &lt;==&gt; x.name
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="__hash__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__hash__</span>(<span class=sig-arg>x</span>)</span>
<br /><i>(Hashing function)</i>
</h3>
x.__hash__() &lt;==&gt; hash(x)
<dl><dt></dt><dd>
<dl><dt><b>Returns:</b></dt>
<dd>
<pre class="literalblock">
hash(x)
</pre>
</dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="__reduce__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__reduce__</span>(<span class="sig-vararg">...</span>)</span>
</h3>
helper for pickle
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="__reduce_ex__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__reduce_ex__</span>(<span class="sig-vararg">...</span>)</span>
</h3>
helper for pickle
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="__repr__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__repr__</span>(<span class=sig-arg>x</span>)</span>
<br /><i>(Representation operator)</i>
</h3>
x.__repr__() &lt;==&gt; repr(x)
<dl><dt></dt><dd>
<dl><dt><b>Returns:</b></dt>
<dd>
<pre class="literalblock">
repr(x)
</pre>
</dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="__setattr__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__setattr__</span>(<span class="sig-vararg">...</span>)</span>
</h3>
x.__setattr__('name', value) &lt;==&gt; x.name = value
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="__str__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__str__</span>(<span class=sig-arg>x</span>)</span>
<br /><i>(Informal representation operator)</i>
</h3>
x.__str__() &lt;==&gt; str(x)
<dl><dt></dt><dd>
<dl><dt><b>Returns:</b></dt>
<dd>
<pre class="literalblock">
str(x)
</pre>
</dd>
</dl>
</dd></dl>
</td></tr></table>
<br />
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sun Jun 27 12:36:56 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>__builtin__.type</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<font size="-1"><b class="breadcrumbs">
Module&nbsp;__builtin__ ::
Class&nbsp;type
</b></font></br>
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[<a href="../private/__builtin__.type-class.html">show&nbsp;private</a>&nbsp;|&nbsp;hide&nbsp;private]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="__builtin__.type-class.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<!-- =========== START OF CLASS DESCRIPTION =========== -->
<h2 class="class">Class type</h2>
<pre class="base-tree">
<a href="__builtin__.object-class.html"><code>object</code></a> --+
|
<b>type</b>
</pre><br />
<hr/>
type(object) -&gt; the object's type type(name, bases, dict) -&gt; a
new type
<hr/>
<!-- =========== START OF METHOD SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Method Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__call__" class="summary-sig-name"><code>__call__</code></a>(<span class=summary-sig-arg>x</span>,
<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__call__(...) &lt;==&gt; x(...)</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__cmp__" class="summary-sig-name"><code>__cmp__</code></a>(<span class=summary-sig-arg>x</span>,
<span class=summary-sig-arg>y</span>)</span></code>
<br />
x.__cmp__(y) &lt;==&gt; cmp(x,y)</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__delattr__" class="summary-sig-name"><code>__delattr__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__delattr__('name') &lt;==&gt; del x.name</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__getattribute__" class="summary-sig-name"><code>__getattribute__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__getattribute__('name') &lt;==&gt; x.name</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__hash__" class="summary-sig-name"><code>__hash__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__hash__() &lt;==&gt; hash(x)</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__new__" class="summary-sig-name"><code>__new__</code></a>(<span class=summary-sig-arg>T</span>,
<span class=summary-sig-arg>S</span>,
<span class="summary-sig-vararg">...</span>)</span></code>
<br />
T.__new__(S, ...) -&gt; a new object with type S, a subtype of T</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__repr__" class="summary-sig-name"><code>__repr__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__repr__() &lt;==&gt; repr(x)</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__setattr__" class="summary-sig-name"><code>__setattr__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__setattr__('name', value) &lt;==&gt; x.name = value</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">list of immediate subclasses</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__subclasses__" class="summary-sig-name"><code>__subclasses__</code></a>()</span></code>
<br />
__subclasses__() -&gt; list of immediate subclasses</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">list</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#mro" class="summary-sig-name"><code>mro</code></a>()</span></code>
<br />
return a type's method resolution order</td></tr>
<tr bgcolor="#e8f0f8" class="group">
<th colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;Inherited from object</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__init__" class="summary-sig-name"><code>__init__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__init__(...) initializes x; see x.__class__.__doc__ for
signature</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__reduce__" class="summary-sig-name"><code>__reduce__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
helper for pickle</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__reduce_ex__" class="summary-sig-name"><code>__reduce_ex__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
helper for pickle</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__str__" class="summary-sig-name"><code>__str__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__str__() &lt;==&gt; str(x)</td></tr>
</table><br />
<!-- =========== START OF CLASS VARIABLE SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Class Variable Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>type</code></font></td>
<td><a name="__base__"></a><b><code>__base__</code></b> = <a href="__builtin__.object-class.html"><code>__builtin__.object</code></a></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>tuple</code></font></td>
<td><b><a href="__builtin__.type-class.html#__bases__"><code>__bases__</code></a></b> = <span title="(&lt;type 'object'&gt;,)"><code>(&lt;type&nbsp;'object'&gt;,) </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>int</code></font></td>
<td><b><a href="__builtin__.type-class.html#__basicsize__"><code>__basicsize__</code></a></b> = <span title="420">420&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>int</code></font></td>
<td><b><a href="__builtin__.type-class.html#__dictoffset__"><code>__dictoffset__</code></a></b> = <span title="132">132&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>int</code></font></td>
<td><b><a href="__builtin__.type-class.html#__flags__"><code>__flags__</code></a></b> = <span title="21995">21995&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>int</code></font></td>
<td><b><a href="__builtin__.type-class.html#__itemsize__"><code>__itemsize__</code></a></b> = <span title="20">20&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>tuple</code></font></td>
<td><b><a href="__builtin__.type-class.html#__mro__"><code>__mro__</code></a></b> = <span title="(&lt;type 'type'&gt;, &lt;type 'object'&gt;)"><code>(&lt;type&nbsp;'type'&gt;,&nbsp;&lt;type&nbsp;'object'&gt;) </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>str</code></font></td>
<td><b><a href="__builtin__.type-class.html#__name__"><code>__name__</code></a></b> = <span title="'type'"><code><span class="variable-quote">'</span>type<span class="variable-quote">'</span> </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>int</code></font></td>
<td><b><a href="__builtin__.type-class.html#__weakrefoffset__"><code>__weakrefoffset__</code></a></b> = <span title="184">184&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
</table><br />
<!-- =========== START OF METHOD DETAILS =========== -->
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="details">
<th colspan="2">Method Details</th></tr>
</table>
<a name="__call__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__call__</span>(<span class=sig-arg>x</span>,
<span class="sig-vararg">...</span>)</span>
<br /><i>(Call operator)</i>
</h3>
x.__call__(...) &lt;==&gt; x(...)
<dl><dt></dt><dd>
<dl><dt><b>Returns:</b></dt>
<dd>
<pre class="literalblock">
x(...)
</pre>
</dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="__cmp__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__cmp__</span>(<span class=sig-arg>x</span>,
<span class=sig-arg>y</span>)</span>
<br /><i>(Comparison operator)</i>
</h3>
x.__cmp__(y) &lt;==&gt; cmp(x,y)
<dl><dt></dt><dd>
<dl><dt><b>Returns:</b></dt>
<dd>
<pre class="literalblock">
cmp(x,y)
</pre>
</dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="__delattr__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__delattr__</span>(<span class="sig-vararg">...</span>)</span>
</h3>
x.__delattr__('name') &lt;==&gt; del x.name
<dl><dt></dt><dd>
<dl><dt><b>Overrides:</b></dt>
<dd><a href="__builtin__.object-class.html#__delattr__"><code>__builtin__.object.__delattr__</code></a></dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="__getattribute__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__getattribute__</span>(<span class="sig-vararg">...</span>)</span>
</h3>
x.__getattribute__('name') &lt;==&gt; x.name
<dl><dt></dt><dd>
<dl><dt><b>Overrides:</b></dt>
<dd><a href="__builtin__.object-class.html#__getattribute__"><code>__builtin__.object.__getattribute__</code></a></dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="__hash__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__hash__</span>(<span class=sig-arg>x</span>)</span>
<br /><i>(Hashing function)</i>
</h3>
x.__hash__() &lt;==&gt; hash(x)
<dl><dt></dt><dd>
<dl><dt><b>Returns:</b></dt>
<dd>
<pre class="literalblock">
hash(x)
</pre>
</dd>
</dl>
<dl><dt><b>Overrides:</b></dt>
<dd><a href="__builtin__.object-class.html#__hash__"><code>__builtin__.object.__hash__</code></a></dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="__new__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__new__</span>(<span class=sig-arg>T</span>,
<span class=sig-arg>S</span>,
<span class="sig-vararg">...</span>)</span>
</h3>
T.__new__(S, ...) -&gt; a new object with type S, a subtype of T
<dl><dt></dt><dd>
<dl><dt><b>Returns:</b></dt>
<dd>
<pre class="literalblock">
a new object with type S, a subtype of T
</pre>
</dd>
</dl>
<dl><dt><b>Overrides:</b></dt>
<dd><a href="__builtin__.type-class.html#__new__"><code>__builtin__.type.__new__</code></a></dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="__repr__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__repr__</span>(<span class=sig-arg>x</span>)</span>
<br /><i>(Representation operator)</i>
</h3>
x.__repr__() &lt;==&gt; repr(x)
<dl><dt></dt><dd>
<dl><dt><b>Returns:</b></dt>
<dd>
<pre class="literalblock">
repr(x)
</pre>
</dd>
</dl>
<dl><dt><b>Overrides:</b></dt>
<dd><a href="__builtin__.object-class.html#__repr__"><code>__builtin__.object.__repr__</code></a></dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="__setattr__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__setattr__</span>(<span class="sig-vararg">...</span>)</span>
</h3>
x.__setattr__('name', value) &lt;==&gt; x.name = value
<dl><dt></dt><dd>
<dl><dt><b>Overrides:</b></dt>
<dd><a href="__builtin__.object-class.html#__setattr__"><code>__builtin__.object.__setattr__</code></a></dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="__subclasses__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__subclasses__</span>()</span>
</h3>
__subclasses__() -&gt; list of immediate subclasses
<dl><dt></dt><dd>
<dl><dt><b>Returns:</b></dt>
<dd>
list of immediate subclasses </dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="mro"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">mro</span>()</span>
</h3>
return a type's method resolution order
<dl><dt></dt><dd>
<dl><dt><b>Returns:</b></dt>
<dd>
list </dd>
</dl>
</dd></dl>
</td></tr></table>
<br />
<!-- =========== START OF CLASS VARIABLE DETAILS =========== -->
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="details">
<th colspan="2">Class Variable Details</th></tr>
</table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="__bases__"></a>
<h3>__bases__</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>tuple</code>
</dd>
<span title="(&lt;type 'object'&gt;,)"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
(&lt;type 'object'&gt;,) </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="__basicsize__"></a>
<h3>__basicsize__</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>int</code>
</dd>
<span title="420"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
420&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="__dictoffset__"></a>
<h3>__dictoffset__</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>int</code>
</dd>
<span title="132"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
132&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="__flags__"></a>
<h3>__flags__</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>int</code>
</dd>
<span title="21995"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
21995&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="__itemsize__"></a>
<h3>__itemsize__</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>int</code>
</dd>
<span title="20"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
20&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="__mro__"></a>
<h3>__mro__</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>tuple</code>
</dd>
<span title="(&lt;type 'type'&gt;, &lt;type 'object'&gt;)"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
(&lt;type 'type'&gt;, &lt;type 'object'&gt;) </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="__name__"></a>
<h3>__name__</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>str</code>
</dd>
<span title="'type'"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
<span class="variable-quote">'</span>type<span class="variable-quote">'</span> </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="__weakrefoffset__"></a>
<h3>__weakrefoffset__</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>int</code>
</dd>
<span title="184"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
184&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<br />
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sun Jun 27 12:36:56 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>bison</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th bgcolor="#70b0f0" class="navselect">&nbsp;&nbsp;&nbsp;Home&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<font size="-1"><b class="breadcrumbs">
Module&nbsp;bison
</b></font></br>
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[<a href="../private/bison-module.html">show&nbsp;private</a>&nbsp;|&nbsp;hide&nbsp;private]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="bison-module.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<!-- =========== START OF MODULE DESCRIPTION =========== -->
<h2 class="module">Module bison</h2>
<p>Wrapper module for interfacing with Bison (yacc)</p>
<p>Written April 2004 by David McNab &lt;david&#64;freenet.org.nz&gt;
Copyright (c) 2004 by David McNab, all rights reserved.</p>
<p>Released under the GNU General Public License, a copy of which should
appear in this distribution in the file called 'COPYING'. If this file is
missing, then you can obtain a copy of the GPL license document from the
GNU website at http://www.gnu.org.</p>
<p>This software is released with no warranty whatsoever. Use it at your
own risk.</p>
If you wish to use this software in a commercial application, and wish
to depart from the GPL licensing requirements, please contact the author
and apply for a commercial license.
<hr/>
<!-- =========== START OF CLASSES =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Classes</th></tr>
<tr><td width="15%">
<b><a href="bison.BisonError-class.html"><code>BisonError</code></a></b></td>
<td>Flags an error to yyparse()</td></tr>
<tr><td width="15%">
<b><a href="bison.BisonNode-class.html"><code>BisonNode</code></a></b></td>
<td>Generic class for wrapping parse targets.</td></tr>
<tr><td width="15%">
<b><a href="bison.BisonParser-class.html"><code>BisonParser</code></a></b></td>
<td>Base parser class</td></tr>
</table><br />
<!-- =========== START OF EXCEPTIONS =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Exceptions</th></tr>
<tr><td width="15%">
<b><a href="bison.ParserSyntaxError-class.html"><code>ParserSyntaxError</code></a></b></td>
<td>&nbsp;</td></tr>
</table><br />
<!-- =========== START OF FUNCTION SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Function Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison-module.html#bisonToPython" class="summary-sig-name"><code>bisonToPython</code></a>(<span class=summary-sig-arg>bisonfileName</span>,
<span class=summary-sig-arg>lexfileName</span>,
<span class=summary-sig-arg>pyfileName</span>,
<span class=summary-sig-arg>generateClasses</span>)</span></code>
<br />
Rips the rules, tokens and precedences from a bison file, and the
verbatim text from a lex file and generates a boilerplate python file
containing a Parser class with handler methods and grammar attributes</td></tr>
</table><br />
<!-- =========== START OF VARIABLE SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Variable Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>SRE_Pattern</code></font></td>
<td><b><a href="bison-module.html#reSpaces"><code>reSpaces</code></a></b> = <span title="&lt;_sre.SRE_Pattern object at 0x4029a2f8&gt;"><code><span class="re"><span class="re-char">\s</span><span class="re-op">+</span></span> </code>
</span></td></tr>
</table><br />
<!-- =========== START OF FUNCTION DETAILS =========== -->
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="details">
<th colspan="2">Function Details</th></tr>
</table>
<a name="bisonToPython"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">bisonToPython</span>(<span class=sig-arg>bisonfileName</span>,
<span class=sig-arg>lexfileName</span>,
<span class=sig-arg>pyfileName</span>,
<span class=sig-arg>generateClasses</span>=<span class=sig-default>0</span>)</span>
</h3>
<p>Rips the rules, tokens and precedences from a bison file, and the
verbatim text from a lex file and generates a boilerplate python file
containing a Parser class with handler methods and grammar
attributes</p>
Arguments:
<ul>
<li>
bisonfileName - name of input bison script
</li>
<li>
lexfileName - name of input flex script
</li>
<li>
pyfileName - name of output python file
</li>
<li>
generateClasses - flag - default 0 - if 1, causes a unique class
to be defined for each parse target, and for the corresponding
target handler method in the main Parser class to use this class
when creating the node.
</li>
</ul>
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<br />
<!-- =========== START OF VARIABLE DETAILS =========== -->
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="details">
<th colspan="2">Variable Details</th></tr>
</table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="reSpaces"></a>
<h3>reSpaces</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>SRE_Pattern</code>
</dd>
<span title="&lt;_sre.SRE_Pattern object at 0x4029a2f8&gt;"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
<span class="re"><span class="re-char">\s</span><span class="re-op">+</span></span> </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<br />
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th bgcolor="#70b0f0" class="navselect">&nbsp;&nbsp;&nbsp;Home&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sun Jun 27 12:36:56 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>bison.BisonError</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<font size="-1"><b class="breadcrumbs">
<a href="bison-module.html">Module&nbsp;bison</a> ::
Class&nbsp;BisonError
</b></font></br>
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[<a href="../private/bison.BisonError-class.html">show&nbsp;private</a>&nbsp;|&nbsp;hide&nbsp;private]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="bison.BisonError-class.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<!-- =========== START OF CLASS DESCRIPTION =========== -->
<h2 class="class">Class BisonError</h2>
<hr/>
<p>Flags an error to yyparse()</p>
You should return this in your actions to notify a syntax error
<hr/>
<!-- =========== START OF METHOD SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Method Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="__init__"></a><span class="summary-sig"><span class="summary-sig-name">__init__</span>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>value</span>)</span></code>
</td></tr>
</table><br />
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sun Jun 27 12:36:56 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>bison.BisonNode</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<font size="-1"><b class="breadcrumbs">
<a href="bison-module.html">Module&nbsp;bison</a> ::
Class&nbsp;BisonNode
</b></font></br>
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[<a href="../private/bison.BisonNode-class.html">show&nbsp;private</a>&nbsp;|&nbsp;hide&nbsp;private]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="bison.BisonNode-class.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<!-- =========== START OF CLASS DESCRIPTION =========== -->
<h2 class="class">Class BisonNode</h2>
<hr/>
<p>Generic class for wrapping parse targets.</p>
Arguments:
<ul>
<li>
targetname - the name of the parse target being wrapped.
</li>
<li>
items - optional - a list of items comprising a clause in the
target rule - typically this will only be used by the PyBison
callback mechanism.
</li>
</ul>
Keywords:
<ul>
<li>
any keywords you want (except 'items'), with any type of value.
keywords will be stored as attributes in the constructed object.
</li>
</ul>
<hr/>
<!-- =========== START OF METHOD SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Method Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="__init__"></a><span class="summary-sig"><span class="summary-sig-name">__init__</span>(<span class=summary-sig-arg>self</span>,
<span class="summary-sig-kwarg">**kw</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonNode-class.html#__getitem__" class="summary-sig-name"><code>__getitem__</code></a>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>item</span>)</span></code>
<br />
Retrieves the ith value from this node, or child nodes</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="__getslice__"></a><span class="summary-sig"><span class="summary-sig-name">__getslice__</span>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>fromidx</span>,
<span class=summary-sig-arg>toidx</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="__iter__"></a><span class="summary-sig"><span class="summary-sig-name">__iter__</span>(<span class=summary-sig-arg>self</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="__len__"></a><span class="summary-sig"><span class="summary-sig-name">__len__</span>(<span class=summary-sig-arg>self</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="__repr__"></a><span class="summary-sig"><span class="summary-sig-name">__repr__</span>(<span class=summary-sig-arg>self</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="__str__"></a><span class="summary-sig"><span class="summary-sig-name">__str__</span>(<span class=summary-sig-arg>self</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonNode-class.html#dump" class="summary-sig-name"><code>dump</code></a>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>indent</span>)</span></code>
<br />
For debugging - prints a recursive dump of a parse tree node and its
children</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonNode-class.html#toprettyxml" class="summary-sig-name"><code>toprettyxml</code></a>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>indent</span>,
<span class=summary-sig-arg>newl</span>,
<span class=summary-sig-arg>encoding</span>)</span></code>
<br />
returns a human-readable xml serialisation of this node and its
children</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonNode-class.html#toxml" class="summary-sig-name"><code>toxml</code></a>(<span class=summary-sig-arg>self</span>)</span></code>
<br />
Returns an xml serialisation of this node and its children, as a raw
string</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonNode-class.html#toxmldoc" class="summary-sig-name"><code>toxmldoc</code></a>(<span class=summary-sig-arg>self</span>)</span></code>
<br />
Returns the node and its children as an xml.dom.minidom.Document
object</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonNode-class.html#toxmlelem" class="summary-sig-name"><code>toxmlelem</code></a>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>docobj</span>)</span></code>
<br />
Returns a DOM Element object of this node and its children</td></tr>
</table><br />
<!-- =========== START OF METHOD DETAILS =========== -->
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="details">
<th colspan="2">Method Details</th></tr>
</table>
<a name="__getitem__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__getitem__</span>(<span class=sig-arg>self</span>,
<span class=sig-arg>item</span>)</span>
<br /><i>(Indexing operator)</i>
</h3>
<p>Retrieves the ith value from this node, or child nodes</p>
<p>If the subscript is a single number, it will be used as an index
into this node's children list.</p>
If the subscript is a list or tuple, we recursively fetch the item
by using the first element as an index into this node's children, the
second element as an index into that child node's children, and so
on
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="dump"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">dump</span>(<span class=sig-arg>self</span>,
<span class=sig-arg>indent</span>=<span class=sig-default>0</span>)</span>
</h3>
For debugging - prints a recursive dump of a parse tree node and its
children
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="toprettyxml"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">toprettyxml</span>(<span class=sig-arg>self</span>,
<span class=sig-arg>indent</span>=<span class=sig-default>'&nbsp;&nbsp;'</span>,
<span class=sig-arg>newl</span>=<span class=sig-default>'\n'</span>,
<span class=sig-arg>encoding</span>=<span class=sig-default>None</span>)</span>
</h3>
returns a human-readable xml serialisation of this node and its
children
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="toxml"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">toxml</span>(<span class=sig-arg>self</span>)</span>
</h3>
<p>Returns an xml serialisation of this node and its children, as a raw
string</p>
Called on the toplevel node, the xml is a representation of the
entire parse tree.
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="toxmldoc"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">toxmldoc</span>(<span class=sig-arg>self</span>)</span>
</h3>
Returns the node and its children as an xml.dom.minidom.Document
object
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="toxmlelem"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">toxmlelem</span>(<span class=sig-arg>self</span>,
<span class=sig-arg>docobj</span>)</span>
</h3>
Returns a DOM Element object of this node and its children
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<br />
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sun Jun 27 12:36:56 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>bison.BisonParser</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<font size="-1"><b class="breadcrumbs">
<a href="bison-module.html">Module&nbsp;bison</a> ::
Class&nbsp;BisonParser
</b></font></br>
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[<a href="../private/bison.BisonParser-class.html">show&nbsp;private</a>&nbsp;|&nbsp;hide&nbsp;private]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="bison.BisonParser-class.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<!-- =========== START OF CLASS DESCRIPTION =========== -->
<h2 class="class">Class BisonParser</h2>
<pre class="base-tree">
<a href="__builtin__.object-class.html"><code>object</code></a> --+
|
<b>BisonParser</b>
</pre><br />
<hr/>
<p>Base parser class</p>
You should subclass this, and provide a bunch of methods called
'on_TargetName', where 'TargetName' is the name of each target in your
grammar (.y) file.
<hr/>
<!-- =========== START OF METHOD SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Method Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonParser-class.html#__init__" class="summary-sig-name"><code>__init__</code></a>(<span class=summary-sig-arg>self</span>,
<span class="summary-sig-kwarg">**kw</span>)</span></code>
<br />
Abstract representation of parser</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="__getitem__"></a><span class="summary-sig"><span class="summary-sig-name">__getitem__</span>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>idx</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonParser-class.html#error" class="summary-sig-name"><code>error</code></a>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>value</span>)</span></code>
<br />
Return the result of this method from a handler to notify a syntax
error</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonParser-class.html#loadxml" class="summary-sig-name"><code>loadxml</code></a>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>raw</span>,
<span class=summary-sig-arg>namespace</span>)</span></code>
<br />
Loads a parse tree from raw xml text</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonParser-class.html#loadxmldoc" class="summary-sig-name"><code>loadxmldoc</code></a>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>xmldoc</span>,
<span class=summary-sig-arg>namespace</span>)</span></code>
<br />
Returns a reconstituted parse tree, loaded from an
xml.dom.minidom.Document instance</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonParser-class.html#loadxmlobj" class="summary-sig-name"><code>loadxmlobj</code></a>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>xmlobj</span>,
<span class=summary-sig-arg>namespace</span>)</span></code>
<br />
Returns a node object, being a parse tree, reconstituted from an
xml.dom.minidom.Element object</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonParser-class.html#read" class="summary-sig-name"><code>read</code></a>(<span class=summary-sig-arg>self</span>,
<span class=summary-sig-arg>nbytes</span>)</span></code>
<br />
Override this in your subclass, if you desire.</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonParser-class.html#run" class="summary-sig-name"><code>run</code></a>(<span class=summary-sig-arg>self</span>,
<span class="summary-sig-kwarg">**kw</span>)</span></code>
<br />
Runs the parser, and returns the top-most parse target.</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonParser-class.html#toprettyxml" class="summary-sig-name"><code>toprettyxml</code></a>(<span class=summary-sig-arg>self</span>)</span></code>
<br />
Returns a human-readable xml representation of the parse tree</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonParser-class.html#toxml" class="summary-sig-name"><code>toxml</code></a>(<span class=summary-sig-arg>self</span>)</span></code>
<br />
Serialises the parse tree and returns it as a raw xml string</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.BisonParser-class.html#toxmldoc" class="summary-sig-name"><code>toxmldoc</code></a>(<span class=summary-sig-arg>self</span>)</span></code>
<br />
Returns an xml.dom.minidom.Document object containing the parse
tree</td></tr>
<tr bgcolor="#e8f0f8" class="group">
<th colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;Inherited from object</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__delattr__" class="summary-sig-name"><code>__delattr__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__delattr__('name') &lt;==&gt; del x.name</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__getattribute__" class="summary-sig-name"><code>__getattribute__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__getattribute__('name') &lt;==&gt; x.name</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__hash__" class="summary-sig-name"><code>__hash__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__hash__() &lt;==&gt; hash(x)</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__reduce__" class="summary-sig-name"><code>__reduce__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
helper for pickle</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__reduce_ex__" class="summary-sig-name"><code>__reduce_ex__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
helper for pickle</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__repr__" class="summary-sig-name"><code>__repr__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__repr__() &lt;==&gt; repr(x)</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__setattr__" class="summary-sig-name"><code>__setattr__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__setattr__('name', value) &lt;==&gt; x.name = value</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__str__" class="summary-sig-name"><code>__str__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__str__() &lt;==&gt; str(x)</td></tr>
<tr bgcolor="#e8f0f8" class="group">
<th colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;Inherited from type</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__new__" class="summary-sig-name"><code>__new__</code></a>(<span class=summary-sig-arg>T</span>,
<span class=summary-sig-arg>S</span>,
<span class="summary-sig-vararg">...</span>)</span></code>
<br />
T.__new__(S, ...) -&gt; a new object with type S, a subtype of T</td></tr>
</table><br />
<!-- =========== START OF CLASS VARIABLE SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Class Variable Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>str</code></font></td>
<td><b><a href="bison.BisonParser-class.html#bisonCFile"><code>bisonCFile</code></a></b> = <span title="'tmp.tab.c'"><code><span class="variable-quote">'</span>tmp.tab.c<span class="variable-quote">'</span> </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>str</code></font></td>
<td><b><a href="bison.BisonParser-class.html#bisonCFile1"><code>bisonCFile1</code></a></b> = <span title="'tmp.bison.c'"><code><span class="variable-quote">'</span>tmp.bison.c<span class="variable-quote">'</span> </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>list</code></font></td>
<td><b><a href="bison.BisonParser-class.html#bisonCmd"><code>bisonCmd</code></a></b> = <span title="['bison', '-d', '-v', '-t']"><code>['bison',&nbsp;'-d',&nbsp;'-v',&nbsp;'-t'] </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>NoneType</code></font></td>
<td><b><a href="bison.BisonParser-class.html#bisonEngineLibName"><code>bisonEngineLibName</code></a></b> = <span title="None">None&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>str</code></font></td>
<td><b><a href="bison.BisonParser-class.html#bisonFile"><code>bisonFile</code></a></b> = <span title="'tmp.y'"><code><span class="variable-quote">'</span>tmp.y<span class="variable-quote">'</span> </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>str</code></font></td>
<td><b><a href="bison.BisonParser-class.html#bisonHFile"><code>bisonHFile</code></a></b> = <span title="'tmp.tab.h'"><code><span class="variable-quote">'</span>tmp.tab.h<span class="variable-quote">'</span> </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>str</code></font></td>
<td><b><a href="bison.BisonParser-class.html#bisonHFile1"><code>bisonHFile1</code></a></b> = <span title="'tokens.h'"><code><span class="variable-quote">'</span>tokens.h<span class="variable-quote">'</span> </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>classobj</code></font></td>
<td><a name="defaultNodeClass"></a><b><code>defaultNodeClass</code></b> = <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>NoneType</code></font></td>
<td><b><a href="bison.BisonParser-class.html#file"><code>file</code></a></b> = <span title="None">None&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>str</code></font></td>
<td><b><a href="bison.BisonParser-class.html#flexCFile"><code>flexCFile</code></a></b> = <span title="'lex.yy.c'"><code><span class="variable-quote">'</span>lex.yy.c<span class="variable-quote">'</span> </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>str</code></font></td>
<td><b><a href="bison.BisonParser-class.html#flexCFile1"><code>flexCFile1</code></a></b> = <span title="'tmp.lex.c'"><code><span class="variable-quote">'</span>tmp.lex.c<span class="variable-quote">'</span> </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>list</code></font></td>
<td><b><a href="bison.BisonParser-class.html#flexCmd"><code>flexCmd</code></a></b> = <span title="['flex']"><code>['flex'] </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>str</code></font></td>
<td><b><a href="bison.BisonParser-class.html#flexFile"><code>flexFile</code></a></b> = <span title="'tmp.l'"><code><span class="variable-quote">'</span>tmp.l<span class="variable-quote">'</span> </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>int</code></font></td>
<td><b><a href="bison.BisonParser-class.html#keepfiles"><code>keepfiles</code></a></b> = <span title="0">0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>NoneType</code></font></td>
<td><b><a href="bison.BisonParser-class.html#last"><code>last</code></a></b> = <span title="None">None&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>NoneType</code></font></td>
<td><b><a href="bison.BisonParser-class.html#lasterror"><code>lasterror</code></a></b> = <span title="None">None&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>int</code></font></td>
<td><b><a href="bison.BisonParser-class.html#verbose"><code>verbose</code></a></b> = <span title="0">0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
</table><br />
<!-- =========== START OF METHOD DETAILS =========== -->
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="details">
<th colspan="2">Method Details</th></tr>
</table>
<a name="__init__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__init__</span>(<span class=sig-arg>self</span>,
<span class="sig-kwarg">**kw</span>)</span>
<br /><i>(Constructor)</i>
</h3>
<p>Abstract representation of parser</p>
Keyword arguments:
<ul>
<li>
read - a callable accepting an int arg (nbytes) and returning a
string, default is this class' read() method
</li>
<li>
file - a file object, or string of a pathname to open as a file,
defaults to sys.stdin. Note that you can leave this blank, and pass
a file keyword argument to the .run() method.
</li>
<li>
verbose - set to 1 to enable verbose output messages, default
0
</li>
<li>
keepfiles - if non-zero, keeps any files generated in the course
of building the parser engine; by default, all these files get
deleted upon a successful engine build
</li>
<li>
defaultNodeClass - the class to use for creating parse nodes,
default is self.defaultNodeClass (in this base class,
BisonNode)
</li>
</ul>
<dl><dt></dt><dd>
<dl><dt><b>Overrides:</b></dt>
<dd><a href="__builtin__.object-class.html#__init__"><code>__builtin__.object.__init__</code></a></dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="error"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">error</span>(<span class=sig-arg>self</span>,
<span class=sig-arg>value</span>)</span>
</h3>
Return the result of this method from a handler to notify a syntax
error
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="loadxml"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">loadxml</span>(<span class=sig-arg>self</span>,
<span class=sig-arg>raw</span>,
<span class=sig-arg>namespace</span>=<span class=sig-default>None</span>)</span>
</h3>
<p>Loads a parse tree from raw xml text</p>
<p>Stores it in the '.last' attribute, which is where the root node of
parsed text gets stored</p>
Arguments:
<ul>
<li>
raw - string containing the raw xml
</li>
<li>
namespace - a dict or module object, where the node classes
required for reconstituting the parse tree, can be found
</li>
</ul>
Returns:
<ul>
<li>
root node object of reconstituted parse tree
</li>
</ul>
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="loadxmldoc"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">loadxmldoc</span>(<span class=sig-arg>self</span>,
<span class=sig-arg>xmldoc</span>,
<span class=sig-arg>namespace</span>=<span class=sig-default>None</span>)</span>
</h3>
<p>Returns a reconstituted parse tree, loaded from an
xml.dom.minidom.Document instance</p>
Arguments:
<ul>
<li>
xmldoc - an xml.dom.minidom.Document instance
</li>
<li>
namespace - a dict from which to find the classes needed to
translate the document into a tree of parse nodes
</li>
</ul>
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="loadxmlobj"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">loadxmlobj</span>(<span class=sig-arg>self</span>,
<span class=sig-arg>xmlobj</span>,
<span class=sig-arg>namespace</span>=<span class=sig-default>None</span>)</span>
</h3>
<p>Returns a node object, being a parse tree, reconstituted from an
xml.dom.minidom.Element object</p>
Arguments:
<ul>
<li>
xmlobj - an xml.dom.minidom.Element instance
</li>
<li>
namespace - a namespace from which the node classes needed for
reconstituting the tree, can be found
</li>
</ul>
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="read"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">read</span>(<span class=sig-arg>self</span>,
<span class=sig-arg>nbytes</span>)</span>
</h3>
<p>Override this in your subclass, if you desire.</p>
Arguments:
<ul>
<li>
nbytes - the maximum length of the string which you may return.
DO NOT return a string longer than this, or else Bad Things will
happen.
</li>
</ul>
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="run"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">run</span>(<span class=sig-arg>self</span>,
<span class="sig-kwarg">**kw</span>)</span>
</h3>
<p>Runs the parser, and returns the top-most parse target.</p>
Keywords:
<ul>
<li>
file - either a string, comprising a file to open and read input
from, or a Python file object
</li>
<li>
debug - enables garrulous parser debugging output, default 0
</li>
</ul>
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="toprettyxml"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">toprettyxml</span>(<span class=sig-arg>self</span>)</span>
</h3>
Returns a human-readable xml representation of the parse tree
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="toxml"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">toxml</span>(<span class=sig-arg>self</span>)</span>
</h3>
Serialises the parse tree and returns it as a raw xml string
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="toxmldoc"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">toxmldoc</span>(<span class=sig-arg>self</span>)</span>
</h3>
Returns an xml.dom.minidom.Document object containing the parse
tree
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<br />
<!-- =========== START OF CLASS VARIABLE DETAILS =========== -->
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="details">
<th colspan="2">Class Variable Details</th></tr>
</table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="bisonCFile"></a>
<h3>bisonCFile</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>str</code>
</dd>
<span title="'tmp.tab.c'"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
<span class="variable-quote">'</span>tmp.tab.c<span class="variable-quote">'</span> </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="bisonCFile1"></a>
<h3>bisonCFile1</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>str</code>
</dd>
<span title="'tmp.bison.c'"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
<span class="variable-quote">'</span>tmp.bison.c<span class="variable-quote">'</span> </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="bisonCmd"></a>
<h3>bisonCmd</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>list</code>
</dd>
<span title="['bison', '-d', '-v', '-t']"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
['bison', '-d', '-v', '-t'] </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="bisonEngineLibName"></a>
<h3>bisonEngineLibName</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>NoneType</code>
</dd>
<span title="None"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
None&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="bisonFile"></a>
<h3>bisonFile</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>str</code>
</dd>
<span title="'tmp.y'"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
<span class="variable-quote">'</span>tmp.y<span class="variable-quote">'</span> </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="bisonHFile"></a>
<h3>bisonHFile</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>str</code>
</dd>
<span title="'tmp.tab.h'"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
<span class="variable-quote">'</span>tmp.tab.h<span class="variable-quote">'</span> </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="bisonHFile1"></a>
<h3>bisonHFile1</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>str</code>
</dd>
<span title="'tokens.h'"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
<span class="variable-quote">'</span>tokens.h<span class="variable-quote">'</span> </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="file"></a>
<h3>file</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>NoneType</code>
</dd>
<span title="None"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
None&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="flexCFile"></a>
<h3>flexCFile</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>str</code>
</dd>
<span title="'lex.yy.c'"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
<span class="variable-quote">'</span>lex.yy.c<span class="variable-quote">'</span> </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="flexCFile1"></a>
<h3>flexCFile1</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>str</code>
</dd>
<span title="'tmp.lex.c'"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
<span class="variable-quote">'</span>tmp.lex.c<span class="variable-quote">'</span> </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="flexCmd"></a>
<h3>flexCmd</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>list</code>
</dd>
<span title="['flex']"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
['flex'] </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="flexFile"></a>
<h3>flexFile</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>str</code>
</dd>
<span title="'tmp.l'"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
<span class="variable-quote">'</span>tmp.l<span class="variable-quote">'</span> </pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="keepfiles"></a>
<h3>keepfiles</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>int</code>
</dd>
<span title="0"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="last"></a>
<h3>last</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>NoneType</code>
</dd>
<span title="None"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
None&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="lasterror"></a>
<h3>lasterror</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>NoneType</code>
</dd>
<span title="None"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
None&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="verbose"></a>
<h3>verbose</h3>
<dl>
<dt></dt>
<dd>
<dl>
<dt><b>Type:</b></dt>
<dd>
<code>int</code>
</dd>
<span title="0"> <dt><b>Value:</b></dt>
<dd><table><tr><td>
<pre class="variable">
0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
</td></tr></table></dd>
</span> </dl>
</dd>
</dl></td></tr></table>
<br />
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sun Jun 27 12:36:56 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>bison.ParserEngine</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<font size="-1"><b class="breadcrumbs">
<a href="bison-module.html">Module&nbsp;bison</a> ::
Class&nbsp;ParserEngine
</b></font></br>
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[<a href="../private/bison.ParserEngine-class.html">show&nbsp;private</a>&nbsp;|&nbsp;hide&nbsp;private]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="bison.ParserEngine-class.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<!-- =========== START OF CLASS DESCRIPTION =========== -->
<h2 class="class">Class ParserEngine</h2>
<pre class="base-tree">
<a href="__builtin__.object-class.html"><code>object</code></a> --+
|
<b>ParserEngine</b>
</pre><br />
<hr/>
<p>Wraps the interface to the binary bison/lex-generated parser engine
dynamic library.</p>
<p>You shouldn't need to deal with this at all.</p>
Takes care of:
<ul>
<li>
building the library (if the parser rules have changed)
</li>
<li>
loading the library and extracting the parser entry point
</li>
<li>
calling the entry point
</li>
<li>
closing the library
</li>
</ul>
Makes direct calls to the platform-dependent routines in
bisondynlib-[linux|windows].c
<hr/>
<!-- =========== START OF METHOD SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Method Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.ParserEngine-class.html#__init__" class="summary-sig-name"><code>__init__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__init__(...) initializes x; see x.__class__.__doc__ for
signature</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.ParserEngine-class.html#__del__" class="summary-sig-name"><code>__del__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
Clean up and bail</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.ParserEngine-class.html#buildLib" class="summary-sig-name"><code>buildLib</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
Creates the parser engine lib</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.ParserEngine-class.html#closeLib" class="summary-sig-name"><code>closeLib</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
Does the necessary cleanups and closes the parser library</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.ParserEngine-class.html#openCurrentLib" class="summary-sig-name"><code>openCurrentLib</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
Tests if library exists and is current.</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.ParserEngine-class.html#openLib" class="summary-sig-name"><code>openLib</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
Loads the parser engine's dynamic library, and extracts the following
symbols:</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="bison.ParserEngine-class.html#runEngine" class="summary-sig-name"><code>runEngine</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
Runs the binary parser engine, as loaded from the lib</td></tr>
<tr bgcolor="#e8f0f8" class="group">
<th colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;Inherited from object</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__delattr__" class="summary-sig-name"><code>__delattr__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__delattr__('name') &lt;==&gt; del x.name</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__getattribute__" class="summary-sig-name"><code>__getattribute__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__getattribute__('name') &lt;==&gt; x.name</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__hash__" class="summary-sig-name"><code>__hash__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__hash__() &lt;==&gt; hash(x)</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__reduce__" class="summary-sig-name"><code>__reduce__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
helper for pickle</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__reduce_ex__" class="summary-sig-name"><code>__reduce_ex__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
helper for pickle</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__repr__" class="summary-sig-name"><code>__repr__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__repr__() &lt;==&gt; repr(x)</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__setattr__" class="summary-sig-name"><code>__setattr__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
<br />
x.__setattr__('name', value) &lt;==&gt; x.name = value</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.object-class.html#__str__" class="summary-sig-name"><code>__str__</code></a>(<span class=summary-sig-arg>x</span>)</span></code>
<br />
x.__str__() &lt;==&gt; str(x)</td></tr>
<tr bgcolor="#e8f0f8" class="group">
<th colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;Inherited from type</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="__builtin__.type-class.html#__new__" class="summary-sig-name"><code>__new__</code></a>(<span class=summary-sig-arg>T</span>,
<span class=summary-sig-arg>S</span>,
<span class="summary-sig-vararg">...</span>)</span></code>
<br />
T.__new__(S, ...) -&gt; a new object with type S, a subtype of T</td></tr>
</table><br />
<!-- =========== START OF METHOD DETAILS =========== -->
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="details">
<th colspan="2">Method Details</th></tr>
</table>
<a name="__init__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-vararg">...</span>)</span>
<br /><i>(Constructor)</i>
</h3>
x.__init__(...) initializes x; see x.__class__.__doc__ for
signature
<dl><dt></dt><dd>
<dl><dt><b>Overrides:</b></dt>
<dd><a href="__builtin__.object-class.html#__init__"><code>__builtin__.object.__init__</code></a></dd>
</dl>
</dd></dl>
</td></tr></table>
<a name="__del__"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">__del__</span>(<span class="sig-vararg">...</span>)</span>
<br /><i>(Destructor)</i>
</h3>
Clean up and bail
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="buildLib"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">buildLib</span>(<span class="sig-vararg">...</span>)</span>
</h3>
<p>Creates the parser engine lib</p>
This consists of:
<ol start="1">
<li>
Ripping the tokens list, precedences, start target, handler
docstrings and lex script from this Parser instance's attribs and
methods
</li>
<li>
Creating bison and lex files
</li>
<li>
Compiling bison/lex files to C
</li>
<li>
Compiling the C files, and link into a dynamic lib
</li>
</ol>
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="closeLib"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">closeLib</span>(<span class="sig-vararg">...</span>)</span>
</h3>
Does the necessary cleanups and closes the parser library
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="openCurrentLib"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">openCurrentLib</span>(<span class="sig-vararg">...</span>)</span>
</h3>
<p>Tests if library exists and is current. If not, builds a fresh
one</p>
Opens the library
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="openLib"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">openLib</span>(<span class="sig-vararg">...</span>)</span>
</h3>
Loads the parser engine's dynamic library, and extracts the
following symbols:
<ul>
<li>
void *do_parse() (runs parser)
</li>
<li>
char *parserHash (contains hash of python parser rules)
</li>
</ul>
<p>Returns lib handle, plus pointer to do_parse() function, as long
ints (which later need to be cast to pointers)</p>
Important note -this is totally linux-specific. If you want windows
support, you'll have to modify these funcs to use glib instead (or
create windows equivalents), in which case I'd greatly appreciate you
sending me a patch.
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<a name="runEngine"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
<h3><span class="sig"><span class="sig-name">runEngine</span>(<span class="sig-vararg">...</span>)</span>
</h3>
Runs the binary parser engine, as loaded from the lib
<dl><dt></dt><dd>
</dd></dl>
</td></tr></table>
<br />
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Fri Apr 23 19:00:01 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>bison.ParserSyntaxError</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<font size="-1"><b class="breadcrumbs">
<a href="bison-module.html">Module&nbsp;bison</a> ::
Class&nbsp;ParserSyntaxError
</b></font></br>
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[<a href="../private/bison.ParserSyntaxError-class.html">show&nbsp;private</a>&nbsp;|&nbsp;hide&nbsp;private]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="bison.ParserSyntaxError-class.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<!-- =========== START OF CLASS DESCRIPTION =========== -->
<h2 class="class">Class ParserSyntaxError</h2>
<pre class="base-tree">
<a href="exceptions.Exception-class.html"><code>Exception</code></a> --+
|
<b>ParserSyntaxError</b>
</pre><br />
<hr/>
<!-- =========== START OF METHOD SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Method Summary</th></tr>
<tr bgcolor="#e8f0f8" class="group">
<th colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;Inherited from Exception</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="exceptions.Exception-class.html#__init__" class="summary-sig-name"><code>__init__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="exceptions.Exception-class.html#__getitem__" class="summary-sig-name"><code>__getitem__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><span class="summary-sig"><a href="exceptions.Exception-class.html#__str__" class="summary-sig-name"><code>__str__</code></a>(<span class="summary-sig-vararg">...</span>)</span></code>
</td></tr>
</table><br />
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sun Jun 27 12:36:56 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
/* Body color */
body { background: #ffffff; color: #000000; }
/* Tables */
table.summary, table.details, table.index
{ background: #e8f0f8; color: #000000; }
tr.summary, tr.details, tr.index
{ background: #70b0f0; color: #000000;
text-align: left; font-size: 120%; }
tr.group { background: #c0e0f8; color: #000000;
text-align: left; font-size: 120%;
font-style: italic; }
/* Documentation page titles */
h2.module { margin-top: 0.2em; }
h2.class { margin-top: 0.2em; }
/* Headings */
h1.heading { font-size: +140%; font-style: italic;
font-weight: bold; }
h2.heading { font-size: +125%; font-style: italic;
font-weight: bold; }
h3.heading { font-size: +110%; font-style: italic;
font-weight: normal; }
/* Base tree */
pre.base-tree { font-size: 80%; margin: 0; }
/* Details Sections */
table.func-details { background: #e8f0f8; color: #000000;
border: 2px groove #c0d0d0;
padding: 0 1em 0 1em; margin: 0.4em 0 0 0; }
h3.func-detail { background: transparent; color: #000000;
margin: 0 0 1em 0; }
table.var-details { background: #e8f0f8; color: #000000;
border: 2px groove #c0d0d0;
padding: 0 1em 0 1em; margin: 0.4em 0 0 0; }
h3.var-details { background: transparent; color: #000000;
margin: 0 0 1em 0; }
/* Function signatures */
.sig { background: transparent; color: #000000;
font-weight: bold; }
.sig-name { background: transparent; color: #006080; }
.sig-arg, .sig-kwarg, .sig-vararg
{ background: transparent; color: #008060; }
.sig-default { background: transparent; color: #602000; }
.summary-sig { background: transparent; color: #000000; }
.summary-sig-name { background: transparent; color: #204080; }
.summary-sig-arg, .summary-sig-kwarg, .summary-sig-vararg
{ background: transparent; color: #008060; }
/* Doctest blocks */
.py-src { background: transparent; color: #000000; }
.py-prompt { background: transparent; color: #005050;
font-weight: bold;}
.py-string { background: transparent; color: #006030; }
.py-comment { background: transparent; color: #003060; }
.py-keyword { background: transparent; color: #600000; }
.py-output { background: transparent; color: #404040; }
pre.doctestblock { background: #f4faff; color: #000000;
padding: .5em; margin: 1em;
border: 1px solid #708890; }
table pre.doctestblock
{ background: #dce4ec; color: #000000;
padding: .5em; margin: 1em;
border: 1px solid #708890; }
/* Variable values */
pre.variable { background: #dce4ec; color: #000000;
padding: .5em; margin: 0;
border: 1px solid #708890; }
.variable-linewrap { background: transparent; color: #604000; }
.variable-ellipsis { background: transparent; color: #604000; }
.variable-quote { background: transparent; color: #604000; }
.re { background: transparent; color: #000000; }
.re-char { background: transparent; color: #006030; }
.re-op { background: transparent; color: #600000; }
.re-group { background: transparent; color: #003060; }
.re-ref { background: transparent; color: #404040; }
/* Navigation bar */
table.navbar { background: #a0c0ff; color: #0000ff;
border: 2px groove #c0d0d0; }
th.navbar { background: #a0c0ff; color: #0000ff; }
th.navselect { background: #70b0ff; color: #000000; }
.nomargin { margin: 0; }
/* Links */
a:link { background: transparent; color: #0000ff; }
a:visited { background: transparent; color: #204080; }
a.navbar:link { background: transparent; color: #0000ff;
text-decoration: none; }
a.navbar:visited { background: transparent; color: #204080;
text-decoration: none; }
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>exceptions.Exception</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<font size="-1"><b class="breadcrumbs">
Module&nbsp;exceptions ::
Class&nbsp;Exception
</b></font></br>
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[<a href="../private/exceptions.Exception-class.html">show&nbsp;private</a>&nbsp;|&nbsp;hide&nbsp;private]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="exceptions.Exception-class.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<!-- =========== START OF CLASS DESCRIPTION =========== -->
<h2 class="class">Class Exception</h2>
<dl><dt><b>Known Subclasses:</b></dt>
<dd>
<a href="bison.ParserSyntaxError-class.html"><code>ParserSyntaxError</code></a></dd></dl>
<hr/>
Common base class for all exceptions.
<hr/>
<!-- =========== START OF METHOD SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
<th colspan="2">Method Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="__init__"></a><span class="summary-sig"><span class="summary-sig-name">__init__</span>(<span class="summary-sig-vararg">...</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="__getitem__"></a><span class="summary-sig"><span class="summary-sig-name">__getitem__</span>(<span class="summary-sig-vararg">...</span>)</span></code>
</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
<td><code><a name="__str__"></a><span class="summary-sig"><span class="summary-sig-name">__str__</span>(<span class="summary-sig-vararg">...</span>)</span></code>
</td></tr>
</table><br />
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sun Jun 27 12:36:56 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<title> PyBison API Reference </title>
</head>
<frameset cols="20%,80%">
<frameset rows="30%,70%">
<frame src="toc.html" name="moduleListFrame">
<frame src="toc-everything.html" name="moduleFrame">
</frameset>
<frame src="bison-module.html" name="mainFrame">
</frameset>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Help</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th bgcolor="#70b0f0" class="navselect">&nbsp;&nbsp;&nbsp;Help&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[<a href="../private/help.html">show&nbsp;private</a>&nbsp;|&nbsp;hide&nbsp;private]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="help.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<center><h2> API Documentation </h2></center>
<p> This document contains the API (Application Programming Interface)
documentation for PyBison API Reference. Documentation for the Python
objects defined by the project is divided into separate pages for each
package, module, and class. The API documentation also includes two
pages containing information about the project as a whole: a trees
page, and an index page. </p>
<h2> Object Documentation </h2>
<p>Each <b>Package Documentation</b> page contains:
<ul>
<li> A description of the package. </li>
<li> A list of the modules and sub-packages contained by the
package. </li>
<li> A summary of the classes defined by the package. </li>
<li> A summary of the functions defined by the package. </li>
<li> A summary of the variables defined by the package. </li>
<li> A detailed description of each function defined by the
package. </li>
<li> A detailed description of each variable defined by the
package. </li>
</ul></p>
<p>Each <b>Module Documentation</b> page contains:
<ul>
<li> A description of the module. </li>
<li> A summary of the classes defined by the module. </li>
<li> A summary of the functions defined by the module. </li>
<li> A summary of the variables defined by the module. </li>
<li> A detailed description of each function defined by the
module. </li>
<li> A detailed description of each variable defined by the
module. </li>
</ul></p>
<p>Each <b>Class Documentation</b> page contains:
<ul>
<li> A class inheritance diagram. </li>
<li> A list of known subclasses. </li>
<li> A description of the class. </li>
<li> A summary of the methods defined by the class. </li>
<li> A summary of the instance variables defined by the class. </li>
<li> A summary of the class (static) variables defined by the
class. </li>
<li> A detailed description of each method defined by the
class. </li>
<li> A detailed description of each instance variable defined by the
class. </li>
<li> A detailed description of each class (static) variable defined
by the class. </li>
</ul></p>
<h2> Project Documentation </h2>
<p> The <b>Trees</b> page contains the module and class hierarchies:
<ul>
<li> The <i>module hierarchy</i> lists every package and module, with
modules grouped into packages. At the top level, and within each
package, modules and sub-packages are listed alphabetically. </li>
<li> The <i>class hierarchy</i> lists every class, grouped by base
class. If a class has more than one base class, then it will be
listed under each base class. At the top level, and under each base
class, classes are listed alphabetically. </li>
</ul></p>
<p> The <b>Index</b> page contains indices of terms and
identifiers:
<ul>
<li> The <i>term index</i> lists every term indexed by any object's
documentation. For each term, the index provides links to each
place where the term is indexed. </li>
<li> The <i>identifier index</i> lists the (short) name of every package,
module, class, method, function, variable, and parameter. For each
identifier, the index provides a short description, and a link to
its documentation. </li>
</ul></p>
<h2> The Table of Contents </h2>
<p> The table of contents occupies the two frames on the left side of
the window. The upper-left frame displays the <i>project
contents</i>, and the lower-left frame displays the <i>module
contents</i>: </p>
<center>
<table class="summary" border="1" cellspacing="0" cellpadding="3">
<tr heigh="30%">
<td align="center">
<font size="-1">Project<br>Contents<hr>...</font></td>
<td align="center" rowspan="2" width="70%">
API<br>Documentation<br>Frame<br><br><br>
</td>
</tr>
<tr>
<td align="center">
<font size="-1">Module<br>Contents<hr>&nbsp;<br>...<br>&nbsp;</font>
</td>
</tr>
</table><br>
</center>
<p> The <b>project contents frame</b> contains a list of all packages
and modules that are defined by the project. Clicking on an entry
will display its contents in the module contents frame. Clicking on a
special entry, labeled "Everything," will display the contents of
the entire project. </p>
<p> The <b>module contents frame</b> contains a list of every
submodule, class, type, exception, function, and variable defined by a
module or package. Clicking on an entry will display its
documentation in the API documentation frame. Clicking on the name of
the module, at the top of the frame, will display the documentation
for the module itself. </p>
<p> The "<b>frames</b>" and "<b>no frames</b>" buttons below the top
navigation bar can be used to control whether the table of contents is
displayed or not. </p>
<h2> The Navigation Bar </h2>
<p> A navigation bar is located at the top and bottom of every page.
It indicates what type of page you are currently viewing, and allows
you to go to related pages. The following table describes the labels
on the navigation bar. Note that not some labels (such as
[Parent]) are not displayed on all pages. </p>
<table class="summary" border="1" cellspacing="0" cellpadding="3" width="100%">
<tr class="summary">
<th>Label</th>
<th>Highlighted when...</th>
<th>Links to...</th>
</tr>
<tr><td valign="top"><b>[Parent]</b></td>
<td valign="top"><i>(never highlighted)</i></td>
<td valign="top"> the parent of the current package </td></tr>
<tr><td valign="top"><b>[Package]</b></td>
<td valign="top">viewing a package</td>
<td valign="top">the package containing the current object
</td></tr>
<tr><td valign="top"><b>[Module]</b></td>
<td valign="top">viewing a module</td>
<td valign="top">the module containing the current object
</td></tr>
<tr><td valign="top"><b>[Class]</b></td>
<td valign="top">viewing a class </td>
<td valign="top">the class containing the current object</td></tr>
<tr><td valign="top"><b>[Trees]</b></td>
<td valign="top">viewing the trees page</td>
<td valign="top"> the trees page </td></tr>
<tr><td valign="top"><b>[Index]</b></td>
<td valign="top">viewing the index page</td>
<td valign="top"> the index page </td></tr>
<tr><td valign="top"><b>[Help]</b></td>
<td valign="top">viewing the help page</td>
<td valign="top"> the help page </td></tr>
</table>
<p> The "<b>show private</b>" and "<b>hide private</b>" buttons below
the top navigation bar can be used to control whether documentation
for private objects is displayed. Private objects are usually defined
as objects whose (short) names begin with a single underscore, but do
not end with an underscore. For example, "<code>_x</code>",
"<code>__pprint</code>", and "<code>epydoc.epytext._tokenize</code>"
are private objects; but "<code>re.sub</code>",
"<code>__init__</code>", and "<code>type_</code>" are not. However,
if a module defines the "<code>__all__</code>" variable, then its
contents are used to decide which objects are private. </p>
<p> A timestamp below the bottom navigation bar indicates when each
page was last updated. </p>
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th bgcolor="#70b0f0" class="navselect">&nbsp;&nbsp;&nbsp;Help&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sun Jun 27 12:36:56 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<title> PyBison API Reference </title>
</head>
<frameset cols="20%,80%">
<frameset rows="30%,70%">
<frame src="toc.html" name="moduleListFrame">
<frame src="toc-everything.html" name="moduleFrame">
</frameset>
<frame src="bison-module.html" name="mainFrame">
</frameset>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Index</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th bgcolor="#70b0f0" class="navselect">&nbsp;&nbsp;&nbsp;Index&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[<a href="../private/indices.html">show&nbsp;private</a>&nbsp;|&nbsp;hide&nbsp;private]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="indices.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<br />
<!-- =========== START OF IDENTIFIER INDEX =========== -->
<table class="index" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="index">
<th colspan="2">Identifier Index</th></tr>
<tr><td width="15%"><a href="__builtin__.object-class.html"><code>object</code></a></td>
<td>Class in module <code>__builtin__</code></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__bases__"><code>__bases__</code></a></td>
<td>Variable in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__basicsize__"><code>__basicsize__</code></a></td>
<td>Variable in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__call__"><code>__call__</code></a></td>
<td>Method in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html"><code>type</code></a></td>
<td>Class in module <code>__builtin__</code></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__cmp__"><code>__cmp__</code></a></td>
<td>Method in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.object-class.html#__delattr__"><code>__delattr__</code></a></td>
<td>Method in class <a href="__builtin__.object-class.html"><code>__builtin__.object</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__delattr__"><code>__delattr__</code></a></td>
<td>Method in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__dictoffset__"><code>__dictoffset__</code></a></td>
<td>Variable in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__flags__"><code>__flags__</code></a></td>
<td>Variable in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.object-class.html#__getattribute__"><code>__getattribute__</code></a></td>
<td>Method in class <a href="__builtin__.object-class.html"><code>__builtin__.object</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__getattribute__"><code>__getattribute__</code></a></td>
<td>Method in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#__getitem__"><code>__getitem__</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#__getitem__"><code>__getitem__</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="exceptions.Exception-class.html#__getitem__"><code>__getitem__</code></a></td>
<td>Method in class <a href="exceptions.Exception-class.html"><code>exceptions.Exception</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#__getslice__"><code>__getslice__</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.object-class.html#__hash__"><code>__hash__</code></a></td>
<td>Method in class <a href="__builtin__.object-class.html"><code>__builtin__.object</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__hash__"><code>__hash__</code></a></td>
<td>Method in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.object-class.html#__init__"><code>__init__</code></a></td>
<td>Method in class <a href="__builtin__.object-class.html"><code>__builtin__.object</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonError-class.html#__init__"><code>__init__</code></a></td>
<td>Method in class <a href="bison.BisonError-class.html"><code>bison.BisonError</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#__init__"><code>__init__</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#__init__"><code>__init__</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="exceptions.Exception-class.html#__init__"><code>__init__</code></a></td>
<td>Method in class <a href="exceptions.Exception-class.html"><code>exceptions.Exception</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__itemsize__"><code>__itemsize__</code></a></td>
<td>Variable in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#__iter__"><code>__iter__</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#__len__"><code>__len__</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__mro__"><code>__mro__</code></a></td>
<td>Variable in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__name__"><code>__name__</code></a></td>
<td>Variable in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__new__"><code>__new__</code></a></td>
<td>Method in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__new__"><code>__new__</code></a></td>
<td>Method in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.object-class.html#__reduce__"><code>__reduce__</code></a></td>
<td>Method in class <a href="__builtin__.object-class.html"><code>__builtin__.object</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.object-class.html#__reduce_ex__"><code>__reduce_ex__</code></a></td>
<td>Method in class <a href="__builtin__.object-class.html"><code>__builtin__.object</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.object-class.html#__repr__"><code>__repr__</code></a></td>
<td>Method in class <a href="__builtin__.object-class.html"><code>__builtin__.object</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__repr__"><code>__repr__</code></a></td>
<td>Method in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#__repr__"><code>__repr__</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.object-class.html#__setattr__"><code>__setattr__</code></a></td>
<td>Method in class <a href="__builtin__.object-class.html"><code>__builtin__.object</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__setattr__"><code>__setattr__</code></a></td>
<td>Method in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.object-class.html#__str__"><code>__str__</code></a></td>
<td>Method in class <a href="__builtin__.object-class.html"><code>__builtin__.object</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#__str__"><code>__str__</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="exceptions.Exception-class.html#__str__"><code>__str__</code></a></td>
<td>Method in class <a href="exceptions.Exception-class.html"><code>exceptions.Exception</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__subclasses__"><code>__subclasses__</code></a></td>
<td>Method in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#__weakrefoffset__"><code>__weakrefoffset__</code></a></td>
<td>Variable in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="bison-module.html"><code>bison</code></a></td>
<td>Module</td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#bisonCFile"><code>bisonCFile</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#bisonCFile1"><code>bisonCFile1</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#bisonCmd"><code>bisonCmd</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#bisonEngineLibName"><code>bisonEngineLibName</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonError-class.html"><code>BisonError</code></a></td>
<td>Class in module <a href="bison-module.html"><code>bison</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#bisonFile"><code>bisonFile</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#bisonHFile"><code>bisonHFile</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#bisonHFile1"><code>bisonHFile1</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html"><code>BisonNode</code></a></td>
<td>Class in module <a href="bison-module.html"><code>bison</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html"><code>BisonParser</code></a></td>
<td>Class in module <a href="bison-module.html"><code>bison</code></a></td></tr>
<tr><td width="15%"><a href="bison-module.html#bisonToPython"><code>bisonToPython</code></a></td>
<td>Function in module <a href="bison-module.html"><code>bison</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html"><code>BisonNode</code></a></td>
<td>Class in module <a href="bison-module.html"><code>bison</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#dump"><code>dump</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#error"><code>error</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="exceptions.Exception-class.html"><code>Exception</code></a></td>
<td>Class in module <code>exceptions</code></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#file"><code>file</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#flexCFile"><code>flexCFile</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#flexCFile1"><code>flexCFile1</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#flexCmd"><code>flexCmd</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#flexFile"><code>flexFile</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#keepfiles"><code>keepfiles</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#last"><code>last</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#lasterror"><code>lasterror</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#loadxml"><code>loadxml</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#loadxmldoc"><code>loadxmldoc</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#loadxmlobj"><code>loadxmlobj</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html#mro"><code>mro</code></a></td>
<td>Method in class <a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.object-class.html"><code>object</code></a></td>
<td>Class in module <code>__builtin__</code></td></tr>
<tr><td width="15%"><a href="bison.ParserSyntaxError-class.html"><code>ParserSyntaxError</code></a></td>
<td>Class in module <a href="bison-module.html"><code>bison</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#read"><code>read</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison-module.html#reSpaces"><code>reSpaces</code></a></td>
<td>Variable in module <a href="bison-module.html"><code>bison</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#run"><code>run</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#toprettyxml"><code>toprettyxml</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#toprettyxml"><code>toprettyxml</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#toxml"><code>toxml</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#toxml"><code>toxml</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#toxmldoc"><code>toxmldoc</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#toxmldoc"><code>toxmldoc</code></a></td>
<td>Method in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
<tr><td width="15%"><a href="bison.BisonNode-class.html#toxmlelem"><code>toxmlelem</code></a></td>
<td>Method in class <a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></td></tr>
<tr><td width="15%"><a href="__builtin__.type-class.html"><code>type</code></a></td>
<td>Class in module <code>__builtin__</code></td></tr>
<tr><td width="15%"><a href="bison.BisonParser-class.html#verbose"><code>verbose</code></a></td>
<td>Variable in class <a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></td></tr>
</table>
<br />
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th bgcolor="#70b0f0" class="navselect">&nbsp;&nbsp;&nbsp;Index&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sun Jun 27 12:36:56 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>bison</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<center><font size="+1"><b><a target="mainFrame" href="bison-module.html">bison</a></b></font></center>
<hr>
<!-- =========== START OF CLASSES =========== -->
<font size="+1"><b>Classes</b></font><br />
<a target="mainFrame" href="bison.BisonError-class.html">BisonError</a><br />
<a target="mainFrame" href="bison.BisonNode-class.html">BisonNode</a><br />
<a target="mainFrame" href="bison.BisonParser-class.html">BisonParser</a><br />
<br />
<!-- =========== START OF EXCEPTIONS =========== -->
<font size="+1"><b>Exceptions</b></font><br />
<a target="mainFrame" href="bison.ParserSyntaxError-class.html">ParserSyntaxError</a><br />
<br />
<!-- =========== START OF FUNCTIONS =========== -->
<font size="+1"><b>Functions</b></font><br />
<a target="mainFrame" href="bison-module.html#bisonToPython">bisonToPython</a><br />
<br />
<!-- =========== START OF VARIABLES =========== -->
<font size="+1"><b>Variables</b></font><br />
<a target="mainFrame" href="bison-module.html#reSpaces">reSpaces</a><br />
<br />
<hr>
<font size="-2">[<a href="../private/toc-bison-module.html">show&nbsp;private</a>&nbsp;|&nbsp;hide&nbsp;private]</font>
</body>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Everything</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<center><font size="+1"><b>Everything</b></font></center>
<hr>
<!-- =========== START OF ALL CLASSES =========== -->
<font size="+1"><b>All&nbsp;Classes</b></font><br />
<a target="mainFrame" href="bison.BisonError-class.html">bison.BisonError</a><br />
<a target="mainFrame" href="bison.BisonNode-class.html">bison.BisonNode</a><br />
<a target="mainFrame" href="bison.BisonParser-class.html">bison.BisonParser</a><br />
<br />
<!-- =========== START OF ALL EXCEPTIONS =========== -->
<font size="+1"><b>All&nbsp;Exceptions</b></font><br />
<a target="mainFrame" href="bison.ParserSyntaxError-class.html">bison.ParserSyntaxError</a><br />
<br />
<!-- =========== START OF ALL FUNCTIONS =========== -->
<font size="+1"><b>All&nbsp;Functions</b></font><br />
<a target="mainFrame" href="bison-module.html#bisonToPython">bisonToPython</a><br />
<br />
<!-- =========== START OF ALL VARIABLES =========== -->
<font size="+1"><b>All&nbsp;Variables</b></font><br />
<a target="mainFrame" href="bison-module.html#reSpaces">reSpaces</a><br />
<br />
<hr>
<font size="-2">[<a href="../private/toc-everything.html">show&nbsp;private</a>&nbsp;|&nbsp;hide&nbsp;private]</font>
</body>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Table of Contents</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<center><font size="+1"><b>Table&nbsp;of&nbsp;Contents</b></font></center>
<hr>
<a target="moduleFrame" href="toc-everything.html">Everything</a><br />
<!-- =========== START OF PACKAGES =========== -->
<br /><font size="+1"><b>Packages</b></font><br />
<!-- =========== START OF MODULES =========== -->
<br /><font size="+1"><b>Modules</b></font><br />
<a target="moduleFrame" href="toc-bison-module.html">bison</a><br />
<br /><hr>
<font size="-2">[<a href="../private/toc.html">show&nbsp;private</a>&nbsp;|&nbsp;hide&nbsp;private]</font>
</body>
</html>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Module and Class Hierarchies</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th bgcolor="#70b0f0" class="navselect">&nbsp;&nbsp;&nbsp;Trees&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[<a href="../private/trees.html">show&nbsp;private</a>&nbsp;|&nbsp;hide&nbsp;private]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="trees.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<!-- =========== START OF MODULE HIERARCHY =========== -->
<h2>Module Hierarchy</h2>
<ul>
<li> <b><a href="bison-module.html"><code>bison</code></a></b>: <i>Wrapper module for interfacing with Bison (yacc)</i>
</ul>
<!-- =========== START OF CLASS HIERARCHY =========== -->
<h2>Class Hierarchy</h2>
<ul>
<li> <b><a href="__builtin__.object-class.html"><code>__builtin__.object</code></a></b>: <i>
The most base type</i>
<ul>
<li> <b><a href="bison.BisonParser-class.html"><code>bison.BisonParser</code></a></b>: <i>
Base parser class</i>
<li> <b><a href="__builtin__.type-class.html"><code>__builtin__.type</code></a></b>: <i>
type(object) -&gt; the object's type type(name, bases, dict) -&gt; a
new type</i>
</ul>
<li> <b><a href="bison.BisonError-class.html"><code>bison.BisonError</code></a></b>: <i>
Flags an error to yyparse()</i>
<li> <b><a href="bison.BisonNode-class.html"><code>bison.BisonNode</code></a></b>: <i>
Generic class for wrapping parse targets.</i>
<li> <b><a href="exceptions.Exception-class.html"><code>exceptions.Exception</code></a></b>: <i>
Common base class for all exceptions.</i>
<ul>
<li> <b><a href="bison.ParserSyntaxError-class.html"><code>bison.ParserSyntaxError</code></a></b>
</ul>
</ul>
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="bison-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
PyBison&nbsp;API&nbsp;Reference
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.0 on Sun Jun 27 12:36:56 2004</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>
#!/usr/bin/env python
"""
A simple pybison parser program implementing a calculator
"""
import sys
from bison import BisonParser, BisonNode
class Parser(BisonParser):
"""
Implements the calculator parser. Grammar rules are defined in the method docstrings.
Scanner rules are in the 'lexscript' attribute.
"""
# ----------------------------------------------------------------
# lexer tokens - these must match those in your lex script (below)
# ----------------------------------------------------------------
tokens = ['NUMBER',
'PLUS', 'MINUS', 'TIMES', 'DIVIDE', 'POW',
'LPAREN', 'RPAREN',
'NEWLINE', 'QUIT']
# ------------------------------
# precedences
# ------------------------------
precedences = (
('left', ('MINUS', 'PLUS')),
('left', ('TIMES', 'DIVIDE')),
('left', ('NEG', )),
('right', ('POW', )),
)
# ------------------------------------------------------------------
# override default read method with a version that prompts for input
# ------------------------------------------------------------------
def read(self, nbytes):
try:
return raw_input("> ") + "\n"
except EOFError:
return ''
# ---------------------------------------------------------------
# These methods are the python handlers for the bison targets.
# (which get called by the bison code each time the corresponding
# parse target is unambiguously reached)
#
# WARNING - don't touch the method docstrings unless you know what
# you are doing - they are in bison rule syntax, and are passed
# verbatim to bison to build the parser engine library.
# ---------------------------------------------------------------
# Declare the start target here (by name)
start = "input"
def on_input(self, target, option, names, values):
"""
input :
| input line
"""
return
def on_line(self, target, option, names, values):
"""
line : NEWLINE
| exp NEWLINE
"""
if option == 1:
print values[0]
def on_exp(self, target, option, names, values):
"""
exp : NUMBER
| exp PLUS exp
| exp MINUS exp
| exp TIMES exp
| exp DIVIDE exp
| MINUS exp %prec NEG
| exp POW exp
| LPAREN exp RPAREN
"""
#print "on_exp: got %s %s %s %s" % (target, option, names, values)
if option == 0:
return float(values[0])
elif option == 1:
return values[0] + values[2]
elif option == 2:
return values[0] - values[2]
elif option == 3:
return values[0] * values[2]
elif option == 4:
return values[0] / values[2]
elif option == 5:
return - values[1]
elif option == 6:
return values[0] ** values[2]
elif option == 7:
return values[1]
# -----------------------------------------
# raw lex script, verbatim here
# -----------------------------------------
lexscript = r"""
%{
//int yylineno = 0;
#include <stdio.h>
#include <string.h>
#include "Python.h"
#define YYSTYPE void *
#include "tokens.h"
extern void *py_parser;
extern void (*py_input)(PyObject *parser, char *buf, int *result, int max_size);
#define returntoken(tok) yylval = PyString_FromString(strdup(yytext)); return (tok);
#define YY_INPUT(buf,result,max_size) { (*py_input)(py_parser, buf, &result, max_size); }
%}
%%
[0-9]+ { returntoken(NUMBER); }
"(" { returntoken(LPAREN); }
")" { returntoken(RPAREN); }
"+" { returntoken(PLUS); }
"-" { returntoken(MINUS); }
"*" { returntoken(TIMES); }
"**" { returntoken(POW); }
"/" { returntoken(DIVIDE); }
"quit" { printf("lex: got QUIT\n"); yyterminate(); returntoken(QUIT); }
[ \t\v\f] {}
[\n] {yylineno++; returntoken(NEWLINE); }
. { printf("unknown char %c ignored, yytext=0x%lx\n", yytext[0], yytext); /* ignore bad chars */}
%%
yywrap() { return(1); }
"""
if __name__ == '__main__':
p = Parser()
p.run()
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>PyBison - Python-based Parsing at the Speed of C</title>
</head>
<body>
<center>
<script type="text/javascript"><!--
google_ad_client = "pub-0243656465094951";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_channel ="";
google_color_border = "DDB7BA";
google_color_bg = "FFF5F6";
google_color_link = "0000CC";
google_color_url = "008000";
google_color_text = "6F6F6F";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</center>
<center>Return to <a href="http://www.freenet.org.nz/python">David's Python Resources</a></center
<h1>PyBison - Python-based Parsing at the Speed of C</h1>
<hr>
<h2>Getting PyBison</h2>
<blockquote>
License: GPL
<small><i>(but we will consider applications for licenses for
commercial non-open-source deployment)</i></small>
<ul>
<li>Download PyBison -
<a href="http://www.freenet.org.nz/python/pybison/pybison-0.1.8.tar.gz">pybison-0.1.8.tar.gz</a>
</li>
<li>See an <a href="calc.py">Example that implements a simple calculator</a></li>
<li>Read the <a href="walkthrough.html">PyBison Walkthrough Tutorial</a></li>
<li>Peruse the <a href="api/index.html">PyBison API Reference</a></li>
<li>View the <a href="CHANGELOG.txt">Change Log</a></li>
</ul>
</blockquote>
<hr>
<h2>Introduction</h2>
<blockquote>
PyBison is a Python binding to the Bison (yacc) and Flex (lex) parser-generator
utilities.<br>
<br>
It allows parsers to be quickly and easily developed as Python class
declarations, and for these parsers to take advantage of the fast and
powerful C-based Bison/Flex.<br>
<br>
Users write a subclass of a basic Parser object, containing a set of methods
and attributes specifying the grammar and lexical analysis rules, and taking
callbacks for providing parser input, and receiving parser target events.<br>
<br>
Presently, PyBison is only working on Linux (and possibly *BSD-based) systems.
However, in time, (or if someone volunteers to help out with probably 2 hours'
coding for a small shim layer) it's very possible PyBison will work on Windows
as well.<br>
<br>
</blockquote>
<hr>
<h2>Features</h2>
<blockquote>
<ul>
<li>Runs at near the speed of C-based parsers, due to direct hooks into bison-generated C code</li>
<li>Full LALR(1) grammar support</li>
<li>Includes a utility to convert your legacy grammar (.y) and scanner (.l) scripts into
python modules compatible with PyBison</li>
<li>Easy to understand - the walkthrough and the examples will have you writing your
own parsers in minutes</li>
<li>Comfortable and intuitive callback mechanisms</li>
<li>Can export parse tree to XML with a simple method call
<b><i style="color:#800000">(New!)</i></b></li>
<li>Can reconstitute a parse tree from XML <b><i style="color:#800000">(New!)</i></b></li>
<li>Examples include working parsers for the languages:
<ul>
<li>ANSI C</li>
<li>Java (1.4.2)</li>
</ul>
</li>
</ul>
</blockquote>
<h2>Comparison to Other Python Parsers</h2>
<blockquote>
This comparison is probably very biased, since it's written by the author
of PyBison. However, it should help you to decide whether PyBison is for you.<br>
<br>
All the other Python-based parser-construction toolkits I've seen work
in pure Python. While this offers conveniences such as not requiring binary compilation,
and eliminating dependencies on third-party libraries and other software, it can
incur a savage performance penalty.<br>
<br>
I've seen some Python parser frameworks which use an idiosyncratic syntax, which I
couldn't (or wouldn't) comfortably relate to, especially since I have a background
of developing large yacc-based packages. In particular, I wanted to build my
parser in genuine Python source files, rather than embedding Python code into
a different script language.<br>
<br>
On the other hand, I found the PLY parser framework to be much more comfortably
Pythonic, in that targets are mapped to class methods. However, I ran into a
couple of problems with PLY, namely:
<ul>
<li>speed - PLY could be very slow with generating the parse tables, and
with parsing its input</li>
<li>capacity - due to its use of named-match regular expressions (and the
underlying Python limitation), the lexical analysis is limited to a
vocabulary of 100 unique token types - insufficient for large modern
languages.</li>
<li>model - PLY is limited to SLR parsing, whereas Bison does full LALR(1)</li>
<li>streaming - PLY's lexer requires the full input string to be made
available in one chunk, making it unsuitable for parsing streams of
unpredictable length, whereas Bison and Flex can work from a continuous
stream.
</ul>
With PyBison, I've opted for a system which:
<ul>
<li>Extracts grammar and lexical analysis information from user-written
parser classes</li>
<li>Generates bison and flex sources, and converts these into C sources</li>
<li>Compiles these into a shared loadable library, which is re-usable with
subsequent parsing runs (and which gets automatically rebuilt if (by
virtue of hashing tests) any of the grammar, precedence, tokens or
lexing rules change</li>
<li>Uses Pyrex to interface with this library, calling its yyparse() routine
and taking callbacks for input requests and target fulfilment events</li>
</ul>
The result is a parser toolkit with a Python front end and Python's luxurious
comfort, ease of use, but with (most of) the speed and power of traditional
bison/yacc-based parsers.
</blockquote>
</body>
</html>
<!--@+leo-ver=4-->
<!--@+node:@file doc/walkthrough.html-->
<!--@@language html-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>PyBison Walkthrough</title>
</head>
<body>
<!--@ @+others-->
<!--@+node:body-->
<center>Back to <a href="index.html">PyBison Homepage</a></center>
<h1>PyBison Walkthrough</h1>
<!--@+others-->
<!--@+node:intro-->
<h2>0. Introduction</h2>
This document aims to get you up to speed with PyBison in the fastest possible
time, by walking you through the motions of using it, and supporting the explanations
with an example.<br>
<br>
<blockquote><big>
NOTE - recent versions of flex violate the ANSI standards.<br>
<br>
If any of the pyBison examples fail to build, remove the following line from the lex code portion of your scripts:
<b><blockquote>int yylineno = 0;</blockquote></b>
Also, make sure your system is capable of looking in the local directory when trying to load .so files. If you see any errors like <b>failed to load somefilename.so</b>, just add "." to <b>LD_LIBRARY_PATH</b>, or
execute the command:
<b><blockquote>export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.</blockquote></b>
</big></blockquote>
<hr>
<!--@-node:intro-->
<!--@+node:1. procure grammar/scanner scripts-->
<h2>1. Procure Grammar and Scanner Scripts</h2>
<blockquote>
The best place to start in building your PyBison parser is to write a grammar (.y)
script, and a scanner (.l) script.<br>
<br>
(Or, if possible, source these scripts from other (open source) projects).<br>
<br>
Once you're familiar with the layout of PyBison parser python modules, you can
skip this step, and start building each new parser from scratch, or fram a template
(refer to the <b>examples/template</b> directory).
<!--@+others-->
<!--@+node:1.1 introducing pybison-->
<h3>1.1. Introducing the bison2py Utility</h3>
<blockquote>
bison2py munges your new (or legacy) grammar (.y) and scanner (.l) files, and
generates a new Python file containing classes and unit test code for your
PyBison parser.<br>
<br>
To see <b>bison2py</b> in action, go into the <b>examples/java</b> directory,
read the README file, and generate a <b>javaparser.py</b> file from <b>javaparser.y</b>
and <b>javaparser.l</b> scripts.<br>
<br>
Study the generated javaparser.py file - it's
especially useful from a point of view of seeing what's good to put into a pybison
python parser file, especially when writing your own.<br>
<br>
In fact, when starting a new parser project, you might like to start by writing <b>.y</b>
and <b>.l</b> files yourself, and repeatedly:
<ol>
<li>Edit these files</li>
<li>Generate a parser from them with bison2py</li>
<li>Test the parser rigorously against a whole range of inputs</li>
<li>Remove the grammar and scanner errors as you find them</li>
<li>Repeat these steps as often as needed till you have a bug-free parser and scanner</li>
</ol>
We suggest you may have a far easier time if you ensure you have a bug-free parser
script before even <i>beginning</i> to edit your target handler and parse node methods.<br>
<br>
Once you've got a stable parser, you'll have a structure to work from. You'll then be free to
discard or archive your .y and .l files, and tweak the grammar and scanner
by editing the target handler docstrings and scanner script attributes, respectively.
</blockquote>
<hr>
<!--@-node:1.1 introducing pybison-->
<!--@+node:1.2 prepare grammar file-->
<h3>1.2. Preparing Your Grammar File</h3>
<blockquote>
If you're using an existing .y file (perhaps sourced from another project),
you'll need to massage it a bit to get it into a state where you can process
it automatically with bison2py.<br>
<br>
In summary, you'll need to:
<ul>
<li>Eliminate actions and comments from rules section</li>
<li>Replace character literals in rules, with abstract tokens</li>
<li>Enclose all <b>:</b>, <b>|</b> and <b>;</b> rule delimiters in whitespace.</li>
</ul>
<h4>1.2.1. Strip Out Comments and Actions</h4>
<blockquote>
With your grammar (.y) file, you'll need to strip out all action statements
and comments from the rules section.<br>
<br>
For instance, if you're using a legacy grammar file, you'll need to convert rules like:
<b>
<pre>
expr: expr PLUS expr
{ $$ = $1 + $3; } /* add the numbers now */
|expr MINUS expr
{ $$ = $1 - $3; }
;</pre>
</b>
to:
<b><pre>
expr : expr PLUS expr
| expr MINUS expr
;</pre></b>
or:
<b>
<pre>
expr
: expr PLUS expr
| expr MINUS expr
;</pre>
</b>
depending on what style meets your taste.<br>
<br>
The reason for this is that your pybison script will receive callbacks every time a parse
target is reached, which is done by automatically appending special action code to each
rule clause. If you don't remove all action statements, the conversion will fail.
</blockquote>
<h4>1.2.2. Replace All Character Literals in Rules</h4>
<blockquote>
Within the PyBison-generated parser, all targets and tokens are rendered as Python
objects (for people familiar with the Python/C API, type <b>PyObject *</b>)<br>
<br>
Therefore, you unfortunately lose the convenience of being able to deal in C character
literals in your rules.<br>
<br>
For instance, with a rule like:
<b><pre>
expr : expr '+' expr
| expr '-' expr
;</pre></b>
you'll have to replace the <b>'+'</b> and <b>'-'</b> char literals to abstract tokens,
and ensure that your scanner script returns Python-wrapped tokens for these operators.
You should end up with a rule like:
<b><pre>
expr : expr PLUS expr
| expr MINUS expr
;</pre></b>
And you'll need to ensure your scanner script does a <b>returntoken(PLUS);</b>
and <b>returntoken(MINUS);</b> for <b>'+'</b> and <b>'-'</b> respectively.
</blockquote>
<h4>1.2.3. Enclose Rule Delimiters in Whitespace</h4>
<blockquote>
You need to ensure that the delimiters <b>:</b>, <b>|</b> and <b>;</b> delimiters used in
your rules have at least one whitespace character on either side. Sorry about this, but
this version of PyBison has some quirks in the regular expressions used for
extracting/dissecting the rules, and bison2py (or the resultant parser) may fail
if you don't follow this step.
</blockquote>
And also, you'll need to have a:
<blockquote><b>
%{
...
%}
</b></blockquote>
section in the prologue (before the first <b>%%</b>).
</blockquote>
<hr>
<!--@-node:1.2 prepare grammar file-->
<!--@+node:1.3 prepare lex file-->
<h3>1.3. Preparing Your Tokeniser File</h3>
<blockquote>
In addition to parse targets callbacks, PyBison has an input callback, so your Parser
object will have control over the input that is sent to the lexer.<br>
<br>
You'll have to set up your tokeniser to use this callback mechanism, and also to wrap
tokens as Python objects.<br>
<br>
To set this up, ensure the following lines are in the C declarations sections of your
lex/flex script:
<b><pre>
%{
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include "Python.h"
#define YYSTYPE void *
#include "tokens.h"
extern void *py_parser;
extern void (*py_input)(PyObject *parser, char *buf, int *result, int max_size);
#define returntoken(tok) yylval = PyString_FromString(strdup(yytext)); return (tok);
#define YY_INPUT(buf,result,max_size) {(*py_input)(py_parser, buf, &result, max_size);}
}%</pre></b>
<b>&lt;quick-diversion&gt;</b>
<small><blockquote>
Let's explain each of these lines now:
<b><pre>
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include "Python.h"</pre></b>
Include the standard <b>stdio.h</b> and <b>string.h</b> headers, as well as the
Python-C API file <b>Python.h</b>.
<b><pre>
#define YYSTYPE void *</pre></b>
All parse targets and tokens are actually of type <b>PyObject *</b>, or 'pointer to
Python object', but neither bison nor flex-generated code need to know this. We'll
just give them opaque pointers, and <b>void *</b> will suffice just fine.
<b><pre>
#include "tokens.h"</pre></b>
When PyBison first instantiates any given parser class (and auto-generates, processes,
compiles, links the grammar/scanner files into a dynamic lib), the bison program generates
a header file of token definitions, which gets renamed to <b>tokens.h</b>. Your scanner
script will need this file, so the token macros will be defined and resolved to the correct
token numbers.
<b><pre>
extern void (*py_input)(PyObject *parser, char *buf, int *result, int max_size);
extern void *py_parser;
#define YY_INPUT(buf,result,max_size) {(*py_input)(py_parser, buf, &result, max_size);}</pre></b>
These lines activate the input callback mechanism. Whenever the scanner needs more input,
it will call a global function called <b>py_input()</b>, which forwards the callback to
your Python Parser's <b>.read(nbytes)</b> method.
<blockquote>
Note that if you want your scanner to use a different source of input (eg, a live TCP socket
connection), you can override this method in your parser class, or pass a <b>read=myreadfunction</b>
keyword argument when instantiating your parser (<b>myreadfunction</b> should be a callable
accepting a single argument <b>nbytes</b>, being the maximum number of bytes to retrieve,
and returning a string).
</blockquote>
<b><pre>
#define returntoken(tok) yylval = PyString_FromString(strdup(yytext)); return (tok);</pre></b>
A macro which wraps all tokens values as Python strings, so your parser target handlers can uplift
the original input text which constitutes that token.
</blockquote></small>
<b>&lt;/quick-diversion&gt;</b><br><br>
Defining the <b>YY_INPUT</b> C macro tells flex to invoke a callback every time it needs
input, so your <b>Parser</b> class' <b>.read()</b> method will have control over what the
lexer receives.<br>
<br>
Now, you'll need to change all the <b>return</b> statements in your token targets to use
<b>returntoken()</b> instead. For example, change:
<blockquote>
<b>
"(" { return LPAREN; }<br>
</b>
</blockquote>
to:
<blockquote>
<b>
"(" { returntoken(LPAREN); }<br>
</b>
</blockquote>
Lastly, in the epilogue of your lexer file (ie, after the second '%%' line), you'll need to add a line like:
<b><pre>
yywrap() { return(1); }
</pre></b>
</blockquote>
<hr>
<!--@-node:1.3 prepare lex file-->
<!--@+node:1.4 do the conversion-->
<h3>1.4. Doing The Conversion</h3>
<blockquote>
When you're sure you've got your .y and .l files prepared properly, you can generate
the .py file, which will contain your pyBison <b>Parser</b> class.<br>
<br>
To do this conversion, run the command:
<blockquote>
<b>bison2py mybisonfile.y myflexfile.l mypythonfile.py</b>
</blockquote>
where <b>mybisonfile.y</b> is your grammar file, with bison/yacc declarations,
<b>myflexfile.l</b> is your tokeniser script, with flex/lex declarations, and
<b>mypythonfile.py</b> is the name of the python file you want to generate.<br>
<br>
You should now see a file <b>mypythonfile.py</b> which contains a couple of import
statements, plus a declaration of a class called <b>Parser</b>.
<blockquote>
If your grammar is large and complex, you should consider adding a <b>-c</b>
argument to the bison2py command.<br>
<br>
This will cause the <b>mypythonfile.py</b> file to be generated with a bunch
of parse node subclasses, one per parse target, and with each grammar target
handler method instantiating its respective parse node class, rather
than the default pybison.BisonNode class.<br>
<br>
Also, it'll generate a <b>ParseNode</b> class (derived from <b>pybison.BisonNode</b>,
from which all these target-specific node classes are derived.
<br>
This can be extremely handy, because you can add a bunch of methods to the
ParseNode class, and optionally override these in your per-target node classes. Also,
override the constructor and/or the existing .dump() method in this class or
the per-target classes.<br>
</blockquote>
</blockquote>
<!--@-node:1.4 do the conversion-->
<!--@-others-->
</blockquote>
<hr>
<!--@-node:1. procure grammar/scanner scripts-->
<!--@+node:2. prepare parser class-->
<a name="chap2">
<h2>2. Prepare Your Parser Class</h2>
<blockquote>
Now, we focus on creation of a working parser.<br>
<br>
Note here that we will be creating the parser .py file by hand from
scratch - not the preferred approach, but chosen here as an alternative
to deriving a parser module boilerplate as discussed in the previous chapter.<br>
<br>
To make this easy, we will use
a simple calculator example.<br>
<br>
Create a new python file, perhaps <b>mycalc.py</b>, and follow these steps:<br>
<hr>
<!--@+others-->
<!--@+node:2.1. required imports-->
<h3>2.1. Required Imports</h3>
<blockquote>
You will need at least the following imports:
<blockquote>
<b>from bison import BisonParser, BisonNode</b>
</blockquote>
<b>BisonParser</b> is the base class from which you derive your own
Parser class.<br>
<br>
<b>BisonNode</b> is a convenient wrapper for containing the contents
of parse targets, and can assist you in building your parse tree.<br>
<br>
</blockquote>
<hr>
<!--@-node:2.1. required imports-->
<!--@+node:2.2. devise your grammar-->
<h3>2.2. Devise Your Grammar</h3>
<blockquote>
We'll base our example on the Calculator example from the standard bison/yacc manual.
Note that we won't use exactly the same token names:
<b>
<pre>
%token NUM
%left '-' '+'
%left '*' '/'
%left NEG /* negation--unary minus */
%right '^' /* exponentiation */
/* Grammar follows */
%%
input: /* empty string */
| input line
;
line: '\n'
| exp '\n' { printf ("\t%.10g\n", $1); }
;
exp: NUM { $$ = $1; }
| exp '+' exp { $$ = $1 + $3; }
| exp '-' exp { $$ = $1 - $3; }
| exp '*' exp { $$ = $1 * $3; }
| exp '/' exp { $$ = $1 / $3; }
| '-' exp %prec NEG { $$ = -$2; }
| exp '^' exp { $$ = pow ($1, $3); }
| '(' exp ')' { $$ = $2; }
;
</pre>
</b>
However, in PyBison, you don't dump all this into a script - you declare the
grammar items one by one in methods of your class.
</blockquote>
<hr>
<!--@-node:2.2. devise your grammar-->
<!--@+node:2.3. skeleton class-->
<h3>2.3. Create Skeleton Parser Class</h3>
<blockquote>
In your calc.py file, you've already done the required imports, so
now you can create your skeleton class declaration:
<b><blockquote><pre>
class Parser(BisonParser):
pass
</pre></blockquote></b>
</blockquote>
<hr>
<!--@-node:2.3. skeleton class-->
<!--@+node:2.4. declare tokens-->
<h3>2.4. Declare the Tokens</h3>
<blockquote>
Now, it's time to declare our tokens. To do this, we add to our class an attribute
called <b>tokens</b> which contains a list of our tokens.<br>
<br>
Our class now looks like this:
<b>
<blockquote>
<pre style="color: #808080">
class Parser(BisonParser):</pre>
<pre>
tokens = ['NUMBER',
'PLUS', 'MINUS', 'TIMES', 'DIVIDE', 'POW',
'LPAREN', 'RPAREN',
'NEWLINE', 'QUIT',
]
</pre>
</blockquote>
</b>
</blockquote>
<hr>
<!--@-node:2.4. declare tokens-->
<!--@+node:2.5. declare precedences-->
<h3>2.5. Declare the Precedences</h3>
<blockquote>
To resolve ambiguities in our grammar, we need to declare which entities
have precedence, and the associativity (left/right) of these entities.<br>
<br>
We adapt this from the example, and add it as an attribute <b>precedences</b>.<br>
<br>
Our class now looks like this:
<b><pre style="color: #808080">
class Parser(BisonParser):
tokens = ['NUMBER',
'PLUS', 'MINUS', 'TIMES', 'DIVIDE', 'POW',
'LPAREN', 'RPAREN',
'NEWLINE', 'QUIT',
]</pre>
<pre>
precedences = (
('left', ('MINUS', 'PLUS')),
('left', ('TIMES', 'DIVIDE')),
('left', ('NEG', )),
('right', ('POW', )),
)</pre></b>
</blockquote>
<hr>
<!--@-node:2.5. declare precedences-->
<!--@+node:2.6. declare the start symbol-->
<h3>2.6. Declare the Start Symbol</h3>
<blockquote>
As you can see from studying the grammar above, the topmost
entity is <b>line</b>. We need to tell PyBison to use this,
by adding an attribute called <b>start</b>.
<br>
Our class now looks like this:
<b><pre style="color: #808080">
class Parser(BisonParser):
tokens = ['NUMBER',
'PLUS', 'MINUS', 'TIMES', 'DIVIDE', 'POW',
'LPAREN', 'RPAREN',
'NEWLINE', 'QUIT',
]
precedences = (
('left', ('MINUS', 'PLUS')),
('left', ('TIMES', 'DIVIDE')),
('left', ('NEG', )),
('right', ('POW', )),
)</pre>
<pre>
start = 'input'</pre></b>
</blockquote>
<hr>
<!--@-node:2.6. declare the start symbol-->
<!--@+node:2.7. add rules callbacks-->
<h3>2.7. Add Rules Callbacks</h3>
<blockquote>
This is the fun part. We add a method to our class for each of
the parse targets.<br>
<br>
For each parse target <b>sometarget</b>, we need to provide a method
called:
<b><blockquote><pre>on_sometarget(self, target, option, names, items)</pre></blockquote></b>
Each such callback method accepts the arguments:
<ul>
<li><b>target</b> - string - the name of the target - passed in mainly as
a convenience for when you're debugging your grammar.
</li>
<li><b>option</b> - int - a numerical index indicating which 'clause' matched
the target. For example, given a rule:
<b><pre>
exp : NUMBER
| exp PLUS exp
| exp MINUS exp</pre></b>
If we have matched the expression <b>3 + 6</b>, the <b>option</b> argument
will be 1, because the clause <b>exp PLUS exp</b> occurs at position 1
in the list of rule clauses.</li>
<li><b>names</b> - list of strings, being names of the terms in the matching clause.
For example, with the above rule, the expression <b>3 + 6</b> would produce a
names list <b>['exp', 'PLUS', 'exp']</b></li>
<li><b>items</b> - list - a list of objects, being the values of the items in the
matching clause. Each item of this list will (in the case of token
matches), be a literal string of the token, or (in the case of previously
handled parse targets), whatever your parse target handler happened to
return previously. For instance, in the <b>3 + 6</b> example, assuming your <b>on_exp()</b>
handler returns a float value, this list would be <b>[3.0, '+', 6.0]</b></li>
</ul>
We must now note a major difference from traditional yacc/bison. In yacc/bison, we
provide <b>{ action-stmts;... }</b> action blocks after each rule clause. But with
pyBison, the one parse target callback handles all possible clauses for that target.
The <b>option</b> argument indicates which clause actually matched.<br>
<br>
Now, with this explanation out of the way, we can get down to the business of actually
writing our callbacks.<br>
<br>
Our class now looks like:
<b><pre style="color: #808080">
class Parser(BisonParser):
tokens = ['NUMBER',
'PLUS', 'MINUS', 'TIMES', 'DIVIDE', 'POW',
'LPAREN', 'RPAREN',
'NEWLINE', 'QUIT',
]
precedences = (
('left', ('MINUS', 'PLUS')),
('left', ('TIMES', 'DIVIDE')),
('left', ('NEG', )),
('right', ('POW', )),
)
start = 'input'</pre>
<pre>
def on_input(self, target, option, names, items):
"""
input :
| input line
"""
return
def on_line(self, target, option, names, items):
"""
line : NEWLINE
| exp NEWLINE
"""
if option == 1:
print "on_line: got exp %s" % items[0]
def on_exp(self, target, option, names, items):
"""
exp : NUMBER
| exp PLUS exp
| exp MINUS exp
| exp TIMES exp
| exp DIVIDE exp
| MINUS exp %prec NEG
| exp POW exp
| LPAREN exp RPAREN
"""
if option == 0:
return float(items[0])
elif option == 1:
return items[0] + items[2]
elif option == 2:
return items[0] - items[2]
elif option == 3:
return items[0] * items[2]
elif option == 4:
return items[0] / items[2]
elif option == 5:
return - items[1]
elif option == 6:
return items[0] ** items[2]
elif option == 7:
return items[1]
</pre></b>
Note one important thing here - the rules, declared in our docstrings, are <b>not</b> terminated
by a semicolon. This is not needed (as in traditional yacc), because the rules
are separated into separate handler method docstrings, rather than being lumped in together.<br>
<br>
So don't put a semicolon in your grammar rule docstrings, or Bad Things might happen.
</blockquote>
<hr>
<!--@-node:2.7. add rules callbacks-->
<!--@+node:2.8. add flex script-->
<h3>2.8. Add Flex Script</h3>
<blockquote>
Finally, we must tell pyBison how to carve up the input into tokens.<br>
<br>
Instead of having a separate flex or lex script, we embed the script
verbatim as attribute <b>lexscript</b>.<br>
<br>
<b>NOTE</b> - you should provide this script as a Python raw string (<b>r"""</b>)<br>
<br>
We'll use here a simple flex script which simply recognises numbers, the '+',
'-', '*', '/', '**' operators, and parentheses.<br>
<br>
For our lexer to work, it will need a C declarations section with the magic lines:
<b><pre>
%{
int yylineno = 0;
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include "Python.h"
#define YYSTYPE void *
#include "tokens.h"
extern void *py_parser;
extern void (*py_input)(PyObject *parser, char *buf, int *result, int max_size);
#define returntoken(tok) yylval = PyString_FromString(strdup(yytext)); return (tok);
#define YY_INPUT(buf,result,max_size) { (*py_input)(py_parser, buf, &result, max_size); }
%}
</pre></b>
(refer to Section 1.3 above for an explanation of these declarations).<br>
<br>
Our completed <b>Parser</b> class declaration now looks like this:
<b><pre>
class Parser(BisonParser):
tokens = ['NUMBER',
'PLUS', 'MINUS', 'TIMES', 'DIVIDE', 'POW',
'LPAREN', 'RPAREN',
'NEWLINE', 'QUIT']
precedences = (
('left', ('MINUS', 'PLUS')),
('left', ('TIMES', 'DIVIDE')),
('left', ('NEG', )),
('right', ('POW', )),
)
def read(self, nbytes):
try:
return raw_input("> ")
except EOFError:
return ''
# Declare the start target here (by name)
start = "input"
def on_input(self, target, option, names, items):
"""
input :
| input line
"""
return
def on_line(self, target, option, names, items):
"""
line : NEWLINE
| exp NEWLINE
"""
if option == 1:
print items[0].value
def on_exp(self, target, option, names, items):
"""
exp : NUMBER
| exp PLUS exp
| exp MINUS exp
| exp TIMES exp
| exp DIVIDE exp
| MINUS exp %prec NEG
| exp POW exp
| LPAREN exp RPAREN
"""
if option == 0:
return float(items[0])
elif option == 1:
return items[0] + items[2]
elif option == 2:
return items[0] - items[2]
elif option == 3:
return items[0] * items[2]
elif option == 4:
return items[0] / items[2]
elif option == 5:
return - items[1]
elif option == 6:
return items[0] ** items[2]
elif option == 7:
return items[1]
lexscript = r"""
%{
int yylineno = 0;
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include "Python.h"
#define YYSTYPE void *
#include "tokens.h"
extern void *py_parser;
extern void (*py_input)(PyObject *parser, char *buf, int *result, int max_size);
#define returntoken(tok) yylval = PyString_FromString(strdup(yytext)); return (tok);
#define YY_INPUT(buf,result,max_size) { (*py_input)(py_parser, buf, &result, max_size); }
%}
%%
[0-9]+ { returntoken(NUMBER); }
"(" { returntoken(LPAREN); }
")" { returntoken(RPAREN); }
"+" { returntoken(PLUS); }
"-" { returntoken(MINUS); }
"*" { returntoken(TIMES); }
"**" { returntoken(POW); }
"/" { returntoken(DIVIDE); }
"quit" { printf("lex: got QUIT\n"); yyterminate(); returntoken(QUIT); }
[ \t\v\f] {}
[\n] {yylineno++; returntoken(NEWLINE); }
. { printf("unknown char %c ignored\n", yytext[0]); /* ignore bad chars */}
%%
int yywrap() { return(1); }
"""
</pre></b>
<blockquote style=""color:#900000"><big><b>NOTE</b> - if you are using recent versions of flex (ie, the ones which violate
the ANSI standards for lex/flex), you'll have to change the lexing code above;
removing the line <b>int yylineno = 0;</b></big></blockquote><br>
<br>
Note that we've sneaked in an additional method, <b>.read(self, nbytes)</b>.
This is another callback that gets invoked by the lexer whenever it needs
more input. <i>(quick tip - in your mycalc.py file, do an 'import readline', so
you get line editing and recall when the parser runs)</i>.<br>
<br>
This gives a lot of flexibility, because our Parser class gets to control
exactly where its input comes from - file, or a string, socket, whatever.<br>
<br>
</blockquote>
<hr>
<!--@-node:2.8. add flex script-->
<!--@+node:2.9. write runner script-->
<h3>2.9. Write Runner Script</h3>
<blockquote>
One quick last thing to do here - we just need a tiny script (say, 'runcalc.py'),
to import our Parser class and run it:
<b><blockquote><pre>
#!/usr/bin/env python
import mycalc
p = mycalc.Parser()
p.run()
</pre></blockquote></b>
There's a specific reason why we do this - if we made our <b>mycalc.py</b>
script executable, then when we first instantiate our <b>Parser</b> class,
PyBison will guess a name for the dynamic library to create. If running
mycalc.py directly, then <b>self.__class__.__module__</b> will be '__main__',
and our dynamic library would be created with the name <b>__main__-parser.so</b>,
which is pretty ugly. You could force a name for the library file by declaring
an additional attribute in the Parser class:
<b><blockquote><pre>
bisonEngineLibName = "mycalc-parser"
</pre></blockquote></b>
Oh, and don't forget to chmod the script to be executable.
</blockquote>
<!--@-node:2.9. write runner script-->
<!--@-others-->
</blockquote>
<hr>
<!--@-node:2. prepare parser class-->
<!--@+node:3. running our example-->
<h2>3. Run The Parser</h2>
<blockquote>
We're now ready to run our completed parser.<br>
<br>
Given that you have created the files <b>mycalc.py</b> and <b>runcalc.py</b>
in the current directory, and that you've already installed PyBison (refer INSTALL
file), you'll be set to go.<br>
<br>
From your shell, just type:
<b><blockquote><pre>
$ ./runcalc.py
</pre></blockquote></b>
The first time you run this parser, it might make a lot of compilation-type noises. For example, my aging Debian-based system produces:
<b><blockquote><pre>
In file included from /usr/include/python2.3/Python.h:8,
from tmp.l:6:
/usr/include/python2.3/pyconfig.h:847:1: warning: "_POSIX_C_SOURCE" redefined
In file included from /usr/include/stdio.h:28,
from tmp.lex.c:11:
/usr/include/features.h:171:1: warning: this is the location of the previous definition
</pre></blockquote></b>
All this relates to a bit of black magic which is happening in the background.<br>
<br>
The first time you instantiate your <b>mycalc.Parser</b> class, the <b>bison.BisonParser</b>
base class tries to load the dynamic library <b>mycalc-parser.so</b> (or, on windows, mycalc-parser.dll).<br>
<br>
If the library file is not present (or if it is out of date, determined from hashing handler docstrings and pertinent attributes in the class), PyBison attempts to build it.<br>
<br>
To build this library, PyBison:
<ul>
<li>Rips the static attributes, and handler method docstrings, from the client
Parser class</li>
<li>Generates temporary grammar (tmp.y) and tokeniser (tmp.l) files</li>
<li>Runs <b>bison</b> (or <b>self.bisonCmd</b>, refer source file bison.pyx) on tmp.y</li>
<li>Runs <b>flex</b> (or <b>self.flexCmd</b>, refer bison.pyx) on tmp.l</li>
<li>Compiles the resulting <b>tmp.bison.c</b> and <b>tmp.flex.c</b> files to
object files</li>
<li>Links these objects into the shared library file <b>mycalc-parser.so</b></li>
Subsequent instantiations of the class will not repeat this compilation, unless you
happen to have changed the embedded lex script, or grammar-related attributes of
your class.<br>
<hr>
Getting back to the point - as long as the <b>mycalc-parser.so</b> library built
and loaded successfully, we should now see a prompt (refer <b>.input(self, nchars)</b>
method in 2.8):
<b><blockquote><pre>
$ ./runcalc.py
&gt;
</pre></blockquote></b>
At this prompt, you can type in numbers, or simple arithmetic expressions, and see the
result get printed out:
<b><blockquote><pre>
&gt; 2 + 3
5
&gt; 4 + 5 * 6
34
</pre></blockquote></b>
(note that the higher precedence of '*' has applied).
</ul>
</blockquote>
<hr>
<!--@-node:3. running our example-->
<!--@+node:4. miscellaneous-->
<h2>4. Miscellaneous Remarks</h2>
<blockquote>
Just a few quick notes, to cover some of the possible gotchas.<br>
<!--@+others-->
<!--@+node:4.1. plurality-->
<h3>4.1. Plurality</h3>
<blockquote>
In the present version of PyBison, you may only have one instance of
any given Parser class actually <i>running</i> at any one time.
This is because the present version of PyBison makes use of a couple
of global C variables to store hooks into your Parser instance.<br>
<br>
However, you can have multiple instances existing at the same time.<br>
<br>
Also, you can have several parsers running at the same time, <b><i>as long as
they are each instantiated from different Parser classes</i></b>.
</blockquote>
<hr>
<!--@-node:4.1. plurality-->
<!--@+node:4.2. building a parse tree-->
<h3>4.2. Building A Parse Tree</h3>
<blockquote>
The <b>.run()</b> method of your parser object returns whatever your handler for
the top-level target returned.<br>
<br>
Building a whole parse tree is pretty simple.<br>
<br>
Within each parse target handler callback (your <b>.on_whateverTarget()</b> methods),
you need to create a new <b>BisonNode</b> instance, and store the component items
(the <b>items</b> argument, or whatever you want to extract from <b>items</b>) as
attributes, then return this BisonNode object.<br>
<br>
Then, with the BisonNode object returned from your parser's <b>.run()</b> method,
you'll be able to traverse the tree of the entire parse run.
</blockquote>
<!--@-node:4.2. building a parse tree-->
<!--@-others-->
</blockquote>
<hr>
<!--@-node:4. miscellaneous-->
<!--@+node:5. conclusion-->
<h2>5. Conclusion</h2>
<blockquote>
Through this document, we have started from scratch, and created and used a
complete, working parser.<br>
<br>
We have presented the options of starting with existing .y and .l scripts and
converting them to a boilerplate PyBison .py file, versus writing your own
python parser file from scratch.<br>
<br>
We have covered the requirements for building Parser classes, the attributes and
methods you need to declare.<br>
<br>
We have discussed the callback model, whereby instances of your Parser class
receive callbacks from PyBison whenever input is required, and whenver a
parse target has been unambiguously reached.<br>
<br>
We have briefly discussed how PyBison derives grammar and tokeniser scripts
from the contents of our Parser class, and how PyBison runs bison and flex on
these scripts, compiles the output, and links the result into a shared library,
which can be used in subsequent uses of the Parser to get almost the full speed
of C-based code, from the comfort and convenience of the Python environment.<br>
<br>
And also, we have briefly mentioned how to use PyBison to build up a parse tree
as an easily-traversed Python data structure.<br>
<br>
We hope this document has got you up to speed without undue head-scratching, and
that you're now starting to get a feel for designing and building your own
parsers.
</blockquote>
<!--@-node:5. conclusion-->
<!--@-others-->
<hr>
<address><a href="mailto:david@freenet.co.nz">David McNab</a></address>
<!-- Created: Fri Apr 23 01:27:41 NZST 2004 -->
<!-- hhmts start -->
<!-- hhmts end -->
<!--@-node:body-->
<!--@-others-->
</body>
</html>
<!--@-node:@file doc/walkthrough.html-->
<!--@-leo-->
This is a parser for ANSI C code.
To generate your python parser, type:
bison2py c
or, if you want parse node classes to be generated as well:
bison2py c -c
Either of those commands will generate an executable c.py file,
containing a Parser class, plus unit test code which by default
reads C source from stdin.
Grammar and scanner scripts were sourced from:
* http://www.lysator.liu.se/c/ANSI-C-grammar-y.html
* http://www.lysator.liu.se/c/ANSI-C-grammar-l.html
D [0-9]
L [a-zA-Z_]
H [a-fA-F0-9]
E [Ee][+-]?{D}+
FS (f|F|l|L)
IS (u|U|l|L)*
%{
/* this scanner sourced from: http://www.lysator.liu.se/c/ANSI-C-grammar-l.html */
void count();
int yylineno = 0;
#include <stdio.h>
#include <string.h>
#include "Python.h"
#define YYSTYPE void *
#include "tokens.h"
extern void *py_parser;
extern void (*py_input)(PyObject *parser, char *buf, int *result, int max_size);
#define returntoken(tok) /*printf("%d=%s\n", tok, yytext);*/ yylval = PyString_FromString(strdup(yytext)); return (tok);
#define YY_INPUT(buf,result,max_size) { (*py_input)(py_parser, buf, &result, max_size); }
%}
%%
"/*" { comment(); }
"auto" { count(); returntoken(AUTO); }
"break" { count(); returntoken(BREAK); }
"case" { count(); returntoken(CASE); }
"char" { count(); returntoken(CHAR); }
"const" { count(); returntoken(CONST); }
"continue" { count(); returntoken(CONTINUE); }
"default" { count(); returntoken(DEFAULT); }
"do" { count(); returntoken(DO); }
"double" { count(); returntoken(DOUBLE); }
"else" { count(); returntoken(ELSE); }
"enum" { count(); returntoken(ENUM); }
"extern" { count(); returntoken(EXTERN); }
"float" { count(); returntoken(FLOAT); }
"for" { count(); returntoken(FOR); }
"goto" { count(); returntoken(GOTO); }
"if" { count(); returntoken(IF); }
"int" { count(); returntoken(INT); }
"long" { count(); returntoken(LONG); }
"register" { count(); returntoken(REGISTER); }
"return" { count(); returntoken(RETURN); }
"short" { count(); returntoken(SHORT); }
"signed" { count(); returntoken(SIGNED); }
"sizeof" { count(); returntoken(SIZEOF); }
"static" { count(); returntoken(STATIC); }
"struct" { count(); returntoken(STRUCT); }
"switch" { count(); returntoken(SWITCH); }
"typedef" { count(); returntoken(TYPEDEF); }
"union" { count(); returntoken(UNION); }
"unsigned" { count(); returntoken(UNSIGNED); }
"void" { count(); returntoken(VOID); }
"volatile" { count(); returntoken(VOLATILE); }
"while" { count(); returntoken(WHILE); }
{L}({L}|{D})* { count(); returntoken(check_type()); }
0[xX]{H}+{IS}? { count(); returntoken(CONSTANT); }
0{D}+{IS}? { count(); returntoken(CONSTANT); }
{D}+{IS}? { count(); returntoken(CONSTANT); }
L?'(\\.|[^\\'])+' { count(); returntoken(CONSTANT); }
{D}+{E}{FS}? { count(); returntoken(CONSTANT); }
{D}*"."{D}+({E})?{FS}? { count(); returntoken(CONSTANT); }
{D}+"."{D}*({E})?{FS}? { count(); returntoken(CONSTANT); }
L?\"(\\.|[^\\"])*\" { count(); returntoken(STRING_LITERAL); }
"..." { count(); returntoken(ELLIPSIS); }
">>=" { count(); returntoken(RIGHT_ASSIGN); }
"<<=" { count(); returntoken(LEFT_ASSIGN); }
"+=" { count(); returntoken(ADD_ASSIGN); }
"-=" { count(); returntoken(SUB_ASSIGN); }
"*=" { count(); returntoken(MUL_ASSIGN); }
"/=" { count(); returntoken(DIV_ASSIGN); }
"%=" { count(); returntoken(MOD_ASSIGN); }
"&=" { count(); returntoken(AND_ASSIGN); }
"^=" { count(); returntoken(XOR_ASSIGN); }
"|=" { count(); returntoken(OR_ASSIGN); }
">>" { count(); returntoken(RIGHT_OP); }
"<<" { count(); returntoken(LEFT_OP); }
"++" { count(); returntoken(INC_OP); }
"--" { count(); returntoken(DEC_OP); }
"->" { count(); returntoken(PTR_OP); }
"&&" { count(); returntoken(BOOL_AND_OP); }
"||" { count(); returntoken(BOOL_OR_OP); }
"<=" { count(); returntoken(LE_OP); }
">=" { count(); returntoken(GE_OP); }
"==" { count(); returntoken(EQ_OP); }
"!=" { count(); returntoken(NE_OP); }
";" { count(); returntoken(SEMICOLON); }
("{"|"<%") { count(); returntoken(LBRACE); }
("}"|"%>") { count(); returntoken(RBRACE); }
"," { count(); returntoken(COMMA); }
":" { count(); returntoken(COLON); }
"=" { count(); returntoken(ASSIGN); }
"(" { count(); returntoken(LPAREN); }
")" { count(); returntoken(RPAREN); }
("["|"<:") { count(); returntoken(LBRACKET); }
("]"|":>") { count(); returntoken(RBRACKET); }
"." { count(); returntoken(PERIOD); }
"&" { count(); returntoken(AND_OP); }
"!" { count(); returntoken(BANG); }
"~" { count(); returntoken(TILDE); }
"-" { count(); returntoken(MINUS); }
"+" { count(); returntoken(PLUS); }
"*" { count(); returntoken(STAR); }
"/" { count(); returntoken(SLASH); }
"%" { count(); returntoken(PERCENT); }
"<" { count(); returntoken(LT_OP); }
">" { count(); returntoken(GT_OP); }
"^" { count(); returntoken(CIRCUMFLEX); }
"|" { count(); returntoken(OR_OP); }
"?" { count(); returntoken(QUESTIONMARK); }
[ \t\v\n\f] { count(); }
. { /* ignore bad characters */ }
%%
yywrap()
{
return(1);
}
comment()
{
char c, c1;
loop:
while ((c = input()) != '*' && c != 0)
/*putchar(c)*/;
if ((c1 = input()) != '/' && c != 0)
{
unput(c1);
goto loop;
}
if (c != 0)
/*putchar(c1)*/;
}
int column = 0;
void count()
{
int i;
for (i = 0; yytext[i] != '\0'; i++)
if (yytext[i] == '\n')
column = 0;
else if (yytext[i] == '\t')
column += 8 - (column % 8);
else
column++;
/*ECHO*/;
}
int check_type()
{
/*
* pseudo code --- this is what it should check
*
* if (yytext == type_name)
* return(TYPE_NAME);
*
* return(IDENTIFIER);
*/
/*
* it actually will only return IDENTIFIER
*/
return(IDENTIFIER);
}
/*
* This grammar sourced from:
* http://www.lysator.liu.se/c/ANSI-C-grammar-y.html
*/
%{
%}
%token IDENTIFIER CONSTANT STRING_LITERAL SIZEOF
%token PTR_OP INC_OP DEC_OP LEFT_OP RIGHT_OP LE_OP GE_OP EQ_OP NE_OP
%token BOOL_AND_OP BOOL_OR_OP MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN ADD_ASSIGN
%token SUB_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN
%token XOR_ASSIGN OR_ASSIGN TYPE_NAME
%token LPAREN RPAREN LBRACKET RBRACKET LBRACE RBRACE
%token PERIOD COMMA COLON SEMICOLON QUESTIONMARK
%token PLUS MINUS STAR SLASH ASSIGN AND_OP OR_OP
%token BANG TILDE PERCENT CIRCUMFLEX
%token GT_OP LT_OP
%token TYPEDEF EXTERN STATIC AUTO REGISTER
%token CHAR SHORT INT LONG SIGNED UNSIGNED FLOAT DOUBLE CONST VOLATILE VOID
%token STRUCT UNION ENUM ELLIPSIS
%token CASE DEFAULT IF ELSE SWITCH WHILE DO FOR GOTO CONTINUE BREAK RETURN
%left COMMA
%right ASSIGN ADD_ASSIGN SUB_ASSIGN MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN
%right QUESTIONMARK COLON
%left BOOL_OR_OP
%left BOOL_AND_OP
%left OR_OP
%left CIRCUMFLEX
%left AND_OP
%left EQ_OP NE_OP
%left LT_OP GT_OP LE_OP GE_OP
%left LEFT_OP RIGHT_OP
%left PLUS MINUS
%left STAR SLASH PERCENT
%right NOT NEG
%right INC_OP SIZEOF DEC_OP
%left LBRACKET LPAREN PERIOD PTR_OP
%start translation_unit
%%
primary_expression
: IDENTIFIER
| CONSTANT
| STRING_LITERAL
| LPAREN expression RPAREN
;
postfix_expression
: primary_expression
| postfix_expression LBRACKET expression RBRACKET
| postfix_expression LPAREN RPAREN
| postfix_expression LPAREN argument_expression_list RPAREN
| postfix_expression PERIOD IDENTIFIER
| postfix_expression PTR_OP IDENTIFIER
| postfix_expression INC_OP
| postfix_expression DEC_OP
;
argument_expression_list
: assignment_expression
| argument_expression_list COMMA assignment_expression
;
unary_expression
: postfix_expression
| INC_OP unary_expression
| DEC_OP unary_expression
| unary_operator cast_expression
| SIZEOF unary_expression
| SIZEOF LPAREN type_name RPAREN
;
unary_operator
: AND_OP
| STAR
| PLUS
| MINUS
| TILDE
| BANG
;
cast_expression
: unary_expression
| LPAREN type_name RPAREN cast_expression
;
multiplicative_expression
: cast_expression
| multiplicative_expression STAR cast_expression
| multiplicative_expression SLASH cast_expression
| multiplicative_expression PERCENT cast_expression
;
additive_expression
: multiplicative_expression
| additive_expression PLUS multiplicative_expression
| additive_expression MINUS multiplicative_expression
;
shift_expression
: additive_expression
| shift_expression LEFT_OP additive_expression
| shift_expression RIGHT_OP additive_expression
;
relational_expression
: shift_expression
| relational_expression LT_OP shift_expression
| relational_expression GT_OP shift_expression
| relational_expression LE_OP shift_expression
| relational_expression GE_OP shift_expression
;
equality_expression
: relational_expression
| equality_expression EQ_OP relational_expression
| equality_expression NE_OP relational_expression
;
and_expression
: equality_expression
| and_expression AND_OP equality_expression
;
exclusive_or_expression
: and_expression
| exclusive_or_expression CIRCUMFLEX and_expression
;
inclusive_or_expression
: exclusive_or_expression
| inclusive_or_expression OR_OP exclusive_or_expression
;
logical_and_expression
: inclusive_or_expression
| logical_and_expression BOOL_AND_OP inclusive_or_expression
;
logical_or_expression
: logical_and_expression
| logical_or_expression BOOL_OR_OP logical_and_expression
;
conditional_expression
: logical_or_expression
| logical_or_expression QUESTIONMARK expression COLON conditional_expression
;
assignment_expression
: conditional_expression
| unary_expression assignment_operator assignment_expression
;
assignment_operator
: ASSIGN
| MUL_ASSIGN
| DIV_ASSIGN
| MOD_ASSIGN
| ADD_ASSIGN
| SUB_ASSIGN
| LEFT_ASSIGN
| RIGHT_ASSIGN
| AND_ASSIGN
| XOR_ASSIGN
| OR_ASSIGN
;
expression
: assignment_expression
| expression COMMA assignment_expression
;
constant_expression
: conditional_expression
;
declaration
: declaration_specifiers SEMICOLON
| declaration_specifiers init_declarator_list SEMICOLON
;
declaration_specifiers
: storage_class_specifier
| storage_class_specifier declaration_specifiers
| type_specifier
| type_specifier declaration_specifiers
| type_qualifier
| type_qualifier declaration_specifiers
;
init_declarator_list
: init_declarator
| init_declarator_list COMMA init_declarator
;
init_declarator
: declarator
| declarator ASSIGN initializer
;
storage_class_specifier
: TYPEDEF
| EXTERN
| STATIC
| AUTO
| REGISTER
;
type_specifier
: VOID
| CHAR
| SHORT
| INT
| LONG
| FLOAT
| DOUBLE
| SIGNED
| UNSIGNED
| struct_or_union_specifier
| enum_specifier
| TYPE_NAME
;
struct_or_union_specifier
: struct_or_union IDENTIFIER LBRACE struct_declaration_list RBRACE
| struct_or_union LBRACE struct_declaration_list RBRACE
| struct_or_union IDENTIFIER
;
struct_or_union
: STRUCT
| UNION
;
struct_declaration_list
: struct_declaration
| struct_declaration_list struct_declaration
;
struct_declaration
: specifier_qualifier_list struct_declarator_list SEMICOLON
;
specifier_qualifier_list
: type_specifier specifier_qualifier_list
| type_specifier
| type_qualifier specifier_qualifier_list
| type_qualifier
;
struct_declarator_list
: struct_declarator
| struct_declarator_list COMMA struct_declarator
;
struct_declarator
: declarator
| COLON constant_expression
| declarator COLON constant_expression
;
enum_specifier
: ENUM LBRACE enumerator_list RBRACE
| ENUM IDENTIFIER LBRACE enumerator_list RBRACE
| ENUM IDENTIFIER
;
enumerator_list
: enumerator
| enumerator_list COMMA enumerator
;
enumerator
: IDENTIFIER
| IDENTIFIER ASSIGN constant_expression
;
type_qualifier
: CONST
| VOLATILE
;
declarator
: pointer direct_declarator
| direct_declarator
;
direct_declarator
: IDENTIFIER
| LPAREN declarator RPAREN
| direct_declarator LBRACKET constant_expression RBRACKET
| direct_declarator LBRACKET RBRACKET
| direct_declarator LPAREN parameter_type_list RPAREN
| direct_declarator LPAREN identifier_list RPAREN
| direct_declarator LPAREN RPAREN
;
pointer
: STAR
| STAR type_qualifier_list
| STAR pointer
| STAR type_qualifier_list pointer
;
type_qualifier_list
: type_qualifier
| type_qualifier_list type_qualifier
;
parameter_type_list
: parameter_list
| parameter_list COMMA ELLIPSIS
;
parameter_list
: parameter_declaration
| parameter_list COMMA parameter_declaration
;
parameter_declaration
: declaration_specifiers declarator
| declaration_specifiers abstract_declarator
| declaration_specifiers
;
identifier_list
: IDENTIFIER
| identifier_list COMMA IDENTIFIER
;
type_name
: specifier_qualifier_list
| specifier_qualifier_list abstract_declarator
;
abstract_declarator
: pointer
| direct_abstract_declarator
| pointer direct_abstract_declarator
;
direct_abstract_declarator
: LPAREN abstract_declarator RPAREN
| LBRACKET RBRACKET
| LBRACKET constant_expression RBRACKET
| direct_abstract_declarator LBRACKET RBRACKET
| direct_abstract_declarator LBRACKET constant_expression RBRACKET
| LPAREN RPAREN
| LPAREN parameter_type_list RPAREN
| direct_abstract_declarator LPAREN RPAREN
| direct_abstract_declarator LPAREN parameter_type_list RPAREN
;
initializer
: assignment_expression
| LBRACE initializer_list RBRACE
| LBRACE initializer_list COMMA RBRACE
;
initializer_list
: initializer
| initializer_list COMMA initializer
;
statement
: labeled_statement
| compound_statement
| expression_statement
| selection_statement
| iteration_statement
| jump_statement
;
labeled_statement
: IDENTIFIER COLON statement
| CASE constant_expression COLON statement
| DEFAULT COLON statement
;
compound_statement
: LBRACE RBRACE
| LBRACE statement_list RBRACE
| LBRACE declaration_list RBRACE
| LBRACE declaration_list statement_list RBRACE
;
declaration_list
: declaration
| declaration_list declaration
;
statement_list
: statement
| statement_list statement
;
expression_statement
: SEMICOLON
| expression SEMICOLON
;
selection_statement
: IF LPAREN expression RPAREN statement
| IF LPAREN expression RPAREN statement ELSE statement
| SWITCH LPAREN expression RPAREN statement
;
iteration_statement
: WHILE LPAREN expression RPAREN statement
| DO statement WHILE LPAREN expression RPAREN SEMICOLON
| FOR LPAREN expression_statement expression_statement RPAREN statement
| FOR LPAREN expression_statement expression_statement expression RPAREN statement
;
jump_statement
: GOTO IDENTIFIER SEMICOLON
| CONTINUE SEMICOLON
| BREAK SEMICOLON
| RETURN SEMICOLON
| RETURN expression SEMICOLON
;
translation_unit
: external_declaration
| translation_unit external_declaration
;
external_declaration
: function_definition
| declaration
;
function_definition
: declaration_specifiers declarator declaration_list compound_statement
| declaration_specifiers declarator compound_statement
| declarator declaration_list compound_statement
| declarator compound_statement
;
%%
#include <stdio.h>
extern char yytext[];
extern int column;
yyerror(s)
char *s;
{
fflush(stdout);
printf("\n%*s\n%*s\n", column, "^", column, s);
}
This is a minimal calculator example, as discussed in the walkthrough
document.
Provided you have installed PyBison, running the run.py script should
trigger the creation of the calc-parser.so parser engine lib, and
run a calculator parser which accepts expressions you type in, and
prints out results.
#!/usr/bin/env python
"""
A simple pybison parser program implementing a calculator
"""
import sys
from bison import BisonParser, BisonNode
class Parser(BisonParser):
"""
Implements the calculator parser. Grammar rules are defined in the method docstrings.
Scanner rules are in the 'lexscript' attribute.
"""
# ----------------------------------------------------------------
# lexer tokens - these must match those in your lex script (below)
# ----------------------------------------------------------------
tokens = ['NUMBER',
'PLUS', 'MINUS', 'TIMES', 'DIVIDE', 'POW',
'LPAREN', 'RPAREN',
'NEWLINE', 'QUIT']
# ------------------------------
# precedences
# ------------------------------
precedences = (
('left', ('MINUS', 'PLUS')),
('left', ('TIMES', 'DIVIDE')),
('left', ('NEG', )),
('right', ('POW', )),
)
# ------------------------------------------------------------------
# override default read method with a version that prompts for input
# ------------------------------------------------------------------
def read(self, nbytes):
try:
return raw_input("> ") + "\n"
except EOFError:
return ''
# ---------------------------------------------------------------
# These methods are the python handlers for the bison targets.
# (which get called by the bison code each time the corresponding
# parse target is unambiguously reached)
#
# WARNING - don't touch the method docstrings unless you know what
# you are doing - they are in bison rule syntax, and are passed
# verbatim to bison to build the parser engine library.
# ---------------------------------------------------------------
# Declare the start target here (by name)
start = "input"
def on_input(self, target, option, names, values):
"""
input :
| input line
"""
return
def on_line(self, target, option, names, values):
"""
line : NEWLINE
| exp NEWLINE
"""
if option == 1:
print values[0]
def on_exp(self, target, option, names, values):
"""
exp : NUMBER
| exp PLUS exp
| exp MINUS exp
| exp TIMES exp
| exp DIVIDE exp
| MINUS exp %prec NEG
| exp POW exp
| LPAREN exp RPAREN
"""
#print "on_exp: got %s %s %s %s" % (target, option, names, values)
if option == 0:
return float(values[0])
elif option == 1:
return values[0] + values[2]
elif option == 2:
return values[0] - values[2]
elif option == 3:
return values[0] * values[2]
elif option == 4:
return values[0] / values[2]
elif option == 5:
return - values[1]
elif option == 6:
return values[0] ** values[2]
elif option == 7:
return values[1]
# -----------------------------------------
# raw lex script, verbatim here
# -----------------------------------------
lexscript = r"""
%{
//int yylineno = 0;
#include <stdio.h>
#include <string.h>
#include "Python.h"
#define YYSTYPE void *
#include "tokens.h"
extern void *py_parser;
extern void (*py_input)(PyObject *parser, char *buf, int *result, int max_size);
#define returntoken(tok) yylval = PyString_FromString(strdup(yytext)); return (tok);
#define YY_INPUT(buf,result,max_size) { (*py_input)(py_parser, buf, &result, max_size); }
%}
%%
[0-9]+ { returntoken(NUMBER); }
"(" { returntoken(LPAREN); }
")" { returntoken(RPAREN); }
"+" { returntoken(PLUS); }
"-" { returntoken(MINUS); }
"*" { returntoken(TIMES); }
"**" { returntoken(POW); }
"/" { returntoken(DIVIDE); }
"quit" { printf("lex: got QUIT\n"); yyterminate(); returntoken(QUIT); }
[ \t\v\f] {}
[\n] {yylineno++; returntoken(NEWLINE); }
. { printf("unknown char %c ignored, yytext=0x%lx\n", yytext[0], yytext); /* ignore bad chars */}
%%
yywrap() { return(1); }
"""
if __name__ == '__main__':
p = Parser()
p.run()
#!/usr/bin/env python
import readline
import calc
parser = calc.Parser(verbose=0, keepfiles=0)
parser.run()
A slightly more powerful calculator that supports variables,
plus some scientific functions like log(), sqr(), sin() etc.
Most notably, this example demonstrates error handling.
If/when one of your rule handlers comes across a condition
which constitutes an error, but which the parser doesn't or can't
pick up (eg division by zero), the handler should do:
return self.error("string-describing-the-error")
This will cause the parser to go into error handling mode.
Also, your rules can pick up errors, by using the magic
target name 'error'. Within error handling code, the
'lasterror' attribute of the parser object will be a
3-tuple:
(line-num, msg, near-token)
where:
- 'line-num' is the input line at which the error (most likely)
occured,
- 'msg' is the error message text (supplied by either your own
prior 'self.error(somestring)' call, or by the parser itself
- 'near-token' is a string, the input token which triggered the
error condition
#!/usr/bin/env python
"""
A more advanced calculator example, with variable storage and scientific
functions (courtesy of python 'math' module)
"""
import sys, math, readline
from bison import BisonParser, BisonNode, BisonError
class Parser(BisonParser):
"""
Implements the calculator parser. Grammar rules are defined in the method docstrings.
Scanner rules are in the 'lexscript' attribute.
"""
# ----------------------------------------------------------------
# lexer tokens - these must match those in your lex script (below)
# ----------------------------------------------------------------
tokens = ['NUMBER',
'PLUS', 'MINUS', 'TIMES', 'DIVIDE', 'MOD', 'POW',
'LPAREN', 'RPAREN',
'NEWLINE', 'QUIT',
'EQUALS', 'PI', 'E',
'IDENTIFIER',
'HELP']
# ------------------------------
# precedences
# ------------------------------
precedences = (
('left', ('MINUS', 'PLUS')),
('left', ('TIMES', 'DIVIDE', 'MOD')),
('left', ('NEG', )),
('right', ('POW', )),
)
# --------------------------------------------
# basename of binary parser engine dynamic lib
# --------------------------------------------
bisonEngineLibName = "calc1-engine"
# ------------------------------------------------------------------
# override default read method with a version that prompts for input
# ------------------------------------------------------------------
def read(self, nbytes):
try:
return raw_input("> ") + "\n"
except EOFError:
return ''
# -----------------------------------------------------------
# override default run method to set up our variables storage
# -----------------------------------------------------------
def run(self, *args, **kw):
self.vars = {}
BisonParser.run(self, *args, **kw)
# ---------------------------------------------------------------
# These methods are the python handlers for the bison targets.
# (which get called by the bison code each time the corresponding
# parse target is unambiguously reached)
#
# WARNING - don't touch the method docstrings unless you know what
# you are doing - they are in bison rule syntax, and are passed
# verbatim to bison to build the parser engine library.
# ---------------------------------------------------------------
# Declare the start target here (by name)
start = "input"
def on_input(self, target, option, names, values):
"""
input :
| input line
"""
if option == 1:
return values[0]
def on_line(self, target, option, names, values):
"""
line : NEWLINE
| exp NEWLINE
| IDENTIFIER EQUALS exp NEWLINE
| HELP
| error
"""
if option == 1:
print values[0]
return values[0]
elif option == 2:
self.vars[values[0]] = values[2]
return values[2]
elif option == 3:
self.show_help()
elif option == 4:
line, msg, near = self.lasterror
print "Line %s: \"%s\" near %s" % (line, msg, repr(near))
def on_exp(self, target, option, names, values):
"""
exp : number | plusexp | minusexp | timesexp | divexp | modexp
| negexp | powexp | parenexp | varexp | functioncall | constant
"""
return values[0]
def on_number(self, target, option, names, values):
"""
number : NUMBER
"""
return float(values[0])
def on_plusexp(self, target, option, names, values):
"""
plusexp : exp PLUS exp
"""
return values[0] + values[2]
def on_minusexp(self, target, option, names, values):
"""
minusexp : exp MINUS exp
"""
return values[0] - values[2]
def on_timesexp(self, target, option, names, values):
"""
timesexp : exp TIMES exp
"""
return values[0] * values[2]
def on_divexp(self, target, option, names, values):
"""
divexp : exp DIVIDE exp
"""
try:
return values[0] / values[2]
except:
return self.error("Division by zero error")
def on_modexp(self, target, option, names, values):
"""
modexp : exp MOD exp
"""
try:
return values[0] % values[2]
except:
return self.error("Modulus by zero error")
def on_powexp(self, target, option, names, values):
"""
powexp : exp POW exp
"""
return values[0] ** values[2]
def on_negexp(self, target, option, names, values):
"""
negexp : MINUS exp %prec NEG
"""
return values[1]
def on_parenexp(self, target, option, names, values):
"""
parenexp : LPAREN exp RPAREN
"""
return values[1]
def on_varexp(self, target, option, names, values):
"""
varexp : IDENTIFIER
"""
if self.vars.has_key(values[0]):
return self.vars[values[0]]
else:
return self.error("No such variable '%s'" % values[0])
def on_functioncall(self, target, option, names, values):
"""
functioncall : IDENTIFIER LPAREN exp RPAREN
"""
func = getattr(math, values[0], None)
if not callable(func):
return self.error("No such function '%s'" % values[0])
try:
return func(values[2])
except Exception, e:
return self.error(e.args[0])
def on_constant(self, target, option, names, values):
"""
constant : PI
| E
"""
return getattr(math, values[0])
# -----------------------------------------
# Display help
# -----------------------------------------
def show_help(self):
print "This PyBison parser implements a basic scientific calculator"
print " * scientific notation now works for numbers, eg '2.3e+12'"
print " * you can assign values to variables, eg 'x = 23.2'"
print " * the constants 'pi' and 'e' are supported"
print " * all the python 'math' module functions are available, eg 'sin(pi/6)'"
print " * errors, such as division by zero, are now reported"
# -----------------------------------------
# raw lex script, verbatim here
# -----------------------------------------
lexscript = r"""
%{
int yylineno = 0;
#include <stdio.h>
#include <string.h>
#include "Python.h"
#define YYSTYPE void *
#include "tokens.h"
extern void *py_parser;
extern void (*py_input)(PyObject *parser, char *buf, int *result, int max_size);
#define returntoken(tok) yylval = PyString_FromString(strdup(yytext)); return (tok);
#define YY_INPUT(buf,result,max_size) { (*py_input)(py_parser, buf, &result, max_size); }
%}
%%
([0-9]*\.?)([0-9]+)(e[-+]?[0-9]+)? { returntoken(NUMBER); }
([0-9]+)(\.?[0-9]*)(e[-+]?[0-9]+)? { returntoken(NUMBER); }
"(" { returntoken(LPAREN); }
")" { returntoken(RPAREN); }
"+" { returntoken(PLUS); }
"-" { returntoken(MINUS); }
"*" { returntoken(TIMES); }
"**" { returntoken(POW); }
"/" { returntoken(DIVIDE); }
"%" { returntoken(MOD); }
"quit" { printf("lex: got QUIT\n"); yyterminate(); returntoken(QUIT); }
"=" { returntoken(EQUALS); }
"e" { returntoken(E); }
"pi" { returntoken(PI); }
"help" { returntoken(HELP); }
[a-zA-Z_][0-9a-zA-Z_]* { returntoken(IDENTIFIER); }
[ \t\v\f] {}
[\n] {yylineno++; returntoken(NEWLINE); }
. { printf("unknown char %c ignored, yytext=0x%lx\n", yytext[0], yytext); /* ignore bad chars */}
%%
yywrap() { return(1); }
"""
if __name__ == '__main__':
p = Parser(keepfiles=0)
print "Scientific calculator example. Type 'help' for help"
p.run()
The javaparser.l and javaparser.y files herein were NOT written by
myself (David McNab).
javaparser.l was taken almost verbatim from an apparently public
domain version, found on the website of
Professor Dave Binkley
(http://www.cs.loyola.edu/~binkley/)
at the Department of Computer Science at Loyola College in Maryland
(http://www.cs.loyola.edu/)
javaparser.y was taken almost verbatim from the source code to
the GNU gcj java compiler.
public class HelloWorldApp {
public HelloWorldApp() {}
public static void main(String[] args) {
System.out.println("Hello, world");
}
public static void main() {
main(new String[]{});
}
}
This is a somewhat more advanced example, containing
bison and lex scripts for a java source code parser.
Note that there is no python file containing a Parser class. We
have to generate one.
To do this, run:
$ bison2py javaparser.y javaparser.l javaparser.py
or just:
$ bison2py javaparser
You should now see a file javaparser.py
Then, just run the run-javaparser.py script. The
script will instantiate a parser and run it on the
whatever source file you give as an argument.
D [0-9]
N [1-9]
L [a-zA-Z_$]
H [a-fA-F0-9]
OC [0-7]
E [Ee][+-]?{D}+
LS [fFdD]
Escape \\[ntbrf\\'"]
Escchar \\{D}({D}?{D})?
Escunichar \\u{H}{H}{H}{H}
%{
int yylineno = 0;
#include <stdio.h>
#include <string.h>
#include "Python.h"
#define YYSTYPE void *
#include "tokens.h"
extern void *py_parser;
extern void (*py_input)(PyObject *parser, char *buf, int *result, int max_size);
#define returntoken(tok) /*printf("%d=%s\n", tok, yytext);*/ yylval = PyString_FromString(strdup(yytext)); return (tok);
#define YY_INPUT(buf,result,max_size) { (*py_input)(py_parser, buf, &result, max_size); }
#include "table.h"
%}
%%
{N}{D}*(l|L)? { returntoken(INTEGER_LITERAL_TOKEN); }
{N}{D}*(d|D)? { returntoken(INTEGER_LITERAL_TOKEN); }
0[xX]{H}+(l|L)? { returntoken(INTEGER_LITERAL_TOKEN); }
0{OC}*(l|L)? { returntoken(INTEGER_LITERAL_TOKEN); }
{D}+"."{D}*({E})?{LS}? { returntoken(FLOATING_POINT_LITERAL_TOKEN); }
"."{D}+({E})?{LS}? { returntoken(FLOATING_POINT_LITERAL_TOKEN); }
{D}+{E}{LS}? { returntoken(FLOATING_POINT_LITERAL_TOKEN); }
{D}{LS} { returntoken(FLOATING_POINT_LITERAL_TOKEN); }
"true" { returntoken(BOOLEAN_LITERAL_TOKEN); }
"false" { returntoken(BOOLEAN_LITERAL_TOKEN); }
{L}({L}|{D})* { returntoken(Table_Lookup(KeywordTable));}
'[^'\\]' { returntoken(CHARACTER_LITERAL_TOKEN);}
'{Escape}' { returntoken(CHARACTER_LITERAL_TOKEN);}
\"([^\"\\]|{Escape}|{Escchar}|{Escunichar})*\" { returntoken(STRING_LITERAL_TOKEN); }
\/\/.*$ {}
\/\* { comment();}
"(" { returntoken(OPEN_PAREN_TOKEN); }
")" { returntoken(CLOSE_PAREN_TOKEN); }
"{" { returntoken(OPEN_BRACE_TOKEN); }
"}" { returntoken(CLOSE_BRACE_TOKEN); }
"[" { returntoken(OPEN_BRACKET_TOKEN); }
"]" { returntoken(CLOSE_BRACKET_TOKEN); }
";" { returntoken(SEMICOLON_TOKEN); }
"," { returntoken(COMMA_TOKEN); }
"." { returntoken(PERIOD_TOKEN); }
"=" { returntoken(ASSIGNS_TOKEN); }
">" { returntoken(GREATER_TOKEN); }
"<" { returntoken(LESS_TOKEN); }
"!" { returntoken(NOT_TOKEN); }
"~" { returntoken(TILDE_TOKEN); }
"?" { returntoken(CONDITIONAL_TOKEN); }
":" { returntoken(COLON_TOKEN); }
"==" { returntoken(EQ_TOKEN); }
"<=" { returntoken(LE_TOKEN); }
">=" { returntoken(GE_TOKEN); }
"!=" { returntoken(NE_OP_TOKEN); }
"||" { returntoken(LOGICAL_OR_TOKEN); }
"&&" { returntoken(LOGICAL_AND_TOKEN); }
"++" { returntoken(INC_TOKEN); }
"--" { returntoken(DEC_TOKEN); }
"+" { returntoken(PLUS_TOKEN); }
"-" { returntoken(MINUS_TOKEN); }
"*" { returntoken(MUL_TOKEN); }
"/" { returntoken(DIV_TOKEN); }
"&" { returntoken(AND_TOKEN); }
"|" { returntoken(OR_TOKEN); }
"^" { returntoken(XOR_TOKEN); }
"%" { returntoken(MOD_TOKEN); }
"<<" { returntoken(SHL_TOKEN); }
">>" { returntoken(SAR_TOKEN); }
">>>" { returntoken(SHL_TOKEN); }
"+=" { returntoken(ADD_ASSIGN_TOKEN); }
"-=" { returntoken(SUB_ASSIGN_TOKEN); }
"*=" { returntoken(MUL_ASSIGN_TOKEN); }
"/=" { returntoken(DIV_ASSIGN_TOKEN); }
"&=" { returntoken(AND_ASSIGN_TOKEN); }
"|=" { returntoken(OR_ASSIGN_TOKEN); }
"^=" { returntoken(XOR_ASSIGN_TOKEN); }
"%=" { returntoken(MOD_ASSIGN_TOKEN); }
"<<=" { returntoken(SHL_ASSIGN_TOKEN); }
">>=" { returntoken(SAR_ASSIGN_TOKEN); }
">>>=" { returntoken(SHR_ASSIGN_TOKEN); }
[ \t\v\f] {}
[\n] {yylineno++;}
. { printf("unknown char %c ignored\n", yytext[0]); /* ignore bad chars */}
%%
yywrap() { return(1); }
/* test_main()
{
int t;
for(t = yylex(), t > 0, t = yylex())
{
printf("%s\t%d\n", yytext,t);
}
return 0;
}
*/
/* input: Table of tokens
* returns TokenCode of keyword if matched or
* ID_TOKEN if no match is found
*/
int Table_Lookup(struct KeywordToken Table[])
{
struct KeywordToken *Curr;
int i = 0;
for (Curr = Table; Curr->Keyword != ""; Curr++)
{
//printf("Table_Lookup: yytext='%s', Curr->Keyword='%s', idx=%d\n", yytext, Curr->Keyword, i);
if (strcmp(Curr->Keyword, yytext)==0)
{
//printf("Table_Lookup: '%s' => %d\n", yytext, Curr->TokenCode);
return (Curr->TokenCode);
}
i++;
}
return ID_TOKEN;
}
commentold()
{
char c = -1, c1;
while(c != 0)
{
for(c = input(); c != '*' && c!=0; c = input())
;
/* now we have a star or no more chars */
if(c == 0 || (c1 = input() == '/'))
return;
if (c1 == '*')
unput(c1);
}
}
comment()
{
int prev=-1, cur=-1;
while (1)
{
cur = input();
if (cur == '/' && prev == '*')
return;
else if (cur == 0)
return;
prev = cur;
}
}
/* yacc grammar for JAVA language */
/* print with psf -p 10 -L50 -l 50 -w -E j.y > xx */
%{
#define REDUCE /* will display the reduce rules */
#undef REDUCE
#define PRNT_SYM
#undef PRNT_SYM
#define YYDEBUG 1
#include <stdio.h>
extern FILE *yyin;
extern int yylineno;
extern int yydebug;
extern char yytext[];
#ifdef REDUCE
# define reduce(a) printf("%s\n",a)
#else
# define reduce(a)
#endif
#define YYSTYPE PyObject *
%}
/* Things defined here have to match the order of what's in the
binop_lookup table. */
%token PLUS_TOKEN MINUS_TOKEN MUL_TOKEN DIV_TOKEN MOD_TOKEN
%token SHL_TOKEN SHR_TOKEN SAR_TOKEN
%token AND_TOKEN XOR_TOKEN OR_TOKEN
%token LOGICAL_AND_TOKEN LOGICAL_OR_TOKEN
%token EQ_TOKEN NE_OP_TOKEN GREATER_TOKEN GE_TOKEN LESS_TOKEN LE_TOKEN
/* This maps to the same binop_lookup entry than the token above */
%token ADD_ASSIGN_TOKEN SUB_ASSIGN_TOKEN MUL_ASSIGN_TOKEN DIV_ASSIGN_TOKEN
%token MOD_ASSIGN_TOKEN
%token SHL_ASSIGN_TOKEN SHR_ASSIGN_TOKEN SAR_ASSIGN_TOKEN
%token AND_ASSIGN_TOKEN XOR_ASSIGN_TOKEN OR_ASSIGN_TOKEN
/* Modifier TOKEN have to be kept in this order. Don't scramble it */
%token PUBLIC_TOKEN PRIVATE_TOKEN PROTECTED_TOKEN
%token STATIC_TOKEN FINAL_TOKEN SYNCHRONIZED_TOKEN
%token VOLATILE_TOKEN TRANSIENT_TOKEN NATIVE_TOKEN
%token PAD_TOKEN ABSTRACT_TOKEN MODIFIER_TOKEN
%token STRICT_TOKEN STRICTFP_TOKEN
/* Keep those two in order, too */
%token DEC_TOKEN INC_TOKEN
/* From now one, things can be in any order */
%token DEFAULT_TOKEN IF_TOKEN THROW_TOKEN
%token BOOLEAN_TOKEN DO_TOKEN IMPLEMENTS_TOKEN
%token THROWS_TOKEN BREAK_TOKEN IMPORT_TOKEN
%token ELSE_TOKEN INSTANCEOF_TOKEN RETURN_TOKEN
%token VOID_TOKEN CATCH_TOKEN INTERFACE_TOKEN
%token CASE_TOKEN EXTENDS_TOKEN FINALLY_TOKEN
%token SUPER_TOKEN WHILE_TOKEN CLASS_TOKEN
%token SWITCH_TOKEN CONST_TOKEN TRY_TOKEN
%token FOR_TOKEN NEW_TOKEN CONTINUE_TOKEN
%token GOTO_TOKEN PACKAGE_TOKEN THIS_TOKEN
%token ASSERT_TOKEN
%token BYTE_TOKEN SHORT_TOKEN INT_TOKEN LONG_TOKEN
%token CHAR_TOKEN
%token FLOAT_TOKEN DOUBLE_TOKEN
%token ID_TOKEN
%token CONDITIONAL_TOKEN COLON_TOKEN TILDE_TOKEN NOT_TOKEN
%token ASSIGN_ANY_TOKEN ASSIGNS_TOKEN
%token OPEN_PAREN_TOKEN CLOSE_PAREN_TOKEN OPEN_BRACE_TOKEN CLOSE_BRACE_TOKEN OPEN_BRACKET_TOKEN CLOSE_BRACKET_TOKEN SEMICOLON_TOKEN COMMA_TOKEN PERIOD_TOKEN
%token INTEGER_LITERAL_TOKEN FLOATING_POINT_LITERAL_TOKEN BOOLEAN_LITERAL_TOKEN STRING_LITERAL_TOKEN
%token CHARACTER_LITERAL_TOKEN NULL_TOKEN
%right SHL_ASSIGN_TOKEN SAR_ASSIGN_TOKEN AND_ASSIGN_TOKEN OR_ASSIGN_TOKEN XOR_ASSIGN_TOKEN
ASSIGNS_TOKEN ADD_ASSIGN_TOKEN SUB_ASSIGN_TOKEN MUL_ASSIGN_TOKEN DIV_ASSIGN_TOKEN MOD_ASSIGN_TOKEN
%left LOGICAL_OR_TOKEN
%left LOGICAL_AND_TOKEN
%left OR_TOKEN
%left XOR_TOKEN
%left AND_TOKEN
%left RELATIVEQEUAL_TOKEN NE_OP_TOKEN
%left GREATER_TOKEN LESS_TOKEN GE_TOKEN LE_TOKEN
%left SHL_TOKEN SAR_TOKEN SHR_TOKEN
%left PLUS_TOKEN MINUS_TOKEN
%left MUL_TOKEN DIV_TOKEN MOD_TOKEN
%nonassoc NOT_TOKEN TILDE_TOKEN
%start goal
%%
goal
: compilation_unit
;
literal
: INTEGER_LITERAL_TOKEN
| FLOATING_POINT_LITERAL_TOKEN
| BOOLEAN_LITERAL_TOKEN
| CHARACTER_LITERAL_TOKEN
| STRING_LITERAL_TOKEN
| NULL_TOKEN
;
type
: primitive_type
| reference_type
;
primitive_type
: INT_TOKEN
| LONG_TOKEN
| FLOAT_TOKEN
| DOUBLE_TOKEN
| BOOLEAN_TOKEN
| BYTE_TOKEN
| CHAR_TOKEN
| SHORT_TOKEN
;
reference_type
: class_or_interface_type
| array_type
;
class_or_interface_type
: name
;
class_type
: class_or_interface_type
;
interface_type
: class_or_interface_type
;
array_type
: primitive_type dims
| name dims
;
name
: simple_name
| qualified_name
;
simple_name
: identifier
;
qualified_name
: name PERIOD_TOKEN identifier
;
identifier
: ID_TOKEN
;
compilation_unit
:
| package_declaration
| import_declarations
| type_declarations
| package_declaration import_declarations
| package_declaration type_declarations
| import_declarations type_declarations
| package_declaration import_declarations type_declarations
;
import_declarations
: import_declaration
| import_declarations import_declaration
;
type_declarations
: type_declaration
| type_declarations type_declaration
;
package_declaration
: PACKAGE_TOKEN name SEMICOLON_TOKEN
;
import_declaration
: single_type_import_declaration
| type_import_on_demand_declaration
;
single_type_import_declaration
: IMPORT_TOKEN name SEMICOLON_TOKEN
;
type_import_on_demand_declaration
: IMPORT_TOKEN name PERIOD_TOKEN MUL_TOKEN SEMICOLON_TOKEN
;
type_declaration
: class_declaration
| interface_declaration
| empty_statement
;
modifiers
: modifier
| modifiers modifier
;
modifier
: STATIC_TOKEN
| PUBLIC_TOKEN
| PROTECTED_TOKEN
| PRIVATE_TOKEN
| ABSTRACT_TOKEN
| FINAL_TOKEN
| NATIVE_TOKEN
| SYNCHRONIZED_TOKEN
| TRANSIENT_TOKEN
| VOLATILE_TOKEN
;
class_declaration
: modifiers CLASS_TOKEN identifier super interfaces class_body
| CLASS_TOKEN identifier super interfaces class_body
;
super
:
| EXTENDS_TOKEN class_type
;
interfaces
:
| IMPLEMENTS_TOKEN interface_type_list
;
interface_type_list
: interface_type
| interface_type_list COMMA_TOKEN interface_type
;
class_body
: OPEN_BRACE_TOKEN CLOSE_BRACE_TOKEN
| OPEN_BRACE_TOKEN class_body_declarations CLOSE_BRACE_TOKEN
;
class_body_declarations
: class_body_declaration
| class_body_declarations class_body_declaration
;
class_body_declaration
: class_member_declaration
| static_initializer
| constructor_declaration
| block
;
class_member_declaration
: field_declaration
| method_declaration
| class_declaration
| interface_declaration
| empty_statement
;
field_declaration
: type variable_declarators SEMICOLON_TOKEN
| modifiers type variable_declarators SEMICOLON_TOKEN
;
variable_declarators
: variable_declarator
| variable_declarators COMMA_TOKEN variable_declarator
;
variable_declarator
: variable_declarator_id
| variable_declarator_id ASSIGNS_TOKEN variable_initializer
;
variable_declarator_id
: identifier
| variable_declarator_id OPEN_BRACKET_TOKEN CLOSE_BRACKET_TOKEN
;
variable_initializer
: expression
| array_initializer
;
method_declaration
: method_header method_body
;
method_header
: type method_declarator throws
| VOID_TOKEN method_declarator throws
| modifiers type method_declarator throws
| modifiers VOID_TOKEN method_declarator throws
;
method_declarator
: identifier OPEN_PAREN_TOKEN CLOSE_PAREN_TOKEN
| identifier OPEN_PAREN_TOKEN formal_parameter_list CLOSE_PAREN_TOKEN
| method_declarator OPEN_BRACKET_TOKEN CLOSE_BRACKET_TOKEN
;
formal_parameter_list
: formal_parameter
| formal_parameter_list COMMA_TOKEN formal_parameter
;
formal_parameter
: type variable_declarator_id
| modifiers type variable_declarator_id
;
throws
:
| THROWS_TOKEN class_type_list
;
class_type_list
: class_type
| class_type_list COMMA_TOKEN class_type
;
method_body
: block
| SEMICOLON_TOKEN
;
static_initializer
: static block
;
static
: modifiers
;
constructor_declaration
: constructor_header constructor_body
;
constructor_header
: constructor_declarator throws
| modifiers constructor_declarator throws
;
constructor_declarator
: simple_name OPEN_PAREN_TOKEN CLOSE_PAREN_TOKEN
| simple_name OPEN_PAREN_TOKEN formal_parameter_list CLOSE_PAREN_TOKEN
;
constructor_body
: block_begin constructor_block_end
| block_begin explicit_constructor_invocation constructor_block_end
| block_begin block_statements constructor_block_end
| block_begin explicit_constructor_invocation block_statements constructor_block_end
;
constructor_block_end
: block_end
;
block_begin
: OPEN_BRACE_TOKEN
;
block_end
: CLOSE_BRACE_TOKEN
;
explicit_constructor_invocation
: this_or_super OPEN_PAREN_TOKEN CLOSE_PAREN_TOKEN SEMICOLON_TOKEN
| this_or_super OPEN_PAREN_TOKEN argument_list CLOSE_PAREN_TOKEN SEMICOLON_TOKEN
| name PERIOD_TOKEN SUPER_TOKEN OPEN_PAREN_TOKEN argument_list CLOSE_PAREN_TOKEN SEMICOLON_TOKEN
| name PERIOD_TOKEN SUPER_TOKEN OPEN_PAREN_TOKEN CLOSE_PAREN_TOKEN SEMICOLON_TOKEN
;
this_or_super
: THIS_TOKEN
| SUPER_TOKEN
;
interface_declaration
: INTERFACE_TOKEN identifier interface_body
| modifiers INTERFACE_TOKEN identifier interface_body
| INTERFACE_TOKEN identifier extends_interfaces interface_body
| modifiers INTERFACE_TOKEN identifier extends_interfaces interface_body
;
extends_interfaces
: EXTENDS_TOKEN interface_type
| extends_interfaces COMMA_TOKEN interface_type
;
interface_body
: OPEN_BRACE_TOKEN CLOSE_BRACE_TOKEN
| OPEN_BRACE_TOKEN interface_member_declarations CLOSE_BRACE_TOKEN
;
interface_member_declarations
: interface_member_declaration
| interface_member_declarations interface_member_declaration
;
interface_member_declaration
: constant_declaration
| abstract_method_declaration
| class_declaration
| interface_declaration
;
constant_declaration
: field_declaration
;
abstract_method_declaration
: method_header SEMICOLON_TOKEN
;
array_initializer
: OPEN_BRACE_TOKEN CLOSE_BRACE_TOKEN
| OPEN_BRACE_TOKEN COMMA_TOKEN CLOSE_BRACE_TOKEN
| OPEN_BRACE_TOKEN variable_initializers CLOSE_BRACE_TOKEN
| OPEN_BRACE_TOKEN variable_initializers COMMA_TOKEN CLOSE_BRACE_TOKEN
;
variable_initializers
: variable_initializer
| variable_initializers COMMA_TOKEN variable_initializer
;
block
: OPEN_BRACE_TOKEN CLOSE_BRACE_TOKEN
| OPEN_BRACE_TOKEN block_statements CLOSE_BRACE_TOKEN
;
block_statements
: block_statement
| block_statements block_statement
;
block_statement
: local_variable_declaration_statement
| statement
| class_declaration
;
local_variable_declaration_statement
: local_variable_declaration SEMICOLON_TOKEN
;
local_variable_declaration
: type variable_declarators
| modifiers type variable_declarators
;
statement
: statement_without_trailing_substatement
| labeled_statement
| if_then_statement
| if_then_else_statement
| while_statement
| for_statement
;
statement_nsi
: statement_without_trailing_substatement
| labeled_statement_nsi
| if_then_else_statement_nsi
| while_statement_nsi
| for_statement_nsi
;
statement_without_trailing_substatement
: block
| empty_statement
| expression_statement
| switch_statement
| do_statement
| break_statement
| continue_statement
| return_statement
| synchronized_statement
| throw_statement
| try_statement
| assert_statement
;
empty_statement
: SEMICOLON_TOKEN
;
label_decl
: identifier COLON_TOKEN
;
labeled_statement
: label_decl statement
;
labeled_statement_nsi
: label_decl statement_nsi
;
expression_statement
: statement_expression SEMICOLON_TOKEN
| SYNCHRONIZED_TOKEN OPEN_PAREN_TOKEN argument_list CLOSE_PAREN_TOKEN block
;
statement_expression
: assignment
| primary
| pre_increment_expression
| pre_decrement_expression
| post_increment_expression
| post_decrement_expression
| method_invocation
| class_instance_creation_expression
;
if_then_statement
: IF_TOKEN OPEN_PAREN_TOKEN expression CLOSE_PAREN_TOKEN statement
;
if_then_else_statement
: IF_TOKEN OPEN_PAREN_TOKEN expression CLOSE_PAREN_TOKEN statement_nsi ELSE_TOKEN statement
;
if_then_else_statement_nsi
: IF_TOKEN OPEN_PAREN_TOKEN expression CLOSE_PAREN_TOKEN statement_nsi ELSE_TOKEN statement_nsi
;
switch_statement
: switch_expression switch_block
;
switch_expression
: SWITCH_TOKEN OPEN_PAREN_TOKEN expression CLOSE_PAREN_TOKEN
;
switch_block
: OPEN_BRACE_TOKEN CLOSE_BRACE_TOKEN
| OPEN_BRACE_TOKEN switch_labels CLOSE_BRACE_TOKEN
| OPEN_BRACE_TOKEN switch_block_statement_groups CLOSE_BRACE_TOKEN
| OPEN_BRACE_TOKEN switch_block_statement_groups switch_labels CLOSE_BRACE_TOKEN
;
switch_block_statement_groups
: switch_block_statement_group
| switch_block_statement_groups switch_block_statement_group
;
switch_block_statement_group
: switch_labels block_statements
;
switch_labels
: switch_label
| switch_labels switch_label
;
switch_label
: CASE_TOKEN constant_expression COLON_TOKEN
| DEFAULT_TOKEN COLON_TOKEN
;
while_expression
: WHILE_TOKEN OPEN_PAREN_TOKEN expression CLOSE_PAREN_TOKEN
;
while_statement
: while_expression statement
;
while_statement_nsi
: while_expression statement_nsi
;
do_statement_begin
: DO_TOKEN
;
do_statement
: do_statement_begin statement WHILE_TOKEN OPEN_PAREN_TOKEN expression CLOSE_PAREN_TOKEN SEMICOLON_TOKEN
;
for_statement
: for_begin SEMICOLON_TOKEN expression SEMICOLON_TOKEN for_update CLOSE_PAREN_TOKEN statement
| for_begin SEMICOLON_TOKEN SEMICOLON_TOKEN for_update CLOSE_PAREN_TOKEN statement
;
for_statement_nsi
: for_begin SEMICOLON_TOKEN expression SEMICOLON_TOKEN for_update CLOSE_PAREN_TOKEN statement_nsi
| for_begin SEMICOLON_TOKEN SEMICOLON_TOKEN for_update CLOSE_PAREN_TOKEN statement_nsi
;
for_header
: FOR_TOKEN OPEN_PAREN_TOKEN
;
for_begin
: for_header for_init
;
for_init
:
| statement_expression_list
| local_variable_declaration
;
for_update
:
| statement_expression_list
;
statement_expression_list
: statement_expression
| statement_expression_list COMMA_TOKEN statement_expression
;
break_statement
: BREAK_TOKEN SEMICOLON_TOKEN
| BREAK_TOKEN identifier SEMICOLON_TOKEN
;
continue_statement
: CONTINUE_TOKEN SEMICOLON_TOKEN
| CONTINUE_TOKEN identifier SEMICOLON_TOKEN
;
return_statement
: RETURN_TOKEN SEMICOLON_TOKEN
| RETURN_TOKEN expression SEMICOLON_TOKEN
;
throw_statement
: THROW_TOKEN expression SEMICOLON_TOKEN
;
assert_statement
: ASSERT_TOKEN expression COLON_TOKEN expression SEMICOLON_TOKEN
| ASSERT_TOKEN expression SEMICOLON_TOKEN
| ASSERT_TOKEN error
| ASSERT_TOKEN expression error
;
synchronized_statement
: synchronized OPEN_PAREN_TOKEN expression CLOSE_PAREN_TOKEN block
| synchronized OPEN_PAREN_TOKEN expression CLOSE_PAREN_TOKEN error
;
synchronized
: MODIFIER_TOKEN
;
try_statement
: TRY_TOKEN block catches
| TRY_TOKEN block finally
| TRY_TOKEN block catches finally
;
catches
: catch_clause
| catches catch_clause
;
catch_clause
: CATCH_TOKEN OPEN_PAREN_TOKEN formal_parameter CLOSE_PAREN_TOKEN block
;
finally
: FINALLY_TOKEN block
;
primary
: primary_no_new_array
| array_creation_expression
;
primary_no_new_array
: literal
| THIS_TOKEN
| OPEN_PAREN_TOKEN expression CLOSE_PAREN_TOKEN
| class_instance_creation_expression
| field_access
| method_invocation
| array_access
| type_literals
| name PERIOD_TOKEN THIS_TOKEN
;
type_literals
: name PERIOD_TOKEN CLASS_TOKEN
| array_type PERIOD_TOKEN CLASS_TOKEN
| primitive_type PERIOD_TOKEN CLASS_TOKEN
| VOID_TOKEN PERIOD_TOKEN CLASS_TOKEN
;
class_instance_creation_expression
: NEW_TOKEN class_type OPEN_PAREN_TOKEN argument_list CLOSE_PAREN_TOKEN
| NEW_TOKEN class_type OPEN_PAREN_TOKEN CLOSE_PAREN_TOKEN
| anonymous_class_creation
| something_dot_new identifier OPEN_PAREN_TOKEN CLOSE_PAREN_TOKEN
| something_dot_new identifier OPEN_PAREN_TOKEN CLOSE_PAREN_TOKEN class_body
| something_dot_new identifier OPEN_PAREN_TOKEN argument_list CLOSE_PAREN_TOKEN
| something_dot_new identifier OPEN_PAREN_TOKEN argument_list CLOSE_PAREN_TOKEN class_body
;
anonymous_class_creation
: NEW_TOKEN class_type OPEN_PAREN_TOKEN CLOSE_PAREN_TOKEN class_body
| NEW_TOKEN class_type OPEN_PAREN_TOKEN argument_list CLOSE_PAREN_TOKEN class_body
;
something_dot_new
: name PERIOD_TOKEN NEW_TOKEN
| primary PERIOD_TOKEN NEW_TOKEN
;
argument_list
: expression
| argument_list COMMA_TOKEN expression
| argument_list COMMA_TOKEN error
;
array_creation_expression
: NEW_TOKEN primitive_type dim_exprs
| NEW_TOKEN class_or_interface_type dim_exprs
| NEW_TOKEN primitive_type dim_exprs dims
| NEW_TOKEN class_or_interface_type dim_exprs dims
| NEW_TOKEN class_or_interface_type dims array_initializer
| NEW_TOKEN primitive_type dims array_initializer
;
dim_exprs
: dim_expr
| dim_exprs dim_expr
;
dim_expr
: OPEN_BRACKET_TOKEN expression CLOSE_BRACKET_TOKEN
;
dims
: OPEN_BRACKET_TOKEN CLOSE_BRACKET_TOKEN
| dims OPEN_BRACKET_TOKEN CLOSE_BRACKET_TOKEN
;
field_access
: primary PERIOD_TOKEN identifier
| SUPER_TOKEN PERIOD_TOKEN identifier
;
method_invocation
: name OPEN_PAREN_TOKEN CLOSE_PAREN_TOKEN
| name OPEN_PAREN_TOKEN argument_list CLOSE_PAREN_TOKEN
| primary PERIOD_TOKEN identifier OPEN_PAREN_TOKEN CLOSE_PAREN_TOKEN
| primary PERIOD_TOKEN identifier OPEN_PAREN_TOKEN argument_list CLOSE_PAREN_TOKEN
| SUPER_TOKEN PERIOD_TOKEN identifier OPEN_PAREN_TOKEN CLOSE_PAREN_TOKEN
| SUPER_TOKEN PERIOD_TOKEN identifier OPEN_PAREN_TOKEN argument_list CLOSE_PAREN_TOKEN
;
array_access
: name OPEN_BRACKET_TOKEN expression CLOSE_BRACKET_TOKEN
| primary_no_new_array OPEN_BRACKET_TOKEN expression CLOSE_BRACKET_TOKEN
;
postfix_expression
: primary
| name
| post_increment_expression
| post_decrement_expression
;
post_increment_expression
: postfix_expression INC_TOKEN
;
post_decrement_expression
: postfix_expression DEC_TOKEN
;
trap_overflow_corner_case
: pre_increment_expression
| pre_decrement_expression
| PLUS_TOKEN unary_expression
| unary_expression_not_plus_minus
;
unary_expression
: trap_overflow_corner_case
| MINUS_TOKEN trap_overflow_corner_case
| MINUS_TOKEN error
;
pre_increment_expression
: INC_TOKEN unary_expression
;
pre_decrement_expression
: DEC_TOKEN unary_expression
;
unary_expression_not_plus_minus
: postfix_expression
| TILDE_TOKEN unary_expression
| NOT_TOKEN unary_expression
| cast_expression
;
cast_expression
: OPEN_PAREN_TOKEN primitive_type dims CLOSE_PAREN_TOKEN unary_expression
| OPEN_PAREN_TOKEN primitive_type CLOSE_PAREN_TOKEN unary_expression
| OPEN_PAREN_TOKEN expression CLOSE_PAREN_TOKEN unary_expression_not_plus_minus
| OPEN_PAREN_TOKEN name dims CLOSE_PAREN_TOKEN unary_expression_not_plus_minus
;
multiplicative_expression
: unary_expression
| multiplicative_expression MUL_TOKEN unary_expression
| multiplicative_expression DIV_TOKEN unary_expression
| multiplicative_expression MOD_TOKEN unary_expression
;
additive_expression
: multiplicative_expression
| additive_expression PLUS_TOKEN multiplicative_expression
| additive_expression MINUS_TOKEN multiplicative_expression
;
shift_expression
: additive_expression
| shift_expression SHL_TOKEN additive_expression
| shift_expression SHR_TOKEN additive_expression
| shift_expression SAR_TOKEN additive_expression
;
relational_expression
: shift_expression
| relational_expression LESS_TOKEN shift_expression
| relational_expression GREATER_TOKEN shift_expression
| relational_expression LE_TOKEN shift_expression
| relational_expression GE_TOKEN shift_expression
| relational_expression INSTANCEOF_TOKEN reference_type
;
equality_expression
: relational_expression
| equality_expression EQ_TOKEN relational_expression
| equality_expression NE_OP_TOKEN relational_expression
;
and_expression
: equality_expression
| and_expression AND_TOKEN equality_expression
;
exclusive_or_expression
: and_expression
| exclusive_or_expression XOR_TOKEN and_expression
;
inclusive_or_expression
: exclusive_or_expression
| inclusive_or_expression OR_TOKEN exclusive_or_expression
;
conditional_and_expression
: inclusive_or_expression
| conditional_and_expression LOGICAL_AND_TOKEN inclusive_or_expression
;
conditional_or_expression
: conditional_and_expression
| conditional_or_expression LOGICAL_OR_TOKEN conditional_and_expression
;
conditional_expression
: conditional_or_expression
| conditional_or_expression CONDITIONAL_TOKEN expression COLON_TOKEN conditional_expression
;
assignment_expression
: conditional_expression
| assignment
;
assignment
: left_hand_side assignment_operator assignment_expression
;
left_hand_side
: name
| field_access
| array_access
;
assignment_operator
: ASSIGNS_TOKEN
| ADD_ASSIGN_TOKEN
| SUB_ASSIGN_TOKEN
| MUL_ASSIGN_TOKEN
| DIV_ASSIGN_TOKEN
| MOD_ASSIGN_TOKEN
| SHL_ASSIGN_TOKEN
| SHR_ASSIGN_TOKEN
| SAR_ASSIGN_TOKEN
| AND_ASSIGN_TOKEN
| XOR_ASSIGN_TOKEN
| OR_ASSIGN_TOKEN
;
expression
: assignment_expression
;
constant_expression
: expression
;
%%
void print_prototype(void)
{
}
void generate_default_constructor(char *name)
{
}
int yyerror(char *mesg)
{
printf("line %d: %s before %s\n", yylineno, mesg, yytext);
exit(0);
}
#!/usr/bin/env python
"""
Runs the java parser on a small java source file
"""
import sys
import javaparser
#src = "tst.java"
argv = sys.argv
argc = len(argv)
if '-v' in argv:
argv.remove('-v')
argc -= 1
verbose = 1
else:
verbose = 0
if argc == 2:
src = argv[1]
else:
src = None
src = "I2PClient.java"
p = myjava.Parser(verbose=verbose)
print "delmebld.py: running parser on HelloWorldApp.java"
res = p.run(file=src)
print "back from engine, parse tree dump follows:"
if 0:
print "------------------------------------------"
res.dump()
print "------------------------------------------"
print "end of parse tree dump"
//@+leo-ver=4
//@+node:@file examples/java/table.h
//@@language c
#include "tokens.h"
struct KeywordToken
{
char * Keyword;
int TokenCode;
};
struct KeywordToken KeywordTable [] =
{
{"abstract", ABSTRACT_TOKEN },
{"boolean", BOOLEAN_TOKEN },
{"break", BREAK_TOKEN },
{"byte", BYTE_TOKEN },
{"case", CASE_TOKEN },
{"catch", CATCH_TOKEN },
{"char", CHAR_TOKEN },
{"class", CLASS_TOKEN },
{"const", CONST_TOKEN },
{"continue", CONTINUE_TOKEN },
{"default", DEFAULT_TOKEN },
{"do", DO_TOKEN },
{"double", DOUBLE_TOKEN },
{"else", ELSE_TOKEN },
{"extends", EXTENDS_TOKEN },
{"final", FINAL_TOKEN },
{"finally", FINALLY_TOKEN },
{"float", FLOAT_TOKEN },
{"for", FOR_TOKEN },
{"goto", GOTO_TOKEN },
{"if", IF_TOKEN },
{"implements", IMPLEMENTS_TOKEN },
{"import", IMPORT_TOKEN },
{"instanceof", INSTANCEOF_TOKEN },
{"int", INT_TOKEN },
{"interface", INTERFACE_TOKEN },
{"long", LONG_TOKEN },
{"native", NATIVE_TOKEN },
{"new", NEW_TOKEN },
{"null", NULL_TOKEN },
{"package", PACKAGE_TOKEN },
{"private", PRIVATE_TOKEN },
{"protected", PROTECTED_TOKEN },
{"public", PUBLIC_TOKEN },
{"return", RETURN_TOKEN },
{"short", SHORT_TOKEN },
{"static", STATIC_TOKEN },
{"strictfp", STRICTFP_TOKEN },
{"super", SUPER_TOKEN },
{"switch", SWITCH_TOKEN },
{"synchronized", SYNCHRONIZED_TOKEN },
{"this", THIS_TOKEN },
{"throw", THROW_TOKEN },
{"throws", THROWS_TOKEN },
{"transient", TRANSIENT_TOKEN },
{"try", TRY_TOKEN },
{"void", VOID_TOKEN },
{"volatile", VOLATILE_TOKEN },
{"while", WHILE_TOKEN },
{"", ID_TOKEN }
};
//@-node:@file examples/java/table.h
//@-leo
The 'template.py' file in this directory is a working
but very minimal parser.
You can execute the file as is - the first time you
do so, it will automatically build and load a parser
engine library.
This parser does nothing except read a bunch of words
from its input stream, where a word is an alphanumeric
string.
Feel free to copy this file somewhere, and tinker away
to your heart's content. This may be for you the fastest
way to get a comfortable 'feel' of how PyBison does things.
#!/usr/bin/env python
"""
Template of a pyBison parser file
This is actually a working parser, but so
minimal as to be totally useless. Refer to the
'.on_someTarget()' rule handler in the class
'Parser' below for more info.
You can do much worse than to copy this file
somewhere, and tinker away to your heart's content.
"""
import sys, traceback
from bison import BisonParser, BisonNode
# -------------------------------------------
# Our own custom base class for all objects
# which get inserted into the parse tree
# -------------------------------------------
class ParseNode(BisonNode):
"""
This is the base class from which all your
parse nodes are derived.
Add methods to this class as you need them
"""
def __init__(self, **kw):
BisonNode.__init__(self, **kw)
def __str__(self):
"""Customise as needed"""
return "<%s instance at 0x%x>" % (self.__class__.__name__, hash(self))
def __repr__(self):
"""Customise as needed"""
return str(self)
def dump(self, indent=0):
"""
Dump out human-readable, indented parse tree
Customise as needed - here, or in the node-specific subclasses
"""
BisonNode.dump(self, indent) # alter as needed
# ----------------------------------------------------
# Now, we need to define a node class for each parse
# target. (This is completely optional, but it can
# turn out to be a PITA if you don't).
# ----------------------------------------------------
class someTarget_Node(ParseNode):
"""
Holds a "someTarget" parse target and its components.
"""
def __init__(self, **kw):
ParseNode.__init__(self, **kw)
def dump(self, indent=0):
ParseNode.dump(self, indent)
# ----------------------------------------------------
# Now, at last, we get to the main Parser class itself
# ----------------------------------------------------
class Parser(BisonParser):
"""
Describe your parser here
"""
# basename of binary parser engine dynamic lib
bisonEngineLibName = "template-engine"
# ----------------------------------------------------------------
# lexer tokens - these must match those in your lex script (below)
# ----------------------------------------------------------------
tokens = [ 'WORD' ]
# ------------------------------
# precedences
# ------------------------------
precedences = (
#('left', ('aTarget1', 'aTarget2',..., 'aTargetn')),
#('right', ('another_target1', 'another_target2',..., 'another_targetn')),
)
# ---------------------------------------------------------------
# These methods are the python handlers for the bison targets.
# (which get called by the bison code each time the corresponding
# parse target is unambiguously reached)
#
# WARNING - don't touch the method docstrings unless you know what
# you are doing - they are in bison rule syntax, and are passed
# verbatim to bison to build the parser engine library.
# ---------------------------------------------------------------
# Declare the start target here (by name)
start = "someTarget"
def on_someTarget(self, target, option, names, values):
"""
someTarget
:
| someTarget WORD
"""
print "on_someTarget: %s %s" % (option, repr(values))
node = someTarget_Node(target=target,
option=option,
names=names,
values=values)
return node
# -----------------------------------------
# raw lex script, verbatim here
#
# the script used here in this template is one which
# breaks up the input stream into strings of
# alphanumeric 'words' and discards everything else
# -----------------------------------------
lexscript = r"""
%{
#include <stdio.h>
#include <string.h>
#include "Python.h"
#define YYSTYPE void *
#include "tokens.h"
int yylineno = 0;
int yywrap() { return(1); }
extern void *py_parser;
extern void (*py_input)(PyObject *parser, char *buf, int *result, int max_size);
#define returntoken(tok) yylval = PyString_FromString(strdup(yytext)); return (tok);
#define YY_INPUT(buf,result,max_size) { (*py_input)(py_parser, buf, &result, max_size); }
%}
%%
[a-zA-Z0-9\.]+ { returntoken(WORD); }
[ \t\n] { /* ignore spaces/tabs/newlines */ }
. { printf("unknown char %c ignored\n", yytext[0]); /* ignore bad chars */}
%%
//yywrap() { return(1); }
"""
# -----------------------------------------
# end raw lex script
# -----------------------------------------
# --------------------------------------------------
# global functions to add in unit-testing our parser
# (same as what gets generated by bison2py)
# --------------------------------------------------
def usage():
print "%s: PyBison template parser" % sys.argv[0]
print "Usage: %s [-k] [-v] [-d] [filename]" % sys.argv[0]
print " -k Keep temporary files used in building parse engine lib"
print " -v Enable verbose messages while parser is running"
print " -d Enable garrulous debug messages from parser engine"
print " filename path of a file to parse, defaults to stdin"
def main(*args):
"""
Unit-testing func
"""
keepfiles = 0
verbose = 0
debug = 0
filename = None
for s in ["-h", "-help", "--h", "--help", "-?"]:
if s in args:
usage()
sys.exit(0)
if len(args) > 0:
if "-k" in args:
keepfiles = 1
args.remove("-k")
if "-v" in args:
verbose = 1
args.remove("-v")
if "-d" in args:
debug = 1
args.remove("-d")
if len(args) > 0:
filename = args[0]
p = Parser(verbose=verbose, keepfiles=keepfiles)
if filename == None:
print "(Reading from standard input - please type stuff)"
tree = p.run(file=filename, debug=debug)
return tree
if __name__ == "__main__":
main(*(sys.argv[1:]))
#@+leo-ver=4
#@+node:@file setup.py
"""
Builds bison python module
"""
version = "0.1"
from distutils.core import setup
from distutils.extension import Extension
from Pyrex.Distutils import build_ext
import sys
if sys.platform == 'win32':
print "Sorry - no windows support at this time - pybison won't work for you"
#sys.exit(1)
libs = []
extra_link_args = []
bison2pyscript = 'utils/bison2py.py'
bisondynlibModule = "src/c/bisondynlib-win32.c"
elif sys.platform == 'linux2':
libs = ['dl']
extra_link_args = []
bison2pyscript = 'utils/bison2py'
bisondynlibModule = "src/c/bisondynlib-linux.c"
else:
print "Sorry, your platform is presently unsupported"
sys.exit(1)
setup(
name = "bison",
version = version,
description='Python bindings for bison/flex parser engine',
author='David McNab <david@freenet.org.nz>',
url='http://www.freenet.org.nz/python/pybison',
ext_modules=[
Extension("bison_", ["src/pyrex/bison_.pyx", bisondynlibModule],
libraries=libs,
extra_link_args=extra_link_args,
)
],
packages=[],
package_dir={'': 'src/python'},
py_modules=['bison'],
cmdclass = {'build_ext': build_ext},
scripts=[bison2pyscript],
)
#@-node:@file setup.py
#@-leo
//@+leo-ver=4
//@+node:@file src/c/bisondynlib-linux.c
//@@language c
/*
* Linux-specific dynamic library manipulation routines
*/
#include <stdio.h>
#include "bisondynlib.h"
#include <dlfcn.h>
void *bisondynlib_open(char *filename)
{
void *handle;
dlerror();
handle = dlopen(filename, (RTLD_NOW|RTLD_GLOBAL));
return handle;
}
int bisondynlib_close(void *handle)
{
return dlclose(handle);
}
char *bisondynlib_err()
{
return dlerror();
}
char *bisondynlib_lookup_hash(void *handle)
{
char **hash;
dlerror();
hash = dlsym(handle, "rules_hash");
/*
printf("bisondynlib_lookup_hash: hash=%s\n", *hash);
*/
return *hash;
}
PyObject *bisondynlib_run(void *handle, PyObject *parser, void *cb, void *in, int debug)
{
void (*pparser)(PyObject *, void *, void *, int);
//PyObject *result;
//printf("bisondynlib_run: looking up parser\n");
pparser = bisondynlib_lookup_parser(handle);
//printf("bisondynlib_run: calling parser, py_input=0x%lx\n", in);
(*pparser)(parser, cb, in, debug);
//printf("bisondynlib_run: back from parser\n");
//return result;
Py_INCREF(Py_None);
return Py_None;
}
/*
* function(void *) returns a pointer to a function(PyObject *, char *) returning PyObject*
*/
PyObject *(*bisondynlib_lookup_parser(void *handle))(PyObject *, void *, void *, int)
{
dlerror();
return dlsym(handle, "do_parse");
}
/*
* Runs the compiler commands which build the parser/lexer into a shared lib
*/
/*
int bisondynlib_build(char *libName, char *pyincdir)
{
char buf[1024];
sprintf(buf, "gcc -fPIC -shared -I%s tmp.bison.c tmp.lex.c -o %s", pyincdir, libName);
printf("Running linux build command: %s\n", buf);
system(buf);
return 0;
}
*/
//@-node:@file src/c/bisondynlib-linux.c
//@-leo
//@+leo-ver=4
//@+node:@file src/c/bisondynlib-win32.c
//@@language c
/*
* Linux-specific dynamic library manipulation routines
*/
#include <stdio.h>
#include "bisondynlib.h"
#include "windows.h"
//#include "dlluser.h"
void * bisondynlib_open(char *filename)
{
HINSTANCE hinstLib;
hinstLib = LoadLibrary(filename);
return (void *)hinstLib;
}
int bisondynlib_close(void *handle)
{
return FreeLibrary((HINSTANCE)handle);
}
char * bisondynlib_err()
{
return NULL;
}
char * bisondynlib_lookup_hash(void *handle)
{
char *hash;
hash = (char *)GetProcAddress((HINSTANCE)handle, "rules_hash");
printf("bisondynlib_lookup_hash: hash=%s\n", hash);
return hash;
}
PyObject * bisondynlib_run(void *handle, PyObject *parser, char *filename, void *cb)
{
PyObject *(*pparser)(PyObject *, char *, void *);
//printf("bisondynlib_run: looking up parser\n");
pparser = bisondynlib_lookup_parser(handle);
//printf("bisondynlib_run: calling parser\n");
(*pparser)(parser, filename, cb);
//printf("bisondynlib_run: back from parser\n");
//return result;
Py_INCREF(Py_None);
return Py_None;
}
/*
* function(void *) returns a pointer to a function(PyObject *, char *) returning PyObject*
*/
PyObject *(*bisondynlib_lookup_parser(void *handle))(PyObject *, char *, void *)
{
//void *pparser;
PyObject *(*pparser)(PyObject *, char *, void *);
pparser = (PyObject *(*)(PyObject *, char *, void *))GetProcAddress((HINSTANCE)handle, "do_parse");
return pparser;
}
/*
* Runs the compiler commands which build the parser/lexer into a shared lib
*/
/*
int bisondynlib_build(char *libName, char *pyincdir)
{
char buf[1024];
sprintf(buf, "gcc -fPIC -shared -I%s tmp.bison.c tmp.lex.c -o %s", pyincdir, libName);
printf("Running linux build command: %s\n", buf);
system(buf);
return 0;
}
*/
//@-node:@file src/c/bisondynlib-win32.c
//@-leo
//@+leo-ver=4
//@+node:@file src/c/bisondynlib.h
//@@language c
/*
* common interface to dynamic library routines
*/
#include <stdio.h>
#include "Python.h"
void *bisondynlib_open(char *filename);
int bisondynlib_close(void *handle);
char *bisondynlib_err(void);
PyObject *(*bisondynlib_lookup_parser(void *handle))(PyObject *, void *, void *, int);
char *bisondynlib_lookup_hash(void *handle);
PyObject *bisondynlib_run(void *handle, PyObject *parser, void *cb, void *in, int debug);
/*
int bisondynlib_build(char *libName, char *pyincdir);
*/
//@-node:@file src/c/bisondynlib.h
//@-leo
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("Hello, world\n");
}
This source diff could not be displayed because it is too large. You can view the blob instead.
extern DL_IMPORT(PyObject) *(py_callback(PyObject *,char (*),int ,int ,void (*),...));
extern DL_IMPORT(void) (py_input(PyObject *,char (*),int (*),int ));
extern DL_IMPORT(void) initbison_(void);
cdef extern object (py_callback(object ,char (*),int ,int ,void (*),...))
cdef extern void (py_input(object ,char (*),int (*),int ))
#@+leo-ver=4
#@+node:@file src/pyrex/bison_.pyx
"""
Pyrex-generated portion of pybison
"""
#@+others
#@+node:python
cdef extern from "Python.h":
object PyString_FromStringAndSize(char *, int)
object PyString_FromString(char *)
char *PyString_AsString(object o)
object PyInt_FromLong(long ival)
long PyInt_AsLong(object io)
object PyList_New(int len)
int PyList_SetItem(object list, int index, object item)
void Py_INCREF(object o)
object PyObject_GetAttrString(object o, char *attr_name)
object PyTuple_New(int len)
int PyTuple_SetItem(object p, int pos, object o)
object PyObject_Call(object callable_object, object args, object kw)
object PyObject_CallObject(object callable_object, object args)
int PyObject_SetAttrString(object o, char *attr_name, object v)
#@-node:python
#@+node:libdl
# use libdl for now - easy and simple - maybe switch to
# glib or libtool if a keen windows dev sends in a patch
#cdef extern from "dlfcn.h":
# void *dlopen(char *filename, int mode)
# int dlclose(void *handle)
# void *dlsym(void *handle, char *name)
# char *dlerror()
#
# ctypedef enum DL_MODES:
# RTLD_LAZY
# RTLD_NOW
# RTLD_BINDING_MASK
# RTLD_NOLOAD
# RTLD_GLOBAL
#@-node:libdl
#@+node:stdio.h
cdef extern from "stdio.h":
int printf(char *format,...)
#@-node:stdio.h
#@+node:string.h
cdef extern from "string.h":
void *memcpy(void *dest, void *src, long n)
#@-node:string.h
#@+node:bisondynlib.h
cdef extern from "../c/bisondynlib.h":
void *bisondynlib_open(char *filename)
int bisondynlib_close(void *handle)
char *bisondynlib_err()
object (*bisondynlib_lookup_parser(void *handle))(object, char *)
char *bisondynlib_lookup_hash(void *handle)
object bisondynlib_run(void *handle, object parser, void *cb, void *pyin, int debug)
#int bisondynlib_build(char *libName, char *includedir)
#@-node:bisondynlib.h
#@+node:py_callback
# Callback function which is invoked by target handlers
# within the C yyparse() function.
cdef public object py_callback(object parser, char *target, int option, int nargs, void *args,...):
cdef int *pargs
pargs = <int *>(&args)
cdef void *objptr
cdef object obj
cdef int i
cdef object valobj
cdef void *val
cdef char *tokval
try:
names = PyList_New(nargs)
values = PyList_New(nargs)
for i in range(nargs):
termname = <char *>(pargs[i*2])
val = <void *>(pargs[i*2+1])
valobj = <object>val
Py_INCREF(termname)
Py_INCREF(valobj)
PyList_SetItem(names, i, termname)
PyList_SetItem(values, i, valobj)
if parser.verbose:
print "py_callback: calling handler for %s" % PyString_FromString(target)
res = parser._handle(target, option, names, values)
return res
except:
traceback.print_exc()
return None
#@-node:py_callback
#@+node:py_input
# callback routine for reading input
cdef public void py_input(object parser, char *buf, int *result, int max_size):
cdef char *buf1
cdef int buflen
#print "py_input: want to read up to %s bytes" % max_size
raw = parser.read(max_size)
buflen = PyInt_AsLong(len(raw))
result[0] = buflen
memcpy(buf, PyString_AsString(raw), buflen)
#print "py_input: got %s bytes" % buflen
#@-node:py_input
#@+node:Python imports
import sys, os, sha, re, imp, traceback
import distutils.sysconfig
import distutils.ccompiler
#@-node:Python imports
#@+node:Python Globals
reSpaces = re.compile("\\s+")
#unquoted = r"""^|[^'"]%s[^'"]?"""
unquoted = "[^'\"]%s[^'\"]?"
#@-node:Python Globals
#@+node:cdef class ParserEngine
cdef class ParserEngine:
"""
Wraps the interface to the binary bison/lex-generated
parser engine dynamic library.
You shouldn't need to deal with this at all.
Takes care of:
- building the library (if the parser rules have changed)
- loading the library and extracting the parser entry point
- calling the entry point
- closing the library
Makes direct calls to the platform-dependent routines in
bisondynlib-[linux|windows].c
"""
#@ @+others
#@+node:C attribs
cdef object parser
cdef object parserHash # hash of current python parser object
cdef object libFilename_py
cdef void *libHandle
# rules hash str embedded in bison parser lib
cdef char *libHash
#@-node:C attribs
#@+node:__init__
def __init__(self, parser, **kw):
"""
Creates a ParserEngine wrapper, and builds/loads the library
Arguments:
- parser - an instance of a subclass of Parser
In the course of initialisation, we check the library
against the parser object's rules. If the lib doesn't
exist, or can't be loaded, or doesn't match, we build
a new library.
Either way, we end up with a binary parser engine which
matches the current rules in the parser object
"""
self.parser = parser
self.libFilename_py = parser.bisonEngineLibName + imp.get_suffixes()[0][0]
self.parserHash = hashParserObject(self.parser)
self.openCurrentLib()
#@-node:__init__
#@+node:openCurrentLib
def openCurrentLib(self):
"""
Tests if library exists and is current.
If not, builds a fresh one
Opens the library and imports the parser entry point
"""
parser = self.parser
verbose = parser.verbose
if not os.path.isfile(self.libFilename_py):
self.buildLib()
self.openLib()
# hash our parser spec, compare to hash val stored in lib
libHash = PyString_FromString(self.libHash)
if self.parserHash != libHash:
if verbose:
print "Hash discrepancy, need to rebuild bison lib"
print " current parser class: %s" % self.parserHash
print " bison library: %s" % libHash
self.closeLib()
self.buildLib()
self.openLib()
else:
if verbose:
print "Hashes match, no need to rebuild bison engine lib"
#@-node:openCurrentLib
#@+node:openLib
def openLib(self):
"""
Loads the parser engine's dynamic library,
and extracts the following symbols:
- void *do_parse() (runs parser)
- char *parserHash (contains hash of python parser rules)
Returns lib handle, plus pointer to do_parse() function, as long ints
(which later need to be cast to pointers)
Important note -this is totally linux-specific.
If you want windows support, you'll have to modify these funcs to
use glib instead (or create windows equivalents), in which case I'd
greatly appreciate you sending me a patch.
"""
cdef char *libFilename
cdef char *err
cdef void *handle
# convert python filename string to c string
libFilename = PyString_AsString(self.libFilename_py)
parser = self.parser
if parser.verbose:
print "Opening library %s" % self.libFilename_py
handle = bisondynlib_open(libFilename)
self.libHandle = handle
err = bisondynlib_err()
if err:
printf("ParserEngine.openLib: error '%s'\n", err)
return
# extract symbols
self.libHash = bisondynlib_lookup_hash(handle)
if parser.verbose:
print "Successfully loaded library"
#@-node:openLib
#@+node:buildLib
def buildLib(self):
"""
Creates the parser engine lib
This consists of:
1. Ripping the tokens list, precedences, start target, handler docstrings
and lex script from this Parser instance's attribs and methods
2. Creating bison and lex files
3. Compiling bison/lex files to C
4. Compiling the C files, and link into a dynamic lib
"""
cdef char *incdir
# -------------------------------------------------
# rip the pertinent grammar specs from parser class
parser = self.parser
# get target handler methods, in the order of appearance in the source file
attribs = dir(parser)
gHandlers = []
for a in attribs:
if a.startswith("on_"):
method = getattr(parser, a)
gHandlers.append(method)
gHandlers.sort(cmpLines)
# get start symbol, tokens, precedences, lex script
gStart = parser.start
gTokens = parser.tokens
gPrecedences = parser.precedences
gLex = parser.lexscript
# ------------------------------------------------
# now, can generate the grammar file
try:
os.unlink(parser.bisonFile)
except:
pass
f = open(parser.bisonFile, "w")
write = f.write
writelines = f.writelines
# grammar file prologue
write("\n".join([
"%{",
'',
"#include <stdio.h>",
'#include "Python.h"',
"extern FILE *yyin;",
"extern int yylineno;"
"extern char *yytext;",
"#define YYSTYPE void*",
#'extern void *py_callback(void *, char *, int, void*, ...);',
'void *(*py_callback)(void *, char *, int, int, void *, ...);',
'void (*py_input)(void *, char *, int *, int);',
'void *py_parser;',
'char *rules_hash = "%s";' % self.parserHash,
'',
"%}",
'',
]))
# write out tokens and start target dec
write("%%token %s\n\n" % " ".join(gTokens))
write("%%start %s\n\n" % gStart)
# write out precedences
for p in gPrecedences:
write("%%%s %s\n" % (p[0], " ".join(p[1])))
write("\n\n%%\n\n")
# carve up docstrings
rules = []
for h in gHandlers:
doc = h.__doc__.strip()
# added by Eugene Oden
#target, options = doc.split(":")
doc = re.sub(unquoted % ";", "", doc)
#print "---------------------"
s = re.split(unquoted % ":", doc)
#print "s=%s" % s
target, options = s
target = target.strip()
options = options.strip()
tmp = []
#print "options = %s" % repr(options)
opts = options.split("|")
#print "opts = %s" % repr(opts)
r = unquoted % r"\|"
#print "r = <%s>" % r
opts1 = re.split(r, " " + options)
#print "opts1 = %s" % repr(opts1)
for o in opts1:
o = o.strip()
tmp.append(reSpaces.split(o))
options = tmp
rules.append((target, options))
# and render rules to grammar file
for rule in rules:
try:
write("%s\n : " % rule[0])
options = []
idx = 0
for option in rule[1]:
nterms = len(option)
if nterms == 1 and option[0] == '':
nterms = 0
option = []
action = '\n {\n'
if 'error' in option:
action = action + " yyerrok;\n"
action = action + ' $$ = (*py_callback)(\n py_parser, "%s", %s, %%s' % \
(rule[0], idx) # note we're deferring the substitution of 'nterms' (last arg)
args = []
if nterms == 0:
args.append('NULL')
i = -1
else:
for i in range(nterms):
if option[i] == '%prec':
i = i - 1
break # hack for rules using '%prec'
args.append('"%s", $%d' % (option[i], i+1))
# now, we have the correct terms count
action = action % (i + 1)
# assemble the full rule + action, ad to list
action = action + ",\n "
action = action + ",\n ".join(args) + "\n );\n"
if 'error' in option:
action = action + " PyObject_SetAttrString(py_parser, \"lasterror\", Py_None);\n"
action = action + " Py_INCREF(Py_None);\n"
action = action + " yyclearin;\n"
action = action + " if (PyObject_HasAttrString($$, \"_pyBisonError\"))\n"
action = action + " {\n"
action = action + " yyerror(PyString_AsString(PyObject_GetAttrString(py_parser, \"lasterror\")));\n"
action = action + " Py_INCREF(Py_None);\n"
action = action + " YYERROR;\n"
action = action + " }\n"
action = action + " }\n"
options.append(" ".join(option) + action)
idx = idx + 1
write(" | ".join(options) + " ;\n\n")
except:
traceback.print_exc()
write("\n\n%%\n\n")
# now generate C code
epilogue = "\n".join([
'void do_parse(void *parser1,',
' void *(*cb)(void *, char *, int, int, void *, ...),',
' void (*in)(void *, char*, int *, int),',
' int debug',
' )',
'{',
' //printf("Not calling yyparse\\n");',
' //return;',
' py_callback = cb;',
' py_input = in;',
" py_parser = parser1;",
" yydebug = debug;",
" //yyin = stdin;",
' //printf("calling yyparse(), in=0x%lx\\n", py_input);',
" yyparse();",
' //printf("Back from parser\\n");',
"}",
"int yyerror(char *mesg)",
"{",
' //printf("yytext=0x%lx\\n", yytext);',
' PyObject *args = PyTuple_New(3);',
' int ret;',
'',
' PyTuple_SetItem(args, 0, PyInt_FromLong(yylineno+1));',
' PyTuple_SetItem(args, 1, PyString_FromString(mesg));',
' PyTuple_SetItem(args, 2, PyString_FromString(yytext));',
'',
' ret = PyObject_SetAttrString((PyObject *)py_parser, "lasterror", args);',
' //printf("PyObject_SetAttrString: %d\\n", ret);',
'',
' //printf("line %d: %s before %s\\n", yylineno+1, mesg, yytext);',
" //exit(0);",
"}",
]) + "\n"
write(epilogue)
# done with grammar file
f.close()
# -----------------------------------------------
# now generate the lex script
try:
os.unlink(parser.flexFile)
except:
pass
lexLines = gLex.split("\n")
tmp = []
for line in lexLines:
tmp.append(line.strip())
f = open(parser.flexFile, "w")
f.write("\n".join(tmp) + "\n")
f.close()
# create and set up a compiler object
ccompiler = distutils.ccompiler.new_compiler(verbose=parser.verbose)
ccompiler.set_include_dirs([distutils.sysconfig.get_python_inc()])
# -----------------------------------------
# Now run bison on the grammar file
#os.system("bison -d tmp.y")
bisonCmd = parser.bisonCmd + [parser.bisonFile]
if parser.verbose:
print "bisonCmd=%s" % repr(bisonCmd)
ccompiler.spawn(bisonCmd)
if parser.verbose:
print "renaming bison output files"
print parser.bisonCFile, "=>", parser.bisonCFile1
print parser.bisonHFile, "=>", parser.bisonHFile1
try:
os.unlink(parser.bisonCFile1)
except:
pass
os.rename(parser.bisonCFile, parser.bisonCFile1)
try:
os.unlink(parser.bisonHFile1)
except:
pass
os.rename(parser.bisonHFile, parser.bisonHFile1)
# -----------------------------------------
# Now run lex on the lex file
#os.system("lex tmp.l")
ccompiler.spawn(parser.flexCmd + [parser.flexFile])
try:
os.unlink(parser.flexCFile1)
except:
pass
os.rename(parser.flexCFile, parser.flexCFile1)
# -----------------------------------------
# Now compile the files into a shared lib
# compile bison and lex c sources
#bisonObj = ccompiler.compile([parser.bisonCFile1])
#lexObj = ccompiler.compile([parser.flexCFile1])
#cl /DWIN32 /G4 /Gs /Oit /MT /nologo /W3 /WX bisondynlib-win32.c /Id:\python23\include
#cc.compile(['bisondynlib-win32.c'],
# extra_preargs=['/DWIN32', '/G4', '/Gs', '/Oit', '/MT', '/nologo', '/W3', '/WX', '/Id:\python23\include'])
# link 'em into a shared lib
objs = ccompiler.compile([parser.bisonCFile1, parser.flexCFile1])
libFileName = parser.bisonEngineLibName+imp.get_suffixes()[0][0]
if os.path.isfile(libFileName+".bak"):
try:
os.unlink(libFileName+".bak")
except:
pass
if os.path.isfile(libFileName):
os.rename(libFileName, libFileName+".bak")
ccompiler.link_shared_object(objs, libFileName)
#incdir = PyString_AsString(get_python_inc())
#bisondynlib_build(self.libFilename_py, incdir)
# --------------------------------------------
# clean up, if we succeeded
hitlist = objs[:]
hitlist.append("tmp.output")
if os.path.isfile(libFileName):
for name in ['bisonFile', 'bisonCFile', 'bisonHFile',
'bisonCFile1', 'bisonHFile1', 'flexFile',
'flexCFile', 'flexCFile1',
] + objs:
fname = getattr(parser, name, None)
#print "want to delete %s" % fname
if fname and os.path.isfile(fname):
hitlist.append(fname)
if not parser.keepfiles:
for f in hitlist:
try:
os.unlink(f)
except:
print "Warning: failed to delete temporary file %s" % f
#@-node:buildLib
#@+node:closeLib
def closeLib(self):
"""
Does the necessary cleanups and closes the parser library
"""
bisondynlib_close(self.libHandle)
#@-node:closeLib
#@+node:runEngine
def runEngine(self, debug=0):
"""
Runs the binary parser engine, as loaded from the lib
"""
cdef void *handle
cdef void *cbvoid
cdef void *invoid
handle = self.libHandle
parser = self.parser
cbvoid = <void *>py_callback
invoid = <void *>py_input
if parser.verbose:
print "runEngine: about to call, py_input=0x%lx..." % (<int>invoid)
return bisondynlib_run(handle, parser, cbvoid, invoid, debug)
if parser.verbose:
print "runEngine: back from parser"
#@-node:runEngine
#@+node:__del__
def __del__(self):
"""
Clean up and bail
"""
self.closeLib()
#@-node:__del__
#@-others
#@-node:cdef class ParserEngine
#@+node:cmpLines
def cmpLines(meth1, meth2):
"""
Used as a sort() argument for sorting parse target handler methods by
the order of their declaration in their source file.
"""
try:
line1 = meth1.func_code.co_firstlineno
line2 = meth2.func_code.co_firstlineno
except:
line1 = meth1.__init__.func_code.co_firstlineno
line2 = meth2.__init__.func_code.co_firstlineno
return cmp(line1, line2)
#@-node:cmpLines
#@+node:hashParserObject
def hashParserObject(parser):
"""
Calculates an sha1 hex 'hash' of the lex script
and grammar rules in a parser class instance.
This is based on the raw text of the lex script attribute,
and the grammar rule docstrings within the handler methods.
Used to detect if someone has changed any grammar rules or
lex script, and therefore, whether a shared parser lib rebuild
is required.
"""
hasher = sha.new()
# add the lex script
hasher.update(parser.lexscript)
# add the tokens
# workaround pyrex weirdness
tokens = list(parser.tokens)
hasher.update(",".join(list(parser.tokens)))
# add the precedences
for direction, tokens in parser.precedences:
hasher.update(direction + "".join(tokens))
# extract the parser target handler names
handlerNames = dir(parser)
#handlerNames = filter(lambda m: m.startswith('on_'), dir(parser))
tmp = []
for name in handlerNames:
if name.startswith('on_'):
tmp.append(name)
handlerNames = tmp
handlerNames.sort()
# extract method objects, filter down to callables
#handlers = [getattr(parser, m) for m in handlerNames]
#handlers = filter(lambda h: callable(h), handlers)
tmp = []
for m in handlerNames:
attr = getattr(parser, m)
if callable(attr):
tmp.append(attr)
handlers = tmp
# now add in the methods' docstrings
for h in handlers:
docString = h.__doc__
hasher.update(docString)
# done
return hasher.hexdigest()
#@-node:hashParserObject
#@-others
#@-node:@file src/pyrex/bison_.pyx
#@-leo
#@+leo-ver=4
#@+node:@file src/python/bison.py
"""
Wrapper module for interfacing with Bison (yacc)
Written April 2004 by David McNab <david@freenet.org.nz>
Copyright (c) 2004 by David McNab, all rights reserved.
Released under the GNU General Public License, a copy
of which should appear in this distribution in the file
called 'COPYING'. If this file is missing, then you can
obtain a copy of the GPL license document from the GNU
website at http://www.gnu.org.
This software is released with no warranty whatsoever.
Use it at your own risk.
If you wish to use this software in a commercial application,
and wish to depart from the GPL licensing requirements,
please contact the author and apply for a commercial license.
"""
#@+others
#@+node:imports
import sys, os, sha, re, imp, traceback, xml.dom, xml.dom.minidom, types
import distutils.sysconfig
import distutils.ccompiler
from bison_ import ParserEngine, unquoted
#@-node:imports
#@+node:globals
reSpaces = re.compile("\\s+")
#@-node:globals
#@+node:exceptions
class ParserSyntaxError(Exception):
pass
#@-node:exceptions
#@+node:class BisonError
class BisonError:
"""
Flags an error to yyparse()
You should return this in your actions to notify a syntax error
"""
_pyBisonError = 1
def __init__(self, value="syntax error"):
self.value = value
#@-node:class BisonError
#@+node:class BisonNode
class BisonNode:
"""
Generic class for wrapping parse targets.
Arguments:
- targetname - the name of the parse target being wrapped.
- items - optional - a list of items comprising a clause
in the target rule - typically this will only be used
by the PyBison callback mechanism.
Keywords:
- any keywords you want (except 'items'), with any type of value.
keywords will be stored as attributes in the constructed object.
"""
#@ @+others
#@+node:__init__
def __init__(self, **kw):
self.__dict__.update(kw)
# ensure some default attribs
self.target = kw.get('target', 'UnnamedTarget')
self.names = kw.get('names', [])
self.values = kw.get('values', [])
self.option = kw.get('option', 0)
# mirror this dict to simplify dumping
self.kw = kw
#@-node:__init__
#@+node:__str__
def __str__(self):
return "<BisonNode:%s>" % self.target
#@-node:__str__
#@+node:__repr__
def __repr__(self):
return str(self)
#@-node:__repr__
#@+node:__getitem__
def __getitem__(self, item):
"""
Retrieves the ith value from this node, or child nodes
If the subscript is a single number, it will be used as an
index into this node's children list.
If the subscript is a list or tuple, we recursively fetch
the item by using the first element as an index into this
node's children, the second element as an index into that
child node's children, and so on
"""
if type(item) in [type(0), type(0L)]:
return self.values[item]
elif type(item) in [type(()), type([])]:
if len(item) == 0:
return self
return self.values[item[0]][item[1:]]
else:
raise TypeError("Can only index %s objects with an int or a list/tuple" % self.__class.__name__)
#@-node:__getitem__
#@+node:__len__
def __len__(self):
return len(self.values)
#@-node:__len__
#@+node:__getslice__
def __getslice__(self, fromidx, toidx):
return self.values[fromidx:toidx]
#@-node:__getslice__
#@+node:__iter__
def __iter__(self):
return iter(self.values)
#@-node:__iter__
#@+node:dump
def dump(self, indent=0):
"""
For debugging - prints a recursive dump of a parse tree node and its children
"""
specialAttribs = ['option', 'target', 'names', 'values']
indents = " " * indent * 2
#print "%s%s: %s %s" % (indents, self.target, self.option, self.names)
print "%s%s:" % (indents, self.target)
for name, val in self.kw.items() + zip(self.names, self.values):
if name in specialAttribs or name.startswith("_"):
continue
if isinstance(val, BisonNode):
val.dump(indent+1)
else:
print indents + " %s=%s" % (name, val)
#@-node:dump
#@+node:toxml
def toxml(self):
"""
Returns an xml serialisation of this node and its children, as a raw string
Called on the toplevel node, the xml is a representation of the
entire parse tree.
"""
return self.toxmldoc().toxml()
#@-node:toxml
#@+node:toprettyxml
def toprettyxml(self, indent=' ', newl='\n', encoding=None):
"""
returns a human-readable xml serialisation of this node and its children
"""
return self.toxmldoc().toprettyxml(indent=indent,
newl=newl,
encoding=encoding)
#@-node:toprettyxml
#@+node:toxmldoc
def toxmldoc(self):
"""
Returns the node and its children as an xml.dom.minidom.Document object
"""
d = xml.dom.minidom.Document()
d.appendChild(self.toxmlelem(d))
return d
#@-node:toxmldoc
#@+node:toxmlelem
def toxmlelem(self, docobj):
"""
Returns a DOM Element object of this node and its children
"""
specialAttribs = ['option', 'target', 'names', 'values']
# generate an xml element obj for this node
x = docobj.createElement(self.target)
# set attribs
for name, val in self.kw.items():
if name in ['names', 'values'] or name.startswith("_"):
continue
x.setAttribute(name, str(val))
#x.setAttribute('target', self.target)
#x.setAttribute('option', self.option)
# and add the children
for name, val in zip(self.names, self.values):
if name in specialAttribs or name.startswith("_"):
continue
if isinstance(val, BisonNode):
x.appendChild(val.toxmlelem(docobj))
else:
sn = docobj.createElement(name)
sn.setAttribute('target', name)
tn = docobj.createTextNode(val)
sn.appendChild(tn)
x.appendChild(sn)
# done
return x
#@-node:toxmlelem
#@-others
#@-node:class BisonNode
#@+node:class BisonParser
class BisonParser(object):
"""
Base parser class
You should subclass this, and provide a bunch of methods called
'on_TargetName', where 'TargetName' is the name of each target in
your grammar (.y) file.
"""
#@ @+others
#@+node:attributes
# ---------------------------------------
# override these if you need to
# command and options for running yacc/bison, except for filename arg
bisonCmd = ["bison", "-d", "-v", '-t']
bisonFile = "tmp.y"
bisonCFile = "tmp.tab.c"
bisonHFile = "tmp.tab.h" # name of header file generated by bison cmd
bisonCFile1 = "tmp.bison.c" # c output file from bison gets renamed to this
bisonHFile1 = "tokens.h" # bison-generated header file gets renamed to this
flexCmd = ["flex", ] # command and options for running [f]lex, except for filename arg
flexFile = "tmp.l"
flexCFile = "lex.yy.c"
flexCFile1 = "tmp.lex.c" # c output file from lex gets renamed to this
verbose = 0
file = None # default to sys.stdin
last = None # last parsed target, top of parse tree
lasterror = None # gets set if there was an error
keepfiles = 0 # set to 1 to keep temporary engine build files
bisonEngineLibName = None # defaults to 'modulename-engine'
defaultNodeClass = BisonNode # class to use by default for creating new parse nodes
#@-node:attributes
#@+node:__init__
def __init__(self, **kw):
"""
Abstract representation of parser
Keyword arguments:
- read - a callable accepting an int arg (nbytes) and returning a string,
default is this class' read() method
- file - a file object, or string of a pathname to open as a file, defaults
to sys.stdin. Note that you can leave this blank, and pass a file keyword
argument to the .run() method.
- verbose - set to 1 to enable verbose output messages, default 0
- keepfiles - if non-zero, keeps any files generated in the
course of building the parser engine; by default, all these
files get deleted upon a successful engine build
- defaultNodeClass - the class to use for creating parse nodes, default
is self.defaultNodeClass (in this base class, BisonNode)
"""
# setup
read = kw.get('read', None)
if read:
self.read = read
fileobj = kw.get('file', None)
if fileobj:
if type(fileobj) == type(""):
try:
fileobj = open(fileobj, "rb")
except:
raise Exception("Cannot open input file %s" % fileobj)
self.file = fileobj
else:
self.file = sys.stdin
nodeClass = kw.get('defaultNodeClass', None)
if nodeClass:
self.defaultNodeClass = nodeClass
self.verbose = kw.get('verbose', 0)
if kw.has_key('keepfiles'):
self.keepfiles = kw['keepfiles']
# if engine lib name not declared, invent ont
if not self.bisonEngineLibName:
self.bisonEngineLibName = self.__class__.__module__ + "-parser"
# get an engine
self.engine = ParserEngine(self)
#@-node:__init__
#@+node:__getattr__
def __getitem__(self, idx):
return self.last[idx]
#@-node:__getattr__
#@+node:_handle
def _handle(self, targetname, option, names, values):
"""
Callback which receives a target from parser, as a targetname
and list of term names and values.
Tries to dispatch to on_TargetName() methods if they exist,
otherwise wraps the target in a BisonNode object
"""
handler = getattr(self, "on_"+targetname, None)
if handler:
if self.verbose:
try:
hdlrline = handler.func_code.co_firstlineno
except:
hdlrline = handler.__init__.func_code.co_firstlineno
print "invoking handler at line %s for %s" % (hdlrline, targetname)
self.last = handler(target=targetname, option=option, names=names, values=values)
if self.verbose:
print "handler for %s returned %s" % (targetname, repr(self.last))
else:
if self.verbose:
print "no handler for %s, using default" % targetname
self.last = BisonNode(targetname, option=option, names=names, values=values)
# reset any resulting errors (assume they've been handled)
#self.lasterror = None
# assumedly the last thing parsed is at the top of the tree
return self.last
#@-node:_handle
#@+node:run
def run(self, **kw):
"""
Runs the parser, and returns the top-most parse target.
Keywords:
- file - either a string, comprising a file to open and read input from, or
a Python file object
- debug - enables garrulous parser debugging output, default 0
"""
if self.verbose:
print "Parser.run: calling engine"
# grab keywords
fileobj = kw.get('file', self.file)
if type(fileobj) == type(""):
filename = fileobj
try:
fileobj = open(fileobj, "rb")
except:
raise Exception("Cannot open input file %s" % fileobj)
else:
filename = None
fileobj = None
read = kw.get('read', self.read)
debug = kw.get('debug', 0)
# back up existing attribs
oldfile = self.file
oldread = self.read
# plug in new ones, if given
if fileobj:
self.file = fileobj
if read:
self.read = read
# do the parsing job, spew if error
self.lasterror = None
self.engine.runEngine(debug)
if self.lasterror:
#print "Got error: %s" % repr(self.error)
if filename != None:
raise ParserSyntaxError("%s:%d: '%s' near '%s'" % ((filename,) + self.lasterror))
else:
raise ParserSyntaxError("Line %d: '%s' near '%s'" % self.lasterror)
# restore old values
self.file = oldfile
self.read = oldread
if self.verbose:
print "Parser.run: back from engine"
return self.last
#@-node:run
#@+node:read
def read(self, nbytes):
"""
Override this in your subclass, if you desire.
Arguments:
- nbytes - the maximum length of the string which you may return.
DO NOT return a string longer than this, or else Bad Things will
happen.
"""
# default to stdin
if self.verbose:
print "Parser.read: want %s bytes" % nbytes
bytes = self.file.readline(nbytes)
if self.verbose:
print "Parser.read: got %s bytes" % len(bytes)
return bytes
#@-node:read
#@+node:_error
def _error(self, linenum, msg, tok):
print "Parser: line %s: syntax error '%s' before '%s'" % (linenum, msg, tok)
#@-node:_error
#@+node:error
def error(self, value):
"""
Return the result of this method from a handler to notify a syntax error
"""
self.lasterror = value
return BisonError(value)
#@-node:error
#@+node:toxml
def toxml(self):
"""
Serialises the parse tree and returns it as a raw xml string
"""
return self.last.toxml()
#@-node:toxml
#@+node:toxmldoc
def toxmldoc(self):
"""
Returns an xml.dom.minidom.Document object containing the parse tree
"""
return self.last.toxmldoc()
#@-node:toxmldoc
#@+node:toprettyxml
def toprettyxml(self):
"""
Returns a human-readable xml representation of the parse tree
"""
return self.last.toprettyxml()
#@-node:toprettyxml
#@+node:loadxml
def loadxml(self, raw, namespace=None):
"""
Loads a parse tree from raw xml text
Stores it in the '.last' attribute, which is where the root node
of parsed text gets stored
Arguments:
- raw - string containing the raw xml
- namespace - a dict or module object, where the node classes required for
reconstituting the parse tree, can be found
Returns:
- root node object of reconstituted parse tree
"""
doc = xml.dom.minidom.parseString(raw)
tree = self.loadxmldoc(doc, namespace)
self.last = tree
return tree
#@-node:loadxml
#@+node:loadxmldoc
def loadxmldoc(self, xmldoc, namespace=None):
"""
Returns a reconstituted parse tree, loaded from an
xml.dom.minidom.Document instance
Arguments:
- xmldoc - an xml.dom.minidom.Document instance
- namespace - a dict from which to find the classes needed
to translate the document into a tree of parse nodes
"""
return self.loadxmlobj(xmldoc.childNodes[0], namespace)
#@-node:loadxmldoc
#@+node:loadxmlobj
def loadxmlobj(self, xmlobj, namespace=None):
"""
Returns a node object, being a parse tree, reconstituted from an
xml.dom.minidom.Element object
Arguments:
- xmlobj - an xml.dom.minidom.Element instance
- namespace - a namespace from which the node classes
needed for reconstituting the tree, can be found
"""
# check on namespace
if type(namespace) is types.ModuleType:
namespace = namespace.__dict__
elif namespace == None:
namespace = globals()
objname = xmlobj.tagName
classname = objname + "_Node"
classobj = namespace.get(classname, None)
namespacekeys = namespace.keys()
# barf if node is not a known parse node or token
if (not classobj) and objname not in self.tokens:
raise Exception("Cannot reconstitute %s: can't find required node class or token %s" % (
objname, classname))
if classobj:
nodeobj = classobj()
# add the attribs
for k,v in xmlobj.attributes.items():
setattr(nodeobj, k, v)
else:
nodeobj = None
#print "----------------"
#print "objname=%s" % repr(objname)
#print "classname=%s" % repr(classname)
#print "classobj=%s" % repr(classobj)
#print "nodeobj=%s" % repr(nodeobj)
# now add the children
for child in xmlobj.childNodes:
#print "%s attributes=%s" % (child, child.attributes.items())
childname = child.attributes['target'].value
#print "childname=%s" % childname
if childname + "_Node" in namespacekeys:
#print "we have a node for class %s" % classname
childobj = self.loadxmlobj(child, namespace)
else:
# it's a token
childobj = child.childNodes[0].nodeValue
#print "got token %s=%s" % (childname, childobj)
nodeobj.names.append(childname)
nodeobj.values.append(childobj)
# done
return nodeobj
#@-node:loadxmlobj
#@+node:_globals
def _globals(self):
return globals().keys()
#@-node:_globals
#@-others
#@-node:class BisonParser
#@+node:bisonToPython
def bisonToPython(bisonfileName, lexfileName, pyfileName, generateClasses=0):
"""
Rips the rules, tokens and precedences from a bison file, and the
verbatim text from a lex file and generates
a boilerplate python file containing a Parser class with handler
methods and grammar attributes
Arguments:
- bisonfileName - name of input bison script
- lexfileName - name of input flex script
- pyfileName - name of output python file
- generateClasses - flag - default 0 - if 1, causes a unique class to
be defined for each parse target, and for the corresponding target
handler method in the main Parser class to use this class when creating
the node.
"""
# try to create output file
try:
pyfile = file(pyfileName, "w")
except:
raise Exception("Cannot create output file '%s'" % pyfileName)
# try to open/read the bison file
try:
rawBison = file(bisonfileName).read()
except:
raise Exception("Cannot open bison file %s" % bisonfileName)
# try to open/read the lex file
try:
rawLex = file(lexfileName).read()
except:
raise Exception("Cannot open lex file %s" % lexfileName)
# break up into the three '%%'-separated sections
try:
prologue, rulesRaw, epilogue = rawBison.split("\n%%\n")
except:
raise Exception(
"File "+bisonfileName+" is not a properly formatted bison file"+\
" (needs 3 sections separated by %%%%"
)
# --------------------------------------
# process prologue
prologue = prologue.split("%}")[-1].strip() # ditch the C code
prologue = re.sub("\\n([\t ]+)", " ", prologue) # join broken lines
#prologueLines = [line.strip() for line in prologue.split("\n")]
lines = prologue.split("\n")
tmp = []
for line in lines:
tmp.append(line.strip())
prologueLines = tmp
prologueLines = filter(None, prologueLines)
tokens = []
precRules = []
for line in prologueLines:
words = reSpaces.split(line)
kwd = words[0]
args = words[1:]
if kwd == '%token':
tokens.extend(args)
elif kwd in ['%left', '%right', '%nonassoc']:
precRules.append((kwd, args))
elif kwd == '%start':
startTarget = args[0]
# -------------------------------------------------------------
# process rules
rulesRaw = re.sub("\\n([\t ]+)", " ", rulesRaw) # join broken lines
#rulesLines = filter(None, [r.strip() for r in rulesRaw.split(";")])
rulesLines = []
#for r in rulesRaw.split(";"):
for r in re.split(unquoted % ";", rulesRaw):
r = r.strip()
if r:
rulesLines.append(r)
rules = []
for rule in rulesLines:
#print "--"
#print repr(rule)
#tgt, terms = rule.split(":")
try:
tgt, terms = re.split(unquoted % ":", rule)
except ValueError:
print "Error in rule: %s" % rule
raise
tgt, terms = tgt.strip(), terms.strip()
#terms = [t.strip() for t in terms.split("|")]
#terms = [reSpaces.split(t) for t in terms]
tmp = []
#for t in terms.split("|"):
for t in re.split(unquoted % r"\|", terms):
t = t.strip()
tmp.append(reSpaces.split(t))
terms = tmp
rules.append((tgt, terms))
# now we have our rulebase, we can churn out our skeleton Python file
pyfile.write("\n".join([
'#!/usr/bin/env python',
'',
'"""',
'PyBison file automatically generated from grammar file %s' % bisonfileName,
'You can edit this module, or import it and subclass the Parser class',
'"""',
'',
'import sys',
'',
'from bison import BisonParser, BisonNode, BisonError',
'',
'bisonFile = "%s" # original bison file' % bisonfileName,
'lexFile = "%s" # original flex file' % lexfileName,
'\n',
]))
# if generating target classes
if generateClasses:
# create a base class for all nodes
pyfile.write("\n".join([
'class ParseNode(BisonNode):',
' """',
' This is the base class from which all your',
' parse nodes are derived.',
' Add methods to this class as you need them',
' """',
' def __init__(self, **kw):',
' BisonNode.__init__(self, **kw)',
'',
' def __str__(self):',
' """Customise as needed"""',
' return "<%s instance at 0x%x>" % (self.__class__.__name__, hash(self))',
'',
' def __repr__(self):',
' """Customise as needed"""',
' return str(self)',
'',
' def dump(self, indent=0):',
' """',
' Dump out human-readable, indented parse tree',
' Customise as needed - here, or in the node-specific subclasses',
' """',
' BisonNode.dump(self, indent) # alter as needed',
'\n',
'# ------------------------------------------------------',
'# Define a node class for each grammar target',
'# ------------------------------------------------------',
'\n',
]))
# now spit out class decs for every parse target
for target, options in rules:
tmp = []
for t in options:
tmp.append(" ".join(t))
# totally self-indulgent grammatical pedantry
if target[0].lower() in ['a','e','i','o','u']:
plural = 'n'
else:
plural = ''
pyfile.write("\n".join([
'class %s_Node(ParseNode):' % target,
' """',
' Holds a%s "%s" parse target and its components.' % (plural, target),
' """',
' def __init__(self, **kw):',
' ParseNode.__init__(self, **kw)',
'',
' def dump(self, indent=0):',
' ParseNode.dump(self, indent)',
'\n',
]))
# start churning out the class dec
pyfile.write("\n".join([
'class Parser(BisonParser):',
' """',
' bison Parser class generated automatically by bison2py from the',
' grammar file "%s" and lex file "%s"' % (bisonfileName, lexfileName),
'',
' You may (and probably should) edit the methods in this class.',
' You can freely edit the rules (in the method docstrings), the',
' tokens list, the start symbol, and the precedences.',
'',
' Each time this class is instantiated, a hashing technique in the',
' base class detects if you have altered any of the rules. If any',
' changes are detected, a new dynamic lib for the parser engine',
' will be generated automatically.',
' """',
'\n',
]))
# add the default node class
if not generateClasses:
pyfile.write("\n".join([
' # -------------------------------------------------',
' # Default class to use for creating new parse nodes',
' # -------------------------------------------------',
' defaultNodeClass = BisonNode',
'\n',
]))
# add the name of the dynamic library we need
libfileName = os.path.splitext(os.path.split(pyfileName)[1])[0] + "-engine"
pyfile.write("\n".join([
' # --------------------------------------------',
' # basename of binary parser engine dynamic lib',
' # --------------------------------------------',
' bisonEngineLibName = "%s"' % libfileName,
'\n',
]))
# add the tokens
#pyfile.write(' tokens = (%s,)\n\n' % ", ".join(['"%s"' % t for t in tokens]))
tmp = []
for t in tokens:
#tmp.append('"'+t+'"')
tmp.append(t)
toks = ", ".join(tmp)
pyfile.write(' # ----------------------------------------------------------------\n')
pyfile.write(' # lexer tokens - these must match those in your lex script (below)\n')
pyfile.write(' # ----------------------------------------------------------------\n')
pyfile.write(' tokens = %s\n\n' % tmp)
# add the precedences
pyfile.write(' # ------------------------------\n')
pyfile.write(' # precedences\n')
pyfile.write(' # ------------------------------\n')
pyfile.write(' precedences = (\n')
for prec in precRules:
tmp = []
for p in prec[1]:
#tmp.append('"'+p+'"')
tmp.append(p)
precline = ", ".join(tmp)
#pyfile.write(' ("%s", (%s,)),\n' % (
pyfile.write(' ("%s", %s,),\n' % (
prec[0][1:], # left/right/nonassoc, quote-wrapped, no '%s'
tmp, # quote-wrapped targets
)
)
pyfile.write(' )\n\n'),
pyfile.write("\n".join([
' # ---------------------------------------------------------------',
' # Declare the start target here (by name)',
' # ---------------------------------------------------------------',
' start = "%s"' % startTarget,
'\n',
]))
# now the interesting bit - write the rule handler methods
pyfile.write("\n".join([
' # ---------------------------------------------------------------',
' # These methods are the python handlers for the bison targets.',
' # (which get called by the bison code each time the corresponding',
' # parse target is unambiguously reached)',
' #',
" # WARNING - don't touch the method docstrings unless you know what",
" # you are doing - they are in bison rule syntax, and are passed",
" # verbatim to bison to build the parser engine library.",
' # ---------------------------------------------------------------',
'\n',
]))
for target, options in rules:
tmp = []
for t in options:
tmp.append(" ".join(t))
if generateClasses:
nodeClassName = target + "_Node"
else:
nodeClassName = 'self.defaultNodeClass'
pyfile.write("\n".join([
' def on_%s(self, target, option, names, values):' % target,
' """',
' %s' % target,
' : ' + "\n | ".join(tmp),
' """',
' return %s(' % nodeClassName,
' target="%s",' % target,
' option=option,',
' names=names,',
' values=values)',
'\n',
]))
# now the ugly bit - add the raw lex script
pyfile.write("\n".join([
' # -----------------------------------------',
' # raw lex script, verbatim here',
' # -----------------------------------------',
' lexscript = r"""',
rawLex,
' """',
' # -----------------------------------------',
' # end raw lex script',
' # -----------------------------------------',
'',
'',
]))
# and now, create a main for testing which either reads stdin, or a filename arg
pyfile.write("\n".join([
'def usage():',
' print "%s: PyBison parser derived from %s and %s" % (sys.argv[0], bisonFile, lexFile)',
' print "Usage: %s [-k] [-v] [-d] [filename]" % sys.argv[0]',
' print " -k Keep temporary files used in building parse engine lib"',
' print " -v Enable verbose messages while parser is running"',
' print " -d Enable garrulous debug messages from parser engine"',
' print " filename path of a file to parse, defaults to stdin"',
'',
'def main(*args):',
' """',
' Unit-testing func',
' """',
'',
' keepfiles = 0',
' verbose = 0',
' debug = 0',
' filename = None',
'',
' for s in ["-h", "-help", "--h", "--help", "-?"]:',
' if s in args:',
' usage()',
' sys.exit(0)',
'',
' if len(args) > 0:',
' if "-k" in args:',
' keepfiles = 1',
' args.remove("-k")',
' if "-v" in args:',
' verbose = 1',
' args.remove("-v")',
' if "-d" in args:',
' debug = 1',
' args.remove("-d")',
' if len(args) > 0:',
' filename = args[0]',
'',
' p = Parser(verbose=verbose, keepfiles=keepfiles)',
' tree = p.run(file=filename, debug=debug)',
' return tree',
'',
'if __name__ == "__main__":',
' main(*(sys.argv[1:]))',
'',
'',
]))
#@-node:bisonToPython
#@-others
#@-node:@file src/python/bison.py
#@-leo
#!/usr/bin/env python
#@+leo-ver=4
#@+node:@file utils/bison2py
#@@first
#@@language python
"""
Utility which creates a boilerplate pybison-compatible
python file from a yacc file and lex file
Run it with 2 arguments - filename.y and filename.l
Output is filename.py
"""
#@+others
#@+node:imports
import sys, os, re, getopt
from bison import bisonToPython
#@-node:imports
#@+node:globals
argv = sys.argv
argc = len(argv)
progname = argv[0]
reSpaces = re.compile("\\s+")
#@-node:globals
#@+node:usage
def usage(s=None):
"""
Display usage info and exit
"""
if s:
print progname+": "+s
print "\n".join([
"Usage: %s [-c] basefilename" % progname,
" or: %s [-c] grammarfile.y lexfile.l pyfile.py" % progname,
"(generates a boilerplate python file from a grammar and lex file)",
"The first form uses 'basefilename' as base for all files, so:",
" %s fred" % progname,
"is equivalent to:",
" %s fred.y fred.l fred.py" % progname,
'',
'The "-c" argument causes the creation of a unique node class',
'for each parse target - highly recommended for complex grammars',
])
sys.exit(1)
#@-node:usage
#@+node:main
def main():
"""
Command-line interface for bison2py
"""
global argc, argv
if '-c' in argv:
generateClasses = 1
argv.remove('-c')
argc = argc - 1
else:
generateClasses = 0
if argc == 2:
basename = argv[1]
bisonfile = basename+".y"
lexfile = basename+".l"
pyfile = basename+".py"
elif argc == 4:
bisonfile, lexfile, pyfile = argv[1:4]
else:
usage("Bad argument count")
bisonToPython(bisonfile, lexfile, pyfile, generateClasses)
#@-node:main
#@+node:MAINLINE
if __name__ == '__main__':
main()
#@-node:MAINLINE
#@-others
#@-node:@file utils/bison2py
#@-leo
#@+leo-ver=4
#@+node:@file utils/bison2py.py
#@@language python
"""
Utility which creates a boilerplate pybison-compatible
python file from a yacc file and lex file
Run it with 2 arguments - filename.y and filename.l
Output is filename.py
"""
#@+others
#@+node:imports
import sys, os, re, getopt
from bison import bisonToPython
#@-node:imports
#@+node:globals
argv = sys.argv
argc = len(argv)
progname = argv[0]
reSpaces = re.compile("\\s+")
#@-node:globals
#@+node:usage
def usage(s=None):
"""
Display usage info and exit
"""
if s:
print progname+": "+s
print "\n".join([
"Usage: %s [-c] basefilename" % progname,
" or: %s [-c] grammarfile.y lexfile.l pyfile.py" % progname,
"(generates a boilerplate python file from a grammar and lex file)",
"The first form uses 'basefilename' as base for all files, so:",
" %s fred" % progname,
"is equivalent to:",
" %s fred.y fred.l fred.py" % progname,
'',
'The "-c" argument causes the creation of a unique node class',
'for each parse target - highly recommended for complex grammars',
])
sys.exit(1)
#@-node:usage
#@+node:main
def main():
"""
Command-line interface for bison2py
"""
global argc, argv
if '-c' in argv:
generateClasses = 1
argv.remove('-c')
argc = argc - 1
else:
generateClasses = 0
if argc == 2:
basename = argv[1]
bisonfile = basename+".y"
lexfile = basename+".l"
pyfile = basename+".py"
elif argc == 4:
bisonfile, lexfile, pyfile = argv[1:4]
else:
usage("Bad argument count")
bisonToPython(bisonfile, lexfile, pyfile, generateClasses)
#@-node:main
#@+node:MAINLINE
if __name__ == '__main__':
main()
#@-node:MAINLINE
#@-others
#@-node:@file utils/bison2py.py
#@-leo
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment