Skip to content

Commit

Permalink
add antlr 2.7.7 cpp runtime for parsing the sqlite3 grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
rp- committed Mar 13, 2013
1 parent f1ce26c commit 3c6ab04
Show file tree
Hide file tree
Showing 86 changed files with 9,127 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libs/antlr-2.7.7/AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Author:
Peter Wells <pete@yamuna.demon.co.uk>
31 changes: 31 additions & 0 deletions libs/antlr-2.7.7/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

SOFTWARE RIGHTS

ANTLR 1989-2006 Developed by Terence Parr
Partially supported by University of San Francisco & jGuru.com

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
parrt@cs.usfca.edu
parrt@antlr.org
191 changes: 191 additions & 0 deletions libs/antlr-2.7.7/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
ANTLR C++ Support Libraries Additional Notes

1.1 Using Microsoft Visual C++

Currently this is still (or again) somewhat experimental. MSVC is not the
development platform and I don't have access to the compiler currently.
YMMV

Make sure you compile the library *and* your project with the same
settings. (multithreaded/debug/etc.)

Visual C++ 6 only is supported for static builds. Some hacking and STLPort
is needed to build a DLL (only for experts).

Visual C++ 7.0 and 7.1 should support both static and DLL builds (DLL
builds might be broken). In general the main problem is getting the right
template instantiations into the DLL. For 7.0 you might have to tweak the
list in lib/cpp/src/dll.cpp. I'm told 7.1 does not need this.

For a static build (works probably best)

1. Create a win32 static library project.
2. Enable RTTI. (Run Time Type Information)
3. Add the source files from <installpath>/antlr/lib/cpp/src to the project
(except dll.cpp) put <installpath>/antlr/lib/cpp in the search path for
include files.

For the DLL build (MSVC 7.0 tested)

* Project settings ("create new project" dialogs)
- Win32 project
- Application Settings
- Application type
- DLL
- Additional options
- Export symbols
* Project properties (change defaults to)
- Configuration Properties
- C/C++
- General
- Additional Include Directories
- drive:\antlr-2.7.2\lib\cpp
- Preprocessor
- Preprocessor Definitions
- WIN32;_DEBUG;_WINDOWS;_USRDLL;ANTLR_EXPORTS
- Code Generation
- Runtime Library
- Multi-threaded Debug DLL (/MDd)
- Enable Function-Level Linking:
- Yes
- Language
- Enable Run-Time Type Info
- Yes
- Precompiled Headers
- Create/Use Precompiled Headers

NOTE: Do not use the antlr generated and support library in a multithreaded
way. It was not designed for a multithreaded environment.

1.3 Building with GCJ

NOTE: outdated the new Makefiles do not support this anymore.

It is also possible to build a native binary of ANTLR. This is somewhat
experimental and can be enabled by giving the --enable-gcj option to
configure. You need a recent GCC to do this and even then the constructed
binary crashes on some platforms.

2. Tested Compilers for this release

Don't get worried if your favourite compiler is not mentioned here. Any
somewhat recent ISO compliant C++ compiler should have little trouble with
the runtime library.

*NOTE* this section was not updated for the new configure script/Makefiles some of the things listed here to pass different flags to configure may not work anymore. Check INSTALL.txt or handedit generated scripts after configure.

2.1 Solaris

2.1.1 Sun Workshop 6.0

Identifies itself as:

CC: Sun WorkShop 6 2000/08/30 C++ 5.1 Patch 109490-01

Compiles out of the box configure using:

CXX=CC CC=cc AR=CC ARFLAGS="-xar -o" ./configure

Use CC to make the archive to ensure bundling of template instances. Check
manpage for details.

2.1.2 GCC

Tested 3.0.4, 3.2.1, 3.2.3, 3.3.2, 3.4.0.

All tested gcc are using a recent GNU binutils for linker and assembler.
You will probably run into trouble if you use the solaris
linker/assembler.

2.2 Windows

2.2.1 Visual C++

Visual C++ 6.0 reported to work well with static build. DLL build not
supported (reported to work when using STLPort in previous ANTLR versions).
I heart that in some cases there could be problems with precompiled headers
and the use of normal '/' in the #include directives (with service pack 5).

Visual C++ 7.0 reported to work, might need some tweaks for DLL builds due
to some shuffling around in the code.

Visual C++ 7.1 reported to work, might need some tweaks, see above.

My current guess is that DLL builds are all over the line broken. A
workaround is to make a DLL from the complete generated parser including
the static ANTLR support library.

2.2.2 Cygwin/MinGW

Not expecting any big problems maybe some tweaks needed in configure.

3. Old notes for a number of compilers

3.1 SGI Irix 6.5.10 MIPSPro compiler

You can't compile ANTLR with the MIPSPro compiler on anything < 6.5.10
because SGI just fixed a big bug dealing with namespaces in that release.

Note: To get it to compile do basically the following:

CC=cc CXX=CC CXXFLAGS=-LANG:std ./configure --prefix=/usr/local/antlr

Note probably dates back to 2.7.0-2.7.1 era.

3.2 Sun CC 5

It may be you'll have to change one or two static_cast<char*>()'s to a
C-style cast. (think that's a compiler bug)

Configure using:

CXX=CC CC=cc RANLIB="CC -xar" ./configure

The custom ranlib is needed to get the template instances into the archive.
Check manpages. Maybe the Sun CC 6 instructions above will work as well.

3.3 GCC on some platforms (Alpha Tru64)

The -pipe option not supported it seems. Configure using:

CFLAGS="-W -Wall" ./configure

Or remove the -pipe's from the generated scripts/Config.make.

4. IT DOESN'T WORK!?

4.1 Compile problems

The ANTLR code uses some relatively new features of C++ which not all
compilers support yet (such as namespaces, and new style standard headers).

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!

4.2 Reporting problems

When reporting problems please try to be as specific as possible e.g.
mention ANTLR release, and try to provide a clear and minimal example of
what goes wrong and what you expected.

Bug reports can be done to Terence or the current subsystem maintainers as
mentioned in the doc directory. Another option is to use the mailing list
linked from http://www.antlr.org.

Before reporting a problem you might want to try with a development
snapshot, there is a link to these in the File Sharing section of

http://www.antlr.org.
83 changes: 83 additions & 0 deletions libs/antlr-2.7.7/TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
* ANTLR should issue a warning if you have protected rules and
filter == true or filter=IGNORE in a lexer?
This can be tackled by tracking rule references in a more general approach.

* Have a look at the doc's.

* 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

* Fix heterogeneous AST stuff. It boils down to adding a method to AST
types that knows how to duplicate the sucker.
-> done clone() added.
Knowing one factory is not enough.
-> done in C++ have a superfactory.
Also look at having to set the astfactory by hand (this is not 100% necessary).
Double check generated code.
http://groups.yahoo.com/group/antlr-interest/message/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

* in action.g (java and C++) ##.initialize / ##->initialize is not
recognized as an assigment to the root node. In the case ## is followed
by ./-> initialize transInfo.assignToRoot should be set to true.
Report by Matthew Ford (12 march 2001)

* Add TokenLabelType option for generated lexers. Hmmm can already set token
factory. Then again.. you may run into a cast fest..

* Fix some #line counting oddities (Mike Barnett)
> nonterm
> {
> ## = #([TOK,"TOK"],
> ... Other stuff ...
> );
> f();
> }
generates wrong #line info need to fix action.g a bit better.

* This one triggers a bug in antlr's codegen.
#perform_action = #( create_tau_ast(#p1->getLine(),#p1->getColumn()), #p1 );

#p1 are replaced by p1 in stead of p1_AST. It's really time to rewrite this
mess.

Workaround:

RefModest_AST tau = create_tau_ast(#p1->getLine(),#p1->getColumn());
#perform_action = #( tau, #p1 );

* Unicode and related.
- The patch from Jean-Daniel Fekete is an approach. But has some issues.
+ It is probably necessary to discern an 'internal' string/char type and
'external' ones. The external ones are for the lexer input. The
'internal ones' are for standard antlr error messages etc. Translators
from external to internal should be provided.
Hmm on second thought.. probably not really an issue.
+ What should the lexer read?
- Unicode units from a 'unicode reader' in a sense this unicode reader
is a lexer itself. Just reading iconv/iconv_open manpages.. Maybe we
can hide this with iconv in the InputBuffer mechanisms?
- Interpret unicode ourselves. Ugh don't want to think of that right now.
we probably redo something that has been done. Only problem is that we
need something that's portable (C++ case)
+ What changes are necessary in the rest of the code to support a wide
character set? Think most should be handled in/below the lexer level.
86 changes: 86 additions & 0 deletions libs/antlr-2.7.7/antlr.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
TEMPLATE = lib

CONFIG = release static

HEADERS += \
antlr/config.hpp \
antlr/TreeParserSharedInputState.hpp \
antlr/TreeParser.hpp \
antlr/TokenWithIndex.hpp \
antlr/TokenStreamSelector.hpp \
antlr/TokenStreamRewriteEngine.hpp \
antlr/TokenStreamRetryException.hpp \
antlr/TokenStreamRecognitionException.hpp \
antlr/TokenStreamIOException.hpp \
antlr/TokenStreamHiddenTokenFilter.hpp \
antlr/TokenStreamException.hpp \
antlr/TokenStreamBasicFilter.hpp \
antlr/TokenStream.hpp \
antlr/TokenRefCount.hpp \
antlr/TokenBuffer.hpp \
antlr/Token.hpp \
antlr/String.hpp \
antlr/SemanticException.hpp \
antlr/RefCount.hpp \
antlr/RecognitionException.hpp \
antlr/ParserSharedInputState.hpp \
antlr/Parser.hpp \
antlr/NoViableAltForCharException.hpp \
antlr/NoViableAltException.hpp \
antlr/MismatchedTokenException.hpp \
antlr/MismatchedCharException.hpp \
antlr/LexerSharedInputState.hpp \
antlr/LLkParser.hpp \
antlr/InputBuffer.hpp \
antlr/IOException.hpp \
antlr/CommonToken.hpp \
antlr/CommonHiddenStreamToken.hpp \
antlr/CommonASTWithHiddenTokens.hpp \
antlr/CommonAST.hpp \
antlr/CircularQueue.hpp \
antlr/CharStreamIOException.hpp \
antlr/CharStreamException.hpp \
antlr/CharScanner.hpp \
antlr/CharInputBuffer.hpp \
antlr/CharBuffer.hpp \
antlr/BitSet.hpp \
antlr/BaseAST.hpp \
antlr/ASTRefCount.hpp \
antlr/ASTPair.hpp \
antlr/ASTNULLType.hpp \
antlr/ASTFactory.hpp \
antlr/ASTArray.hpp \
antlr/AST.hpp \
antlr/ANTLRUtil.hpp \
antlr/ANTLRException.hpp

SOURCES += \
src/TreeParser.cpp \
src/TokenStreamSelector.cpp \
src/TokenStreamRewriteEngine.cpp \
src/TokenStreamHiddenTokenFilter.cpp \
src/TokenStreamBasicFilter.cpp \
src/TokenRefCount.cpp \
src/TokenBuffer.cpp \
src/Token.cpp \
src/String.cpp \
src/RecognitionException.cpp \
src/Parser.cpp \
src/NoViableAltForCharException.cpp \
src/NoViableAltException.cpp \
src/MismatchedTokenException.cpp \
src/MismatchedCharException.cpp \
src/LLkParser.cpp \
src/InputBuffer.cpp \
src/CommonToken.cpp \
src/CommonHiddenStreamToken.cpp \
src/CommonASTWithHiddenTokens.cpp \
src/CommonAST.cpp \
src/CharScanner.cpp \
src/CharBuffer.cpp \
src/BitSet.cpp \
src/BaseAST.cpp \
src/ASTRefCount.cpp \
src/ASTNULLType.cpp \
src/ASTFactory.cpp \
src/ANTLRUtil.cpp
Loading

0 comments on commit 3c6ab04

Please sign in to comment.