Introduction

When writing a computer program, implementing methods to read data from input files with a complex structure can be surprisingly difficult. For example, if the input data comes from an untrusted source, errors in the input file often need to be dealt with very carefully. If your program is written in Python and if the input data is sufficiently structured (i.e., if the format can be described by a context free grammar), Wisent[1] can help you to implement parts of the input processing of your program. This manual documents both Wisent release 0.6.2, and the Python code this Wisent release can generate for your project.

_images/wisent1500.jpg
[1]The photo shows a cave painting of a wisent in the cave of Altamira in spain. The image was taken from the Wikimedia Commons and is in the public domain.

What is Wisent?

Wisent is a parser generator for Python. Its input is a description of a data format in form of a context free grammar, its output is Python code to parse such data. The parser generator (see Documentation for Wisent) has the following features:

  • Wisent can deal with general LR(1) grammars.
  • Provides helpful error messages: if there is a problem with the input grammar, Wisent generates an example input string to illustrate the problem.
  • The language to specify grammars allows use of the ? (optional elements), * (zero or more copies) and + (one or more copies) operators.
  • Wisent is distributed under the terms of the GNU General Public License (GPL) version 2.

The generated parsers (see Documentation for the Generated Parser) have the following features:

  • The generated parser is stand-alone, i.e. you can add the generated parser to your project without adding Wisent to the project dependencies.
  • The generated parser is implemented as a Python class.
  • Automatic error repair and good error reporting: on invalid input, the generated parser tries to fix the problem to allow continuing the parsing process. At the end of parsing, all detected errors are reported together.
  • A call to the parser returns a parse tree. Wisent can create parsers which omit “uninteresting” nodes from the generated tree.
  • The generated parsers can be distributed under the 3-clause BSD license. Since this license is compatible with the GPL, you can of course use the generated parsers in GPL projects.

About the Name

I called the program “Wisent” because the first parser generator I encountered was Bison and the Wisent is the European variant of the Bison. Unfortunately, I learned later that there are at least two other parser generators which use the name “Wisent”:

Download and Copying

You can download Wisent freely from the Wisent homepage. Wisent comes with no warranty, to the extent permitted by law. You may redistribute copies of Wisent under the terms of the GNU General Public License. For more information about these matters, read the file COPYING of the source code distribution.

Contact

Please email any suggestions and bug reports to the program’s author, Jochen Voss. Your message should include the Wisent version number, as obtained by the command wisent -V.

Table Of Contents

Previous topic

Table of Contents

Next topic

Tutorial