__init__.py
Go to the documentation of this file.
00001 """ @package antlr3
00002 @brief ANTLR3 runtime package
00003 
00004 This module contains all support classes, which are needed to use recognizers
00005 generated by ANTLR3.
00006 
00007 @mainpage
00008 
00009 \note Please be warned that the line numbers in the API documentation do not
00010 match the real locations in the source code of the package. This is an
00011 unintended artifact of doxygen, which I could only convince to use the
00012 correct module names by concatenating all files from the package into a single
00013 module file...
00014 
00015 Here is a little overview over the most commonly used classes provided by
00016 this runtime:
00017 
00018 @section recognizers Recognizers
00019 
00020 These recognizers are baseclasses for the code which is generated by ANTLR3.
00021 
00022 - BaseRecognizer: Base class with common recognizer functionality.
00023 - Lexer: Base class for lexers.
00024 - Parser: Base class for parsers.
00025 - tree.TreeParser: Base class for %tree parser.
00026 
00027 @section streams Streams
00028 
00029 Each recognizer pulls its input from one of the stream classes below. Streams
00030 handle stuff like buffering, look-ahead and seeking.
00031 
00032 A character stream is usually the first element in the pipeline of a typical
00033 ANTLR3 application. It is used as the input for a Lexer.
00034 
00035 - ANTLRStringStream: Reads from a string objects. The input should be a unicode
00036   object, or ANTLR3 will have trouble decoding non-ascii data.
00037 - ANTLRFileStream: Opens a file and read the contents, with optional character
00038   decoding.
00039 - ANTLRInputStream: Reads the date from a file-like object, with optional
00040   character decoding.
00041 
00042 A Parser needs a TokenStream as input (which in turn is usually fed by a
00043 Lexer):
00044 
00045 - CommonTokenStream: A basic and most commonly used TokenStream
00046   implementation.
00047 - TokenRewriteStream: A modification of CommonTokenStream that allows the
00048   stream to be altered (by the Parser). See the 'tweak' example for a usecase.
00049 
00050 And tree.TreeParser finally fetches its input from a tree.TreeNodeStream:
00051 
00052 - tree.CommonTreeNodeStream: A basic and most commonly used tree.TreeNodeStream
00053   implementation.
00054   
00055 
00056 @section tokenstrees Tokens and Trees
00057 
00058 A Lexer emits Token objects which are usually buffered by a TokenStream. A
00059 Parser can build a Tree, if the output=AST option has been set in the grammar.
00060 
00061 The runtime provides these Token implementations:
00062 
00063 - CommonToken: A basic and most commonly used Token implementation.
00064 - ClassicToken: A Token object as used in ANTLR 2.x, used to %tree
00065   construction.
00066 
00067 Tree objects are wrapper for Token objects.
00068 
00069 - tree.CommonTree: A basic and most commonly used Tree implementation.
00070 
00071 A tree.TreeAdaptor is used by the parser to create tree.Tree objects for the
00072 input Token objects.
00073 
00074 - tree.CommonTreeAdaptor: A basic and most commonly used tree.TreeAdaptor
00075 implementation.
00076 
00077 
00078 @section Exceptions
00079 
00080 RecognitionException are generated, when a recognizer encounters incorrect
00081 or unexpected input.
00082 
00083 - RecognitionException
00084   - MismatchedRangeException
00085   - MismatchedSetException
00086     - MismatchedNotSetException
00087     .
00088   - MismatchedTokenException
00089   - MismatchedTreeNodeException
00090   - NoViableAltException
00091   - EarlyExitException
00092   - FailedPredicateException
00093   .
00094 .
00095 
00096 A tree.RewriteCardinalityException is raised, when the parsers hits a
00097 cardinality mismatch during AST construction. Although this is basically a
00098 bug in your grammar, it can only be detected at runtime.
00099 
00100 - tree.RewriteCardinalityException
00101   - tree.RewriteEarlyExitException
00102   - tree.RewriteEmptyStreamException
00103   .
00104 .
00105 
00106 """
00107 
00108 # tree.RewriteRuleElementStream
00109 # tree.RewriteRuleSubtreeStream
00110 # tree.RewriteRuleTokenStream
00111 # CharStream
00112 # DFA
00113 # TokenSource
00114 
00115 # [The "BSD licence"]
00116 # Copyright (c) 2005-2008 Terence Parr
00117 # All rights reserved.
00118 #
00119 # Redistribution and use in source and binary forms, with or without
00120 # modification, are permitted provided that the following conditions
00121 # are met:
00122 # 1. Redistributions of source code must retain the above copyright
00123 #    notice, this list of conditions and the following disclaimer.
00124 # 2. Redistributions in binary form must reproduce the above copyright
00125 #    notice, this list of conditions and the following disclaimer in the
00126 #    documentation and/or other materials provided with the distribution.
00127 # 3. The name of the author may not be used to endorse or promote products
00128 #    derived from this software without specific prior written permission.
00129 #
00130 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00131 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00132 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00133 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00134 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00135 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00136 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00137 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00138 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00139 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00140 
00141 __version__ = '3.1.2'
00142 
00143 def version_str_to_tuple(version_str):
00144     import re
00145     import sys
00146 
00147     if version_str == 'HEAD':
00148         return (sys.maxint, sys.maxint, sys.maxint, sys.maxint)
00149 
00150     m = re.match(r'(\d+)\.(\d+)(\.(\d+))?(b(\d+))?', version_str)
00151     if m is None:
00152         raise ValueError("Bad version string %r" % version_str)
00153 
00154     major = int(m.group(1))
00155     minor = int(m.group(2))
00156     patch = int(m.group(4) or 0)
00157     beta = int(m.group(6) or sys.maxint)
00158 
00159     return (major, minor, patch, beta)
00160 
00161 
00162 runtime_version_str = __version__
00163 runtime_version = version_str_to_tuple(runtime_version_str)
00164 
00165 
00166 from constants import *
00167 from dfa import *
00168 from exceptions import *
00169 from recognizers import *
00170 from streams import *
00171 from tokens import *


rve_interface_gen
Author(s): Josh Faust
autogenerated on Wed Dec 11 2013 14:31:00