summaryrefslogtreecommitdiffstats
path: root/poxml/antlr
diff options
context:
space:
mode:
Diffstat (limited to 'poxml/antlr')
-rw-r--r--poxml/antlr/AUTHORS2
-rw-r--r--poxml/antlr/COPYING32
-rw-r--r--poxml/antlr/ChangeLog293
-rw-r--r--poxml/antlr/INSTALL183
-rw-r--r--poxml/antlr/Makefile.am2
-rw-r--r--poxml/antlr/README72
-rw-r--r--poxml/antlr/TODO34
-rw-r--r--poxml/antlr/antlr/ANTLRException.hpp60
-rw-r--r--poxml/antlr/antlr/AST.hpp108
-rw-r--r--poxml/antlr/antlr/ASTArray.hpp63
-rw-r--r--poxml/antlr/antlr/ASTFactory.hpp113
-rw-r--r--poxml/antlr/antlr/ASTNULLType.hpp72
-rw-r--r--poxml/antlr/antlr/ASTPair.hpp77
-rw-r--r--poxml/antlr/antlr/ASTRefCount.hpp104
-rw-r--r--poxml/antlr/antlr/BaseAST.hpp106
-rw-r--r--poxml/antlr/antlr/BitSet.hpp50
-rw-r--r--poxml/antlr/antlr/CharBuffer.hpp75
-rw-r--r--poxml/antlr/antlr/CharScanner.hpp265
-rw-r--r--poxml/antlr/antlr/CharStreamException.hpp18
-rw-r--r--poxml/antlr/antlr/CharStreamIOException.hpp20
-rw-r--r--poxml/antlr/antlr/CircularQueue.hpp88
-rw-r--r--poxml/antlr/antlr/CommonAST.hpp68
-rw-r--r--poxml/antlr/antlr/CommonASTWithHiddenTokens.hpp41
-rw-r--r--poxml/antlr/antlr/CommonHiddenStreamToken.hpp30
-rw-r--r--poxml/antlr/antlr/CommonToken.hpp77
-rw-r--r--poxml/antlr/antlr/InputBuffer.hpp158
-rw-r--r--poxml/antlr/antlr/LLkParser.hpp82
-rw-r--r--poxml/antlr/antlr/LexerSharedInputState.hpp49
-rw-r--r--poxml/antlr/antlr/Makefile.am45
-rw-r--r--poxml/antlr/antlr/MismatchedCharException.hpp127
-rw-r--r--poxml/antlr/antlr/MismatchedTokenException.hpp167
-rw-r--r--poxml/antlr/antlr/NoViableAltException.hpp71
-rw-r--r--poxml/antlr/antlr/NoViableAltForCharException.hpp64
-rw-r--r--poxml/antlr/antlr/Parser.hpp213
-rw-r--r--poxml/antlr/antlr/ParserSharedInputState.hpp42
-rw-r--r--poxml/antlr/antlr/RecognitionException.hpp78
-rw-r--r--poxml/antlr/antlr/RefCount.hpp87
-rw-r--r--poxml/antlr/antlr/SemanticException.hpp52
-rw-r--r--poxml/antlr/antlr/String.hpp47
-rw-r--r--poxml/antlr/antlr/Token.hpp106
-rw-r--r--poxml/antlr/antlr/TokenBuffer.hpp141
-rw-r--r--poxml/antlr/antlr/TokenStream.hpp54
-rw-r--r--poxml/antlr/antlr/TokenStreamBasicFilter.hpp35
-rw-r--r--poxml/antlr/antlr/TokenStreamException.hpp19
-rw-r--r--poxml/antlr/antlr/TokenStreamHiddenTokenFilter.hpp84
-rw-r--r--poxml/antlr/antlr/TokenStreamIOException.hpp22
-rw-r--r--poxml/antlr/antlr/TokenStreamRecognitionException.hpp21
-rw-r--r--poxml/antlr/antlr/TokenStreamRetryException.hpp17
-rw-r--r--poxml/antlr/antlr/TokenStreamSelector.hpp78
-rw-r--r--poxml/antlr/antlr/TreeParser.hpp159
-rw-r--r--poxml/antlr/antlr/TreeParserSharedInputState.hpp34
-rw-r--r--poxml/antlr/antlr/config.hpp168
-rw-r--r--poxml/antlr/configure.in22
-rw-r--r--poxml/antlr/src/ANTLRException.cpp57
-rw-r--r--poxml/antlr/src/ASTFactory.cpp218
-rw-r--r--poxml/antlr/src/ASTRefCount.cpp74
-rw-r--r--poxml/antlr/src/BaseAST.cpp320
-rw-r--r--poxml/antlr/src/BitSet.cpp76
-rw-r--r--poxml/antlr/src/CharBuffer.cpp67
-rw-r--r--poxml/antlr/src/CharScanner.cpp430
-rw-r--r--poxml/antlr/src/CommonAST.cpp100
-rw-r--r--poxml/antlr/src/CommonASTWithHiddenTokens.cpp29
-rw-r--r--poxml/antlr/src/CommonHiddenStreamToken.cpp46
-rw-r--r--poxml/antlr/src/CommonToken.cpp81
-rw-r--r--poxml/antlr/src/InputBuffer.cpp109
-rw-r--r--poxml/antlr/src/LLkParser.cpp105
-rw-r--r--poxml/antlr/src/LexerSharedInputState.cpp55
-rw-r--r--poxml/antlr/src/Makefile.am39
-rw-r--r--poxml/antlr/src/MismatchedCharException.cpp153
-rw-r--r--poxml/antlr/src/MismatchedTokenException.cpp223
-rw-r--r--poxml/antlr/src/NoViableAltException.cpp82
-rw-r--r--poxml/antlr/src/NoViableAltForCharException.cpp71
-rw-r--r--poxml/antlr/src/Parser.cpp304
-rw-r--r--poxml/antlr/src/ParserSharedInputState.cpp37
-rw-r--r--poxml/antlr/src/RecognitionException.cpp87
-rw-r--r--poxml/antlr/src/String.cpp61
-rw-r--r--poxml/antlr/src/Token.cpp108
-rw-r--r--poxml/antlr/src/TokenBuffer.cpp107
-rw-r--r--poxml/antlr/src/TokenStreamBasicFilter.cpp34
-rw-r--r--poxml/antlr/src/TokenStreamHiddenTokenFilter.cpp146
-rw-r--r--poxml/antlr/src/TokenStreamSelector.cpp97
-rw-r--r--poxml/antlr/src/TreeParser.cpp165
-rw-r--r--poxml/antlr/src/TreeParserSharedInputState.cpp22
83 files changed, 7798 insertions, 0 deletions
diff --git a/poxml/antlr/AUTHORS b/poxml/antlr/AUTHORS
new file mode 100644
index 00000000..7bdc4852
--- /dev/null
+++ b/poxml/antlr/AUTHORS
@@ -0,0 +1,2 @@
+Author:
+ Peter Wells <pete@yamuna.demon.co.uk>
diff --git a/poxml/antlr/COPYING b/poxml/antlr/COPYING
new file mode 100644
index 00000000..ce9ec595
--- /dev/null
+++ b/poxml/antlr/COPYING
@@ -0,0 +1,32 @@
+
+SOFTWARE RIGHTS
+
+ANTLR MageLang Institute, 1989-1999
+http://www.ANTLR.org
+
+We reserve no legal rights to the ANTLR--it is fully in the
+public domain. An individual or company may do whatever
+they wish with source code distributed with ANTLR or the
+code generated by ANTLR, including the incorporation of
+ANTLR, or its output, into commerical software.
+
+We encourage users to develop software with ANTLR. However,
+we do ask that credit is given to us for developing
+ANTLR. By "credit", we mean that if you use ANTLR or
+incorporate any source code into one of your programs
+(commercial product, research project, or otherwise) that
+you acknowledge this fact somewhere in the documentation,
+research report, etc... If you like ANTLR and have
+developed a nice tool with the output, please mention that
+you developed it using ANTLR. In addition, we ask that the
+headers remain intact in our source code. As long as these
+guidelines are kept, we expect to continue enhancing this
+system and expect to make other tools available as they are
+completed.
+
+The primary ANTLR guy:
+
+Terence Parr
+MageLang Institute; http://www.MageLang.com
+parrt@jguru.com
+parrt@magelang.com
diff --git a/poxml/antlr/ChangeLog b/poxml/antlr/ChangeLog
new file mode 100644
index 00000000..735046e5
--- /dev/null
+++ b/poxml/antlr/ChangeLog
@@ -0,0 +1,293 @@
+Not 100% complete. Changes from develtree are not listed yet.
+
+Change 400 on 2000/09/27 by klaren@klaren.hawking.main
+
+ Made little TCL script to pretty print a ChangeLog with C++ stuff.
+
+
+Change 399 on 2000/09/27 by klaren@klaren.hawking.main
+
+ Fixed generating too many ASTNULL checks in wrong places.
+
+
+Change 397 on 2000/09/27 by klaren@klaren.hawking.main
+
+ Some *UGLY* fixes for the last typecasting problems in Cpp codegen. It
+ now works. In 2.7.2 or later I'll fix this in a nice way.
+
+
+Change 397 on 2000/09/27 by klaren@klaren.hawking.main
+
+ Some *UGLY* fixes for the last typecasting problems in Cpp codegen. It
+ now works. In 2.7.2 or later I'll fix this in a nice way.
+
+
+Change 394 on 2000/09/26 by klaren@klaren.hawking.main
+
+ Prefixed Unicode optimization checks with a ASTNULL check.
+
+
+Change 393 on 2000/09/25 by klaren@klaren.hawking.main
+
+ Bumped up the version no from 2.7.1a4 to 2.7.1.
+
+
+Change 380 on 2000/09/24 by parrt@parrt.foggy
+
+ integrating ric's stuff into main
+
+
+Change 380 on 2000/09/24 by parrt@parrt.foggy
+
+ integrating ric's stuff into main
+
+
+Change 380 on 2000/09/24 by parrt@parrt.foggy
+
+ integrating ric's stuff into main
+
+
+Change 348 on 2000/09/07 by klaren@klaren.hawking.main
+
+ Small improvement in constructor of CommonAST.
+
+
+Change 344 on 2000/09/06 by klaren@klaren.hawking.main
+
+ Fixed missing namespace in generated TreeParsers as reported by Ross
+ Bencina.
+
+
+Change 341 on 2000/09/06 by klaren@klaren.hawking.main
+
+ Miniscule fix for Borland C++Builder 4.0/C++ 5.4. (extra parens)
+
+
+Change 317 on 2000/08/22 by klaren@klaren.hawking.main
+
+ Updated changelog for a5 (or was it 2.7.1) release..
+
+
+Change 316 on 2000/08/22 by klaren@klaren.hawking.main
+
+ All kinds of small Makefile/configure tweaks. All gcc-isms should be
+ gone now.
+
+
+Change 309 on 2000/08/15 by klaren@klaren.hawking.main
+
+ Integrate bugfixes from klaren.dev to MismatchedChar/TokenException.
+
+
+Change 297 on 2000/08/07 by klaren@klaren.kronecker.main
+
+ Fixes for namespace/namespaceAntlr/namespaceStd/genHashLines options.
+
+
+Change 296 on 2000/08/07 by klaren@klaren.kronecker.main
+
+ Virtualized all functions that someone should want to override. Probably
+ necessary for heteroAST stuff.
+
+
+Change 291 on 2000/08/07 by klaren@klaren.kronecker.main
+
+ Some tweaks to configure.in and Makefile.am's. Fix for CXXFLAGS being
+ set incorrectly when not using gcc.
+
+
+Change 290 on 2000/08/05 by klaren@klaren.kronecker.main
+
+ Updated prototype of toLower to definition in cpp file. It seems I
+ messed them up a while back.
+
+
+Change 289 on 2000/08/05 by klaren@klaren.kronecker.main
+
+ Added namespace macro to out_of_range exception.
+
+
+Change 288 on 2000/07/28 by parrt@parrt.foggy
+
+ re-added toLower return type fix
+
+
+Change 285 on 2000/07/19 by klaren@klaren.kronecker.main
+
+ Fixed thinko.
+
+
+Change 284 on 2000/07/19 by klaren@klaren.kronecker.main
+
+ Dumped output of p4 changes -l into it...
+
+
+Change 283 on 2000/07/19 by klaren@klaren.kronecker.main
+
+ Fix for bug found by Michael Ebner. Bitset size was not increased in add
+ method.
+
+
+Change 280 on 2000/07/19 by klaren@klaren.kronecker.main
+
+ Made namespaceAntlr, namespaceStd and genHashlines options file-level
+ options. Removed nameSpace member from Tool class all is now handled in
+ CppCodegenerator.java.
+
+
+Change 276 on 2000/07/18 by klaren@klaren.kronecker.main
+
+ C++ Changes for the indented traceXXXX output as invented by Monty Zukowski
+
+
+Change 275 on 2000/07/18 by klaren@klaren.kronecker.main
+
+ Added missing initializer in generated code for TreeParser
+
+
+Change 272 on 2000/07/17 by klaren@klaren.kronecker.main
+
+ Another workspace for MSVC6 has support for dll's (for version 2.6.1).
+
+
+Change 271 on 2000/07/17 by klaren@klaren.kronecker.main
+
+ New autoconf/automake stuff for the C++ support library.
+
+
+Change 270 on 2000/07/17 by klaren@klaren.kronecker.main
+
+ Fixed error within the NO_STATIC_CONSTS #ifdef
+
+
+Change 269 on 2000/07/17 by klaren@klaren.kronecker.main
+
+ Move C++ files to lib/cpp/src as first step for autoconf setup
+
+
+Change 268 on 2000/07/17 by klaren@klaren.kronecker.main
+
+ Add contrib dir and Microsoft Visual C++ 6.0 projects supplied by John
+ Millaway
+
+
+Change 260 on 2000/07/14 by klaren@klaren.kronecker.main
+
+ Fixed crashbugs/typos in constructors of Mismatched[Token|Char]Exception
+
+
+Change 258 on 2000/07/10 by parrt@parrt.foggy
+
+ fixes per klaren
+
+
+Change 258 on 2000/07/10 by parrt@parrt.foggy
+
+ fixes per klaren
+
+
+Change 248 on 2000/07/04 by parrt@parrt.foggy
+
+ Ric Klaren's changes to C++ lib
+
+
+Change 247 on 2000/07/04 by parrt@parrt.foggy
+
+ Ric Klaren's changes for namespaces
+
+
+Change 239 on 2000/06/03 by parrt@parrt.foggy
+
+ adjusted so it works; header actions got converted to Token objects from
+ Strings; lots of cast problems and then null ptr exceptions.
+
+Change 235 on 2000/05/31 by pete@pete.linux
+
+ More changes to support #line generation in C++ (from Ric Klaren)
+
+Change 220 on 2000/05/29 by parrt@parrt.foggy
+
+ changed char to int for toLower
+
+
+Change 219 on 2000/05/28 by pete@pete.linux
+
+ Mirroring Java changes
+
+
+Change 218 on 2000/05/28 by pete@pete.linux
+
+ Cleaned up the #line generator a little.
+
+
+Change 211 on 2000/05/27 by parrt@parrt.foggy
+
+ had same bug as JavaCodeGenerator related to ~(A|B)
+
+
+Change 205 on 2000/05/24 by pete@pete.linux
+
+ Add support for Metrowerks Codewarrior
+
+
+Change 203 on 2000/05/22 by pete@pete.linux
+
+ Fix for multithreading from Jan Mikkelsen
+
+
+Change 202 on 2000/05/21 by pete@pete.linux
+
+ Merged in some fixes from Ric Klaren for tracing TreeParsers, cleaner
+ namespace code, and #line generation.
+
+
+Change 202 on 2000/05/21 by pete@pete.linux
+
+ Merged in some fixes from Ric Klaren for tracing TreeParsers, cleaner
+ namespace code, and #line generation.
+
+Change 201 on 2000/05/21 by pete@pete.linux
+
+ Added destructors with empty throw specs, as suggested by Dan Field.
+
+
+Change 200 on 2000/05/21 by pete@pete.linux
+
+ Various performance improvements, mostly from Eric Dumas.
+
+
+Change 183 on 2000/02/08 by pete@pete.linux
+
+ Added support for Sun CC 5.0 (from Michael Schmitt)
+
+
+Change 182 on 2000/02/08 by pete@pete.linux
+
+ Fix a couple of minor problems with C++ generation (noted by Michael
+ Schmitt)
+
+Change 132 on 2000/01/18 by parrt@parrt.foggy
+
+ setting type to ktext for everything
+
+
+Change 132 on 2000/01/18 by parrt@parrt.foggy
+
+ setting type to ktext for everything
+
+
+Change 131 on 2000/01/18 by parrt@parrt.foggy
+
+ from dev back to main
+
+
+Change 131 on 2000/01/18 by parrt@parrt.foggy
+
+ from dev back to main
+
+
+Change 1 on 1999/12/13 by parrt@parrt.foggy
+
+ adding 2.6.0 from antlr site as initial main line
+
+
diff --git a/poxml/antlr/INSTALL b/poxml/antlr/INSTALL
new file mode 100644
index 00000000..30dd4d49
--- /dev/null
+++ b/poxml/antlr/INSTALL
@@ -0,0 +1,183 @@
+Basic Installation
+==================
+
+ These are generic installation instructions. Check out the README for
+additional info.
+
+ The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation. It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions. Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, a file
+`config.cache' that saves the results of its tests to speed up
+reconfiguring, and a file `config.log' containing compiler output
+(useful mainly for debugging `configure').
+
+ If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release. If at some point `config.cache'
+contains results you don't want to keep, you may remove or edit it.
+
+ The file `configure.in' is used to create `configure' by a program
+called `autoconf'. You only need `configure.in' if you want to change
+it or regenerate `configure' using a newer version of `autoconf'.
+
+The simplest way to compile this package is:
+
+ 1. `cd' to the directory containing the package's source code and type
+ `./configure' to configure the package for your system. If you're
+ using `csh' on an old version of System V, you might need to type
+ `sh ./configure' instead to prevent `csh' from trying to execute
+ `configure' itself.
+
+ Running `configure' takes awhile. While running, it prints some
+ messages telling which features it is checking for.
+
+ 2. Type `make' to compile the package.
+
+ 3. Optionally, type `make check' to run any self-tests that come with
+ the package.
+
+ 4. Type `make install' to install the programs and any data files and
+ documentation.
+
+ 5. You can remove the program binaries and object files from the
+ source code directory by typing `make clean'. To also remove the
+ files that `configure' created (so you can compile the package for
+ a different kind of computer), type `make distclean'. There is
+ also a `make maintainer-clean' target, but that is intended mainly
+ for the package's developers. If you use it, you may have to get
+ all sorts of other programs in order to regenerate files that came
+ with the distribution.
+
+Compilers and Options
+=====================
+
+ Some systems require unusual options for compilation or linking that
+the `configure' script does not know about. You can give `configure'
+initial values for variables by setting them in the environment. Using
+a Bourne-compatible shell, you can do that on the command line like
+this:
+ CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
+
+Or on systems that have the `env' program, you can do it like this:
+ env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
+
+Compiling For Multiple Architectures
+====================================
+
+ You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory. To do this, you must use a version of `make' that
+supports the `VPATH' variable, such as GNU `make'. `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script. `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+ If you have to use a `make' that does not supports the `VPATH'
+variable, you have to compile the package for one architecture at a time
+in the source code directory. After you have installed the package for
+one architecture, use `make distclean' before reconfiguring for another
+architecture.
+
+Installation Names
+==================
+
+ By default, `make install' will install the package's files in
+`/usr/local/bin', `/usr/local/man', etc. You can specify an
+installation prefix other than `/usr/local' by giving `configure' the
+option `--prefix=PATH'.
+
+ You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files. If you
+give `configure' the option `--exec-prefix=PATH', the package will use
+PATH as the prefix for installing programs and libraries.
+Documentation and other data files will still use the regular prefix.
+
+ In addition, if you use an unusual directory layout you can give
+options like `--bindir=PATH' to specify different values for particular
+kinds of files. Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+ If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+ Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System). The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+ For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+ There may be some features `configure' can not figure out
+automatically, but needs to determine by the type of host the package
+will run on. Usually `configure' can figure that out, but if it prints
+a message saying it can not guess the host type, give it the
+`--host=TYPE' option. TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name with three fields:
+ CPU-COMPANY-SYSTEM
+
+See the file `config.sub' for the possible values of each field. If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the host type.
+
+ If you are building compiler tools for cross-compiling, you can also
+use the `--target=TYPE' option to select the type of system they will
+produce code for and the `--build=TYPE' option to select the type of
+system on which you are compiling the package.
+
+Sharing Defaults
+================
+
+ If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists. Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Operation Controls
+==================
+
+ `configure' recognizes the following options to control how it
+operates.
+
+`--cache-file=FILE'
+ Use and save the results of the tests in FILE instead of
+ `./config.cache'. Set FILE to `/dev/null' to disable caching, for
+ debugging `configure'.
+
+`--help'
+ Print a summary of the options to `configure', and exit.
+
+`--quiet'
+`--silent'
+`-q'
+ Do not print messages saying which checks are being made. To
+ suppress all normal output, redirect it to `/dev/null' (any error
+ messages will still be shown).
+
+`--srcdir=DIR'
+ Look for the package's source code in directory DIR. Usually
+ `configure' can determine that directory automatically.
+
+`--version'
+ Print the version of Autoconf used to generate the `configure'
+ script, and exit.
+
+`configure' also accepts some other, not widely useful, options.
diff --git a/poxml/antlr/Makefile.am b/poxml/antlr/Makefile.am
new file mode 100644
index 00000000..be459d64
--- /dev/null
+++ b/poxml/antlr/Makefile.am
@@ -0,0 +1,2 @@
+SUBDIRS = src antlr
+
diff --git a/poxml/antlr/README b/poxml/antlr/README
new file mode 100644
index 00000000..6ca0913b
--- /dev/null
+++ b/poxml/antlr/README
@@ -0,0 +1,72 @@
+C++ support libraries
+
+Original GNU autconf stuff contributed by Braden N. McDaniel. Slightly
+hacked up by me (Ric Klaren (klaren@cs.utwente.nl)) for who it's the first
+autoconf/automake/aclocal stuff ever, so suggestions additions welcome.
+
+HOW TO INSTALL
+
+In theory do:
+
+./configure --prefix=<basedirectory where you want it installed>
+make
+make install
+
+Now libantlr.a should reside under <basedir>/lib/libantlr.a and the
+includes should be at <basedir>/include/antlr.
+
+NOTE: this only installs the C++ library and header files.
+
+In the contrib directory a dsp/dsw project for Microsoft Visual C++ can be
+found.
+
+In general this library needs runtime typing information (RTTI) make sure
+you enable this in whatever compiler you are using.
+
+SUPPORTED COMPILERS
+
+Pasted from the FAQ entry on: http://www.jguru.com/jguru/faq/view.jsp?EID=121
+
+Compiler OS Version
+------------------ --------------------- ----------
+Sun Workshop 4.2 Solaris 2.6, 7 2.7.1a2
+Sun Workshop 5.0 Solaris 2.7 2.7.1a2
+Sun Workshop 6.0 Solaris 2.7 2.7.1a2
+egcs-1.1.2 Solaris 2.6,7 2.7.1a2
+egcs-1.1.2 Linux 2.2, Solaris 2.6 2.7.1a2
+gcc-2.95.2 Linux 2.2, Solaris 2.6,7 2.7.1a2
+gcc-2.96 (20000527) Solaris 2.6 2.7.1a2
+aCC A.01.21 HP-UX 10.20 2.7.0 no!
+Visual C++ 6.0 PC 2.7.1a2 (warnings)
+Intel C++ 4.0 NT 4.0 2.7.0
+Borland 5.0 NT 4.0 2.7.0
+
+IT DOESN'T WORK!?
+
+Check out the faq: http://www.jguru.com/jguru/faq/view.jsp?EID=120
+
+The text of that entry (by Peter Wells):
+
+The ANTLR code uses some relatively new features of C++ which not all
+compilers support yet (such as namespaces, and new style standard headers).
+
+There is work currently in progress to provide a compatibility mode for
+ANTLR, to enable older compilers to handle this.
+
+At the moment, you may be able to work around the problem with a few nasty
+tricks:
+
+Try creating some header files like 'iostream' just containing:
+
+#include <iostream.h>
+
+and compile with an option to define away the word 'std', such as
+
+CC .... -Dstd= ....
+
+Also in the antlr subdirectory there's a file config.hpp. Tweak this one to
+enable/disable the different bells and whistles used in the rest of the code.
+Don't forget to submit those changes back to us (along with compiler info)
+so we can incorporate them in our next release!
+
+Thanks!
diff --git a/poxml/antlr/TODO b/poxml/antlr/TODO
new file mode 100644
index 00000000..51d104c3
--- /dev/null
+++ b/poxml/antlr/TODO
@@ -0,0 +1,34 @@
+* Improve configure scripts => KICK OUT automake!
+
+* Add allocators to the objects
+
+* Look more at exception handling
+
+* TreeParser.cpp around line 76 the MismatchedTokenException here does not
+ use ttype to improve it's errormessage. Would require changing a bit in
+ MismatchedTokenException.cpp
+
+* On Thu, Sep 21, 2000 at 12:33:48AM -0700, John Lambert <JohnL@jBASE.com> wrote:
+ > 1) The literal EOF is not defined and causes the define of EOF_CHAR in
+ > CharScanner.hpp to fail.
+
+ ANTLR with STL Port. Changing the EOF define to char_traits<char>::eof()
+ breaks things for gcc-2.95.2. Fix this in next release portably.
+ http://www.egroups.com/message/antlr-interest/2520
+
+* John Millaway requested some mechanism to add code to the constructor
+ of the parser/lexer/treewalker. This can be usefull.
+ http://www.egroups.com/message/antlr-interest/2501
+
+* Fix heterogeneous AST stuff. It boils down to adding a method to AST
+ types that knows how to duplicate the sucker. Atm duptree cannot work
+ because of this. Knowing one factory is not enough. Also look at having
+ to set the astfactory by hand (this is not 100% necessary).
+ http://www.egroups.com/message/antlr-interest/2496
+
+* Look at messageLog stuff Ross Bencina proposed. Looks good at first glance.
+ http://www.egroups.com/message/antlr-interest/2555
+
+* Add RW_STL & CC 4.2 patch from Ulrich Teichert:
+ See my mailbox.. and these comments from Ross Bencina:
+ http://www.egroups.com/message/antlr-interest/2494
diff --git a/poxml/antlr/antlr/ANTLRException.hpp b/poxml/antlr/antlr/ANTLRException.hpp
new file mode 100644
index 00000000..efbe0d7f
--- /dev/null
+++ b/poxml/antlr/antlr/ANTLRException.hpp
@@ -0,0 +1,60 @@
+#ifndef INC_ANTLRException_hpp__
+#define INC_ANTLRException_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/config.hpp"
+#include <exception>
+#include <string>
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+class ANTLRException : public ANTLR_USE_NAMESPACE(std)exception {
+private:
+ ANTLR_USE_NAMESPACE(std)string text;
+
+public:
+ ANTLRException();
+ ANTLRException(const ANTLR_USE_NAMESPACE(std)string& s);
+ virtual ~ANTLRException() throw();
+
+ virtual ANTLR_USE_NAMESPACE(std)string toString() const;
+
+ virtual ANTLR_USE_NAMESPACE(std)string getMessage() const;
+
+ virtual const char* what() const throw();
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_ANTLRException_hpp__
diff --git a/poxml/antlr/antlr/AST.hpp b/poxml/antlr/antlr/AST.hpp
new file mode 100644
index 00000000..a36ffd15
--- /dev/null
+++ b/poxml/antlr/antlr/AST.hpp
@@ -0,0 +1,108 @@
+#ifndef INC_AST_hpp__
+#define INC_AST_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/config.hpp"
+#include "antlr/ASTRefCount.hpp"
+#include "antlr/Token.hpp"
+#include <vector>
+#include <string>
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+struct ASTRef;
+
+class AST {
+public:
+ AST() : ref(0) {}
+ virtual ~AST() {}
+
+ virtual void addChild(RefAST c)=0;
+
+ virtual bool equals(RefAST t) const=0;
+ virtual bool equalsList(RefAST t) const=0;
+ virtual bool equalsListPartial(RefAST t) const=0;
+ virtual bool equalsTree(RefAST t) const=0;
+ virtual bool equalsTreePartial(RefAST t) const=0;
+
+ virtual ANTLR_USE_NAMESPACE(std)vector<RefAST> findAll(RefAST t)=0;
+ virtual ANTLR_USE_NAMESPACE(std)vector<RefAST> findAllPartial(RefAST t)=0;
+
+ /** Get the first child of this node; null if no children */
+ virtual RefAST getFirstChild() const=0;
+ /** Get the next sibling in line after this one */
+ virtual RefAST getNextSibling() const=0;
+
+ /** Get the token text for this node */
+ virtual ANTLR_USE_NAMESPACE(std)string getText() const=0;
+ /** Get the token type for this node */
+ virtual int getType() const=0;
+
+ virtual void initialize(int t,const ANTLR_USE_NAMESPACE(std)string& txt)=0;
+ virtual void initialize(RefAST t)=0;
+ virtual void initialize(RefToken t)=0;
+
+ /** Set the first child of a node. */
+ virtual void setFirstChild(RefAST c)=0;
+ /** Set the next sibling after this one. */
+ virtual void setNextSibling(RefAST n)=0;
+
+ /** Set the token text for this node */
+ virtual void setText(const ANTLR_USE_NAMESPACE(std)string& txt)=0;
+ /** Set the token type for this node */
+ virtual void setType(int type)=0;
+
+ virtual ANTLR_USE_NAMESPACE(std)string toString() const=0;
+ virtual ANTLR_USE_NAMESPACE(std)string toStringList() const=0;
+ virtual ANTLR_USE_NAMESPACE(std)string toStringTree() const=0;
+private:
+ friend struct ASTRef;
+ ASTRef* ref;
+
+ AST(const AST& other);
+ AST(RefAST other);
+ AST& operator=(const AST& other);
+ AST& operator=(RefAST other);
+};
+
+extern RefAST nullAST;
+extern AST* const nullASTptr;
+
+#ifdef NEEDS_OPERATOR_LESS_THAN
+inline operator<(RefAST l,RefAST r); // {return true;}
+#endif
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_AST_hpp__
diff --git a/poxml/antlr/antlr/ASTArray.hpp b/poxml/antlr/antlr/ASTArray.hpp
new file mode 100644
index 00000000..5203acf0
--- /dev/null
+++ b/poxml/antlr/antlr/ASTArray.hpp
@@ -0,0 +1,63 @@
+#ifndef INC_ASTArray_hpp__
+#define INC_ASTArray_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/config.hpp"
+#include "antlr/AST.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/** ASTArray is a class that allows ANTLR to
+ * generate code that can create and initialize an array
+ * in one expression, like:
+ * (new ASTArray(3))->add(x)->add(y)->add(z)
+ */
+class ASTArray {
+public:
+ int size; // = 0;
+ ANTLR_USE_NAMESPACE(std)vector<RefAST> array;
+
+ ASTArray(int capacity)
+ : size(0)
+ , array(capacity)
+ {}
+ ASTArray* add(RefAST node) {
+ array[size++] = node;
+ return this;
+ }
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_ASTArray_hpp__
diff --git a/poxml/antlr/antlr/ASTFactory.hpp b/poxml/antlr/antlr/ASTFactory.hpp
new file mode 100644
index 00000000..584cee6d
--- /dev/null
+++ b/poxml/antlr/antlr/ASTFactory.hpp
@@ -0,0 +1,113 @@
+#ifndef INC_ASTFactory_hpp__
+#define INC_ASTFactory_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/config.hpp"
+#include "antlr/AST.hpp"
+#include "antlr/ASTArray.hpp"
+#include "antlr/ASTPair.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/** AST Support code shared by TreeParser and Parser.
+ * We use delegation to share code (and have only one
+ * bit of code to maintain) rather than subclassing
+ * or superclassing (forces AST support code to be
+ * loaded even when you don't want to do AST stuff).
+ *
+ * Typically, setASTNodeType is used to specify the
+ * type of node to create, but you can override
+ * create to make heterogeneous nodes etc...
+ */
+class ASTFactory {
+public:
+ typedef RefAST (*factory_type)();
+protected:
+ /** Name of AST class to create during tree construction.
+ * Null implies that the create method should create
+ * a default AST type such as CommonAST.
+ */
+ factory_type nodeFactory;
+
+public:
+ ASTFactory();
+ /** Add a child to the current AST */
+ void addASTChild(ASTPair& currentAST, RefAST child);
+ /** Create a new empty AST node; if the user did not specify
+ * an AST node type, then create a default one: CommonAST.
+ */
+ virtual RefAST create();
+ RefAST create(int type);
+ RefAST create(int type, const ANTLR_USE_NAMESPACE(std)string& txt);
+ /** Create a new empty AST node; if the user did not specify
+ * an AST node type, then create a default one: CommonAST.
+ */
+ RefAST create(RefAST tr);
+ RefAST create(RefToken tok);
+ /** Copy a single node. clone() is not used because
+ * we want to return an AST not a plain object...a type
+ * safety issue. Further, we want to have all AST node
+ * creation go through the factory so creation can be
+ * tracked. Returns null if t is null.
+ */
+ RefAST dup(RefAST t);
+ /** Duplicate tree including siblings of root. */
+ RefAST dupList(RefAST t);
+ /**Duplicate a tree, assuming this is a root node of a tree--
+ * duplicate that node and what's below; ignore siblings of root node.
+ */
+ RefAST dupTree(RefAST t);
+ /** Make a tree from a list of nodes. The first element in the
+ * array is the root. If the root is null, then the tree is
+ * a simple list not a tree. Handles null children nodes correctly.
+ * For example, build(a, b, null, c) yields tree (a b c). build(null,a,b)
+ * yields tree (nil a b).
+ */
+ RefAST make(ANTLR_USE_NAMESPACE(std)vector<RefAST> nodes);
+ /** Make a tree from a list of nodes, where the nodes are contained
+ * in an ASTArray object
+ */
+ RefAST make(ASTArray* nodes);
+ /** Make an AST the root of current AST */
+ void makeASTRoot(ASTPair& currentAST, RefAST root);
+ void setASTNodeFactory(factory_type factory);
+ virtual ~ASTFactory() {}
+private:
+ ASTFactory( const ASTFactory& );
+ ASTFactory& operator=( const ASTFactory& );
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_ASTFactory_hpp__
diff --git a/poxml/antlr/antlr/ASTNULLType.hpp b/poxml/antlr/antlr/ASTNULLType.hpp
new file mode 100644
index 00000000..8f3faa46
--- /dev/null
+++ b/poxml/antlr/antlr/ASTNULLType.hpp
@@ -0,0 +1,72 @@
+#ifndef INC_ASTNULLType_hpp__
+#define INC_ASTNULLType_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/config.hpp"
+#include "antlr/AST.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/** There is only one instance of this class **/
+class ASTNULLType : public AST {
+public:
+ void addChild(RefAST c) {;}
+ bool equals(RefAST t) const {return false;}
+ bool equalsList(RefAST t) const {return false;}
+ bool equalsListPartial(RefAST t) const {return false;}
+ bool equalsTree(RefAST t) const {return false;}
+ bool equalsTreePartial(RefAST t) const {return false;}
+ ANTLR_USE_NAMESPACE(std)vector<RefAST> findAll(RefAST tree)
+ {return ANTLR_USE_NAMESPACE(std)vector<RefAST>();}
+ ANTLR_USE_NAMESPACE(std)vector<RefAST> findAllPartial(RefAST subtree)
+ {return ANTLR_USE_NAMESPACE(std)vector<RefAST>();}
+ RefAST getFirstChild() const { return this; }
+ RefAST getNextSibling() const { return this; }
+ ANTLR_USE_NAMESPACE(std)string getText() const { return "<ASTNULL>"; }
+ int getType() const { return Token::NULL_TREE_LOOKAHEAD; }
+ void initialize(int t, const ANTLR_USE_NAMESPACE(std)string& txt) {}
+ void initialize(RefAST t) {}
+ void initialize(RefToken t) {}
+ void setFirstChild(RefAST c) {;}
+ void setNextSibling(RefAST n) {;}
+ void setText(const ANTLR_USE_NAMESPACE(std)string& text) {;}
+ void setType(int ttype) {;}
+ ANTLR_USE_NAMESPACE(std)string toString() const {return getText();}
+ ANTLR_USE_NAMESPACE(std)string toStringList() const {return getText();}
+ ANTLR_USE_NAMESPACE(std)string toStringTree() const {return getText();}
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_ASTNULLType_hpp__
diff --git a/poxml/antlr/antlr/ASTPair.hpp b/poxml/antlr/antlr/ASTPair.hpp
new file mode 100644
index 00000000..eb7629ba
--- /dev/null
+++ b/poxml/antlr/antlr/ASTPair.hpp
@@ -0,0 +1,77 @@
+#ifndef INC_ASTPair_hpp__
+#define INC_ASTPair_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+#include "antlr/config.hpp"
+#include "antlr/AST.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/** ASTPair: utility class used for manipulating a pair of ASTs
+ * representing the current AST root and current AST sibling.
+ * This exists to compensate for the lack of pointers or 'var'
+ * arguments in Java.
+ *
+ * OK, so we can do those things in C++, but it seems easier
+ * to stick with the Java way for now.
+ */
+class ASTPair {
+public:
+ RefAST root; // current root of tree
+ RefAST child; // current child to which siblings are added
+
+ /** Make sure that child is the last sibling */
+ void advanceChildToEnd() {
+ if (child) {
+ while (child->getNextSibling()) {
+ child = child->getNextSibling();
+ }
+ }
+ }
+// /** Copy an ASTPair. Don't call it clone() because we want type-safety */
+// ASTPair copy() {
+// ASTPair tmp = new ASTPair();
+// tmp.root = root;
+// tmp.child = child;
+// return tmp;
+// }
+ ANTLR_USE_NAMESPACE(std)string toString() const {
+ ANTLR_USE_NAMESPACE(std)string r = !root ? ANTLR_USE_NAMESPACE(std)string("null") : root->getText();
+ ANTLR_USE_NAMESPACE(std)string c = !child ? ANTLR_USE_NAMESPACE(std)string("null") : child->getText();
+ return "["+r+","+c+"]";
+ }
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_ASTPair_hpp__
diff --git a/poxml/antlr/antlr/ASTRefCount.hpp b/poxml/antlr/antlr/ASTRefCount.hpp
new file mode 100644
index 00000000..cb44128b
--- /dev/null
+++ b/poxml/antlr/antlr/ASTRefCount.hpp
@@ -0,0 +1,104 @@
+#ifndef INC_ASTRefCount_hpp__
+# define INC_ASTRefCount_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+# include "antlr/config.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+ class AST;
+
+struct ASTRef
+{
+ AST* const ptr;
+ unsigned int count;
+
+ ASTRef(AST* p);
+ ~ASTRef();
+ ASTRef* increment();
+ bool decrement();
+
+ static ASTRef* getRef(const AST* p);
+private:
+ ASTRef( const ASTRef& );
+ ASTRef& operator=( const ASTRef& );
+};
+
+template<class T>
+ class ASTRefCount
+{
+private:
+ ASTRef* ref;
+
+public:
+ ASTRefCount(const AST* p=0)
+ : ref(p ? ASTRef::getRef(p) : 0)
+ {
+ }
+ ASTRefCount(const ASTRefCount<T>& other)
+ : ref(other.ref ? other.ref->increment() : 0)
+ {
+ }
+ ~ASTRefCount()
+ {
+ if (ref && ref->decrement()) delete ref;
+ }
+ ASTRefCount<T>& operator=(AST* other)
+ {
+ ASTRef* tmp=ASTRef::getRef(other);
+ if (ref && ref->decrement()) delete ref;
+ ref=tmp;
+ return *this;
+ }
+ ASTRefCount<T>& operator=(const ASTRefCount<T>& other)
+ {
+ ASTRef* tmp=other.ref ? other.ref->increment() : 0;
+ if (ref && ref->decrement()) delete ref;
+ ref=tmp;
+ return *this;
+ }
+
+ operator T* () const
+ { return ref ? static_cast<T*>(ref->ptr) : 0; }
+ T* operator->() const
+ { return ref ? static_cast<T*>(ref->ptr) : 0; }
+ T* get() const
+ { return ref ? static_cast<T*>(ref->ptr) : 0; }
+};
+
+typedef ASTRefCount<AST> RefAST;
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_ASTRefCount_hpp__
diff --git a/poxml/antlr/antlr/BaseAST.hpp b/poxml/antlr/antlr/BaseAST.hpp
new file mode 100644
index 00000000..7b93c1ef
--- /dev/null
+++ b/poxml/antlr/antlr/BaseAST.hpp
@@ -0,0 +1,106 @@
+#ifndef INC_BaseAST_hpp__
+#define INC_BaseAST_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/config.hpp"
+#include "antlr/AST.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+class BaseAST;
+typedef ASTRefCount<BaseAST> RefBaseAST;
+
+class BaseAST : public AST {
+public:
+ BaseAST() : AST() {}
+ virtual ~BaseAST() {}
+protected:
+ RefBaseAST down;
+ RefBaseAST right;
+
+//private:
+// static bool verboseStringConversion;
+// static ANTLR_USE_NAMESPACE(std)vector<ANTLR_USE_NAMESPACE(std)string> tokenNames;
+
+public:
+ virtual void addChild(RefAST c);
+
+private:
+ void doWorkForFindAll(ANTLR_USE_NAMESPACE(std)vector<RefAST>& v,
+ RefAST target,bool partialMatch);
+
+public:
+ virtual bool equals(RefAST t) const;
+ virtual bool equalsList(RefAST t) const;
+ virtual bool equalsListPartial(RefAST t) const;
+ virtual bool equalsTree(RefAST t) const;
+ virtual bool equalsTreePartial(RefAST t) const;
+
+ virtual ANTLR_USE_NAMESPACE(std)vector<RefAST> findAll(RefAST t);
+ virtual ANTLR_USE_NAMESPACE(std)vector<RefAST> findAllPartial(RefAST t);
+
+ /** Get the first child of this node; null if no children */
+ virtual RefAST getFirstChild() const;
+ /** Get the next sibling in line after this one */
+ virtual RefAST getNextSibling() const;
+
+ /** Get the token text for this node */
+ virtual ANTLR_USE_NAMESPACE(std)string getText() const;
+ /** Get the token type for this node */
+ virtual int getType() const;
+
+ /** Remove all children */
+ virtual void removeChildren();
+
+ /** Set the first child of a node. */
+ virtual void setFirstChild(RefAST c);
+ /** Set the next sibling after this one. */
+ void setNextSibling(RefAST n);
+
+ /** Set the token text for this node */
+ virtual void setText(const ANTLR_USE_NAMESPACE(std)string& txt);
+ /** Set the token type for this node */
+ virtual void setType(int type);
+
+// static void setVerboseStringConversion(bool verbose,
+// const ANTLR_USE_NAMESPACE(std)vector<ANTLR_USE_NAMESPACE(std)string>& names);
+
+ virtual ANTLR_USE_NAMESPACE(std)string toString() const;
+ virtual ANTLR_USE_NAMESPACE(std)string toStringList() const;
+ virtual ANTLR_USE_NAMESPACE(std)string toStringTree() const;
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_BaseAST_hpp__
diff --git a/poxml/antlr/antlr/BitSet.hpp b/poxml/antlr/antlr/BitSet.hpp
new file mode 100644
index 00000000..4eb400c7
--- /dev/null
+++ b/poxml/antlr/antlr/BitSet.hpp
@@ -0,0 +1,50 @@
+#ifndef INC_BitSet_hpp__
+#define INC_BitSet_hpp__
+
+#include "antlr/config.hpp"
+#include <vector>
+#include <stdexcept>
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/**A BitSet to replace java.util.BitSet.
+ * Primary differences are that most set operators return new sets
+ * as opposed to oring and anding "in place". Further, a number of
+ * operations were added. I cannot contain a BitSet because there
+ * is no way to access the internal bits (which I need for speed)
+ * and, because it is final, I cannot subclass to add functionality.
+ * Consider defining set degree. Without access to the bits, I must
+ * call a method n times to test the ith bit...ack!
+ *
+ * Also seems like or() from util is wrong when size of incoming set is bigger
+ * than this.length.
+ *
+ *
+ * This is a C++ version of the Java class described above, with only
+ * a handful of the methods implemented, because we don't need the
+ * others at runtime. It's really just a wrapper around vector<bool>,
+ * which should probably be changed to a wrapper around bitset, once
+ * bitset is more widely available.
+ *
+ * @author Terence Parr, MageLang Institute
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+class BitSet {
+private:
+ ANTLR_USE_NAMESPACE(std)vector<bool> storage;
+
+public:
+ BitSet(int nbits=64);
+ BitSet(const unsigned long* bits_,int nlongs);
+ ~BitSet();
+
+ void add(int el);
+
+ bool member(int el) const;
+
+ ANTLR_USE_NAMESPACE(std)vector<int> toArray() const;
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_BitSet_hpp__
diff --git a/poxml/antlr/antlr/CharBuffer.hpp b/poxml/antlr/antlr/CharBuffer.hpp
new file mode 100644
index 00000000..45d467bb
--- /dev/null
+++ b/poxml/antlr/antlr/CharBuffer.hpp
@@ -0,0 +1,75 @@
+#ifndef INC_CharBuffer_hpp__
+#define INC_CharBuffer_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+/**A Stream of characters fed to the lexer from a InputStream that can
+ * be rewound via mark()/rewind() methods.
+ * <p>
+ * A dynamic array is used to buffer up all the input characters. Normally,
+ * "k" characters are stored in the buffer. More characters may be stored during
+ * guess mode (testing syntactic predicate), or when LT(i>k) is referenced.
+ * Consumption of characters is deferred. In other words, reading the next
+ * character is not done by conume(), but deferred until needed by LA or LT.
+ * <p>
+ *
+ * @see antlr.CharQueue
+ */
+
+#include "antlr/config.hpp"
+#include "antlr/InputBuffer.hpp"
+#include <iostream>
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+class CharBuffer : public InputBuffer {
+private:
+ // char source
+ ANTLR_USE_NAMESPACE(std)istream& input;
+
+public:
+ /** Create a character buffer */
+ CharBuffer(ANTLR_USE_NAMESPACE(std)istream& input_);
+
+ /** Get the next character from the stream */
+ int getChar();
+
+private:
+// Not implemented.
+// CharBuffer(const CharBuffer& other);
+// CharBuffer& operator=(const CharBuffer& other);
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_CharBuffer_hpp__
diff --git a/poxml/antlr/antlr/CharScanner.hpp b/poxml/antlr/antlr/CharScanner.hpp
new file mode 100644
index 00000000..b0ab9276
--- /dev/null
+++ b/poxml/antlr/antlr/CharScanner.hpp
@@ -0,0 +1,265 @@
+#ifndef INC_CharScanner_hpp__
+#define INC_CharScanner_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * $Id$
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/config.hpp"
+#include "antlr/TokenStream.hpp"
+#include "antlr/RecognitionException.hpp"
+#include "antlr/InputBuffer.hpp"
+#include "antlr/BitSet.hpp"
+#include "antlr/LexerSharedInputState.hpp"
+#include <map>
+#include <cstdio>
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+class CharScanner;
+
+class CharScannerLiteralsLess : public ANTLR_USE_NAMESPACE(std)binary_function<ANTLR_USE_NAMESPACE(std)string,ANTLR_USE_NAMESPACE(std)string,bool> {
+private:
+ const CharScanner* scanner;
+public:
+#ifdef NO_TEMPLATE_PARTS
+ CharScannerLiteralsLess(); // not really used
+#endif
+ CharScannerLiteralsLess(const CharScanner* theScanner);
+ bool operator() (const ANTLR_USE_NAMESPACE(std)string& x,const ANTLR_USE_NAMESPACE(std)string& y) const;
+private:
+// CharScannerLiteralsLess(const CharScannerLiteralsLess&);
+// CharScannerLiteralsLess& operator=(const CharScannerLiteralsLess&);
+};
+
+class CharScanner : public TokenStream {
+private:
+#ifndef NO_STATIC_CONSTS
+ static const int NO_CHAR = 0;
+#else
+ enum {
+ NO_CHAR = 0
+ };
+#endif
+
+public:
+#ifndef NO_STATIC_CONSTS
+ static const int EOF_CHAR = EOF;
+#else
+ enum {
+ EOF_CHAR = EOF
+ };
+#endif
+
+protected:
+ ANTLR_USE_NAMESPACE(std)string text; // text of current token
+
+ bool saveConsumedInput; // does consume() save characters?
+
+ typedef RefToken (*factory_type)();
+ factory_type tokenFactory; // what kind of tokens to create?
+
+ bool caseSensitive;
+ ANTLR_USE_NAMESPACE(std)map<ANTLR_USE_NAMESPACE(std)string,int,CharScannerLiteralsLess> literals; // set by subclass
+
+ RefToken _returnToken; // used to return tokens w/o using return val
+
+ // Input chars
+ LexerSharedInputState inputState;
+
+ /** Used during filter mode to indicate that path is desired.
+ * A subsequent scan error will report an error as usual if acceptPath=true;
+ */
+ bool commitToPath;
+
+public:
+ CharScanner();
+
+ CharScanner(InputBuffer& cb);
+ CharScanner(InputBuffer* cb);
+
+ CharScanner(const LexerSharedInputState& state);
+
+ virtual ~CharScanner();
+
+ virtual void append(char c);
+
+ virtual void append(const ANTLR_USE_NAMESPACE(std)string& s);
+
+ virtual void commit();
+
+ virtual void consume();
+
+ /** Consume chars until one matches the given char */
+ virtual void consumeUntil(int c);
+
+ /** Consume chars until one matches the given set */
+ virtual void consumeUntil(const BitSet& set);
+
+ virtual bool getCaseSensitive() const;
+
+ virtual bool getCaseSensitiveLiterals() const=0;
+
+ virtual int getColumn() const;
+
+ virtual void setColumn(int c);
+
+ virtual bool getCommitToPath() const;
+
+ virtual const ANTLR_USE_NAMESPACE(std)string& getFilename() const;
+
+ virtual InputBuffer& getInputBuffer();
+
+ virtual LexerSharedInputState getInputState();
+
+ virtual int getLine() const;
+
+ /** return a copy of the current text buffer */
+ virtual const ANTLR_USE_NAMESPACE(std)string& getText() const;
+
+ virtual RefToken getTokenObject() const;
+
+ virtual int LA(int i);
+
+protected:
+ virtual RefToken makeToken(int t);
+
+public:
+ virtual int mark();
+
+ virtual void match(int c);
+
+ virtual void match(const BitSet& b);
+
+ virtual void match(const ANTLR_USE_NAMESPACE(std)string& s);
+
+ virtual void matchNot(int c);
+
+ virtual void matchRange(int c1, int c2);
+
+ virtual void newline();
+
+ virtual void tab();
+
+ void panic();
+
+ void panic(const ANTLR_USE_NAMESPACE(std)string& s);
+
+ /** Report exception errors caught in nextToken() */
+ virtual void reportError(const RecognitionException& e);
+
+ /** Parser error-reporting function can be overridden in subclass */
+ virtual void reportError(const ANTLR_USE_NAMESPACE(std)string& s);
+
+ /** Parser warning-reporting function can be overridden in subclass */
+ virtual void reportWarning(const ANTLR_USE_NAMESPACE(std)string& s);
+
+ virtual void resetText();
+
+ virtual void rewind(int pos);
+
+ virtual void setCaseSensitive(bool t);
+
+ virtual void setCommitToPath(bool commit);
+
+ virtual void setFilename(const ANTLR_USE_NAMESPACE(std)string& f);
+
+ virtual void setInputState(LexerSharedInputState state);
+
+ virtual void setLine(int l);
+
+ virtual void setText(const ANTLR_USE_NAMESPACE(std)string& s);
+
+ virtual void setTokenObjectFactory(factory_type factory);
+
+ // Test the token text against the literals table
+ // Override this method to perform a different literals test
+ virtual int testLiteralsTable(int ttype) const;
+
+ // Test the text passed in against the literals table
+ // Override this method to perform a different literals test
+ // This is used primarily when you want to test a portion of
+ // a token
+ virtual int testLiteralsTable(const ANTLR_USE_NAMESPACE(std)string& text,int ttype) const;
+
+ // Override this method to get more specific case handling
+ virtual int toLower(int c) const;
+
+protected:
+ class Tracer {
+ private:
+ CharScanner* parser;
+ ANTLR_USE_NAMESPACE(std)string text;
+ public:
+ Tracer(CharScanner* p,const ANTLR_USE_NAMESPACE(std)string& t)
+ : parser(p), text(t) { parser->traceIn(text); }
+ ~Tracer()
+ { parser->traceOut(text); }
+ };
+
+ int traceDepth;
+public:
+ virtual void traceIndent();
+ virtual void traceIn(const ANTLR_USE_NAMESPACE(std)string& rname);
+ virtual void traceOut(const ANTLR_USE_NAMESPACE(std)string& rname);
+
+ /* This method is called by YourLexer::nextToken() when the lexer has
+ * hit EOF condition. EOF is NOT a character.
+ * This method is not called if EOF is reached during
+ * syntactic predicate evaluation or during evaluation
+ * of normal lexical rules, which presumably would be
+ * an IOException. This traps the "normal" EOF condition.
+ *
+ * uponEOF() is called after the complete evaluation of
+ * the previous token and only if your parser asks
+ * for another token beyond that last non-EOF token.
+ *
+ * You might want to throw token or char stream exceptions
+ * like: "Heh, premature eof" or a retry stream exception
+ * ("I found the end of this file, go back to referencing file").
+ */
+ virtual void uponEOF();
+};
+
+inline int CharScanner::LA(int i)
+{
+ if ( caseSensitive ) {
+ return inputState->getInput().LA(i);
+ } else {
+ return toLower(inputState->getInput().LA(i));
+ }
+}
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_CharScanner_hpp__
diff --git a/poxml/antlr/antlr/CharStreamException.hpp b/poxml/antlr/antlr/CharStreamException.hpp
new file mode 100644
index 00000000..33f52061
--- /dev/null
+++ b/poxml/antlr/antlr/CharStreamException.hpp
@@ -0,0 +1,18 @@
+#ifndef INC_CharStreamException_hpp__
+#define INC_CharStreamException_hpp__
+
+#include "antlr/config.hpp"
+#include "antlr/ANTLRException.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+class CharStreamException : public ANTLRException {
+public:
+ CharStreamException(const ANTLR_USE_NAMESPACE(std)string& s)
+ : ANTLRException(s) {}
+ ~CharStreamException() throw() {}
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_CharStreamException_hpp__
diff --git a/poxml/antlr/antlr/CharStreamIOException.hpp b/poxml/antlr/antlr/CharStreamIOException.hpp
new file mode 100644
index 00000000..1a8b1d1e
--- /dev/null
+++ b/poxml/antlr/antlr/CharStreamIOException.hpp
@@ -0,0 +1,20 @@
+#ifndef INC_CharStreamIOException_hpp__
+#define INC_CharStreamIOException_hpp__
+
+#include "antlr/config.hpp"
+#include "antlr/CharStreamException.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+class CharStreamIOException : public CharStreamException {
+public:
+ ANTLR_USE_NAMESPACE(std)exception io;
+
+ CharStreamIOException(ANTLR_USE_NAMESPACE(std)exception& e)
+ : CharStreamException(e.what()), io(e) {}
+ ~CharStreamIOException() throw() {}
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_CharStreamIOException_hpp__
diff --git a/poxml/antlr/antlr/CircularQueue.hpp b/poxml/antlr/antlr/CircularQueue.hpp
new file mode 100644
index 00000000..eadf8d42
--- /dev/null
+++ b/poxml/antlr/antlr/CircularQueue.hpp
@@ -0,0 +1,88 @@
+#ifndef INC_CircularQueue_hpp__
+#define INC_CircularQueue_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/config.hpp"
+#include <vector>
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+// Resize every 5000 items
+#define OFFSET_MAX_RESIZE 5000
+
+template <class T>
+class CircularQueue {
+private:
+ ANTLR_USE_NAMESPACE(std)vector<T> storage;
+
+public:
+ CircularQueue()
+ : storage(), m_offset(0) {}
+ ~CircularQueue()
+ {}
+
+ T elementAt(int idx) const
+ { return storage[idx+m_offset]; } //Is this safe?
+ void removeFirst()
+ {
+ if (m_offset >= OFFSET_MAX_RESIZE) {
+ storage.erase( storage.begin(), storage.begin() + m_offset + 1 );
+ m_offset = 0;
+ } else {
+ ++m_offset;
+ }
+ }
+ inline void removeItems( int nb )
+ {
+ if (m_offset >= OFFSET_MAX_RESIZE) {
+ storage.erase( storage.begin(), storage.begin() + m_offset + nb );
+ m_offset = 0;
+ } else {
+ m_offset+=nb;
+ }
+ }
+ void append(const T& t)
+ { storage.push_back(t); }
+ int entries() const
+ { return storage.size()-m_offset; }
+
+private:
+ int m_offset;
+ CircularQueue(const CircularQueue&);
+ const CircularQueue& operator=(const CircularQueue&);
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_CircularQueue_hpp__
diff --git a/poxml/antlr/antlr/CommonAST.hpp b/poxml/antlr/antlr/CommonAST.hpp
new file mode 100644
index 00000000..c7ab7313
--- /dev/null
+++ b/poxml/antlr/antlr/CommonAST.hpp
@@ -0,0 +1,68 @@
+#ifndef INC_CommonAST_hpp__
+#define INC_CommonAST_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/config.hpp"
+#include "antlr/BaseAST.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+class CommonAST : public BaseAST {
+public:
+ CommonAST();
+ CommonAST(RefToken t);
+ virtual ~CommonAST();
+
+ virtual ANTLR_USE_NAMESPACE(std)string getText() const;
+ virtual int getType() const;
+
+ virtual void initialize(int t,const ANTLR_USE_NAMESPACE(std)string& txt);
+ virtual void initialize(RefAST t);
+ virtual void initialize(RefToken t);
+
+ virtual void setText(const ANTLR_USE_NAMESPACE(std)string& txt);
+ virtual void setType(int type);
+
+ static RefAST factory();
+
+protected:
+ int ttype;
+ ANTLR_USE_NAMESPACE(std)string text;
+};
+
+typedef ASTRefCount<CommonAST> RefCommonAST;
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_CommonAST_hpp__
diff --git a/poxml/antlr/antlr/CommonASTWithHiddenTokens.hpp b/poxml/antlr/antlr/CommonASTWithHiddenTokens.hpp
new file mode 100644
index 00000000..11e030e7
--- /dev/null
+++ b/poxml/antlr/antlr/CommonASTWithHiddenTokens.hpp
@@ -0,0 +1,41 @@
+#ifndef INC_CommonASTWithHiddenTokens_hpp__
+#define INC_CommonASTWithHiddenTokens_hpp__
+
+/** A CommonAST whose initialization copies hidden token
+ * information from the Token used to create a node.
+ */
+
+#include "antlr/config.hpp"
+#include "antlr/CommonAST.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+class CommonASTWithHiddenTokens : public CommonAST {
+public:
+ CommonASTWithHiddenTokens() : CommonAST()
+ {
+ }
+ virtual ~CommonASTWithHiddenTokens()
+ {
+ }
+protected:
+ RefToken hiddenBefore,hiddenAfter; // references to hidden tokens
+public:
+ virtual RefToken getHiddenAfter() const
+ { return hiddenAfter; }
+ virtual RefToken getHiddenBefore() const
+ { return hiddenBefore; }
+
+ // Borland C++ builder seems to need the decl's of the first two...
+ virtual void initialize(int t,const ANTLR_USE_NAMESPACE(std)string& txt);
+ virtual void initialize(RefAST t);
+ virtual void initialize(RefToken t);
+
+ static RefAST factory();
+};
+
+typedef ASTRefCount<CommonASTWithHiddenTokens> RefCommonASTWithHiddenTokens;
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_CommonASTWithHiddenTokens_hpp__
diff --git a/poxml/antlr/antlr/CommonHiddenStreamToken.hpp b/poxml/antlr/antlr/CommonHiddenStreamToken.hpp
new file mode 100644
index 00000000..50ff2354
--- /dev/null
+++ b/poxml/antlr/antlr/CommonHiddenStreamToken.hpp
@@ -0,0 +1,30 @@
+#ifndef INC_CommonHiddenStreamToken_hpp__
+#define INC_CommonHiddenStreamToken_hpp__
+
+#include "antlr/config.hpp"
+#include "antlr/CommonToken.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+class CommonHiddenStreamToken : public CommonToken {
+protected:
+ RefToken hiddenBefore;
+ RefToken hiddenAfter;
+
+public:
+ CommonHiddenStreamToken();
+ CommonHiddenStreamToken(int t, const ANTLR_USE_NAMESPACE(std)string& txt);
+ CommonHiddenStreamToken(const ANTLR_USE_NAMESPACE(std)string& s);
+
+ RefToken getHiddenAfter();
+ RefToken getHiddenBefore();
+
+ static RefToken factory();
+
+ void setHiddenAfter(RefToken t);
+ void setHiddenBefore(RefToken t);
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_CommonHiddenStreamToken_hpp__
diff --git a/poxml/antlr/antlr/CommonToken.hpp b/poxml/antlr/antlr/CommonToken.hpp
new file mode 100644
index 00000000..669aa535
--- /dev/null
+++ b/poxml/antlr/antlr/CommonToken.hpp
@@ -0,0 +1,77 @@
+#ifndef INC_CommonToken_hpp__
+#define INC_CommonToken_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/config.hpp"
+#include "antlr/Token.hpp"
+#include <string>
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+class CommonToken : public Token {
+protected:
+ // most tokens will want line and text information
+ int line;
+ int col;
+ ANTLR_USE_NAMESPACE(std)string text;
+
+public:
+ CommonToken();
+ CommonToken(int t, const ANTLR_USE_NAMESPACE(std)string& txt);
+ CommonToken(const ANTLR_USE_NAMESPACE(std)string& s);
+
+ int getLine() const;
+ ANTLR_USE_NAMESPACE(std)string getText() const;
+ void setLine(int l);
+ void setText(const ANTLR_USE_NAMESPACE(std)string& s);
+
+ ANTLR_USE_NAMESPACE(std)string toString() const;
+
+ /** Return token's start column */
+ int getColumn() const;
+
+ void setColumn(int c);
+
+ bool isInvalid() const;
+
+ static RefToken factory();
+
+private:
+ CommonToken(const CommonToken&);
+ const CommonToken& operator=(const CommonToken&);
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_CommonToken_hpp__
diff --git a/poxml/antlr/antlr/InputBuffer.hpp b/poxml/antlr/antlr/InputBuffer.hpp
new file mode 100644
index 00000000..96e62191
--- /dev/null
+++ b/poxml/antlr/antlr/InputBuffer.hpp
@@ -0,0 +1,158 @@
+#ifndef INC_InputBuffer_hpp__
+#define INC_InputBuffer_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+/**A Stream of characters fed to the lexer from a InputStream that can
+ * be rewound via mark()/rewind() methods.
+ * <p>
+ * A dynamic array is used to buffer up all the input characters. Normally,
+ * "k" characters are stored in the buffer. More characters may be stored during
+ * guess mode (testing syntactic predicate), or when LT(i>k) is referenced.
+ * Consumption of characters is deferred. In other words, reading the next
+ * character is not done by conume(), but deferred until needed by LA or LT.
+ * <p>
+ *
+ * @see antlr.CharQueue
+ */
+
+#include "antlr/config.hpp"
+#include "antlr/CircularQueue.hpp"
+#include <string>
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+class InputBuffer {
+protected:
+ // char source
+ // leave to subclasses
+
+ // Number of active markers
+ int nMarkers; // = 0;
+
+ // Additional offset used when markers are active
+ int markerOffset; // = 0;
+
+ // Number of calls to consume() since last LA() or LT() call
+ int numToConsume; // = 0;
+
+ // Circular queue
+ CircularQueue<int> queue;
+
+public:
+ /** Create a character buffer */
+ InputBuffer();
+
+ virtual ~InputBuffer() {}
+
+ /** This method updates the state of the input buffer so that
+ * the text matched since the most recent mark() is no longer
+ * held by the buffer. So, you either do a mark/rewind for
+ * failed predicate or mark/commit to keep on parsing without
+ * rewinding the input.
+ */
+ void commit();
+
+ /** Mark another character for deferred consumption */
+ virtual void consume();
+
+ /** Ensure that the character buffer is sufficiently full */
+ virtual void fill(int amount);
+
+ /** Override this in subclasses to get the next character */
+ virtual int getChar()=0;
+
+ ANTLR_USE_NAMESPACE(std)string getLAChars() const;
+
+ ANTLR_USE_NAMESPACE(std)string getMarkedChars() const;
+
+ virtual bool isMarked() const;
+
+ /** Get a lookahead character */
+ virtual int LA(int i);
+
+ /**Return an integer marker that can be used to rewind the buffer to
+ * its current state.
+ */
+ virtual int mark();
+
+ /**Rewind the character buffer to a marker.
+ * @param mark Marker returned previously from mark()
+ */
+ virtual void rewind(int mark);
+
+protected:
+ /** Sync up deferred consumption */
+ void syncConsume();
+
+private:
+ InputBuffer(const InputBuffer& other);
+ InputBuffer& operator=(const InputBuffer& other);
+};
+
+/** Sync up deferred consumption */
+inline void InputBuffer::syncConsume() {
+#ifdef OLD_CODE
+ while (numToConsume > 0) {
+ if (nMarkers > 0)
+ {
+ // guess mode -- leave leading characters and bump offset.
+ markerOffset++;
+ } else {
+ // normal mode -- remove first character
+ queue.removeFirst();
+ }
+ numToConsume--;
+ }
+#endif
+
+ if (numToConsume > 0) {
+ if (nMarkers > 0) {
+ markerOffset += numToConsume;
+ } else {
+ queue.removeItems( numToConsume );
+ }
+ numToConsume = 0;
+ }
+}
+
+/** Get a lookahead character */
+inline int InputBuffer::LA(int i)
+{
+ fill(i);
+ return queue.elementAt(markerOffset + i - 1);
+}
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_InputBuffer_hpp__
diff --git a/poxml/antlr/antlr/LLkParser.hpp b/poxml/antlr/antlr/LLkParser.hpp
new file mode 100644
index 00000000..8b8db188
--- /dev/null
+++ b/poxml/antlr/antlr/LLkParser.hpp
@@ -0,0 +1,82 @@
+#ifndef INC_LLkParser_hpp__
+#define INC_LLkParser_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/config.hpp"
+#include "antlr/Parser.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/**An LL(k) parser.
+ *
+ * @see antlr.Token
+ * @see antlr.TokenBuffer
+ * @see antlr.LL1Parser
+ */
+class LLkParser : public Parser {
+protected:
+ int k;
+
+public:
+// LLkParser(int k_);
+
+ LLkParser(const ParserSharedInputState& lexer, int k_);
+
+ LLkParser(TokenBuffer& tokenBuf, int k_);
+
+ LLkParser(TokenStream& lexer, int k_);
+
+ /**Consume another token from the input stream. Can only write sequentially!
+ * If you need 3 tokens ahead, you must consume() 3 times.
+ * <p>
+ * Note that it is possible to overwrite tokens that have not been matched.
+ * For example, calling consume() 3 times when k=2, means that the first token
+ * consumed will be overwritten with the 3rd.
+ */
+ void consume();
+
+ int LA(int i);
+
+ RefToken LT(int i);
+
+private:
+ void trace(const ANTLR_USE_NAMESPACE(std)string& ee, const ANTLR_USE_NAMESPACE(std)string& rname);
+public:
+ void traceIn(const ANTLR_USE_NAMESPACE(std)string& rname);
+ void traceOut(const ANTLR_USE_NAMESPACE(std)string& rname);
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_LLkParser_hpp__
diff --git a/poxml/antlr/antlr/LexerSharedInputState.hpp b/poxml/antlr/antlr/LexerSharedInputState.hpp
new file mode 100644
index 00000000..dba2a5f4
--- /dev/null
+++ b/poxml/antlr/antlr/LexerSharedInputState.hpp
@@ -0,0 +1,49 @@
+#ifndef INC_LexerSharedInputState_hpp__
+#define INC_LexerSharedInputState_hpp__
+
+#include "antlr/config.hpp"
+#include "antlr/InputBuffer.hpp"
+#include "antlr/RefCount.hpp"
+#include <string>
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/** This object contains the data associated with an
+ * input stream of characters. Multiple lexers
+ * share a single LexerSharedInputState to lex
+ * the same input stream.
+ */
+class LexerInputState {
+public:
+ LexerInputState(InputBuffer* inbuf);
+ LexerInputState(InputBuffer& inbuf);
+ LexerInputState(ANTLR_USE_NAMESPACE(std)istream& in);
+ ~LexerInputState();
+
+ int column;
+ int line;
+ int tokenStartColumn;
+ int tokenStartLine;
+ int guessing;
+ /** What file (if known) caused the problem? */
+ ANTLR_USE_NAMESPACE(std)string filename;
+ InputBuffer& getInput();
+private:
+ InputBuffer* input;
+ bool inputResponsible;
+
+ // we don't want these:
+ LexerInputState(const LexerInputState&);
+ LexerInputState& operator=(const LexerInputState&);
+};
+
+typedef RefCount<LexerInputState> LexerSharedInputState;
+
+inline InputBuffer& LexerInputState::getInput()
+{
+ return *input;
+}
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_LexerSharedInputState_hpp__
diff --git a/poxml/antlr/antlr/Makefile.am b/poxml/antlr/antlr/Makefile.am
new file mode 100644
index 00000000..bafa1347
--- /dev/null
+++ b/poxml/antlr/antlr/Makefile.am
@@ -0,0 +1,45 @@
+noinst_HEADERS = \
+ ANTLRException.hpp \
+ AST.hpp \
+ ASTArray.hpp \
+ ASTFactory.hpp \
+ ASTNULLType.hpp \
+ ASTPair.hpp \
+ ASTRefCount.hpp \
+ BaseAST.hpp \
+ BitSet.hpp \
+ CharBuffer.hpp \
+ CharScanner.hpp \
+ CharStreamException.hpp \
+ CharStreamIOException.hpp \
+ CircularQueue.hpp \
+ CommonAST.hpp \
+ CommonASTWithHiddenTokens.hpp \
+ CommonHiddenStreamToken.hpp \
+ CommonToken.hpp \
+ InputBuffer.hpp \
+ LLkParser.hpp \
+ LexerSharedInputState.hpp \
+ MismatchedCharException.hpp \
+ MismatchedTokenException.hpp \
+ NoViableAltException.hpp \
+ NoViableAltForCharException.hpp \
+ Parser.hpp \
+ ParserSharedInputState.hpp \
+ RecognitionException.hpp \
+ RefCount.hpp \
+ SemanticException.hpp \
+ String.hpp \
+ Token.hpp \
+ TokenBuffer.hpp \
+ TokenStream.hpp \
+ TokenStreamBasicFilter.hpp \
+ TokenStreamException.hpp \
+ TokenStreamHiddenTokenFilter.hpp \
+ TokenStreamIOException.hpp \
+ TokenStreamRecognitionException.hpp \
+ TokenStreamRetryException.hpp \
+ TokenStreamSelector.hpp \
+ TreeParser.hpp \
+ TreeParserSharedInputState.hpp \
+ config.hpp
diff --git a/poxml/antlr/antlr/MismatchedCharException.hpp b/poxml/antlr/antlr/MismatchedCharException.hpp
new file mode 100644
index 00000000..ea923a9d
--- /dev/null
+++ b/poxml/antlr/antlr/MismatchedCharException.hpp
@@ -0,0 +1,127 @@
+#ifndef INC_MismatchedCharException_hpp__
+#define INC_MismatchedCharException_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/config.hpp"
+#include "antlr/RecognitionException.hpp"
+#include "antlr/BitSet.hpp"
+#include "antlr/CharScanner.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+class MismatchedCharException : public RecognitionException {
+public:
+ // Types of chars
+#ifndef NO_STATIC_CONSTS
+ static const int CHAR = 1;
+ static const int NOT_CHAR = 2;
+ static const int RANGE = 3;
+ static const int NOT_RANGE = 4;
+ static const int SET = 5;
+ static const int NOT_SET = 6;
+#else
+ enum {
+ CHAR = 1,
+ NOT_CHAR = 2,
+ RANGE = 3,
+ NOT_RANGE = 4,
+ SET = 5,
+ NOT_SET = 6
+ };
+#endif
+
+public:
+ // One of the above
+ int mismatchType;
+
+ // what was found on the input stream
+ int foundChar;
+
+ // For CHAR/NOT_CHAR and RANGE/NOT_RANGE
+ int expecting;
+
+ // For RANGE/NOT_RANGE (expecting is lower bound of range)
+ int upper;
+
+ // For SET/NOT_SET
+ BitSet set;
+
+protected:
+ // who knows...they may want to ask scanner questions
+ CharScanner* scanner;
+
+public:
+ MismatchedCharException();
+
+ // Expected range / not range
+ MismatchedCharException(
+ int c,
+ int lower,
+ int upper_,
+ bool matchNot,
+ CharScanner* scanner_
+ );
+
+ // Expected token / not token
+ MismatchedCharException(
+ int c,
+ int expecting_,
+ bool matchNot,
+ CharScanner* scanner_
+ );
+
+ // Expected BitSet / not BitSet
+ MismatchedCharException(
+ int c,
+ BitSet set_,
+ bool matchNot,
+ CharScanner* scanner_
+ );
+
+ MismatchedCharException(
+ const ANTLR_USE_NAMESPACE(std)string& s,
+ int line
+ );
+ ~MismatchedCharException() throw() {}
+
+ /**
+ * Returns the error message that happened on the line/col given.
+ * Copied from toString().
+ */
+ ANTLR_USE_NAMESPACE(std)string getMessage() const;
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_MismatchedCharException_hpp__
diff --git a/poxml/antlr/antlr/MismatchedTokenException.hpp b/poxml/antlr/antlr/MismatchedTokenException.hpp
new file mode 100644
index 00000000..ae4a82cd
--- /dev/null
+++ b/poxml/antlr/antlr/MismatchedTokenException.hpp
@@ -0,0 +1,167 @@
+#ifndef INC_MismatchedTokenException_hpp__
+#define INC_MismatchedTokenException_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/config.hpp"
+#include "antlr/RecognitionException.hpp"
+#include "antlr/BitSet.hpp"
+#include "antlr/Token.hpp"
+#include "antlr/AST.hpp"
+#include <vector>
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+class MismatchedTokenException : public RecognitionException {
+private:
+ // Token names array for formatting
+ ANTLR_USE_NAMESPACE(std)vector<ANTLR_USE_NAMESPACE(std)string> tokenNames;
+
+public:
+ // The token that was encountered
+ const RefToken token;
+ // The offending AST node if tree walking
+ const RefAST node;
+
+ ANTLR_USE_NAMESPACE(std)string tokenText; // taken from node or token object
+
+ // Types of tokens
+#ifndef NO_STATIC_CONSTS
+ static const int TOKEN = 1;
+ static const int NOT_TOKEN = 2;
+ static const int RANGE = 3;
+ static const int NOT_RANGE = 4;
+ static const int SET = 5;
+ static const int NOT_SET = 6;
+#else
+ enum {
+ TOKEN = 1,
+ NOT_TOKEN = 2,
+ RANGE = 3,
+ NOT_RANGE = 4,
+ SET = 5,
+ NOT_SET = 6
+ };
+#endif
+
+public:
+ // One of the above
+ int mismatchType;
+
+ // For TOKEN/NOT_TOKEN and RANGE/NOT_RANGE
+ int expecting;
+
+ // For RANGE/NOT_RANGE (expecting is lower bound of range)
+ int upper;
+
+ // For SET/NOT_SET
+ BitSet set;
+
+ MismatchedTokenException();
+
+ // Expected range / not range
+ MismatchedTokenException(
+ const ANTLR_USE_NAMESPACE(std)vector<ANTLR_USE_NAMESPACE(std)string>& tokenNames_,
+ RefAST node_,
+ int lower,
+ int upper_,
+ bool matchNot
+ );
+
+ // Expected token / not token
+ MismatchedTokenException(
+ const ANTLR_USE_NAMESPACE(std)vector<ANTLR_USE_NAMESPACE(std)string>& tokenNames_,
+ RefAST node_,
+ int expecting_,
+ bool matchNot
+ );
+
+ // Expected BitSet / not BitSet
+ MismatchedTokenException(
+ const ANTLR_USE_NAMESPACE(std)vector<ANTLR_USE_NAMESPACE(std)string>& tokenNames_,
+ RefAST node_,
+ BitSet set_,
+ bool matchNot
+ );
+
+ // Expected range / not range
+ MismatchedTokenException(
+ const ANTLR_USE_NAMESPACE(std)vector<ANTLR_USE_NAMESPACE(std)string>& tokenNames_,
+ RefToken token_,
+ int lower,
+ int upper_,
+ bool matchNot,
+ const ANTLR_USE_NAMESPACE(std)string& fileName_
+ );
+
+ // Expected token / not token
+ MismatchedTokenException(
+ const ANTLR_USE_NAMESPACE(std)vector<ANTLR_USE_NAMESPACE(std)string>& tokenNames_,
+ RefToken token_,
+ int expecting_,
+ bool matchNot,
+ const ANTLR_USE_NAMESPACE(std)string& fileName_
+ );
+
+ // Expected BitSet / not BitSet
+ MismatchedTokenException(
+ const ANTLR_USE_NAMESPACE(std)vector<ANTLR_USE_NAMESPACE(std)string>& tokenNames_,
+ RefToken token_,
+ BitSet set_,
+ bool matchNot,
+ const ANTLR_USE_NAMESPACE(std)string& fileName_
+ );
+ ~MismatchedTokenException() throw() {}
+
+ /**
+ * @deprecated As of ANTLR 2.7.0
+ */
+ ANTLR_USE_NAMESPACE(std)string getErrorMessage() const;
+
+ /**
+ * Returns the error message that happened on the line/col given.
+ * Copied from toString().
+ */
+ ANTLR_USE_NAMESPACE(std)string getMessage() const;
+
+private:
+ ANTLR_USE_NAMESPACE(std)string tokenName(int tokenType) const;
+
+public:
+ ANTLR_USE_NAMESPACE(std)string toString() const;
+
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_MismatchedTokenException_hpp__
diff --git a/poxml/antlr/antlr/NoViableAltException.hpp b/poxml/antlr/antlr/NoViableAltException.hpp
new file mode 100644
index 00000000..f85bcf96
--- /dev/null
+++ b/poxml/antlr/antlr/NoViableAltException.hpp
@@ -0,0 +1,71 @@
+#ifndef INC_NoViableAltException_hpp__
+#define INC_NoViableAltException_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/config.hpp"
+#include "antlr/RecognitionException.hpp"
+#include "antlr/Token.hpp"
+#include "antlr/AST.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+class NoViableAltException : public RecognitionException {
+public:
+ const RefToken token;
+ const RefAST node; // handles parsing and treeparsing
+
+ NoViableAltException(RefAST t);
+
+ NoViableAltException(RefToken t,const ANTLR_USE_NAMESPACE(std)string& fileName_);
+ ~NoViableAltException() throw() {}
+
+ /**
+ * @deprecated As of ANTLR 2.7.0
+ */
+ ANTLR_USE_NAMESPACE(std)string getErrorMessage() const;
+
+ /**
+ * Returns a clean error message (no line number/column information)
+ */
+ ANTLR_USE_NAMESPACE(std)string getMessage() const;
+
+ /**
+ * Returns a string representation of this exception.
+ */
+ virtual ANTLR_USE_NAMESPACE(std)string toString() const;
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_NoViableAltException_hpp__
diff --git a/poxml/antlr/antlr/NoViableAltForCharException.hpp b/poxml/antlr/antlr/NoViableAltForCharException.hpp
new file mode 100644
index 00000000..756e9c7f
--- /dev/null
+++ b/poxml/antlr/antlr/NoViableAltForCharException.hpp
@@ -0,0 +1,64 @@
+#ifndef INC_NoViableAltForCharException_hpp__
+#define INC_NoViableAltForCharException_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Institute
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Institute
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/config.hpp"
+#include "antlr/RecognitionException.hpp"
+#include "antlr/CharScanner.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+class NoViableAltForCharException : public RecognitionException {
+public:
+ int foundChar;
+
+ NoViableAltForCharException(int c, CharScanner* scanner);
+
+ NoViableAltForCharException(int c, const ANTLR_USE_NAMESPACE(std)string& fileName_, int line_);
+ ~NoViableAltForCharException() throw() {}
+
+ /**
+ * @deprecated As of ANTLR 2.7.0
+ */
+ virtual ANTLR_USE_NAMESPACE(std)string getErrorMessage() const;
+
+ /**
+ * Returns a clean error message (no line number/column information)
+ */
+ virtual ANTLR_USE_NAMESPACE(std)string getMessage() const;
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_NoViableAltForCharException_hpp__
diff --git a/poxml/antlr/antlr/Parser.hpp b/poxml/antlr/antlr/Parser.hpp
new file mode 100644
index 00000000..767953d3
--- /dev/null
+++ b/poxml/antlr/antlr/Parser.hpp
@@ -0,0 +1,213 @@
+#ifndef INC_Parser_hpp__
+#define INC_Parser_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/config.hpp"
+#include "antlr/BitSet.hpp"
+#include "antlr/TokenBuffer.hpp"
+#include "antlr/RecognitionException.hpp"
+#include "antlr/ASTFactory.hpp"
+#include "antlr/ParserSharedInputState.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/**A generic ANTLR parser (LL(k) for k>=1) containing a bunch of
+ * utility routines useful at any lookahead depth. We distinguish between
+ * the LL(1) and LL(k) parsers because of efficiency. This may not be
+ * necessary in the near future.
+ *
+ * Each parser object contains the state of the parse including a lookahead
+ * cache (the form of which is determined by the subclass), whether or
+ * not the parser is in guess mode, where tokens come from, etc...
+ *
+ * <p>
+ * During <b>guess</b> mode, the current lookahead token(s) and token type(s)
+ * cache must be saved because the token stream may not have been informed
+ * to save the token (via <tt>mark</tt>) before the <tt>try</tt> block.
+ * Guessing is started by:
+ * <ol>
+ * <li>saving the lookahead cache.
+ * <li>marking the current position in the TokenBuffer.
+ * <li>increasing the guessing level.
+ * </ol>
+ *
+ * After guessing, the parser state is restored by:
+ * <ol>
+ * <li>restoring the lookahead cache.
+ * <li>rewinding the TokenBuffer.
+ * <li>decreasing the guessing level.
+ * </ol>
+ *
+ * @see antlr.Token
+ * @see antlr.TokenBuffer
+ * @see antlr.TokenStream
+ * @see antlr.LL1Parser
+ * @see antlr.LLkParser
+ */
+
+extern bool DEBUG_PARSER;
+
+class Parser {
+protected:
+ ParserSharedInputState inputState;
+
+ /** Nesting level of registered handlers */
+ // int exceptionLevel;
+
+ /** Table of token type to token names */
+ ANTLR_USE_NAMESPACE(std)vector<ANTLR_USE_NAMESPACE(std)string> tokenNames;
+ /** AST return value for a rule is squirreled away here */
+ RefAST returnAST;
+ /** AST support code; parser and treeparser delegate to this object */
+ ASTFactory astFactory;
+
+// Parser();
+
+ Parser(TokenBuffer& input_);
+ Parser(TokenBuffer* input_);
+
+ Parser(const ParserSharedInputState& state);
+
+public:
+ virtual ~Parser();
+
+protected:
+ void setTokenNames(const char** tokenNames_);
+
+public:
+ /**Get another token object from the token stream */
+ virtual void consume()=0;
+
+ /** Consume tokens until one matches the given token */
+ void consumeUntil(int tokenType);
+
+ /** Consume tokens until one matches the given token set */
+ void consumeUntil(const BitSet& set);
+
+ /** Get the AST return value squirreled away in the parser */
+ RefAST getAST();
+
+ ASTFactory& getASTFactory();
+
+ ANTLR_USE_NAMESPACE(std)string getFilename() const;
+
+ virtual ParserSharedInputState getInputState() const;
+
+ ANTLR_USE_NAMESPACE(std)string getTokenName(int num) const;
+ ANTLR_USE_NAMESPACE(std)vector<ANTLR_USE_NAMESPACE(std)string> getTokenNames() const;
+
+ /** Return the token type of the ith token of lookahead where i=1
+ * is the current token being examined by the parser (i.e., it
+ * has not been matched yet).
+ */
+ virtual int LA(int i)=0;
+
+ /**Return the ith token of lookahead */
+ virtual RefToken LT(int i)=0;
+
+ // Forwarded to TokenBuffer
+ virtual int mark();
+
+ /**Make sure current lookahead symbol matches token type <tt>t</tt>.
+ * Throw an exception upon mismatch, which is catch by either the
+ * error handler or by the syntactic predicate.
+ */
+ void match(int t);
+
+ /**Make sure current lookahead symbol matches the given set
+ * Throw an exception upon mismatch, which is catch by either the
+ * error handler or by the syntactic predicate.
+ */
+ void match(const BitSet& b);
+
+ void matchNot(int t);
+
+ static void panic();
+
+ /** Parser error-reporting function can be overridden in subclass */
+ virtual void reportError(const RecognitionException& ex);
+
+ /** Parser error-reporting function can be overridden in subclass */
+ virtual void reportError(const ANTLR_USE_NAMESPACE(std)string& s);
+
+ /** Parser warning-reporting function can be overridden in subclass */
+ virtual void reportWarning(const ANTLR_USE_NAMESPACE(std)string& s);
+
+ virtual void rewind(int pos);
+
+ /** Set the object used to generate ASTs */
+// void setASTFactory(ASTFactory astFactory_);
+
+ /** Specify the type of node to create during tree building */
+ void setASTNodeFactory(ASTFactory::factory_type factory);
+
+ void setFilename(const ANTLR_USE_NAMESPACE(std)string& f);
+
+ void setInputState(ParserSharedInputState state);
+
+ /** Set or change the input token buffer */
+// void setTokenBuffer(TokenBuffer<Token>* t);
+
+ virtual void traceIndent();
+ virtual void traceIn(const ANTLR_USE_NAMESPACE(std)string& rname);
+ virtual void traceOut(const ANTLR_USE_NAMESPACE(std)string& rname);
+protected:
+ int traceDepth; // used to keep track of the indentation for the trace
+
+protected:
+ /** Utility class which allows tracing to work even when exceptions are
+ * thrown.
+ */
+ class Tracer {
+ private:
+ Parser* parser;
+ ANTLR_USE_NAMESPACE(std)string text;
+ public:
+ Tracer(Parser* p,const ANTLR_USE_NAMESPACE(std)string& t)
+ : parser(p), text(t) { parser->traceIn(text); }
+ ~Tracer()
+ { parser->traceOut(text); }
+ private:
+ Tracer(const Tracer&); // undefined
+ const Tracer& operator=(const Tracer&); // undefined
+ };
+
+private:
+ Parser(const Parser&); // undefined
+ const Parser& operator=(const Parser&); // undefined
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_Parser_hpp__
diff --git a/poxml/antlr/antlr/ParserSharedInputState.hpp b/poxml/antlr/antlr/ParserSharedInputState.hpp
new file mode 100644
index 00000000..b5599954
--- /dev/null
+++ b/poxml/antlr/antlr/ParserSharedInputState.hpp
@@ -0,0 +1,42 @@
+#ifndef INC_ParserSharedInputState_hpp__
+#define INC_ParserSharedInputState_hpp__
+
+#include "antlr/config.hpp"
+#include "antlr/TokenBuffer.hpp"
+#include "antlr/RefCount.hpp"
+#include <string>
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/** This object contains the data associated with an
+ * input stream of tokens. Multiple parsers
+ * share a single ParserSharedInputState to parse
+ * the same stream of tokens.
+ */
+class ParserInputState {
+public:
+ ParserInputState(TokenBuffer* input_);
+ ParserInputState(TokenBuffer& input_);
+ ~ParserInputState();
+
+public:
+ /** Are we guessing (guessing>0)? */
+ int guessing; //= 0;
+ /** What file (if known) caused the problem? */
+ ANTLR_USE_NAMESPACE(std)string filename;
+ TokenBuffer& getInput();
+private:
+ /** Where to get token objects */
+ TokenBuffer* input;
+ bool inputResponsible;
+
+ // we don't want these:
+ ParserInputState(const ParserInputState&);
+ ParserInputState& operator=(const ParserInputState&);
+};
+
+typedef RefCount<ParserInputState> ParserSharedInputState;
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_ParserSharedInputState_hpp__
diff --git a/poxml/antlr/antlr/RecognitionException.hpp b/poxml/antlr/antlr/RecognitionException.hpp
new file mode 100644
index 00000000..c6439111
--- /dev/null
+++ b/poxml/antlr/antlr/RecognitionException.hpp
@@ -0,0 +1,78 @@
+#ifndef INC_RecognitionException_hpp__
+#define INC_RecognitionException_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/config.hpp"
+#include "antlr/ANTLRException.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+class RecognitionException : public ANTLRException {
+public:
+ ANTLR_USE_NAMESPACE(std)string fileName; // not used by treeparsers
+ int line; // not used by treeparsers
+ int column; // not used by treeparsers
+
+ RecognitionException();
+
+ RecognitionException(const ANTLR_USE_NAMESPACE(std)string& s);
+
+ RecognitionException(const ANTLR_USE_NAMESPACE(std)string& s,const ANTLR_USE_NAMESPACE(std)string& fileName_,int line);
+ RecognitionException(const ANTLR_USE_NAMESPACE(std)string& s,const ANTLR_USE_NAMESPACE(std)string& fileName_,int line,int column);
+ ~RecognitionException() throw() {}
+
+ /**
+ * @return the column number that this exception happened on.
+ * @author Shawn P. Vincent (svincent@svincent.com)
+ */
+ virtual int getColumn() const;
+ /**
+ * @deprecated As of ANTLR 2.7.0
+ */
+ virtual ANTLR_USE_NAMESPACE(std)string getErrorMessage() const;
+protected:
+ virtual ANTLR_USE_NAMESPACE(std)string getFileLineString() const;
+public:
+ virtual ANTLR_USE_NAMESPACE(std)string getFilename() const;
+ /**
+ * @return the line number that this exception happened on.
+ * @author Shawn P. Vincent (svincent@svincent.com)
+ */
+ virtual int getLine() const;
+ virtual ANTLR_USE_NAMESPACE(std)string toString() const;
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_RecognitionException_hpp__
diff --git a/poxml/antlr/antlr/RefCount.hpp b/poxml/antlr/antlr/RefCount.hpp
new file mode 100644
index 00000000..9306576b
--- /dev/null
+++ b/poxml/antlr/antlr/RefCount.hpp
@@ -0,0 +1,87 @@
+#ifndef INC_RefCount_hpp__
+#define INC_RefCount_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/config.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+template<class T>
+class RefCount {
+private:
+ struct Ref {
+ T* const ptr;
+ unsigned int count;
+
+ Ref(T* p) : ptr(p), count(1) {}
+ ~Ref() {delete ptr;}
+ Ref* increment() {++count;return this;}
+ bool decrement() {return (--count==0);}
+ private:
+ Ref(const Ref&);
+ Ref& operator=(const Ref&);
+ }* ref;
+
+public:
+ explicit RefCount(T* p=0)
+ : ref(p ? new Ref(p) : 0)
+ {
+ }
+ RefCount(const RefCount<T>& other)
+ : ref(other.ref ? other.ref->increment() : 0)
+ {
+ }
+ ~RefCount()
+ {
+ if (ref && ref->decrement()) delete ref;
+ }
+ RefCount<T>& operator=(const RefCount<T>& other)
+ {
+ Ref* tmp=other.ref ? other.ref->increment() : 0;
+ if (ref && ref->decrement()) delete ref;
+ ref=tmp;
+ return *this;
+ }
+
+ operator T* () const
+ { return ref ? ref->ptr : 0; }
+ T* operator->() const
+ { return ref ? ref->ptr : 0; }
+ T* get() const
+ { return ref ? ref->ptr : 0; }
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_RefCount_hpp__
diff --git a/poxml/antlr/antlr/SemanticException.hpp b/poxml/antlr/antlr/SemanticException.hpp
new file mode 100644
index 00000000..3f1a9447
--- /dev/null
+++ b/poxml/antlr/antlr/SemanticException.hpp
@@ -0,0 +1,52 @@
+#ifndef INC_SemanticException_hpp__
+#define INC_SemanticException_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/config.hpp"
+#include "antlr/RecognitionException.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+class SemanticException : public RecognitionException {
+public:
+ SemanticException(const ANTLR_USE_NAMESPACE(std)string& s)
+ : RecognitionException(s) {}
+ SemanticException(const ANTLR_USE_NAMESPACE(std)string& s,const ANTLR_USE_NAMESPACE(std)string& fileName_,int line_)
+ : RecognitionException(s,fileName_,line_) {}
+ ~SemanticException() throw() {}
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_SemanticException_hpp__
diff --git a/poxml/antlr/antlr/String.hpp b/poxml/antlr/antlr/String.hpp
new file mode 100644
index 00000000..5fac82d6
--- /dev/null
+++ b/poxml/antlr/antlr/String.hpp
@@ -0,0 +1,47 @@
+#ifndef INC_String_hpp__
+#define INC_String_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/config.hpp"
+#include <string>
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+ANTLR_USE_NAMESPACE(std)string operator+(const ANTLR_USE_NAMESPACE(std)string& lhs,int rhs);
+
+ANTLR_USE_NAMESPACE(std)string charName(int ch);
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_String_hpp__
diff --git a/poxml/antlr/antlr/Token.hpp b/poxml/antlr/antlr/Token.hpp
new file mode 100644
index 00000000..b85551c3
--- /dev/null
+++ b/poxml/antlr/antlr/Token.hpp
@@ -0,0 +1,106 @@
+#ifndef INC_Token_hpp__
+#define INC_Token_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/config.hpp"
+#include "antlr/RefCount.hpp"
+#include <string>
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/** A token is minimally a token type. Subclasses can add the text matched
+ * for the token and line info.
+ */
+
+class Token;
+typedef RefCount<Token> RefToken;
+
+class Token {
+public:
+ // constants
+#ifndef NO_STATIC_CONSTS
+ static const int MIN_USER_TYPE = 4;
+ static const int NULL_TREE_LOOKAHEAD = 3;
+ static const int INVALID_TYPE = 0;
+ static const int EOF_TYPE = 1;
+ static const int SKIP = -1;
+#else
+ enum {
+ MIN_USER_TYPE = 4,
+ NULL_TREE_LOOKAHEAD = 3,
+ INVALID_TYPE = 0,
+ EOF_TYPE = 1,
+ SKIP = -1
+ };
+#endif
+
+ // each Token has at least a token type
+ int type; //=INVALID_TYPE;
+
+public:
+ // the illegal token object
+ static RefToken badToken; // = new Token(INVALID_TYPE, "<no text>");
+
+ Token();
+ Token(int t);
+ Token(int t, const ANTLR_USE_NAMESPACE(std)string& txt);
+
+ virtual int getColumn() const;
+ virtual int getLine() const;
+ virtual ANTLR_USE_NAMESPACE(std)string getText() const;
+ virtual int getType() const;
+
+ virtual void setColumn(int c);
+
+ virtual void setLine(int l);
+ virtual void setText(const ANTLR_USE_NAMESPACE(std)string& t);
+ virtual void setType(int t);
+
+ virtual ANTLR_USE_NAMESPACE(std)string toString() const;
+
+ virtual ~Token();
+private:
+ Token(const Token&);
+ const Token& operator=(const Token&);
+};
+
+#ifdef NEEDS_OPERATOR_LESS_THAN
+inline operator<(RefToken l,RefToken r); //{return true;}
+#endif
+
+extern RefToken nullToken;
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_Token_hpp__
diff --git a/poxml/antlr/antlr/TokenBuffer.hpp b/poxml/antlr/antlr/TokenBuffer.hpp
new file mode 100644
index 00000000..b7c1b25f
--- /dev/null
+++ b/poxml/antlr/antlr/TokenBuffer.hpp
@@ -0,0 +1,141 @@
+#ifndef INC_TokenBuffer_hpp__
+#define INC_TokenBuffer_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/config.hpp"
+#include "antlr/TokenStream.hpp"
+#include "antlr/CircularQueue.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/**A Stream of Token objects fed to the parser from a TokenStream that can
+ * be rewound via mark()/rewind() methods.
+ * <p>
+ * A dynamic array is used to buffer up all the input tokens. Normally,
+ * "k" tokens are stored in the buffer. More tokens may be stored during
+ * guess mode (testing syntactic predicate), or when LT(i>k) is referenced.
+ * Consumption of tokens is deferred. In other words, reading the next
+ * token is not done by conume(), but deferred until needed by LA or LT.
+ * <p>
+ *
+ * @see antlr.Token
+ * @see antlr.TokenStream
+ * @see antlr.TokenQueue
+ */
+class TokenBuffer {
+protected:
+ // Token source
+ TokenStream& input;
+
+private:
+ // Number of active markers
+ int nMarkers;
+
+ // Additional offset used when markers are active
+ int markerOffset;
+
+ // Number of calls to consume() since last LA() or LT() call
+ int numToConsume;
+
+ // Circular queue
+ CircularQueue<RefToken> queue;
+
+public:
+ /** Create a token buffer */
+ TokenBuffer(TokenStream& input_);
+
+ /** Mark another token for deferred consumption */
+ void consume();
+
+private:
+ /** Ensure that the token buffer is sufficiently full */
+ void fill(int amount);
+
+public:
+ /** Get a lookahead token value */
+ int LA(int i);
+
+ /** Get a lookahead token */
+ RefToken LT(int i);
+
+ /**Return an integer marker that can be used to rewind the buffer to
+ * its current state.
+ */
+ int mark();
+
+ /**Rewind the token buffer to a marker.
+ * @param mark Marker returned previously from mark()
+ */
+ void rewind(int mark);
+
+private:
+ /** Sync up deferred consumption */
+ void syncConsume();
+
+private:
+ TokenBuffer(const TokenBuffer& other);
+ const TokenBuffer& operator=(const TokenBuffer& other);
+public:
+// virtual ~TokenBuffer() {}
+};
+
+/** Sync up deferred consumption */
+inline void TokenBuffer::syncConsume()
+{
+#ifdef OLD_CODE
+ while (numToConsume > 0) {
+ if (nMarkers > 0) {
+ // guess mode -- leave leading tokens and bump offset.
+ markerOffset++;
+ } else {
+ // normal mode -- remove first token
+ queue.removeFirst();
+ }
+ numToConsume--;
+ }
+#endif
+
+ if (numToConsume > 0) {
+ if (nMarkers > 0) {
+ markerOffset += numToConsume;
+ } else {
+ queue.removeItems( numToConsume );
+ }
+ numToConsume = 0;
+ }
+}
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_TokenBuffer_hpp__
diff --git a/poxml/antlr/antlr/TokenStream.hpp b/poxml/antlr/antlr/TokenStream.hpp
new file mode 100644
index 00000000..e8436419
--- /dev/null
+++ b/poxml/antlr/antlr/TokenStream.hpp
@@ -0,0 +1,54 @@
+#ifndef INC_TokenStream_hpp__
+#define INC_TokenStream_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+/**This interface allows any object to pretend it is a stream
+ * of tokens.
+ * @author Terence Parr, MageLang Institute
+ */
+
+#include "antlr/config.hpp"
+#include "antlr/Token.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+class TokenStream {
+public:
+ virtual RefToken nextToken()=0;
+ virtual ~TokenStream() {}
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_TokenStream_hpp__
diff --git a/poxml/antlr/antlr/TokenStreamBasicFilter.hpp b/poxml/antlr/antlr/TokenStreamBasicFilter.hpp
new file mode 100644
index 00000000..5438878b
--- /dev/null
+++ b/poxml/antlr/antlr/TokenStreamBasicFilter.hpp
@@ -0,0 +1,35 @@
+#ifndef INC_TokenStreamBasicFilter_hpp__
+#define INC_TokenStreamBasicFilter_hpp__
+
+#include "antlr/config.hpp"
+#include "antlr/BitSet.hpp"
+#include "antlr/TokenStream.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/** This object is a TokenStream that passes through all
+ * tokens except for those that you tell it to discard.
+ * There is no buffering of the tokens.
+ */
+class TokenStreamBasicFilter : public TokenStream {
+ /** The set of token types to discard */
+protected:
+ BitSet discardMask;
+
+ /** The input stream */
+protected:
+ TokenStream* input;
+
+public:
+ TokenStreamBasicFilter(TokenStream& input_);
+
+ void discard(int ttype);
+
+ void discard(const BitSet& mask);
+
+ RefToken nextToken();
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_TokenStreamBasicFilter_hpp__
diff --git a/poxml/antlr/antlr/TokenStreamException.hpp b/poxml/antlr/antlr/TokenStreamException.hpp
new file mode 100644
index 00000000..2dc96776
--- /dev/null
+++ b/poxml/antlr/antlr/TokenStreamException.hpp
@@ -0,0 +1,19 @@
+#ifndef INC_TokenStreamException_hpp__
+#define INC_TokenStreamException_hpp__
+
+#include "antlr/config.hpp"
+#include "antlr/ANTLRException.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+class TokenStreamException : public ANTLRException {
+public:
+ TokenStreamException() {}
+ TokenStreamException(const ANTLR_USE_NAMESPACE(std)string& s)
+ : ANTLRException(s) {}
+ virtual ~TokenStreamException() throw() {}
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_TokenStreamException_hpp__
diff --git a/poxml/antlr/antlr/TokenStreamHiddenTokenFilter.hpp b/poxml/antlr/antlr/TokenStreamHiddenTokenFilter.hpp
new file mode 100644
index 00000000..47aad001
--- /dev/null
+++ b/poxml/antlr/antlr/TokenStreamHiddenTokenFilter.hpp
@@ -0,0 +1,84 @@
+#ifndef INC_TokenStreamHiddenTokenFilter_hpp__
+#define INC_TokenStreamHiddenTokenFilter_hpp__
+
+#include "antlr/config.hpp"
+#include "antlr/TokenStreamBasicFilter.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/**This object filters a token stream coming from a lexer
+ * or another TokenStream so that only certain token channels
+ * get transmitted to the parser.
+ *
+ * Any of the channels can be filtered off as "hidden" channels whose
+ * tokens can be accessed from the parser.
+ */
+class TokenStreamHiddenTokenFilter : public TokenStreamBasicFilter {
+ // protected BitSet discardMask;
+protected:
+ BitSet hideMask;
+
+private:
+ RefToken nextMonitoredToken;
+
+protected:
+ /** track tail of hidden list emanating from previous
+ * monitored token
+ */
+ RefToken lastHiddenToken;
+
+ RefToken firstHidden; // = null;
+
+public:
+ TokenStreamHiddenTokenFilter(TokenStream& input);
+
+protected:
+ void consume();
+
+private:
+ void consumeFirst();
+
+public:
+ BitSet getDiscardMask() const;
+
+ /** Return a ptr to the hidden token appearing immediately after
+ * token t in the input stream.
+ */
+ RefToken getHiddenAfter(RefToken t);
+
+ /** Return a ptr to the hidden token appearing immediately before
+ * token t in the input stream.
+ */
+ RefToken getHiddenBefore(RefToken t);
+
+ BitSet getHideMask() const;
+
+ /** Return the first hidden token if one appears
+ * before any monitored token.
+ */
+ RefToken getInitialHiddenToken();
+
+ void hide(int m);
+
+ void hide(const BitSet& mask);
+
+protected:
+ RefToken LA(int i);
+
+public:
+/** Return the next monitored token.
+ * Test the token following the monitored token.
+ * If following is another monitored token, save it
+ * for the next invocation of nextToken (like a single
+ * lookahead token) and return it then.
+ * If following is unmonitored, nondiscarded (hidden)
+ * channel token, add it to the monitored token.
+ *
+ * Note: EOF must be a monitored Token.
+ */
+ RefToken nextToken();
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_TokenStreamHiddenTokenFilter_hpp__
diff --git a/poxml/antlr/antlr/TokenStreamIOException.hpp b/poxml/antlr/antlr/TokenStreamIOException.hpp
new file mode 100644
index 00000000..9ac6d759
--- /dev/null
+++ b/poxml/antlr/antlr/TokenStreamIOException.hpp
@@ -0,0 +1,22 @@
+#ifndef INC_TokenStreamIOException_hpp__
+#define INC_TokenStreamIOException_hpp__
+
+#include "antlr/config.hpp"
+#include "antlr/TokenStreamException.hpp"
+#include <exception>
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+class TokenStreamIOException : public TokenStreamException {
+public:
+ ANTLR_USE_NAMESPACE(std)exception io;
+
+ TokenStreamIOException() {}
+ TokenStreamIOException(const ANTLR_USE_NAMESPACE(std)exception& e)
+ : TokenStreamException(e.what()), io(e) {}
+ ~TokenStreamIOException() throw() {}
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_TokenStreamIOException_hpp__
diff --git a/poxml/antlr/antlr/TokenStreamRecognitionException.hpp b/poxml/antlr/antlr/TokenStreamRecognitionException.hpp
new file mode 100644
index 00000000..4aa4609f
--- /dev/null
+++ b/poxml/antlr/antlr/TokenStreamRecognitionException.hpp
@@ -0,0 +1,21 @@
+#ifndef INC_TokenStreamRecognitionException_hpp__
+#define INC_TokenStreamRecognitionException_hpp__
+
+#include "antlr/config.hpp"
+#include "antlr/TokenStreamException.hpp"
+#include <exception>
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+class TokenStreamRecognitionException : public TokenStreamException {
+public:
+ RecognitionException recog;
+
+ TokenStreamRecognitionException(RecognitionException& re)
+ : TokenStreamException(re.getMessage()), recog(re) {}
+ ~TokenStreamRecognitionException() throw() {}
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_TokenStreamRecognitionException_hpp__
diff --git a/poxml/antlr/antlr/TokenStreamRetryException.hpp b/poxml/antlr/antlr/TokenStreamRetryException.hpp
new file mode 100644
index 00000000..a940d8c4
--- /dev/null
+++ b/poxml/antlr/antlr/TokenStreamRetryException.hpp
@@ -0,0 +1,17 @@
+#ifndef INC_TokenStreamRetryException_hpp__
+#define INC_TokenStreamRetryException_hpp__
+
+#include "antlr/config.hpp"
+#include "antlr/TokenStreamException.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+class TokenStreamRetryException : public TokenStreamException {
+public:
+ TokenStreamRetryException() {}
+ ~TokenStreamRetryException() throw() {}
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_TokenStreamRetryException_hpp__
diff --git a/poxml/antlr/antlr/TokenStreamSelector.hpp b/poxml/antlr/antlr/TokenStreamSelector.hpp
new file mode 100644
index 00000000..7e7d7398
--- /dev/null
+++ b/poxml/antlr/antlr/TokenStreamSelector.hpp
@@ -0,0 +1,78 @@
+#ifndef INC_TokenStreamSelector_hpp__
+#define INC_TokenStreamSelector_hpp__
+
+#include "antlr/config.hpp"
+#include "antlr/TokenStream.hpp"
+#include <map>
+#include <stack>
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/** A token stream MUX (multiplexor) knows about n token streams
+ * and can multiplex them onto the same channel for use by token
+ * stream consumer like a parser. This is a way to have multiple
+ * lexers break up the same input stream for a single parser.
+ * Or, you can have multiple instances of the same lexer handle
+ * multiple input streams; this works great for includes.
+ */
+class TokenStreamSelector : public TokenStream {
+protected:
+ /** The set of inputs to the MUX */
+#ifdef OS_NO_ALLOCATOR
+ typedef ANTLR_USE_NAMESPACE(std)less<ANTLR_USE_NAMESPACE(std)string> lessp;
+ typedef ANTLR_USE_NAMESPACE(std)map<ANTLR_USE_NAMESPACE(std)string,TokenStream*,lessp> inputStreamNames_coll;
+#else
+ typedef ANTLR_USE_NAMESPACE(std)map<ANTLR_USE_NAMESPACE(std)string,TokenStream*> inputStreamNames_coll;
+#endif
+ inputStreamNames_coll inputStreamNames;
+
+ /** The currently-selected token stream input */
+ TokenStream* input;
+
+ /** Used to track stack of input streams */
+#ifdef OS_NO_ALLOCATOR
+ typedef ANTLR_USE_NAMESPACE(std)stack<TokenStream*, ANTLR_USE_NAMESPACE(std)deque<TokenStream*> > streamStack_coll;
+#else
+ typedef ANTLR_USE_NAMESPACE(std)stack<TokenStream*> streamStack_coll;
+#endif
+ streamStack_coll streamStack;
+
+public:
+ TokenStreamSelector();
+ ~TokenStreamSelector();
+
+ void addInputStream(TokenStream* stream, const ANTLR_USE_NAMESPACE(std)string& key);
+
+ /** Return the stream from which tokens are being pulled at
+ * the moment.
+ */
+ TokenStream* getCurrentStream() const;
+
+ TokenStream* getStream(const ANTLR_USE_NAMESPACE(std)string& sname) const;
+
+ RefToken nextToken();
+
+ TokenStream* pop();
+
+ void push(TokenStream* stream);
+
+ void push(const ANTLR_USE_NAMESPACE(std)string& sname);
+
+ /** Abort recognition of current Token and try again.
+ * A stream can push a new stream (for include files
+ * for example, and then retry(), which will cause
+ * the current stream to abort back to this.nextToken().
+ * this.nextToken() then asks for a token from the
+ * current stream, which is the new "substream."
+ */
+ void retry();
+
+/** Set the stream without pushing old stream */
+ void select(TokenStream* stream);
+
+ void select(const ANTLR_USE_NAMESPACE(std)string& sname);
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_TokenStreamSelector_hpp__
diff --git a/poxml/antlr/antlr/TreeParser.hpp b/poxml/antlr/antlr/TreeParser.hpp
new file mode 100644
index 00000000..ed474bd1
--- /dev/null
+++ b/poxml/antlr/antlr/TreeParser.hpp
@@ -0,0 +1,159 @@
+#ifndef INC_TreeParser_hpp__
+#define INC_TreeParser_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+#include "antlr/config.hpp"
+#include "antlr/AST.hpp"
+#include "antlr/ASTFactory.hpp"
+#include "antlr/BitSet.hpp"
+#include "antlr/RecognitionException.hpp"
+#include "antlr/TreeParserSharedInputState.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+class TreeParser {
+public:
+ TreeParser();
+ TreeParser(const TreeParserSharedInputState& state);
+ virtual ~TreeParser();
+
+protected:
+ void setTokenNames(const char** tokenNames_);
+
+public:
+ /** The AST Null object; the parsing cursor is set to this when
+ * it is found to be null. This way, we can test the
+ * token type of a node without having to have tests for null
+ * everywhere.
+ */
+ static RefAST ASTNULL;
+
+protected:
+ /** Where did this rule leave off parsing; avoids a return parameter */
+ RefAST _retTree;
+
+ /** guessing nesting level; guessing==0 implies not guessing */
+ // int guessing; // = 0;
+
+ /** Nesting level of registered handlers */
+ // int exceptionLevel; // = 0;
+
+ TreeParserSharedInputState inputState;
+
+ /** Table of token type to token names */
+ ANTLR_USE_NAMESPACE(std)vector<ANTLR_USE_NAMESPACE(std)string> tokenNames;
+
+ /** AST return value for a rule is squirreled away here */
+ RefAST returnAST;
+
+ /** AST support code; parser and treeparser delegate to this object */
+ ASTFactory astFactory; // = new ASTFactory();
+
+ /** Used to keep track of indent depth with -traceTreeParser */
+ int traceDepth;
+
+public:
+ /** Get the AST return value squirreled away in the parser */
+ RefAST getAST() const {
+ return returnAST;
+ }
+
+ ANTLR_USE_NAMESPACE(std)string getTokenName(int num) const;
+ ANTLR_USE_NAMESPACE(std)vector<ANTLR_USE_NAMESPACE(std)string> getTokenNames() const;
+
+protected:
+ void match(RefAST t, int ttype);
+
+public:
+ /**Make sure current lookahead symbol matches the given set
+ * Throw an exception upon mismatch, which is catch by either the
+ * error handler or by the syntactic predicate.
+ */
+ void match(RefAST t, const BitSet& b);
+
+protected:
+ void matchNot(RefAST t, int ttype);
+
+public:
+ static void panic();
+
+ /** Parser error-reporting function can be overridden in subclass */
+ virtual void reportError(const RecognitionException& ex);
+
+ /** Parser error-reporting function can be overridden in subclass */
+ virtual void reportError(const ANTLR_USE_NAMESPACE(std)string& s);
+
+ /** Parser warning-reporting function can be overridden in subclass */
+ virtual void reportWarning(const ANTLR_USE_NAMESPACE(std)string& s);
+
+ /** Specify an object with support code (shared by
+ * Parser and TreeParser. Normally, the programmer
+ * does not play with this, using setASTNodeType instead.
+ */
+// void setASTFactory(ASTFactory f);
+
+ /** Specify the type of node to create during tree building */
+ void setASTNodeFactory(ASTFactory::factory_type factory);
+
+protected:
+ /** Utility class which allows tracing to work even when exceptions are
+ * thrown.
+ */
+ class Tracer {
+ private:
+ TreeParser* parser;
+ ANTLR_USE_NAMESPACE(std)string text;
+ RefAST tree;
+ public:
+ Tracer(TreeParser* p,const ANTLR_USE_NAMESPACE(std)string& t, RefAST a)
+ : parser(p), text(t), tree(a) { parser->traceIn(text,tree); }
+ ~Tracer()
+ { parser->traceOut(text,tree); }
+ private:
+ Tracer(const Tracer&); // undefined
+ const Tracer& operator=(const Tracer&); // undefined
+ };
+
+public:
+ void traceIndent();
+ void traceIn(const ANTLR_USE_NAMESPACE(std)string& rname, RefAST t);
+ void traceOut(const ANTLR_USE_NAMESPACE(std)string& rname, RefAST t);
+
+private:
+ TreeParser(const TreeParser& other);
+ TreeParser& operator=(const TreeParser& other);
+};
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_TreeParser_hpp__
diff --git a/poxml/antlr/antlr/TreeParserSharedInputState.hpp b/poxml/antlr/antlr/TreeParserSharedInputState.hpp
new file mode 100644
index 00000000..8f7b0922
--- /dev/null
+++ b/poxml/antlr/antlr/TreeParserSharedInputState.hpp
@@ -0,0 +1,34 @@
+#ifndef INC_TreeParserSharedInputState_hpp__
+#define INC_TreeParserSharedInputState_hpp__
+
+#include "antlr/config.hpp"
+#include "antlr/RefCount.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/** This object contains the data associated with an
+ * input AST. Multiple parsers
+ * share a single TreeParserSharedInputState to parse
+ * the same tree or to have the parser walk multiple
+ * trees.
+ */
+class TreeParserInputState {
+public:
+ TreeParserInputState();
+ ~TreeParserInputState();
+
+public:
+ /** Are we guessing (guessing>0)? */
+ int guessing; //= 0;
+
+private:
+ // we don't want these:
+ TreeParserInputState(const TreeParserInputState&);
+ TreeParserInputState& operator=(const TreeParserInputState&);
+};
+
+typedef RefCount<TreeParserInputState> TreeParserSharedInputState;
+
+ANTLR_END_NAMESPACE
+
+#endif //INC_TreeParserSharedInputState_hpp__
diff --git a/poxml/antlr/antlr/config.hpp b/poxml/antlr/antlr/config.hpp
new file mode 100644
index 00000000..8ac94a3a
--- /dev/null
+++ b/poxml/antlr/antlr/config.hpp
@@ -0,0 +1,168 @@
+#ifndef INC_config_hpp__
+#define INC_config_hpp__
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+/*
+ * Just a simple configuration file to differentiate between the
+ * various compilers used.
+ */
+
+/*
+ Some compilers do not accept namespaces std:: for example.
+ In this case, just define #define ANTLR_USE_NAMESPACE(_x_).
+
+ See SunWorkShop 4.2 for example.
+ */
+#define ANTLR_USE_NAMESPACE(_x_) _x_::
+#define ANTLR_USING_NAMESPACE(_x_) using namespace _x_;
+#define ANTLR_BEGIN_NAMESPACE(_x_) namespace _x_ {
+#define ANTLR_END_NAMESPACE }
+#define ANTLR_C_USING(_x_)
+
+#if defined(_MSC_VER) && !defined(__ICL) // Microsoft Visual C++
+
+// This warning really gets on my nerves.
+// It's the one about symbol longer than 256 chars, and it happens
+// all the time with STL.
+#pragma warning( disable : 4786 )
+
+// Now, some defines for shortcomings in the MS compiler:
+
+// Not allowed to put 'static const int XXX=20;' in a class definition
+#define NO_STATIC_CONSTS
+// Using vector<XXX> requires operator<(X,X) to be defined
+#define NEEDS_OPERATOR_LESS_THAN
+// No strcasecmp in the C library (so use stricmp instead)
+// - Anyone know which is in which standard?
+#define NO_STRCASECMP
+
+#endif
+
+#if defined(__ICL)
+#define NO_STRCASECMP
+#endif
+
+//
+// SunPro Compiler (Using OBJECTSPACE STL)
+//
+#ifdef __SUNPRO_CC
+
+#if (__SUNPRO_CC >= 0x500)
+
+#define NEEDS_OPERATOR_LESS_THAN
+#define NO_TEMPLATE_PARTS
+
+#else
+
+#undef namespace
+#define namespace
+
+
+#if (__SUNPRO_CC == 0x420)
+
+/* This code is specif to SunWspro Compiler 4.2, and will compile with
+ the objectspace 2.1 toolkit for Solaris2.6 */
+#define HAS_NOT_CASSERT_H
+#define HAS_NOT_CSTRING_H
+#define HAS_NOT_CCTYPE_H
+#define HAS_NOT_CSTDIO_H
+#define HAS_OSTREAM_H
+
+/* #define OS_SOLARIS_2_6
+#define OS_NO_WSTRING
+#define OS_NO_ALLOCATORS
+#define OS_MULTI_THREADED
+#define OS_SOLARIS_NATIVE
+#define OS_REALTIME
+#define __OSVERSION__=5
+#define SVR4
+*/
+
+// ObjectSpace + some specific templates constructions with stl.
+/* #define OS_NO_ALLOCATOR */
+
+// This great compiler does not have the namespace feature.
+#undef ANTLR_USE_NAMESPACE
+#define ANTLR_USE_NAMESPACE(_x_)
+#undef ANTLR_USING_NAMESPACE
+#define ANTLR_USING_NAMESPACE(_x_)
+#undef ANTLR_BEGIN_NAMESPACE
+#define ANTLR_BEGIN_NAMESPACE(_x_)
+#undef ANTLR_END_NAMESPACE
+#define ANTLR_END_NAMESPACE
+
+#endif
+
+#undef explicit
+#define explicit
+
+#define exception os_exception
+#define bad_exception os_bad_exception
+
+// Not allowed to put 'static const int XXX=20;' in a class definition
+#define NO_STATIC_CONSTS
+// Using vector<XXX> requires operator<(X,X) to be defined
+#define NEEDS_OPERATOR_LESS_THAN
+
+#endif
+
+#endif
+
+//
+// Inprise C++ Builder 3.0
+//
+#ifdef __BCPLUSPLUS__
+
+#define NO_TEMPLATE_PARTS
+#define NO_STRCASECMP
+#endif
+
+#ifdef _AIX
+#include <strings.h>
+#endif
+
+//
+// Metrowerks Codewarrior
+//
+#ifdef __MWERKS__
+#if (__MWERKS__ <= 0x2201)
+#define NO_TEMPLATE_PARTS
+#define ANTLR_REALLY_NO_STRCASECMP
+#endif
+
+#undef ANTLR_C_USING
+#define ANTLR_C_USING(_x_) using std:: ## _x_;
+#endif
+
+#endif //INC_config_hpp__
diff --git a/poxml/antlr/configure.in b/poxml/antlr/configure.in
new file mode 100644
index 00000000..66f8cf15
--- /dev/null
+++ b/poxml/antlr/configure.in
@@ -0,0 +1,22 @@
+AC_INIT(src/Parser.cpp)
+
+PACKAGE=libantlr
+VERSION="2.7.1"
+LIBANTLR_SO_VERSION=0:0:0
+
+AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
+
+AM_DISABLE_SHARED
+AM_PROG_LIBTOOL
+AC_PROG_CXX
+AC_PROG_CXXCPP
+AC_PROG_RANLIB
+
+test "$ac_cv_prog_gxx" = 'yes' && CXXFLAGS="$CXXFLAGS -W -Wall -pipe"
+
+AC_SUBST(LIBANTLR_SO_VERSION)
+AC_SUBST(LIBTOOL_DEPS)
+
+AC_OUTPUT(Makefile \
+ src/Makefile \
+ antlr/Makefile)
diff --git a/poxml/antlr/src/ANTLRException.cpp b/poxml/antlr/src/ANTLRException.cpp
new file mode 100644
index 00000000..42632e71
--- /dev/null
+++ b/poxml/antlr/src/ANTLRException.cpp
@@ -0,0 +1,57 @@
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1998
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1998
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/ANTLRException.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+ANTLRException::ANTLRException() : text("")
+{}
+
+ANTLRException::ANTLRException(const ANTLR_USE_NAMESPACE(std)string& s)
+: text(s)
+{}
+
+ANTLRException::~ANTLRException() throw()
+{}
+
+ANTLR_USE_NAMESPACE(std)string ANTLRException::toString() const
+{ return text; }
+
+ANTLR_USE_NAMESPACE(std)string ANTLRException::getMessage() const
+{ return text; }
+
+const char* ANTLRException::what() const throw()
+{ return text.c_str(); }
+
+ANTLR_END_NAMESPACE
+
diff --git a/poxml/antlr/src/ASTFactory.cpp b/poxml/antlr/src/ASTFactory.cpp
new file mode 100644
index 00000000..e44386f7
--- /dev/null
+++ b/poxml/antlr/src/ASTFactory.cpp
@@ -0,0 +1,218 @@
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1998
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1998
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/ASTFactory.hpp"
+#include "antlr/CommonAST.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/** AST Support code shared by TreeParser and Parser.
+ * We use delegation to share code (and have only one
+ * bit of code to maintain) rather than subclassing
+ * or superclassing (forces AST support code to be
+ * loaded even when you don't want to do AST stuff).
+ *
+ * Typically, setASTNodeType is used to specify the
+ * type of node to create, but you can override
+ * create to make heterogeneous nodes etc...
+ */
+
+ASTFactory::ASTFactory() : nodeFactory(&CommonAST::factory)
+{
+}
+
+/** Add a child to the current AST */
+void ASTFactory::addASTChild(ASTPair& currentAST, RefAST child)
+{
+ if (child) {
+ if (!currentAST.root) {
+ // Make new child the current root
+ currentAST.root = child;
+ }
+ else {
+ if (!currentAST.child) {
+ // Add new child to current root
+ currentAST.root->setFirstChild(child);
+ }
+ else {
+ currentAST.child->setNextSibling(child);
+ }
+ }
+ // Make new child the current child
+ currentAST.child = child;
+ currentAST.advanceChildToEnd();
+ }
+}
+/** Create a new empty AST node; if the user did not specify
+ * an AST node type, then create a default one: CommonAST.
+ */
+RefAST ASTFactory::create()
+{
+ RefAST node = nodeFactory();
+ node->setType(Token::INVALID_TYPE);
+ return node;
+}
+
+RefAST ASTFactory::create(int type)
+{
+ RefAST t = nodeFactory();
+ t->initialize(type,"");
+ return t;
+}
+
+RefAST ASTFactory::create(int type, const ANTLR_USE_NAMESPACE(std)string& txt)
+{
+ RefAST t = nodeFactory();
+ t->initialize(type,txt);
+ return t;
+}
+
+/** Create a new empty AST node; if the user did not specify
+ * an AST node type, then create a default one: CommonAST.
+ */
+RefAST ASTFactory::create(RefAST tr)
+{
+ if (!tr)
+ return nullAST;
+
+ RefAST t = nodeFactory();
+ t->initialize(tr);
+ return t;
+}
+
+RefAST ASTFactory::create(RefToken tok)
+{
+ RefAST t = nodeFactory();
+ t->initialize(tok);
+ return t;
+}
+/** Copy a single node. clone() is not used because
+ * we want to return an AST not a plain object...a type
+ * safety issue. Further, we want to have all AST node
+ * creation go through the factory so creation can be
+ * tracked. Returns null if t is null.
+ */
+RefAST ASTFactory::dup(RefAST t)
+{
+ return create(t); // if t==null, create returns null
+}
+
+/** Duplicate tree including siblings of root. */
+RefAST ASTFactory::dupList(RefAST t)
+{
+ RefAST result = dupTree(t); // if t == null, then result==null
+ RefAST nt = result;
+ while (t) { // for each sibling of the root
+ t = t->getNextSibling();
+ nt->setNextSibling(dupTree(t)); // dup each subtree, building new tree
+ nt = nt->getNextSibling();
+ }
+ return result;
+}
+/**Duplicate a tree, assuming this is a root node of a tree--
+ * duplicate that node and what's below; ignore siblings of root node.
+ */
+RefAST ASTFactory::dupTree(RefAST t)
+{
+ RefAST result = dup(t); // make copy of root
+ // copy all children of root.
+ if (t) {
+ result->setFirstChild( dupList(t->getFirstChild()) );
+ }
+ return result;
+}
+/** Make a tree from a list of nodes. The first element in the
+ * array is the root. If the root is null, then the tree is
+ * a simple list not a tree. Handles null children nodes correctly.
+ * For example, build(a, b, null, c) yields tree (a b c). build(null,a,b)
+ * yields tree (nil a b).
+ */
+RefAST ASTFactory::make(ANTLR_USE_NAMESPACE(std)vector<RefAST> nodes)
+{
+ if ( nodes.size()==0 )
+ return RefAST(nullASTptr);
+ RefAST root = nodes[0];
+ RefAST tail = RefAST(nullASTptr);
+ if (root) {
+ root->setFirstChild(RefAST(nullASTptr)); // don't leave any old pointers set
+ }
+ // link in children;
+ for (unsigned int i=1; i<nodes.size(); i++) {
+ if ( !nodes[i] ) continue; // ignore null nodes
+ if ( !root ) {
+ // Set the root and set it up for a flat list
+ root = tail = nodes[i];
+ }
+ else if ( !tail ) {
+ root->setFirstChild(nodes[i]);
+ tail = root->getFirstChild();
+ }
+ else {
+ tail->setNextSibling(nodes[i]);
+ tail = tail->getNextSibling();
+ }
+ // Chase tail to last sibling
+ while (tail->getNextSibling()) {
+ tail = tail->getNextSibling();
+ }
+ }
+ return root;
+}
+/** Make a tree from a list of nodes, where the nodes are contained
+ * in an ASTArray object
+ */
+RefAST ASTFactory::make(ASTArray* nodes)
+{
+ RefAST ret = make(nodes->array);
+ delete nodes;
+ return ret;
+}
+/** Make an AST the root of current AST */
+void ASTFactory::makeASTRoot(ASTPair& currentAST, RefAST root)
+{
+ if (root) {
+ // Add the current root as a child of new root
+ root->addChild(currentAST.root);
+ // The new current child is the last sibling of the old root
+ currentAST.child = currentAST.root;
+ currentAST.advanceChildToEnd();
+ // Set the new root
+ currentAST.root = root;
+ }
+}
+void ASTFactory::setASTNodeFactory(factory_type factory)
+{
+ nodeFactory = factory;
+}
+
+ANTLR_END_NAMESPACE
+
diff --git a/poxml/antlr/src/ASTRefCount.cpp b/poxml/antlr/src/ASTRefCount.cpp
new file mode 100644
index 00000000..1da98306
--- /dev/null
+++ b/poxml/antlr/src/ASTRefCount.cpp
@@ -0,0 +1,74 @@
+#include "antlr/ASTRefCount.hpp"
+#include "antlr/AST.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+ASTRef::ASTRef(AST* p)
+ : ptr(p), count(1)
+{
+ if (p && !p->ref)
+ p->ref = this;
+}
+
+ASTRef::~ASTRef()
+{
+ delete ptr;
+}
+
+ASTRef* ASTRef::increment()
+{
+ ++count;
+ return this;
+}
+
+bool ASTRef::decrement()
+{
+ return (--count==0);
+}
+
+ASTRef* ASTRef::getRef(const AST* p)
+{
+ if (p) {
+ AST* pp = const_cast<AST*>(p);
+ if (pp->ref)
+ return pp->ref->increment();
+ else
+ return new ASTRef(pp);
+ } else
+ return 0;
+}
+
+ANTLR_END_NAMESPACE
+
diff --git a/poxml/antlr/src/BaseAST.cpp b/poxml/antlr/src/BaseAST.cpp
new file mode 100644
index 00000000..4080e0e8
--- /dev/null
+++ b/poxml/antlr/src/BaseAST.cpp
@@ -0,0 +1,320 @@
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1998
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1998
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/BaseAST.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+//bool BaseAST::verboseStringConversion;
+//ANTLR_USE_NAMESPACE(std)vector<ANTLR_USE_NAMESPACE(std)string> BaseAST::tokenNames;
+
+void BaseAST::addChild(RefAST c)
+{
+ if (!c)
+ return;
+ RefBaseAST tmp=down;
+ if (tmp) {
+ while (tmp->right)
+ tmp=tmp->right;
+ tmp->right=c;
+ } else {
+ down=c;
+ }
+}
+
+void BaseAST::doWorkForFindAll(
+ ANTLR_USE_NAMESPACE(std)vector<RefAST>& v,
+ RefAST target,bool partialMatch)
+{
+ // Start walking sibling lists, looking for matches.
+ for (RefAST sibling=this;
+ sibling;
+ sibling=sibling->getNextSibling())
+ {
+ if ( (partialMatch && sibling->equalsTreePartial(target)) ||
+ (!partialMatch && sibling->equalsTree(target)) ) {
+ v.push_back(sibling);
+ }
+ // regardless of match or not, check any children for matches
+ if ( sibling->getFirstChild() ) {
+ RefBaseAST(sibling->getFirstChild())->doWorkForFindAll(v, target, partialMatch);
+ }
+ }
+
+}
+
+/** Is node t equal to this in terms of token type and text? */
+bool BaseAST::equals(RefAST t) const
+{
+ if (!t)
+ return false;
+ return (getText() == t->getText()) && (getType() == t->getType());
+}
+
+/** Is t an exact structural and equals() match of this tree. The
+ * 'this' reference is considered the start of a sibling list.
+ */
+bool BaseAST::equalsList(RefAST t) const
+{
+ // the empty tree is not a match of any non-null tree.
+ if (!t)
+ return false;
+
+ // Otherwise, start walking sibling lists. First mismatch, return false.
+ RefAST sibling=this;
+ for (;sibling && t;
+ sibling=sibling->getNextSibling(), t=t->getNextSibling()) {
+ // as a quick optimization, check roots first.
+ if (!sibling->equals(t))
+ return false;
+ // if roots match, do full list match test on children.
+ if (sibling->getFirstChild()) {
+ if (!sibling->getFirstChild()->equalsList(t->getFirstChild()))
+ return false;
+ }
+ // sibling has no kids, make sure t doesn't either
+ else if (t->getFirstChild())
+ return false;
+ }
+
+ if (!sibling && !t)
+ return true;
+
+ // one sibling list has more than the other
+ return false;
+}
+
+/** Is 'sub' a subtree of this list?
+ * The siblings of the root are NOT ignored.
+ */
+bool BaseAST::equalsListPartial(RefAST sub) const
+{
+ // the empty tree is always a subset of any tree.
+ if (!sub)
+ return true;
+
+ // Otherwise, start walking sibling lists. First mismatch, return false.
+ RefAST sibling=this;
+ for (;sibling && sub;
+ sibling=sibling->getNextSibling(), sub=sub->getNextSibling()) {
+ // as a quick optimization, check roots first.
+ if (!sibling->equals(sub))
+ return false;
+ // if roots match, do partial list match test on children.
+ if (sibling->getFirstChild())
+ if (!sibling->getFirstChild()->equalsListPartial(sub->getFirstChild()))
+ return false;
+ }
+
+ if (!sibling && sub)
+ // nothing left to match in this tree, but subtree has more
+ return false;
+
+ // either both are null or sibling has more, but subtree doesn't
+ return true;
+}
+
+/** Is tree rooted at 'this' equal to 't'? The siblings
+ * of 'this' are ignored.
+ */
+bool BaseAST::equalsTree(RefAST t) const
+{
+ // check roots first
+ if (!equals(t))
+ return false;
+ // if roots match, do full list match test on children.
+ if (getFirstChild()) {
+ if (!getFirstChild()->equalsList(t->getFirstChild()))
+ return false;
+ }
+ // sibling has no kids, make sure t doesn't either
+ else if (t->getFirstChild())
+ return false;
+
+ return true;
+}
+
+/** Is 'sub' a subtree of the tree rooted at 'this'? The siblings
+ * of 'this' are ignored.
+ */
+bool BaseAST::equalsTreePartial(RefAST sub) const
+{
+ // the empty tree is always a subset of any tree.
+ if (!sub)
+ return true;
+
+ // check roots first
+ if (!equals(sub))
+ return false;
+ // if roots match, do full list partial match test on children.
+ if (getFirstChild())
+ if (!getFirstChild()->equalsListPartial(sub->getFirstChild()))
+ return false;
+
+ return true;
+}
+
+/** Walk the tree looking for all exact subtree matches. Return
+ * an ASTEnumerator that lets the caller walk the list
+ * of subtree roots found herein.
+ */
+ANTLR_USE_NAMESPACE(std)vector<RefAST> BaseAST::findAll(RefAST target)
+{
+ ANTLR_USE_NAMESPACE(std)vector<RefAST> roots;
+
+ // the empty tree cannot result in an enumeration
+ if (target) {
+ doWorkForFindAll(roots,target,false); // find all matches recursively
+ }
+
+ return roots;
+}
+
+/** Walk the tree looking for all subtrees. Return
+ * an ASTEnumerator that lets the caller walk the list
+ * of subtree roots found herein.
+ */
+ANTLR_USE_NAMESPACE(std)vector<RefAST> BaseAST::findAllPartial(RefAST target)
+{
+ ANTLR_USE_NAMESPACE(std)vector<RefAST> roots;
+
+ // the empty tree cannot result in an enumeration
+ if (target) {
+ doWorkForFindAll(roots,target,true); // find all matches recursively
+ }
+
+ return roots;
+}
+
+RefAST BaseAST::getFirstChild() const
+{
+ return RefAST(down);
+}
+
+RefAST BaseAST::getNextSibling() const
+{
+ return RefAST(right);
+}
+
+ANTLR_USE_NAMESPACE(std)string BaseAST::getText() const
+{
+ return "";
+}
+
+int BaseAST::getType() const
+{
+ return 0;
+}
+
+void BaseAST::removeChildren()
+{
+ down=nullAST;
+}
+
+void BaseAST::setFirstChild(RefAST c)
+{
+ down=c;
+}
+
+void BaseAST::setNextSibling(RefAST n)
+{
+ right=n;
+}
+
+void BaseAST::setText(const ANTLR_USE_NAMESPACE(std)string& txt)
+{
+}
+
+void BaseAST::setType(int type)
+{
+}
+
+//void BaseAST::setVerboseStringConversion(bool verbose,
+// const ANTLR_USE_NAMESPACE(std)vector<ANTLR_USE_NAMESPACE(std)string>& names)
+//{
+// verboseStringConversion = verbose;
+// tokenNames = names;
+//}
+
+ANTLR_USE_NAMESPACE(std)string BaseAST::toString() const
+{
+// if ( verboseStringConversion &&
+// !getText().equalsIgnoreCase(tokenNames[getType()]) &&
+// !getText().equalsIgnoreCase(Tool.stripFrontBack(tokenNames[getType()],"\"","\"")) ) {
+// b.append('[');
+// b.append(getText());
+// b.append(",<");
+// b.append(tokenNames[getType()]);
+// b.append(">]");
+// return b.toString();
+// }
+ return getText();
+}
+
+ANTLR_USE_NAMESPACE(std)string BaseAST::toStringList() const
+{
+ ANTLR_USE_NAMESPACE(std)string ts="";
+ if (getFirstChild()) {
+ ts+=" ( ";
+ ts+=toString();
+ ts+=getFirstChild()->toStringList();
+ ts+=" )";
+ } else {
+ ts+=" ";
+ ts+=toString();
+ }
+ if (getNextSibling())
+ ts+=getNextSibling()->toStringList();
+ return ts;
+}
+
+ANTLR_USE_NAMESPACE(std)string BaseAST::toStringTree() const
+{
+ ANTLR_USE_NAMESPACE(std)string ts="";
+ if (getFirstChild()) {
+ ts+=" ( ";
+ ts+=toString();
+ ts+=getFirstChild()->toStringList();
+ ts+=" )";
+ } else {
+ ts+=" ";
+ ts+=toString();
+ }
+ return ts;
+}
+
+// this is nasty, but it makes the code generation easier
+RefAST nullAST;
+AST* const nullASTptr=0;
+
+ANTLR_END_NAMESPACE
+
diff --git a/poxml/antlr/src/BitSet.cpp b/poxml/antlr/src/BitSet.cpp
new file mode 100644
index 00000000..a0a1b110
--- /dev/null
+++ b/poxml/antlr/src/BitSet.cpp
@@ -0,0 +1,76 @@
+#include "antlr/BitSet.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/** A BitSet to replace java.util.BitSet.
+ * Primary differences are that most set operators return new sets
+ * as opposed to oring and anding "in place". Further, a number of
+ * operations were added. I cannot contain a BitSet because there
+ * is no way to access the internal bits (which I need for speed)
+ * and, because it is final, I cannot subclass to add functionality.
+ * Consider defining set degree. Without access to the bits, I must
+ * call a method n times to test the ith bit...ack!
+ *
+ * Also seems like or() from util is wrong when size of incoming set is bigger
+ * than this.length.
+ *
+ * This is a C++ version of the Java class described above, with only
+ * a handful of the methods implemented, because we don't need the
+ * others at runtime. It's really just a wrapper around vector<bool>,
+ * which should probably be changed to a wrapper around bitset, once
+ * bitset is more widely available.
+ *
+ * @author Terence Parr, MageLang Institute
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+BitSet::BitSet(int nbits)
+ : storage(nbits)
+{
+ for (int i=0;i<nbits;i++) {
+ storage[i] = false;
+ }
+}
+
+BitSet::BitSet(const unsigned long* bits_,int nlongs)
+ : storage(nlongs*32)
+{
+ for ( int i = 0 ; i < nlongs*32; i++) {
+ storage[i] = (bits_[i>>5] & (1UL << (i&31))) ? true : false;
+ }
+}
+
+BitSet::~BitSet()
+{
+}
+
+void BitSet::add(int el)
+{
+ if ( el < 0 )
+ throw ANTLR_USE_NAMESPACE(std)out_of_range(ANTLR_USE_NAMESPACE(std)string("antlr::BitSet.cpp line 49"));
+
+ if( static_cast<unsigned int>(el) >= storage.size() )
+ storage.resize( el+1, false );
+
+ storage[el] = true;
+}
+
+bool BitSet::member(int el) const
+{
+ if ( el < 0 || static_cast<unsigned int>(el) >= storage.size())
+ return false;
+
+ return storage[el];
+}
+
+ANTLR_USE_NAMESPACE(std)vector<int> BitSet::toArray() const
+{
+ ANTLR_USE_NAMESPACE(std)vector<int> elems;
+ for (unsigned int i=0;i<storage.size();i++) {
+ if (storage[i])
+ elems.push_back(i);
+ }
+
+ return elems;
+}
+
+ANTLR_END_NAMESPACE
diff --git a/poxml/antlr/src/CharBuffer.cpp b/poxml/antlr/src/CharBuffer.cpp
new file mode 100644
index 00000000..a43eb153
--- /dev/null
+++ b/poxml/antlr/src/CharBuffer.cpp
@@ -0,0 +1,67 @@
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1998
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1998
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+/**A Stream of characters fed to the lexer from a InputStream that can
+ * be rewound via mark()/rewind() methods.
+ * <p>
+ * A dynamic array is used to buffer up all the input characters. Normally,
+ * "k" characters are stored in the buffer. More characters may be stored during
+ * guess mode (testing syntactic predicate), or when LT(i>k) is referenced.
+ * Consumption of characters is deferred. In other words, reading the next
+ * character is not done by conume(), but deferred until needed by LA or LT.
+ * <p>
+ *
+ * @see antlr.CharQueue
+ */
+
+#include "antlr/CharBuffer.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/** Create a character buffer */
+CharBuffer::CharBuffer(ANTLR_USE_NAMESPACE(std)istream& input_)
+: input(input_)
+{}
+
+/** Get the next character from the stream */
+int CharBuffer::getChar()
+{
+// try {
+ return input.get();
+// }
+// catch (???& e) {
+// throw CharStreamIOException(e);
+// }
+}
+
+ANTLR_END_NAMESPACE
+
diff --git a/poxml/antlr/src/CharScanner.cpp b/poxml/antlr/src/CharScanner.cpp
new file mode 100644
index 00000000..ff40138d
--- /dev/null
+++ b/poxml/antlr/src/CharScanner.cpp
@@ -0,0 +1,430 @@
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1998
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1998
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/CharScanner.hpp"
+#include "antlr/CommonToken.hpp"
+#include "antlr/MismatchedCharException.hpp"
+#include <map>
+
+#ifdef HAS_NOT_CCTYPE_H
+#include <ctype.h>
+#else
+#include <cctype>
+#endif
+
+#include <iostream>
+
+#ifdef HAS_NOT_CSTRING_H
+#include <string>
+#else
+#include <cstring>
+#endif
+#include <stdlib.h>
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+ANTLR_C_USING(exit)
+ANTLR_C_USING(tolower)
+
+#ifdef ANTLR_REALLY_NO_STRCASECMP
+// Apparently, neither strcasecmp nor stricmp is standard, and Codewarrior
+// on the mac has neither...
+inline int strcasecmp(const char *s1, const char *s2)
+{
+ while (true)
+ {
+ char c1 = tolower(*s1++),
+ c2 = tolower(*s2++);
+ if (c1 < c2) return -1;
+ if (c1 > c2) return 1;
+ if (c1 == 0) return 0;
+ }
+}
+#else
+#ifdef NO_STRCASECMP
+ANTLR_C_USING(stricmp)
+#else
+ANTLR_C_USING(strcasecmp)
+#endif
+#endif
+
+CharScannerLiteralsLess::CharScannerLiteralsLess(const CharScanner* theScanner)
+: scanner(theScanner)
+{}
+
+bool CharScannerLiteralsLess::operator() (const ANTLR_USE_NAMESPACE(std)string& x,const ANTLR_USE_NAMESPACE(std)string& y) const
+{
+ if (scanner->getCaseSensitiveLiterals()) {
+ return ANTLR_USE_NAMESPACE(std)less<ANTLR_USE_NAMESPACE(std)string>()(x,y);
+ } else {
+#ifdef NO_STRCASECMP
+ return (stricmp(x.c_str(),y.c_str())<0);
+#else
+ return (strcasecmp(x.c_str(),y.c_str())<0);
+#endif
+ }
+}
+
+CharScanner::CharScanner(InputBuffer& cb)
+ : saveConsumedInput(true) //, caseSensitiveLiterals(true)
+ , literals(CharScannerLiteralsLess(this))
+ , inputState(new LexerInputState(cb))
+ , commitToPath(false)
+ , traceDepth(0)
+{
+ setTokenObjectFactory(&CommonToken::factory);
+}
+
+CharScanner::CharScanner(InputBuffer* cb)
+ : saveConsumedInput(true) //, caseSensitiveLiterals(true)
+ , literals(CharScannerLiteralsLess(this))
+ , inputState(new LexerInputState(cb))
+ , commitToPath(false)
+ , traceDepth(0)
+{
+ setTokenObjectFactory(&CommonToken::factory);
+}
+
+CharScanner::CharScanner(const LexerSharedInputState& state)
+ : saveConsumedInput(true) //, caseSensitiveLiterals(true)
+ , literals(CharScannerLiteralsLess(this))
+ , inputState(state)
+ , commitToPath(false)
+ , traceDepth(0)
+{
+ setTokenObjectFactory(&CommonToken::factory);
+}
+
+CharScanner::~CharScanner()
+{
+}
+
+void CharScanner::append(char c)
+{
+ if (saveConsumedInput) {
+ int l = text.length();
+ if ((l%256) == 0) text.reserve(l+256);
+ text.replace(l,0,&c,1);
+ }
+}
+
+void CharScanner::append(const ANTLR_USE_NAMESPACE(std)string& s)
+{
+ if (saveConsumedInput)
+ text+=s;
+}
+
+void CharScanner::commit()
+{
+ inputState->getInput().commit();
+}
+
+void CharScanner::consume()
+{
+ if (inputState->guessing == 0) {
+ int c = LA(1);
+ if (caseSensitive) {
+ append(c);
+ } else {
+ // use input.LA(), not LA(), to get original case
+ // CharScanner.LA() would toLower it.
+ append(inputState->getInput().LA(1));
+ }
+ if (c == '\t') {
+ tab();
+ }
+ else {
+ inputState->column++;
+ }
+ }
+ inputState->getInput().consume();
+}
+
+/** Consume chars until one matches the given char */
+void CharScanner::consumeUntil(int c)
+{
+ while (LA(1) != EOF_CHAR && LA(1) != c)
+ {
+ consume();
+ }
+}
+
+/** Consume chars until one matches the given set */
+void CharScanner::consumeUntil(const BitSet& set)
+{
+ while (LA(1) != EOF_CHAR && !set.member(LA(1))) {
+ consume();
+ }
+}
+
+bool CharScanner::getCaseSensitive() const
+{ return caseSensitive; }
+
+//bool CharScanner::getCaseSensitiveLiterals() const
+//{ return caseSensitiveLiterals; }
+
+int CharScanner::getColumn() const
+{ return inputState->column; }
+
+void CharScanner::setColumn(int c)
+{ inputState->column = c; }
+
+bool CharScanner::getCommitToPath() const
+{ return commitToPath; }
+
+const ANTLR_USE_NAMESPACE(std)string& CharScanner::getFilename() const
+{ return inputState->filename; }
+
+InputBuffer& CharScanner::getInputBuffer()
+{ return inputState->getInput(); }
+
+LexerSharedInputState CharScanner::getInputState()
+{ return inputState; }
+
+int CharScanner::getLine() const
+{ return inputState->line; }
+
+/** return a copy of the current text buffer */
+const ANTLR_USE_NAMESPACE(std)string& CharScanner::getText() const
+{ return text; }
+
+RefToken CharScanner::getTokenObject() const
+{ return _returnToken; }
+
+RefToken CharScanner::makeToken(int t)
+{
+ RefToken tok=tokenFactory();
+ tok->setType(t);
+ tok->setColumn(inputState->tokenStartColumn);
+ tok->setLine(inputState->tokenStartLine);
+ return tok;
+}
+
+int CharScanner::mark()
+{
+ return inputState->getInput().mark();
+}
+
+void CharScanner::match(int c)
+{
+ if ( LA(1) != c ) {
+ throw MismatchedCharException(LA(1),c,false,this);
+ }
+ consume();
+}
+
+void CharScanner::match(const BitSet& b)
+{
+ if (!b.member(LA(1))) {
+ throw MismatchedCharException(LA(1),b,false,this);
+ }
+ consume();
+}
+
+void CharScanner::match(const ANTLR_USE_NAMESPACE(std)string& s)
+{
+ int len = s.length();
+ for (int i=0; i<len; i++) {
+ if ( LA(1) != s[i] ) {
+ throw MismatchedCharException(LA(1),s[i],false,this);
+ }
+ consume();
+ }
+}
+
+void CharScanner::matchNot(int c)
+{
+ if ( LA(1) == c ) {
+ throw MismatchedCharException(LA(1),c,true,this);
+ }
+ consume();
+}
+
+void CharScanner::matchRange(int c1, int c2)
+{
+ if (LA(1)<c1 || LA(1)>c2) {
+ throw MismatchedCharException(LA(1),c1,c2,false,this);
+ }
+ consume();
+}
+
+void CharScanner::newline()
+{
+ ++inputState->line;
+ inputState->column=1;
+}
+
+/** advance the current column number by an appropriate amount.
+ * If you do not override this to specify how much to jump for
+ * a tab, then tabs are counted as one char. This method is
+ * called from consume().
+ */
+void CharScanner::tab() {
+ // update inputState->column as function of
+ // inputState->column and tab stops.
+ // For example, if tab stops are columns 1 and 5 etc...
+ // and column is 3, then add 2 to column.
+ ++inputState->column;
+}
+
+void CharScanner::panic()
+{
+ ANTLR_USE_NAMESPACE(std)cerr << "CharScanner: panic" << ANTLR_USE_NAMESPACE(std)endl;
+ exit(1);
+}
+
+void CharScanner::panic(const ANTLR_USE_NAMESPACE(std)string& s)
+{
+ ANTLR_USE_NAMESPACE(std)cerr << "CharScanner: panic: " << s.c_str() << ANTLR_USE_NAMESPACE(std)endl;
+ exit(1);
+}
+
+/** Report exception errors caught in nextToken() */
+void CharScanner::reportError(const RecognitionException& ex)
+{
+ ANTLR_USE_NAMESPACE(std)cerr << ex.toString().c_str() << ANTLR_USE_NAMESPACE(std)endl;
+}
+
+/** Parser error-reporting function can be overridden in subclass */
+void CharScanner::reportError(const ANTLR_USE_NAMESPACE(std)string& s)
+{
+ if (getFilename().empty())
+ ANTLR_USE_NAMESPACE(std)cerr << "error: " << s.c_str() << ANTLR_USE_NAMESPACE(std)endl;
+ else
+ ANTLR_USE_NAMESPACE(std)cerr << getFilename().c_str() << ": error: " << s.c_str() << ANTLR_USE_NAMESPACE(std)endl;
+}
+
+/** Parser warning-reporting function can be overridden in subclass */
+void CharScanner::reportWarning(const ANTLR_USE_NAMESPACE(std)string& s)
+{
+ if (getFilename().empty())
+ ANTLR_USE_NAMESPACE(std)cerr << "warning: " << s.c_str() << ANTLR_USE_NAMESPACE(std)endl;
+ else
+ ANTLR_USE_NAMESPACE(std)cerr << getFilename().c_str() << ": warning: " << s.c_str() << ANTLR_USE_NAMESPACE(std)endl;
+}
+
+void CharScanner::resetText()
+{
+ text="";
+ inputState->tokenStartColumn = inputState->column;
+ inputState->tokenStartLine = inputState->line;
+}
+
+void CharScanner::rewind(int pos)
+{
+ inputState->getInput().rewind(pos);
+}
+
+void CharScanner::setCaseSensitive(bool t)
+{
+ caseSensitive = t;
+}
+
+void CharScanner::setCommitToPath(bool commit)
+{
+ commitToPath = commit;
+}
+
+void CharScanner::setFilename(const ANTLR_USE_NAMESPACE(std)string& f)
+{ inputState->filename=f; }
+
+void CharScanner::setInputState(LexerSharedInputState state)
+{ inputState = state; }
+
+void CharScanner::setLine(int l)
+{ inputState->line=l; }
+
+void CharScanner::setText(const ANTLR_USE_NAMESPACE(std)string& s)
+{ text=s; }
+
+void CharScanner::setTokenObjectFactory(factory_type factory)
+{ tokenFactory=factory; }
+
+/** Test the token text against the literals table
+ * Override this method to perform a different literals test */
+int CharScanner::testLiteralsTable(int ttype) const
+{
+ ANTLR_USE_NAMESPACE(std)map<ANTLR_USE_NAMESPACE(std)string,int,CharScannerLiteralsLess>::const_iterator i = literals.find(text);
+ if (i != literals.end())
+ ttype = (*i).second;
+ return ttype;
+}
+
+/** Test the text passed in against the literals table
+ * Override this method to perform a different literals test
+ * This is used primarily when you want to test a portion of
+ * a token.
+ */
+int CharScanner::testLiteralsTable(const ANTLR_USE_NAMESPACE(std)string& text_, int ttype) const
+{
+ ANTLR_USE_NAMESPACE(std)map<ANTLR_USE_NAMESPACE(std)string,int,CharScannerLiteralsLess>::const_iterator i = literals.find(text_);
+ if (i != literals.end())
+ ttype = (*i).second;
+ return ttype;
+}
+
+/** Override this method to get more specific case handling */
+int CharScanner::toLower(int c) const
+{
+ return tolower(c);
+}
+
+void CharScanner::traceIndent()
+{
+ for( int i = 0; i < traceDepth; i++ )
+ ANTLR_USE_NAMESPACE(std)cout << " ";
+}
+
+void CharScanner::traceIn(const ANTLR_USE_NAMESPACE(std)string& rname)
+{
+ traceDepth++;
+ traceIndent();
+ ANTLR_USE_NAMESPACE(std)cout << "> lexer " << rname.c_str() << "; c==" << LA(1) << ANTLR_USE_NAMESPACE(std)endl;
+}
+
+void CharScanner::traceOut(const ANTLR_USE_NAMESPACE(std)string& rname)
+{
+ traceIndent();
+ ANTLR_USE_NAMESPACE(std)cout << "< lexer " << rname.c_str() << "; c==" << LA(1) << ANTLR_USE_NAMESPACE(std)endl;
+ traceDepth--;
+}
+
+void CharScanner::uponEOF()
+{
+}
+
+#ifndef NO_STATIC_CONSTS
+const int CharScanner::NO_CHAR;
+const int CharScanner::EOF_CHAR;
+#endif
+
+ANTLR_END_NAMESPACE
+
diff --git a/poxml/antlr/src/CommonAST.cpp b/poxml/antlr/src/CommonAST.cpp
new file mode 100644
index 00000000..3a4067e3
--- /dev/null
+++ b/poxml/antlr/src/CommonAST.cpp
@@ -0,0 +1,100 @@
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1998
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1998
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/config.hpp"
+#include "antlr/CommonAST.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+CommonAST::CommonAST()
+: BaseAST(),
+ ttype( Token::INVALID_TYPE ),
+ text("")
+{
+}
+
+CommonAST::CommonAST(RefToken t)
+: BaseAST(),
+ ttype( t->getType() ),
+ text( t->getText() )
+{
+}
+
+CommonAST::~CommonAST()
+{
+}
+
+ANTLR_USE_NAMESPACE(std)string CommonAST::getText() const
+{
+ return text;
+}
+
+int CommonAST::getType() const
+{
+ return ttype;
+}
+
+void CommonAST::initialize(int t,const ANTLR_USE_NAMESPACE(std)string& txt)
+{
+ setType(t);
+ setText(txt);
+}
+
+void CommonAST::initialize(RefAST t)
+{
+ setType(t->getType());
+ setText(t->getText());
+}
+
+void CommonAST::initialize(RefToken t)
+{
+ setType(t->getType());
+ setText(t->getText());
+}
+
+void CommonAST::setText(const ANTLR_USE_NAMESPACE(std)string& txt)
+{
+ text = txt;
+}
+
+void CommonAST::setType(int type)
+{
+ ttype = type;
+}
+
+RefAST CommonAST::factory()
+{
+ return RefAST(new CommonAST);
+}
+
+ANTLR_END_NAMESPACE
+
diff --git a/poxml/antlr/src/CommonASTWithHiddenTokens.cpp b/poxml/antlr/src/CommonASTWithHiddenTokens.cpp
new file mode 100644
index 00000000..d6c242d2
--- /dev/null
+++ b/poxml/antlr/src/CommonASTWithHiddenTokens.cpp
@@ -0,0 +1,29 @@
+#include "antlr/config.hpp"
+#include "antlr/CommonASTWithHiddenTokens.hpp"
+#include "antlr/CommonHiddenStreamToken.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+void CommonASTWithHiddenTokens::initialize(int t,const ANTLR_USE_NAMESPACE(std)string& txt)
+{
+ CommonAST::initialize(t,txt);
+}
+
+void CommonASTWithHiddenTokens::initialize(RefAST t)
+{
+ CommonAST::initialize(t);
+}
+
+void CommonASTWithHiddenTokens::initialize(RefToken t)
+{
+ CommonAST::initialize(t);
+ hiddenBefore = static_cast<CommonHiddenStreamToken*>(t.get())->getHiddenBefore();
+ hiddenAfter = static_cast<CommonHiddenStreamToken*>(t.get())->getHiddenAfter();
+}
+
+RefAST CommonASTWithHiddenTokens::factory()
+{
+ return RefAST(new CommonASTWithHiddenTokens);
+}
+
+ANTLR_END_NAMESPACE
diff --git a/poxml/antlr/src/CommonHiddenStreamToken.cpp b/poxml/antlr/src/CommonHiddenStreamToken.cpp
new file mode 100644
index 00000000..d33927cc
--- /dev/null
+++ b/poxml/antlr/src/CommonHiddenStreamToken.cpp
@@ -0,0 +1,46 @@
+#include "antlr/CommonHiddenStreamToken.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+CommonHiddenStreamToken::CommonHiddenStreamToken()
+: CommonToken()
+{
+}
+
+CommonHiddenStreamToken::CommonHiddenStreamToken(int t, const ANTLR_USE_NAMESPACE(std)string& txt)
+: CommonToken(t,txt)
+{
+}
+
+CommonHiddenStreamToken::CommonHiddenStreamToken(const ANTLR_USE_NAMESPACE(std)string& s)
+: CommonToken(s)
+{
+}
+
+RefToken CommonHiddenStreamToken::getHiddenAfter()
+{
+ return hiddenAfter;
+}
+
+RefToken CommonHiddenStreamToken::getHiddenBefore()
+{
+ return hiddenBefore;
+}
+
+RefToken CommonHiddenStreamToken::factory()
+{
+ return RefToken(new CommonHiddenStreamToken);
+}
+
+void CommonHiddenStreamToken::setHiddenAfter(RefToken t)
+{
+ hiddenAfter = t;
+}
+
+void CommonHiddenStreamToken::setHiddenBefore(RefToken t)
+{
+ hiddenBefore = t;
+}
+
+ANTLR_END_NAMESPACE
+
diff --git a/poxml/antlr/src/CommonToken.cpp b/poxml/antlr/src/CommonToken.cpp
new file mode 100644
index 00000000..ff60bd79
--- /dev/null
+++ b/poxml/antlr/src/CommonToken.cpp
@@ -0,0 +1,81 @@
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1998
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1998
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/CommonToken.hpp"
+#include "antlr/String.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+CommonToken::CommonToken() : Token(), line(1), col(1), text("")
+{}
+
+CommonToken::CommonToken(int t, const ANTLR_USE_NAMESPACE(std)string& txt)
+ : Token(t), line(1), col(1), text(txt)
+{}
+
+CommonToken::CommonToken(const ANTLR_USE_NAMESPACE(std)string& s)
+ : Token(), line(1), col(1), text(s)
+{}
+
+int CommonToken::getLine() const
+{ return line; }
+
+ANTLR_USE_NAMESPACE(std)string CommonToken::getText() const
+{ return text; }
+
+void CommonToken::setLine(int l)
+{ line=l; }
+
+void CommonToken::setText(const ANTLR_USE_NAMESPACE(std)string& s)
+{ text=s; }
+
+ANTLR_USE_NAMESPACE(std)string CommonToken::toString() const
+{
+ return "[\""+getText()+"\",<"+type+">,line="+line+"]";
+}
+
+int CommonToken::getColumn() const
+{ return col; }
+
+void CommonToken::setColumn(int c)
+{ col=c; }
+
+bool CommonToken::isInvalid() const
+{ return type==INVALID_TYPE; }
+
+RefToken CommonToken::factory()
+{
+ return RefToken(new CommonToken);
+}
+
+ANTLR_END_NAMESPACE
+
diff --git a/poxml/antlr/src/InputBuffer.cpp b/poxml/antlr/src/InputBuffer.cpp
new file mode 100644
index 00000000..058c32ab
--- /dev/null
+++ b/poxml/antlr/src/InputBuffer.cpp
@@ -0,0 +1,109 @@
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1998
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1998
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+/**A Stream of characters fed to the lexer from a InputStream that can
+ * be rewound via mark()/rewind() methods.
+ * <p>
+ * A dynamic array is used to buffer up all the input characters. Normally,
+ * "k" characters are stored in the buffer. More characters may be stored during
+ * guess mode (testing syntactic predicate), or when LT(i>k) is referenced.
+ * Consumption of characters is deferred. In other words, reading the next
+ * character is not done by conume(), but deferred until needed by LA or LT.
+ * <p>
+ *
+ * @see antlr.CharQueue
+ */
+
+#include "antlr/InputBuffer.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/** Create a character buffer */
+InputBuffer::InputBuffer()
+: nMarkers(0), markerOffset(0), numToConsume(0)
+{}
+
+/** This method updates the state of the input buffer so that
+ * the text matched since the most recent mark() is no longer
+ * held by the buffer. So, you either do a mark/rewind for
+ * failed predicate or mark/commit to keep on parsing without
+ * rewinding the input.
+ */
+void InputBuffer::commit()
+{
+ nMarkers--;
+}
+
+/** Mark another character for deferred consumption */
+void InputBuffer::consume()
+{
+ numToConsume++;
+}
+
+/** Ensure that the character buffer is sufficiently full */
+void InputBuffer::fill(int amount)
+{
+ syncConsume();
+ // Fill the buffer sufficiently to hold needed characters
+ while (queue.entries() < amount + markerOffset) {
+ // Append the next character
+ queue.append(getChar());
+ }
+}
+
+bool InputBuffer::isMarked() const
+{
+ return (nMarkers != 0);
+}
+
+/**Return an integer marker that can be used to rewind the buffer to
+ * its current state.
+ */
+int InputBuffer::mark()
+{
+ syncConsume();
+ nMarkers++;
+ return markerOffset;
+}
+
+/**Rewind the character buffer to a marker.
+ * @param mark Marker returned previously from mark()
+ */
+void InputBuffer::rewind(int mark)
+{
+ syncConsume();
+ markerOffset = mark;
+ nMarkers--;
+}
+
+ANTLR_END_NAMESPACE
+
diff --git a/poxml/antlr/src/LLkParser.cpp b/poxml/antlr/src/LLkParser.cpp
new file mode 100644
index 00000000..2f21cd8b
--- /dev/null
+++ b/poxml/antlr/src/LLkParser.cpp
@@ -0,0 +1,105 @@
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1998
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1998
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/LLkParser.hpp"
+#include <iostream>
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/**An LL(k) parser.
+ *
+ * @see antlr.Token
+ * @see antlr.TokenBuffer
+ * @see antlr.LL1Parser
+ */
+
+// LLkParser(int k_);
+
+LLkParser::LLkParser(const ParserSharedInputState& state, int k_)
+: Parser(state), k(k_)
+{}
+
+LLkParser::LLkParser(TokenBuffer& tokenBuf, int k_)
+: Parser(tokenBuf), k(k_)
+{}
+
+LLkParser::LLkParser(TokenStream& lexer, int k_)
+: Parser(new TokenBuffer(lexer)), k(k_)
+{
+}
+
+/**Consume another token from the input stream. Can only write sequentially!
+ * If you need 3 tokens ahead, you must consume() 3 times.
+ * <p>
+ * Note that it is possible to overwrite tokens that have not been matched.
+ * For example, calling consume() 3 times when k=2, means that the first token
+ * consumed will be overwritten with the 3rd.
+ */
+void LLkParser::consume()
+{ inputState->getInput().consume(); }
+
+int LLkParser::LA(int i)
+{ return inputState->getInput().LA(i); }
+
+RefToken LLkParser::LT(int i)
+{ return inputState->getInput().LT(i); }
+
+void LLkParser::trace(const ANTLR_USE_NAMESPACE(std)string& ee, const ANTLR_USE_NAMESPACE(std)string& rname)
+{
+ traceIndent();
+
+ ANTLR_USE_NAMESPACE(std)cout << ee.c_str() << rname.c_str() << ((inputState->guessing>0)?"; [guessing]":"; ");
+
+ for (int i = 1; i <= k; i++)
+ {
+ if (i != 1) {
+ ANTLR_USE_NAMESPACE(std)cout << ", ";
+ }
+ ANTLR_USE_NAMESPACE(std)cout << "LA(" << i << ")==" << LT(i)->getText().c_str();
+ }
+
+ ANTLR_USE_NAMESPACE(std)cout << ANTLR_USE_NAMESPACE(std)endl;
+}
+
+void LLkParser::traceIn(const ANTLR_USE_NAMESPACE(std)string& rname)
+{
+ traceDepth++;
+ trace("> ",rname);
+}
+
+void LLkParser::traceOut(const ANTLR_USE_NAMESPACE(std)string& rname)
+{
+ trace("< ",rname);
+ traceDepth--;
+}
+
+ANTLR_END_NAMESPACE
diff --git a/poxml/antlr/src/LexerSharedInputState.cpp b/poxml/antlr/src/LexerSharedInputState.cpp
new file mode 100644
index 00000000..a95f33a8
--- /dev/null
+++ b/poxml/antlr/src/LexerSharedInputState.cpp
@@ -0,0 +1,55 @@
+#include "antlr/LexerSharedInputState.hpp"
+#include "antlr/CharBuffer.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/** This object contains the data associated with an
+ * input stream of characters. Multiple lexers
+ * share a single LexerSharedInputState to lex
+ * the same input stream.
+ */
+
+LexerInputState::LexerInputState(InputBuffer* inbuf)
+: column(1)
+, line(1)
+, tokenStartColumn(1)
+, tokenStartLine(1)
+, guessing(0)
+, filename("")
+, input(inbuf)
+, inputResponsible(true)
+{
+}
+
+LexerInputState::LexerInputState(InputBuffer& inbuf)
+: column(1)
+, line(1)
+, tokenStartColumn(1)
+, tokenStartLine(1)
+, guessing(0)
+, filename("")
+, input(&inbuf)
+, inputResponsible(false)
+{
+}
+
+LexerInputState::LexerInputState(ANTLR_USE_NAMESPACE(std)istream& in)
+: column(1)
+, line(1)
+, tokenStartColumn(1)
+, tokenStartLine(1)
+, guessing(0)
+, filename("")
+, input(new CharBuffer(in))
+, inputResponsible(true)
+{
+}
+
+LexerInputState::~LexerInputState()
+{
+ if (inputResponsible)
+ delete input;
+}
+
+ANTLR_END_NAMESPACE
+
diff --git a/poxml/antlr/src/Makefile.am b/poxml/antlr/src/Makefile.am
new file mode 100644
index 00000000..7a5d2426
--- /dev/null
+++ b/poxml/antlr/src/Makefile.am
@@ -0,0 +1,39 @@
+
+# Make #include <antlr/xxx> work..
+INCLUDES=-I$(srcdir)/..
+KDE_CXXFLAGS = $(USE_EXCEPTIONS)
+
+noinst_LTLIBRARIES = libantlr.la
+
+libantlr_la_LDFLAGS = -no-undefined
+
+libantlr_la_SOURCES = \
+ ANTLRException.cpp \
+ ASTFactory.cpp \
+ ASTRefCount.cpp \
+ BaseAST.cpp \
+ BitSet.cpp \
+ CharBuffer.cpp \
+ CharScanner.cpp \
+ CommonAST.cpp \
+ CommonASTWithHiddenTokens.cpp \
+ CommonHiddenStreamToken.cpp \
+ CommonToken.cpp \
+ InputBuffer.cpp \
+ LLkParser.cpp \
+ LexerSharedInputState.cpp \
+ MismatchedCharException.cpp \
+ MismatchedTokenException.cpp \
+ NoViableAltException.cpp \
+ NoViableAltForCharException.cpp \
+ Parser.cpp \
+ ParserSharedInputState.cpp \
+ RecognitionException.cpp \
+ String.cpp \
+ Token.cpp \
+ TokenBuffer.cpp \
+ TokenStreamBasicFilter.cpp \
+ TokenStreamHiddenTokenFilter.cpp \
+ TokenStreamSelector.cpp \
+ TreeParser.cpp \
+ TreeParserSharedInputState.cpp
diff --git a/poxml/antlr/src/MismatchedCharException.cpp b/poxml/antlr/src/MismatchedCharException.cpp
new file mode 100644
index 00000000..4dede0e8
--- /dev/null
+++ b/poxml/antlr/src/MismatchedCharException.cpp
@@ -0,0 +1,153 @@
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1999
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1999
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/MismatchedCharException.hpp"
+#include "antlr/String.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+MismatchedCharException::MismatchedCharException()
+: RecognitionException("Mismatched char")
+{}
+
+// Expected range / not range
+MismatchedCharException::MismatchedCharException(
+ int c,
+ int lower,
+ int upper_,
+ bool matchNot,
+ CharScanner* scanner_
+) : RecognitionException("Mismatched char",
+ scanner_->getFilename(),
+ scanner_->getLine(),
+ scanner_->getColumn())
+ , mismatchType(matchNot ? NOT_RANGE : RANGE)
+ , foundChar(c)
+ , expecting(lower)
+ , upper(upper_)
+ , scanner(scanner_)
+{
+}
+
+// Expected token / not token
+MismatchedCharException::MismatchedCharException(
+ int c,
+ int expecting_,
+ bool matchNot,
+ CharScanner* scanner_
+) : RecognitionException("Mismatched char",
+ scanner_->getFilename(),
+ scanner_->getLine(),
+ scanner_->getColumn())
+ , mismatchType(matchNot ? NOT_CHAR : CHAR)
+ , foundChar(c)
+ , expecting(expecting_)
+ , scanner(scanner_)
+{
+}
+
+// Expected BitSet / not BitSet
+MismatchedCharException::MismatchedCharException(
+ int c,
+ BitSet set_,
+ bool matchNot,
+ CharScanner* scanner_
+) : RecognitionException("Mismatched char",
+ scanner_->getFilename(),
+ scanner_->getLine(),
+ scanner_->getColumn())
+ , mismatchType(matchNot ? NOT_SET : SET)
+ , foundChar(c)
+ , set(set_)
+ , scanner(scanner_)
+{
+}
+
+MismatchedCharException::MismatchedCharException(
+ const ANTLR_USE_NAMESPACE(std)string& s,
+ int line
+) : RecognitionException(s)
+{
+}
+
+/**
+ * Returns the error message that happened on the line/col given.
+ * Copied from toString().
+ */
+ANTLR_USE_NAMESPACE(std)string MismatchedCharException::getMessage() const
+{
+ ANTLR_USE_NAMESPACE(std)string s;
+
+ switch (mismatchType) {
+ case CHAR :
+ s += "expecting '" + charName(expecting) + "', found '" + charName(foundChar) + "'";
+ break;
+ case NOT_CHAR :
+ s += "expecting anything but '" + charName(expecting) + "'; got it anyway";
+ break;
+ case RANGE :
+ s += "expecting token in range: '" + charName(expecting) + "'..'" + charName(upper) + "', found '" + charName(foundChar) + "'";
+ break;
+ case NOT_RANGE :
+ s += "expecting token NOT in range: " + charName(expecting) + "'..'" + charName(upper) + "', found '" + charName(foundChar) + "'";
+ break;
+ case SET :
+ case NOT_SET :
+ {
+ s += ANTLR_USE_NAMESPACE(std)string("expecting ") + (mismatchType == NOT_SET ? "NOT " : "") + "one of (";
+ ANTLR_USE_NAMESPACE(std)vector<int> elems = set.toArray();
+ for (int i = 0; i < (int) elems.size(); i++) {
+ s += " '";
+ s += charName(elems[i]);
+ s += "'";
+ }
+ s += "), found '" + charName(foundChar) + "'";
+ }
+ break;
+ default :
+ s += RecognitionException::getMessage();
+ break;
+ }
+
+ return s;
+}
+
+#ifndef NO_STATIC_CONSTS
+const int MismatchedCharException::CHAR;
+const int MismatchedCharException::NOT_CHAR;
+const int MismatchedCharException::RANGE;
+const int MismatchedCharException::NOT_RANGE;
+const int MismatchedCharException::SET;
+const int MismatchedCharException::NOT_SET;
+#endif
+
+ANTLR_END_NAMESPACE
diff --git a/poxml/antlr/src/MismatchedTokenException.cpp b/poxml/antlr/src/MismatchedTokenException.cpp
new file mode 100644
index 00000000..b8b10808
--- /dev/null
+++ b/poxml/antlr/src/MismatchedTokenException.cpp
@@ -0,0 +1,223 @@
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1998
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1998
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/MismatchedTokenException.hpp"
+#include "antlr/String.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+MismatchedTokenException::MismatchedTokenException()
+: RecognitionException("Mismatched Token: expecting any AST node","<AST>",1)
+, token(0)
+, node(nullASTptr)
+{
+}
+
+// Expected range / not range
+MismatchedTokenException::MismatchedTokenException(
+ const ANTLR_USE_NAMESPACE(std)vector<ANTLR_USE_NAMESPACE(std)string>& tokenNames_,
+ RefAST node_,
+ int lower,
+ int upper_,
+ bool matchNot
+) : RecognitionException("Mismatched Token")
+ , tokenNames(tokenNames_)
+ , token(0)
+ , node(node_)
+ , tokenText( (node_ ? node_->toString(): ANTLR_USE_NAMESPACE(std)string("<empty tree>")) )
+ , mismatchType(matchNot ? NOT_RANGE : RANGE)
+ , expecting(lower)
+ , upper(upper_)
+{
+ fileName = "<AST>";
+}
+
+// Expected token / not token
+MismatchedTokenException::MismatchedTokenException(
+ const ANTLR_USE_NAMESPACE(std)vector<ANTLR_USE_NAMESPACE(std)string>& tokenNames_,
+ RefAST node_,
+ int expecting_,
+ bool matchNot
+) : RecognitionException("Mismatched Token")
+ , tokenNames(tokenNames_)
+ , token(0)
+ , node(node_)
+ , tokenText( (node_ ? node_->toString(): ANTLR_USE_NAMESPACE(std)string("<empty tree>")) )
+ , mismatchType(matchNot ? NOT_TOKEN : TOKEN)
+ , expecting(expecting_)
+{
+ fileName = "<AST>";
+}
+
+// Expected BitSet / not BitSet
+MismatchedTokenException::MismatchedTokenException(
+ const ANTLR_USE_NAMESPACE(std)vector<ANTLR_USE_NAMESPACE(std)string>& tokenNames_,
+ RefAST node_,
+ BitSet set_,
+ bool matchNot
+) : RecognitionException("Mismatched Token")
+ , tokenNames(tokenNames_)
+ , token(0)
+ , node(node_)
+ , tokenText( (node_ ? node_->toString(): ANTLR_USE_NAMESPACE(std)string("<empty tree>")) )
+ , mismatchType(matchNot ? NOT_SET : SET)
+ , set(set_)
+{
+ fileName = "<AST>";
+}
+
+// Expected range / not range
+MismatchedTokenException::MismatchedTokenException(
+ const ANTLR_USE_NAMESPACE(std)vector<ANTLR_USE_NAMESPACE(std)string>& tokenNames_,
+ RefToken token_,
+ int lower,
+ int upper_,
+ bool matchNot,
+ const ANTLR_USE_NAMESPACE(std)string& fileName_
+) : RecognitionException("Mismatched Token",fileName_,token_->getLine(),token_->getColumn())
+ , tokenNames(tokenNames_)
+ , token(token_)
+ , node(nullASTptr)
+ , tokenText(token_->getText())
+ , mismatchType(matchNot ? NOT_RANGE : RANGE)
+ , expecting(lower)
+ , upper(upper_)
+{
+}
+
+// Expected token / not token
+MismatchedTokenException::MismatchedTokenException(
+ const ANTLR_USE_NAMESPACE(std)vector<ANTLR_USE_NAMESPACE(std)string>& tokenNames_,
+ RefToken token_,
+ int expecting_,
+ bool matchNot,
+ const ANTLR_USE_NAMESPACE(std)string& fileName_
+) : RecognitionException("Mismatched Token",fileName_,token_->getLine(),token_->getColumn())
+ , tokenNames(tokenNames_)
+ , token(token_)
+ , node(nullASTptr)
+ , tokenText(token_->getText())
+ , mismatchType(matchNot ? NOT_TOKEN : TOKEN)
+ , expecting(expecting_)
+{
+}
+
+// Expected BitSet / not BitSet
+MismatchedTokenException::MismatchedTokenException(
+ const ANTLR_USE_NAMESPACE(std)vector<ANTLR_USE_NAMESPACE(std)string>& tokenNames_,
+ RefToken token_,
+ BitSet set_,
+ bool matchNot,
+ const ANTLR_USE_NAMESPACE(std)string& fileName_
+) : RecognitionException("Mismatched Token",fileName_,token_->getLine(),token_->getColumn())
+ , tokenNames(tokenNames_)
+ , token(token_)
+ , node(nullASTptr)
+ , tokenText(token_->getText())
+ , mismatchType(matchNot ? NOT_SET : SET)
+ , set(set_)
+{
+}
+
+// deprecated As of ANTLR 2.7.0
+ANTLR_USE_NAMESPACE(std)string MismatchedTokenException::getErrorMessage() const
+{
+ return getMessage();
+}
+
+ANTLR_USE_NAMESPACE(std)string MismatchedTokenException::getMessage() const
+{
+ ANTLR_USE_NAMESPACE(std)string s;
+ switch (mismatchType) {
+ case TOKEN:
+ s += "expecting " + tokenName(expecting) + ", found '" + tokenText + "'";
+ break;
+ case NOT_TOKEN:
+ s += "expecting anything but " + tokenName(expecting) + "; got it anyway";
+ break;
+ case RANGE:
+ s += "expecting token in range: " + tokenName(expecting) + ".." + tokenName(upper) + ", found '" + tokenText + "'";
+ break;
+ case NOT_RANGE:
+ s += "expecting token NOT in range: " + tokenName(expecting) + ".." + tokenName(upper) + ", found '" + tokenText + "'";
+ break;
+ case SET:
+ case NOT_SET:
+ {
+ s += ANTLR_USE_NAMESPACE(std)string("expecting ") + (mismatchType == NOT_SET ? "NOT " : "") + "one of (";
+ ANTLR_USE_NAMESPACE(std)vector<int> elems = set.toArray();
+ for (int i = 0; i < (int) elems.size(); i++)
+ {
+ s += " ";
+ s += tokenName(elems[i]);
+ }
+ s += "), found '" + tokenText + "'";
+ }
+ break;
+ default:
+ s = RecognitionException::getMessage();
+ break;
+ }
+ return s;
+}
+
+ANTLR_USE_NAMESPACE(std)string MismatchedTokenException::tokenName(int tokenType) const
+{
+ if (tokenType == Token::INVALID_TYPE) {
+ return "<Set of tokens>";
+ }
+ else if (tokenType < 0 || tokenType >= (int) tokenNames.size()) {
+ return ANTLR_USE_NAMESPACE(std)string("<") + tokenType + ">";
+ }
+ else {
+ return tokenNames[tokenType];
+ }
+}
+
+ANTLR_USE_NAMESPACE(std)string MismatchedTokenException::toString() const {
+ if (token) {
+ return getFileLineString() + getMessage();
+ }
+ return getMessage();
+}
+
+#ifndef NO_STATIC_CONSTS
+const int MismatchedTokenException::TOKEN;
+const int MismatchedTokenException::NOT_TOKEN;
+const int MismatchedTokenException::RANGE;
+const int MismatchedTokenException::NOT_RANGE;
+const int MismatchedTokenException::SET;
+const int MismatchedTokenException::NOT_SET;
+#endif
+
+ANTLR_END_NAMESPACE
+
diff --git a/poxml/antlr/src/NoViableAltException.cpp b/poxml/antlr/src/NoViableAltException.cpp
new file mode 100644
index 00000000..433f4325
--- /dev/null
+++ b/poxml/antlr/src/NoViableAltException.cpp
@@ -0,0 +1,82 @@
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1998
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1998
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/NoViableAltException.hpp"
+#include "antlr/String.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+NoViableAltException::NoViableAltException(RefAST t)
+: RecognitionException("NoViableAlt")
+, token(0)
+, node(t)
+{
+ fileName = "<AST>";
+}
+
+NoViableAltException::NoViableAltException(RefToken t,const ANTLR_USE_NAMESPACE(std)string& fileName_)
+: RecognitionException("NoViableAlt") // line ")+t.getLine()+" token is "+t.getText())
+, token(t)
+, node(nullASTptr)
+{
+ line = t->getLine();
+ column = t->getColumn();
+ fileName = fileName_;
+}
+
+ANTLR_USE_NAMESPACE(std)string NoViableAltException::getErrorMessage() const
+{
+ return getMessage();
+}
+
+ANTLR_USE_NAMESPACE(std)string NoViableAltException::getMessage() const
+{
+ if (token)
+ return ANTLR_USE_NAMESPACE(std)string("unexpected token: ")+token->getText();
+
+ // must a tree parser error if token==null
+ if (!node) {
+ return "unexpected end of subtree";
+ }
+ return ANTLR_USE_NAMESPACE(std)string("unexpected AST node: ")+node->toString();
+}
+
+ANTLR_USE_NAMESPACE(std)string NoViableAltException::toString() const
+{
+ if (token)
+ return getFileLineString()+getMessage();
+ else
+ return getMessage();
+}
+
+ANTLR_END_NAMESPACE
+
diff --git a/poxml/antlr/src/NoViableAltForCharException.cpp b/poxml/antlr/src/NoViableAltForCharException.cpp
new file mode 100644
index 00000000..2ff9120f
--- /dev/null
+++ b/poxml/antlr/src/NoViableAltForCharException.cpp
@@ -0,0 +1,71 @@
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Institute
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Institute
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/NoViableAltForCharException.hpp"
+#include "antlr/String.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+NoViableAltForCharException::NoViableAltForCharException(int c, CharScanner* scanner)
+: RecognitionException("NoViableAlt")
+, foundChar(c)
+{
+ line = scanner->getLine();
+ fileName = scanner->getFilename();
+}
+
+NoViableAltForCharException::NoViableAltForCharException(int c, const ANTLR_USE_NAMESPACE(std)string& fileName_, int line_)
+: RecognitionException("NoViableAlt")
+, foundChar(c)
+{
+ line = line_;
+ fileName = fileName_;
+}
+
+/**
+ * @deprecated As of ANTLR 2.7.0
+ */
+ANTLR_USE_NAMESPACE(std)string NoViableAltForCharException::getErrorMessage() const
+{
+ return getMessage();
+}
+
+/**
+ * Returns a clean error message (no line number/column information)
+ */
+ANTLR_USE_NAMESPACE(std)string NoViableAltForCharException::getMessage() const
+{
+ return ANTLR_USE_NAMESPACE(std)string("unexpected char: ")+charName(foundChar);
+}
+
+ANTLR_END_NAMESPACE
+
diff --git a/poxml/antlr/src/Parser.cpp b/poxml/antlr/src/Parser.cpp
new file mode 100644
index 00000000..5a0388d4
--- /dev/null
+++ b/poxml/antlr/src/Parser.cpp
@@ -0,0 +1,304 @@
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1998
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1998
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/Parser.hpp"
+
+#include "antlr/BitSet.hpp"
+#include "antlr/TokenBuffer.hpp"
+#include "antlr/MismatchedTokenException.hpp"
+//#include "antlr/ASTFactory.hpp"
+#include <iostream>
+#include <stdlib.h>
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+ANTLR_C_USING(exit)
+
+/**A generic ANTLR parser (LL(k) for k>=1) containing a bunch of
+ * utility routines useful at any lookahead depth. We distinguish between
+ * the LL(1) and LL(k) parsers because of efficiency. This may not be
+ * necessary in the near future.
+ *
+ * Each parser object contains the state of the parse including a lookahead
+ * cache (the form of which is determined by the subclass), whether or
+ * not the parser is in guess mode, where tokens come from, etc...
+ *
+ * <p>
+ * During <b>guess</b> mode, the current lookahead token(s) and token type(s)
+ * cache must be saved because the token stream may not have been informed
+ * to save the token (via <tt>mark</tt>) before the <tt>try</tt> block.
+ * Guessing is started by:
+ * <ol>
+ * <li>saving the lookahead cache.
+ * <li>marking the current position in the TokenBuffer.
+ * <li>increasing the guessing level.
+ * </ol>
+ *
+ * After guessing, the parser state is restored by:
+ * <ol>
+ * <li>restoring the lookahead cache.
+ * <li>rewinding the TokenBuffer.
+ * <li>decreasing the guessing level.
+ * </ol>
+ *
+ * @see antlr.Token
+ * @see antlr.TokenBuffer
+ * @see antlr.TokenStream
+ * @see antlr.LL1Parser
+ * @see antlr.LLkParser
+ */
+
+bool DEBUG_PARSER=false;
+
+Parser::Parser(TokenBuffer& input)
+: inputState(new ParserInputState(input)), traceDepth(0)
+{
+}
+
+Parser::Parser(TokenBuffer* input)
+: inputState(new ParserInputState(input)), traceDepth(0)
+{
+}
+
+Parser::Parser(const ParserSharedInputState& state)
+: inputState(state), traceDepth(0)
+{
+}
+
+Parser::~Parser()
+{
+}
+
+void Parser::setTokenNames(const char** tokenNames_)
+{
+ while (*tokenNames_) {
+ tokenNames.push_back(*(tokenNames_++));
+ }
+}
+
+/** Consume tokens until one matches the given token */
+void Parser::consumeUntil(int tokenType)
+{
+ while (LA(1) != Token::EOF_TYPE && LA(1) != tokenType)
+ consume();
+}
+
+/** Consume tokens until one matches the given token set */
+void Parser::consumeUntil(const BitSet& set)
+{
+ while (LA(1) != Token::EOF_TYPE && !set.member(LA(1)))
+ consume();
+}
+
+/** Get the AST return value squirreled away in the parser */
+RefAST Parser::getAST()
+{
+ return returnAST;
+}
+
+ASTFactory& Parser::getASTFactory()
+{
+ return astFactory;
+}
+
+ANTLR_USE_NAMESPACE(std)string Parser::getFilename() const
+{
+ return inputState->filename;
+}
+
+ParserSharedInputState Parser::getInputState() const
+{
+ return inputState;
+}
+
+ANTLR_USE_NAMESPACE(std)string Parser::getTokenName(int num) const
+{
+ return tokenNames[num];
+}
+
+ANTLR_USE_NAMESPACE(std)vector<ANTLR_USE_NAMESPACE(std)string> Parser::getTokenNames() const
+{
+ return tokenNames;
+}
+
+// Forwarded to TokenBuffer
+int Parser::mark()
+{
+ return inputState->getInput().mark();
+}
+
+/**Make sure current lookahead symbol matches token type <tt>t</tt>.
+ * Throw an exception upon mismatch, which is catch by either the
+ * error handler or by the syntactic predicate.
+ */
+void Parser::match(int t)
+{
+ if ( DEBUG_PARSER )
+ {
+ traceIndent();
+ ANTLR_USE_NAMESPACE(std)cout << "enter match(" << t << ") with LA(1)=" << LA(1) << ANTLR_USE_NAMESPACE(std)endl;
+ }
+ if ( LA(1)!=t ) {
+ if ( DEBUG_PARSER )
+ {
+ traceIndent();
+ ANTLR_USE_NAMESPACE(std)cout << "token mismatch: " << LA(1) << "!=" << t << ANTLR_USE_NAMESPACE(std)endl;
+ }
+ throw MismatchedTokenException(tokenNames, LT(1), t, false, getFilename());
+ } else {
+ // mark token as consumed -- fetch next token deferred until LA/LT
+ consume();
+ }
+}
+
+/**Make sure current lookahead symbol matches the given set
+ * Throw an exception upon mismatch, which is catch by either the
+ * error handler or by the syntactic predicate.
+ */
+void Parser::match(const BitSet& b)
+{
+ if ( DEBUG_PARSER )
+ {
+ traceIndent();
+ ANTLR_USE_NAMESPACE(std)cout << "enter match(" << "bitset" /*b.toString()*/
+ << ") with LA(1)=" << LA(1) << ANTLR_USE_NAMESPACE(std)endl;
+ }
+ if ( !b.member(LA(1)) ) {
+ if ( DEBUG_PARSER )
+ {
+ traceIndent();
+ ANTLR_USE_NAMESPACE(std)cout << "token mismatch: " << LA(1) << " not member of "
+ << "bitset" /*b.toString()*/ << ANTLR_USE_NAMESPACE(std)endl;
+ }
+ throw MismatchedTokenException(tokenNames, LT(1), b, false, getFilename());
+ } else {
+ // mark token as consumed -- fetch next token deferred until LA/LT
+ consume();
+ }
+}
+
+void Parser::matchNot(int t)
+{
+ if ( LA(1)==t ) {
+ // Throws inverted-sense exception
+ throw MismatchedTokenException(tokenNames, LT(1), t, true, getFilename());
+ } else {
+ // mark token as consumed -- fetch next token deferred until LA/LT
+ consume();
+ }
+}
+
+void Parser::panic()
+{
+ ANTLR_USE_NAMESPACE(std)cerr << "Parser: panic" << ANTLR_USE_NAMESPACE(std)endl;
+ exit(1);
+}
+
+/** Parser error-reporting function can be overridden in subclass */
+void Parser::reportError(const RecognitionException& ex)
+{
+ ANTLR_USE_NAMESPACE(std)cerr << ex.toString().c_str() << ANTLR_USE_NAMESPACE(std)endl;
+}
+
+/** Parser error-reporting function can be overridden in subclass */
+void Parser::reportError(const ANTLR_USE_NAMESPACE(std)string& s)
+{
+ if ( getFilename().empty() )
+ ANTLR_USE_NAMESPACE(std)cerr << "error: " << s.c_str() << ANTLR_USE_NAMESPACE(std)endl;
+ else
+ ANTLR_USE_NAMESPACE(std)cerr << getFilename().c_str() << ": error: " << s.c_str() << ANTLR_USE_NAMESPACE(std)endl;
+}
+
+/** Parser warning-reporting function can be overridden in subclass */
+void Parser::reportWarning(const ANTLR_USE_NAMESPACE(std)string& s)
+{
+ if ( getFilename().empty() )
+ ANTLR_USE_NAMESPACE(std)cerr << "warning: " << s.c_str() << ANTLR_USE_NAMESPACE(std)endl;
+ else
+ ANTLR_USE_NAMESPACE(std)cerr << getFilename().c_str() << ": warning: " << s.c_str() << ANTLR_USE_NAMESPACE(std)endl;
+}
+
+void Parser::rewind(int pos)
+{
+ inputState->getInput().rewind(pos);
+}
+
+/** Set the object used to generate ASTs */
+// void setASTFactory(ASTFactory astFactory_);
+
+/** Specify the type of node to create during tree building */
+void Parser::setASTNodeFactory(ASTFactory::factory_type factory)
+{
+ astFactory.setASTNodeFactory(factory);
+}
+
+void Parser::setFilename(const ANTLR_USE_NAMESPACE(std)string& f)
+{
+ inputState->filename = f;
+}
+
+void Parser::setInputState(ParserSharedInputState state)
+{
+ inputState = state;
+}
+
+/** Set or change the input token buffer */
+// void setTokenBuffer(TokenBuffer<Token>* t);
+
+void Parser::traceIndent()
+{
+ for( int i = 0; i < traceDepth; i++ )
+ ANTLR_USE_NAMESPACE(std)cout << " ";
+}
+
+void Parser::traceIn(const ANTLR_USE_NAMESPACE(std)string& rname)
+{
+ traceDepth++;
+
+ for( int i = 0; i < traceDepth; i++ )
+ ANTLR_USE_NAMESPACE(std)cout << " ";
+
+ ANTLR_USE_NAMESPACE(std)cout << "> " << rname.c_str() << "; LA(1)==" << LT(1)->getText().c_str() <<
+ ((inputState->guessing>0)?" [guessing]":"") << ANTLR_USE_NAMESPACE(std)endl;
+}
+
+void Parser::traceOut(const ANTLR_USE_NAMESPACE(std)string& rname)
+{
+ for( int i = 0; i < traceDepth; i++ )
+ ANTLR_USE_NAMESPACE(std)cout << " ";
+
+ ANTLR_USE_NAMESPACE(std)cout << "< " << rname.c_str() << "; LA(1)==" << LT(1)->getText().c_str() <<
+ ((inputState->guessing>0)?" [guessing]":"") << ANTLR_USE_NAMESPACE(std)endl;
+
+ traceDepth--;
+}
+
+ANTLR_END_NAMESPACE
diff --git a/poxml/antlr/src/ParserSharedInputState.cpp b/poxml/antlr/src/ParserSharedInputState.cpp
new file mode 100644
index 00000000..102aba87
--- /dev/null
+++ b/poxml/antlr/src/ParserSharedInputState.cpp
@@ -0,0 +1,37 @@
+#include "antlr/ParserSharedInputState.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/** This object contains the data associated with an
+ * input stream of tokens. Multiple parsers
+ * share a single ParserSharedInputState to parse
+ * the same stream of tokens.
+ */
+
+ParserInputState::ParserInputState(TokenBuffer* input_)
+: guessing(0)
+, input(input_)
+, inputResponsible(true)
+{
+}
+
+ParserInputState::ParserInputState(TokenBuffer& input_)
+: guessing(0)
+, input(&input_)
+, inputResponsible(false)
+{
+}
+
+ParserInputState::~ParserInputState()
+{
+ if (inputResponsible)
+ delete input;
+}
+
+TokenBuffer& ParserInputState::getInput()
+{
+ return *input;
+}
+
+ANTLR_END_NAMESPACE
+
diff --git a/poxml/antlr/src/RecognitionException.cpp b/poxml/antlr/src/RecognitionException.cpp
new file mode 100644
index 00000000..1d1bd53d
--- /dev/null
+++ b/poxml/antlr/src/RecognitionException.cpp
@@ -0,0 +1,87 @@
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1998
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1998
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/RecognitionException.hpp"
+#include "antlr/String.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+RecognitionException::RecognitionException()
+: ANTLRException("parsing error"), line(1), column(1)
+{}
+
+RecognitionException::RecognitionException(const ANTLR_USE_NAMESPACE(std)string& s)
+: ANTLRException(s)
+{}
+
+RecognitionException::RecognitionException(const ANTLR_USE_NAMESPACE(std)string& s,const ANTLR_USE_NAMESPACE(std)string& fileName_,int line_)
+: ANTLRException(s), fileName(fileName_), line(line_)
+{}
+
+RecognitionException::RecognitionException(const ANTLR_USE_NAMESPACE(std)string& s,const ANTLR_USE_NAMESPACE(std)string& fileName_,int line_,int column_)
+: ANTLRException(s), fileName(fileName_), line(line_), column(column_)
+{}
+
+int RecognitionException::getColumn() const
+{
+ return column;
+}
+
+ANTLR_USE_NAMESPACE(std)string RecognitionException::getErrorMessage() const
+{
+ return getMessage();
+}
+
+ANTLR_USE_NAMESPACE(std)string RecognitionException::getFileLineString() const
+{
+ if ( fileName.length() )
+ return fileName+": "+line+": ";
+ else
+ return ANTLR_USE_NAMESPACE(std)string("line ")+line+": ";
+}
+
+ANTLR_USE_NAMESPACE(std)string RecognitionException::getFilename() const
+{
+ return fileName;
+}
+
+int RecognitionException::getLine() const
+{
+ return line;
+}
+
+ANTLR_USE_NAMESPACE(std)string RecognitionException::toString() const
+{
+ return getFileLineString()+getMessage();
+}
+
+ANTLR_END_NAMESPACE
diff --git a/poxml/antlr/src/String.cpp b/poxml/antlr/src/String.cpp
new file mode 100644
index 00000000..6d9df7a5
--- /dev/null
+++ b/poxml/antlr/src/String.cpp
@@ -0,0 +1,61 @@
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1998
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1998
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/String.hpp"
+
+#ifdef HAS_NOT_CSTDIO_H
+#include <stdio.h>
+#else
+#include <cstdio>
+#endif
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+ANTLR_C_USING(sprintf)
+
+ANTLR_USE_NAMESPACE(std)string operator+(const ANTLR_USE_NAMESPACE(std)string& lhs,int rhs)
+{
+ char tmp[100];
+ sprintf(tmp,"%d",rhs);
+ return lhs+tmp;
+}
+
+ANTLR_USE_NAMESPACE(std)string charName(int ch)
+{
+ if (ch == EOF)
+ return "EOF";
+ else {
+ return ANTLR_USE_NAMESPACE(std)string(1, static_cast<char>(ch));
+ }
+}
+
+ANTLR_END_NAMESPACE
+
diff --git a/poxml/antlr/src/Token.cpp b/poxml/antlr/src/Token.cpp
new file mode 100644
index 00000000..f307774f
--- /dev/null
+++ b/poxml/antlr/src/Token.cpp
@@ -0,0 +1,108 @@
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1998
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1998
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/Token.hpp"
+#include "antlr/String.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+RefToken Token::badToken(new Token(Token::INVALID_TYPE, "<no text>"));
+
+Token::Token() : type(INVALID_TYPE)
+{
+}
+
+Token::Token(int t) : type(t)
+{
+}
+
+Token::Token(int t, const ANTLR_USE_NAMESPACE(std)string& txt)
+ : type(t)
+{
+ type=t;
+ setText(txt);
+}
+
+int Token::getColumn() const
+{
+ return 0;
+}
+
+int Token::getLine() const
+{
+ return 0;
+}
+
+ANTLR_USE_NAMESPACE(std)string Token::getText() const
+{
+ return "<no text>";
+}
+
+int Token::getType() const
+{
+ return type;
+}
+
+void Token::setColumn(int c)
+{}
+
+void Token::setLine(int l)
+{}
+
+void Token::setText(const ANTLR_USE_NAMESPACE(std)string& t)
+{}
+
+void Token::setType(int t)
+{
+ type=t;
+}
+
+ANTLR_USE_NAMESPACE(std)string Token::toString() const
+{
+ return "[\""+getText()+"\",<"+type+">]";
+}
+
+Token::~Token()
+{}
+
+RefToken nullToken;
+
+#ifndef NO_STATIC_CONSTS
+const int Token::MIN_USER_TYPE;
+const int Token::NULL_TREE_LOOKAHEAD;
+const int Token::INVALID_TYPE;
+const int Token::EOF_TYPE;
+const int Token::SKIP;
+#endif
+
+ANTLR_END_NAMESPACE
+
diff --git a/poxml/antlr/src/TokenBuffer.cpp b/poxml/antlr/src/TokenBuffer.cpp
new file mode 100644
index 00000000..ded5df9b
--- /dev/null
+++ b/poxml/antlr/src/TokenBuffer.cpp
@@ -0,0 +1,107 @@
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1998
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1998
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+
+#include "antlr/TokenBuffer.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/**A Stream of Token objects fed to the parser from a TokenStream that can
+ * be rewound via mark()/rewind() methods.
+ * <p>
+ * A dynamic array is used to buffer up all the input tokens. Normally,
+ * "k" tokens are stored in the buffer. More tokens may be stored during
+ * guess mode (testing syntactic predicate), or when LT(i>k) is referenced.
+ * Consumption of tokens is deferred. In other words, reading the next
+ * token is not done by conume(), but deferred until needed by LA or LT.
+ * <p>
+ *
+ * @see antlr.Token
+ * @see antlr.TokenStream
+ * @see antlr.TokenQueue
+ */
+
+/** Create a token buffer */
+TokenBuffer::TokenBuffer(TokenStream& input_)
+: input(input_)
+{ nMarkers=0; markerOffset=0; numToConsume=0; }
+
+/** Mark another token for deferred consumption */
+void TokenBuffer::consume()
+{ numToConsume++; }
+
+/** Ensure that the token buffer is sufficiently full */
+void TokenBuffer::fill(int amount)
+{
+ syncConsume();
+ // Fill the buffer sufficiently to hold needed tokens
+ while (queue.entries() < amount + markerOffset) {
+ // Append the next token
+ queue.append(input.nextToken());
+ }
+}
+
+/** Get a lookahead token value */
+int TokenBuffer::LA(int i)
+{
+ fill(i);
+ return queue.elementAt(markerOffset+i-1)->type;
+}
+
+/** Get a lookahead token */
+RefToken TokenBuffer::LT(int i)
+{
+ fill(i);
+ return queue.elementAt(markerOffset+i-1);
+}
+
+/**Return an integer marker that can be used to rewind the buffer to
+ * its current state.
+ */
+int TokenBuffer::mark()
+{
+ syncConsume();
+ nMarkers++;
+ return markerOffset;
+}
+
+/**Rewind the token buffer to a marker.
+ * @param mark Marker returned previously from mark()
+ */
+void TokenBuffer::rewind(int mark)
+{
+ syncConsume();
+ markerOffset=mark;
+ nMarkers--;
+}
+
+ANTLR_END_NAMESPACE
+
diff --git a/poxml/antlr/src/TokenStreamBasicFilter.cpp b/poxml/antlr/src/TokenStreamBasicFilter.cpp
new file mode 100644
index 00000000..71257f46
--- /dev/null
+++ b/poxml/antlr/src/TokenStreamBasicFilter.cpp
@@ -0,0 +1,34 @@
+#include "antlr/TokenStreamBasicFilter.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/** This object is a TokenStream that passes through all
+ * tokens except for those that you tell it to discard.
+ * There is no buffering of the tokens.
+ */
+TokenStreamBasicFilter::TokenStreamBasicFilter(TokenStream& input_)
+: input(&input_)
+{
+}
+
+void TokenStreamBasicFilter::discard(int ttype)
+{
+ discardMask.add(ttype);
+}
+
+void TokenStreamBasicFilter::discard(const BitSet& mask)
+{
+ discardMask = mask;
+}
+
+RefToken TokenStreamBasicFilter::nextToken()
+{
+ RefToken tok = input->nextToken();
+ while ( tok && discardMask.member(tok->getType()) ) {
+ tok = input->nextToken();
+ }
+ return tok;
+}
+
+ANTLR_END_NAMESPACE
+
diff --git a/poxml/antlr/src/TokenStreamHiddenTokenFilter.cpp b/poxml/antlr/src/TokenStreamHiddenTokenFilter.cpp
new file mode 100644
index 00000000..827ca382
--- /dev/null
+++ b/poxml/antlr/src/TokenStreamHiddenTokenFilter.cpp
@@ -0,0 +1,146 @@
+#include "antlr/TokenStreamHiddenTokenFilter.hpp"
+#include "antlr/CommonHiddenStreamToken.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/**This object filters a token stream coming from a lexer
+ * or another TokenStream so that only certain token channels
+ * get transmitted to the parser.
+ *
+ * Any of the channels can be filtered off as "hidden" channels whose
+ * tokens can be accessed from the parser.
+ */
+
+TokenStreamHiddenTokenFilter::TokenStreamHiddenTokenFilter(TokenStream& input)
+: TokenStreamBasicFilter(input)
+{
+}
+
+void TokenStreamHiddenTokenFilter::consume()
+{
+ nextMonitoredToken = input->nextToken();
+}
+
+void TokenStreamHiddenTokenFilter::consumeFirst()
+{
+ consume();
+
+ // Handle situation where hidden or discarded tokens
+ // appear first in input stream
+ RefToken p;
+ // while hidden or discarded scarf tokens
+ while ( hideMask.member(LA(1)->getType()) || discardMask.member(LA(1)->getType()) ) {
+ if ( hideMask.member(LA(1)->getType()) ) {
+ if ( !p ) {
+ p = LA(1);
+ }
+ else {
+ static_cast<CommonHiddenStreamToken*>(p.get())->setHiddenAfter(LA(1));
+ static_cast<CommonHiddenStreamToken*>(LA(1).get())->setHiddenBefore(p); // double-link
+ p = LA(1);
+ }
+ lastHiddenToken = p;
+ if (!firstHidden)
+ firstHidden = p; // record hidden token if first
+ }
+ consume();
+ }
+}
+
+BitSet TokenStreamHiddenTokenFilter::getDiscardMask() const
+{
+ return discardMask;
+}
+
+/** Return a ptr to the hidden token appearing immediately after
+ * token t in the input stream.
+ */
+RefToken TokenStreamHiddenTokenFilter::getHiddenAfter(RefToken t)
+{
+ return static_cast<CommonHiddenStreamToken*>(t.get())->getHiddenAfter();
+}
+
+/** Return a ptr to the hidden token appearing immediately before
+ * token t in the input stream.
+ */
+RefToken TokenStreamHiddenTokenFilter::getHiddenBefore(RefToken t)
+{
+ return static_cast<CommonHiddenStreamToken*>(t.get())->getHiddenBefore();
+}
+
+BitSet TokenStreamHiddenTokenFilter::getHideMask() const
+{
+ return hideMask;
+}
+
+/** Return the first hidden token if one appears
+ * before any monitored token.
+ */
+RefToken TokenStreamHiddenTokenFilter::getInitialHiddenToken()
+{
+ return firstHidden;
+}
+
+void TokenStreamHiddenTokenFilter::hide(int m)
+{
+ hideMask.add(m);
+}
+
+void TokenStreamHiddenTokenFilter::hide(const BitSet& mask)
+{
+ hideMask = mask;
+}
+
+RefToken TokenStreamHiddenTokenFilter::LA(int i)
+{
+ return nextMonitoredToken;
+}
+
+/** Return the next monitored token.
+* Test the token following the monitored token.
+* If following is another monitored token, save it
+* for the next invocation of nextToken (like a single
+* lookahead token) and return it then.
+* If following is unmonitored, nondiscarded (hidden)
+* channel token, add it to the monitored token.
+*
+* Note: EOF must be a monitored Token.
+*/
+RefToken TokenStreamHiddenTokenFilter::nextToken()
+{
+ // handle an initial condition; don't want to get lookahead
+ // token of this splitter until first call to nextToken
+ if ( !LA(1) ) {
+ consumeFirst();
+ }
+
+ // we always consume hidden tokens after monitored, thus,
+ // upon entry LA(1) is a monitored token.
+ RefToken monitored = LA(1);
+ // point to hidden tokens found during last invocation
+ static_cast<CommonHiddenStreamToken*>(monitored.get())->setHiddenBefore(lastHiddenToken);
+ lastHiddenToken = nullToken;
+
+ // Look for hidden tokens, hook them into list emanating
+ // from the monitored tokens.
+ consume();
+ RefToken p = monitored;
+ // while hidden or discarded scarf tokens
+ while ( hideMask.member(LA(1)->getType()) || discardMask.member(LA(1)->getType()) ) {
+ if ( hideMask.member(LA(1)->getType()) ) {
+ // attach the hidden token to the monitored in a chain
+ // link forwards
+ static_cast<CommonHiddenStreamToken*>(p.get())->setHiddenAfter(LA(1));
+ // link backwards
+ if (p != monitored) { //hidden cannot point to monitored tokens
+ static_cast<CommonHiddenStreamToken*>(LA(1).get())->setHiddenBefore(p);
+ }
+ p = lastHiddenToken = LA(1);
+ }
+ consume();
+ }
+ return monitored;
+}
+
+ANTLR_END_NAMESPACE
+
diff --git a/poxml/antlr/src/TokenStreamSelector.cpp b/poxml/antlr/src/TokenStreamSelector.cpp
new file mode 100644
index 00000000..2e6527a8
--- /dev/null
+++ b/poxml/antlr/src/TokenStreamSelector.cpp
@@ -0,0 +1,97 @@
+#include "antlr/TokenStreamSelector.hpp"
+#include "antlr/TokenStreamRetryException.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/** A token stream MUX (multiplexor) knows about n token streams
+ * and can multiplex them onto the same channel for use by token
+ * stream consumer like a parser. This is a way to have multiple
+ * lexers break up the same input stream for a single parser.
+ * Or, you can have multiple instances of the same lexer handle
+ * multiple input streams; this works great for includes.
+ */
+
+TokenStreamSelector::TokenStreamSelector()
+: input(0)
+{
+}
+
+TokenStreamSelector::~TokenStreamSelector()
+{
+}
+
+void TokenStreamSelector::addInputStream(TokenStream* stream, const ANTLR_USE_NAMESPACE(std)string& key)
+{
+ inputStreamNames[key] = stream;
+}
+
+TokenStream* TokenStreamSelector::getCurrentStream() const
+{
+ return input;
+}
+
+TokenStream* TokenStreamSelector::getStream(const ANTLR_USE_NAMESPACE(std)string& sname) const
+{
+ inputStreamNames_coll::const_iterator i = inputStreamNames.find(sname);
+ if (i == inputStreamNames.end()) {
+ throw ANTLR_USE_NAMESPACE(std)string("TokenStream ")+sname+" not found";
+ }
+ return (*i).second;
+}
+
+RefToken TokenStreamSelector::nextToken()
+{
+ // keep looking for a token until you don't
+ // get a retry exception
+ for (;;) {
+ try {
+ return input->nextToken();
+ }
+ catch (TokenStreamRetryException& r) {
+ // just retry "forever"
+ }
+ }
+}
+
+TokenStream* TokenStreamSelector::pop()
+{
+ TokenStream* stream = streamStack.top();
+ streamStack.pop();
+ select(stream);
+ return stream;
+}
+
+void TokenStreamSelector::push(TokenStream* stream)
+{
+ streamStack.push(input);
+ select(stream);
+}
+
+void TokenStreamSelector::push(const ANTLR_USE_NAMESPACE(std)string& sname)
+{
+ streamStack.push(input);
+ select(sname);
+}
+
+void TokenStreamSelector::retry()
+{
+ throw TokenStreamRetryException();
+}
+
+/** Set the stream without pushing old stream */
+void TokenStreamSelector::select(TokenStream* stream)
+{
+ input = stream;
+}
+
+void TokenStreamSelector::select(const ANTLR_USE_NAMESPACE(std)string& sname)
+{
+ inputStreamNames_coll::const_iterator i = inputStreamNames.find(sname);
+ if (i == inputStreamNames.end()) {
+ throw ANTLR_USE_NAMESPACE(std)string("TokenStream ")+sname+" not found";
+ }
+ input = (*i).second;
+}
+
+ANTLR_END_NAMESPACE
+
diff --git a/poxml/antlr/src/TreeParser.cpp b/poxml/antlr/src/TreeParser.cpp
new file mode 100644
index 00000000..6d302737
--- /dev/null
+++ b/poxml/antlr/src/TreeParser.cpp
@@ -0,0 +1,165 @@
+/**
+ * <b>SOFTWARE RIGHTS</b>
+ * <p>
+ * ANTLR 2.6.0 MageLang Insitute, 1998
+ * <p>
+ * We reserve no legal rights to the ANTLR--it is fully in the
+ * public domain. An individual or company may do whatever
+ * they wish with source code distributed with ANTLR or the
+ * code generated by ANTLR, including the incorporation of
+ * ANTLR, or its output, into commerical software.
+ * <p>
+ * We encourage users to develop software with ANTLR. However,
+ * we do ask that credit is given to us for developing
+ * ANTLR. By "credit", we mean that if you use ANTLR or
+ * incorporate any source code into one of your programs
+ * (commercial product, research project, or otherwise) that
+ * you acknowledge this fact somewhere in the documentation,
+ * research report, etc... If you like ANTLR and have
+ * developed a nice tool with the output, please mention that
+ * you developed it using ANTLR. In addition, we ask that the
+ * headers remain intact in our source code. As long as these
+ * guidelines are kept, we expect to continue enhancing this
+ * system and expect to make other tools available as they are
+ * completed.
+ * <p>
+ * The ANTLR gang:
+ * @version ANTLR 2.6.0 MageLang Insitute, 1998
+ * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
+ * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
+ * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
+ */
+#include "antlr/TreeParser.hpp"
+#include "antlr/ASTNULLType.hpp"
+#include "antlr/MismatchedTokenException.hpp"
+#include <iostream>
+#include <stdlib.h>
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+ANTLR_C_USING(exit)
+
+TreeParser::TreeParser()
+: inputState(new TreeParserInputState()), traceDepth(0)
+{
+}
+
+TreeParser::TreeParser(const TreeParserSharedInputState& state)
+: inputState(state), traceDepth(0)
+{
+}
+
+TreeParser::~TreeParser()
+{
+}
+
+void TreeParser::setTokenNames(const char** tokenNames_)
+{
+ while (*tokenNames_) {
+ tokenNames.push_back(*(tokenNames_++));
+ }
+}
+
+/** The AST Null object; the parsing cursor is set to this when
+ * it is found to be null. This way, we can test the
+ * token type of a node without having to have tests for null
+ * everywhere.
+ */
+RefAST TreeParser::ASTNULL(new ASTNULLType);
+
+/** Get the AST return value squirreled away in the parser */
+//RefAST getAST() const {
+// return returnAST;
+//}
+
+void TreeParser::match(RefAST t, int ttype)
+{
+ if (!t || t==ASTNULL || t->getType()!=ttype)
+ throw MismatchedTokenException();
+}
+
+/**Make sure current lookahead symbol matches the given set
+ * Throw an exception upon mismatch, which is caught by either the
+ * error handler or by the syntactic predicate.
+ */
+void TreeParser::match(RefAST t, const BitSet& b)
+{
+ if ( !t || t==ASTNULL || !b.member(t->getType()) ) {
+ throw MismatchedTokenException();
+ }
+}
+
+void TreeParser::matchNot(RefAST t, int ttype)
+{
+ //ANTLR_USE_NAMESPACE(std)cout << "match(" << ttype << "); cursor is " << t.toString() << ANTLR_USE_NAMESPACE(std)endl;
+ if ( !t || t==ASTNULL || t->getType()==ttype ) {
+ throw MismatchedTokenException();
+ }
+}
+
+void TreeParser::panic()
+{
+ ANTLR_USE_NAMESPACE(std)cerr << "TreeWalker: panic" << ANTLR_USE_NAMESPACE(std)endl;
+ exit(1);
+}
+
+/** Parser error-reporting function can be overridden in subclass */
+void TreeParser::reportError(const RecognitionException& ex)
+{
+ ANTLR_USE_NAMESPACE(std)cerr << ex.toString().c_str() << ANTLR_USE_NAMESPACE(std)endl;
+}
+
+/** Parser error-reporting function can be overridden in subclass */
+void TreeParser::reportError(const ANTLR_USE_NAMESPACE(std)string& s)
+{
+ ANTLR_USE_NAMESPACE(std)cerr << "error: " << s.c_str() << ANTLR_USE_NAMESPACE(std)endl;
+}
+
+/** Parser warning-reporting function can be overridden in subclass */
+void TreeParser::reportWarning(const ANTLR_USE_NAMESPACE(std)string& s)
+{
+ ANTLR_USE_NAMESPACE(std)cerr << "warning: " << s.c_str() << ANTLR_USE_NAMESPACE(std)endl;
+}
+
+/** Specify an object with support code (shared by
+ * Parser and TreeParser. Normally, the programmer
+ * does not play with this, using setASTNodeType instead.
+ */
+// void TreeParser::setASTFactory(ASTFactory f);
+
+/** Specify the type of node to create during tree building */
+void TreeParser::setASTNodeFactory(ASTFactory::factory_type factory)
+{
+ astFactory.setASTNodeFactory(factory);
+}
+
+/** Procedure to write out an indent for traceIn and traceOut */
+void TreeParser::traceIndent()
+{
+ for( int i = 0; i < traceDepth; i++ )
+ ANTLR_USE_NAMESPACE(std)cout << " ";
+}
+
+void TreeParser::traceIn(const ANTLR_USE_NAMESPACE(std)string& rname, RefAST t)
+{
+ traceDepth++;
+ traceIndent();
+
+ ANTLR_USE_NAMESPACE(std)cout << "> " << rname.c_str()
+ << "(" << (t ? t->toString().c_str() : "null") << ")"
+ << ((inputState->guessing>0)?" [guessing]":"")
+ << ANTLR_USE_NAMESPACE(std)endl;
+}
+
+void TreeParser::traceOut(const ANTLR_USE_NAMESPACE(std)string& rname, RefAST t)
+{
+ traceIndent();
+
+ ANTLR_USE_NAMESPACE(std)cout << "< " << rname.c_str()
+ << "(" << (t ? t->toString().c_str() : "null") << ")"
+ << ((inputState->guessing>0)?" [guessing]":"")
+ << ANTLR_USE_NAMESPACE(std)endl;
+
+ traceDepth--;
+}
+
+ANTLR_END_NAMESPACE
diff --git a/poxml/antlr/src/TreeParserSharedInputState.cpp b/poxml/antlr/src/TreeParserSharedInputState.cpp
new file mode 100644
index 00000000..89f1d5dc
--- /dev/null
+++ b/poxml/antlr/src/TreeParserSharedInputState.cpp
@@ -0,0 +1,22 @@
+#include "antlr/TreeParserSharedInputState.hpp"
+
+ANTLR_BEGIN_NAMESPACE(antlr)
+
+/** This object contains the data associated with an
+ * input AST. Multiple parsers
+ * share a single TreeParserSharedInputState to parse
+ * the same tree or to have the parser walk multiple
+ * trees.
+ */
+
+TreeParserInputState::TreeParserInputState()
+: guessing(0)
+{
+}
+
+TreeParserInputState::~TreeParserInputState()
+{
+}
+
+ANTLR_END_NAMESPACE
+