From 7d4f47bd0bf7544dbd7f64ed4089e80780c1d2bd Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Wed, 16 Dec 2020 17:43:36 +0900 Subject: Renaming of files in preparation for code style tools. Signed-off-by: Michele Calgaro --- kapptemplate/existing.module | 2 +- kbabel/Makefile.am | 2 +- kbabel/common/libgettext/CMakeLists.txt | 2 +- kbabel/common/libgettext/Makefile.am | 8 +- kbabel/datatools/accelerators/CMakeLists.txt | 2 +- kbabel/datatools/accelerators/Makefile.am | 2 +- kbabel/datatools/accelerators/main.cc | 137 --------- kbabel/datatools/accelerators/main.cpp | 137 +++++++++ kbabel/datatools/arguments/CMakeLists.txt | 2 +- kbabel/datatools/arguments/Makefile.am | 2 +- kbabel/datatools/arguments/main.cc | 277 ----------------- kbabel/datatools/arguments/main.cpp | 277 +++++++++++++++++ kbabel/datatools/context/CMakeLists.txt | 2 +- kbabel/datatools/context/Makefile.am | 2 +- kbabel/datatools/context/main.cc | 115 -------- kbabel/datatools/context/main.cpp | 115 ++++++++ kbabel/datatools/equations/CMakeLists.txt | 2 +- kbabel/datatools/equations/Makefile.am | 2 +- kbabel/datatools/equations/main.cc | 113 ------- kbabel/datatools/equations/main.cpp | 113 +++++++ kbabel/datatools/length/CMakeLists.txt | 2 +- kbabel/datatools/length/Makefile.am | 2 +- kbabel/datatools/length/main.cc | 142 --------- kbabel/datatools/length/main.cpp | 142 +++++++++ kbabel/datatools/not-translated/CMakeLists.txt | 2 +- kbabel/datatools/not-translated/Makefile.am | 2 +- kbabel/datatools/not-translated/main.cc | 129 -------- kbabel/datatools/not-translated/main.cpp | 129 ++++++++ kbabel/datatools/pluralforms/CMakeLists.txt | 2 +- kbabel/datatools/pluralforms/Makefile.am | 2 +- kbabel/datatools/pluralforms/main.cc | 129 -------- kbabel/datatools/pluralforms/main.cpp | 129 ++++++++ kbabel/datatools/punctuation/CMakeLists.txt | 2 +- kbabel/datatools/punctuation/Makefile.am | 2 +- kbabel/datatools/punctuation/main.cc | 157 ---------- kbabel/datatools/punctuation/main.cpp | 157 ++++++++++ kbabel/datatools/regexp/CMakeLists.txt | 2 +- kbabel/datatools/regexp/Makefile.am | 2 +- kbabel/datatools/regexp/main.cc | 181 ------------ kbabel/datatools/regexp/main.cpp | 181 ++++++++++++ kbabel/datatools/regexp/regexplist.xml | 4 +- kbabel/datatools/setfuzzy/CMakeLists.txt | 2 +- kbabel/datatools/setfuzzy/Makefile.am | 2 +- kbabel/datatools/setfuzzy/main.cc | 98 ------ kbabel/datatools/setfuzzy/main.cpp | 98 ++++++ kbabel/datatools/whitespace/CMakeLists.txt | 2 +- kbabel/datatools/whitespace/Makefile.am | 2 +- kbabel/datatools/whitespace/main.cc | 144 --------- kbabel/datatools/whitespace/main.cpp | 144 +++++++++ kbabel/datatools/xml/CMakeLists.txt | 2 +- kbabel/datatools/xml/Makefile.am | 2 +- kbabel/datatools/xml/main.cc | 206 ------------- kbabel/datatools/xml/main.cpp | 206 +++++++++++++ .../kbabeldict/modules/dbsearchengine/makemsgdb.C | 327 --------------------- .../modules/dbsearchengine/makemsgdb.cpp | 327 +++++++++++++++++++++ kspy/Makefile.am | 2 +- poxml/GettextLexer.cpp | 16 +- poxml/GettextLexer.h | 47 +++ poxml/GettextLexer.hpp | 47 --- poxml/GettextParser.cpp | 14 +- poxml/GettextParser.h | 53 ++++ poxml/GettextParser.hpp | 53 ---- poxml/GettextParserTokenTypes.h | 22 ++ poxml/GettextParserTokenTypes.hpp | 22 -- poxml/antlr/README | 2 +- poxml/antlr/TODO | 2 +- poxml/antlr/antlr/ANTLRException.h | 60 ++++ poxml/antlr/antlr/ANTLRException.hpp | 60 ---- poxml/antlr/antlr/AST.h | 108 +++++++ poxml/antlr/antlr/AST.hpp | 108 ------- poxml/antlr/antlr/ASTArray.h | 63 ++++ poxml/antlr/antlr/ASTArray.hpp | 63 ---- poxml/antlr/antlr/ASTFactory.h | 113 +++++++ poxml/antlr/antlr/ASTFactory.hpp | 113 ------- poxml/antlr/antlr/ASTNULLType.h | 72 +++++ poxml/antlr/antlr/ASTNULLType.hpp | 72 ----- poxml/antlr/antlr/ASTPair.h | 77 +++++ poxml/antlr/antlr/ASTPair.hpp | 77 ----- poxml/antlr/antlr/ASTRefCount.h | 104 +++++++ poxml/antlr/antlr/ASTRefCount.hpp | 104 ------- poxml/antlr/antlr/BaseAST.h | 106 +++++++ poxml/antlr/antlr/BaseAST.hpp | 106 ------- poxml/antlr/antlr/BitSet.h | 50 ++++ poxml/antlr/antlr/BitSet.hpp | 50 ---- poxml/antlr/antlr/CharBuffer.h | 75 +++++ poxml/antlr/antlr/CharBuffer.hpp | 75 ----- poxml/antlr/antlr/CharScanner.h | 266 +++++++++++++++++ poxml/antlr/antlr/CharScanner.hpp | 266 ----------------- poxml/antlr/antlr/CharStreamException.h | 18 ++ poxml/antlr/antlr/CharStreamException.hpp | 18 -- poxml/antlr/antlr/CharStreamIOException.h | 20 ++ poxml/antlr/antlr/CharStreamIOException.hpp | 20 -- poxml/antlr/antlr/CircularQueue.h | 88 ++++++ poxml/antlr/antlr/CircularQueue.hpp | 88 ------ poxml/antlr/antlr/CommonAST.h | 68 +++++ poxml/antlr/antlr/CommonAST.hpp | 68 ----- poxml/antlr/antlr/CommonASTWithHiddenTokens.h | 41 +++ poxml/antlr/antlr/CommonASTWithHiddenTokens.hpp | 41 --- poxml/antlr/antlr/CommonHiddenStreamToken.h | 30 ++ poxml/antlr/antlr/CommonHiddenStreamToken.hpp | 30 -- poxml/antlr/antlr/CommonToken.h | 77 +++++ poxml/antlr/antlr/CommonToken.hpp | 77 ----- poxml/antlr/antlr/InputBuffer.h | 158 ++++++++++ poxml/antlr/antlr/InputBuffer.hpp | 158 ---------- poxml/antlr/antlr/LLkParser.h | 82 ++++++ poxml/antlr/antlr/LLkParser.hpp | 82 ------ poxml/antlr/antlr/LexerSharedInputState.h | 49 +++ poxml/antlr/antlr/LexerSharedInputState.hpp | 49 --- poxml/antlr/antlr/Makefile.am | 88 +++--- poxml/antlr/antlr/MismatchedCharException.h | 127 ++++++++ poxml/antlr/antlr/MismatchedCharException.hpp | 127 -------- poxml/antlr/antlr/MismatchedTokenException.h | 167 +++++++++++ poxml/antlr/antlr/MismatchedTokenException.hpp | 167 ----------- poxml/antlr/antlr/NoViableAltException.h | 71 +++++ poxml/antlr/antlr/NoViableAltException.hpp | 71 ----- poxml/antlr/antlr/NoViableAltForCharException.h | 64 ++++ poxml/antlr/antlr/NoViableAltForCharException.hpp | 64 ---- poxml/antlr/antlr/Parser.h | 213 ++++++++++++++ poxml/antlr/antlr/Parser.hpp | 213 -------------- poxml/antlr/antlr/ParserSharedInputState.h | 42 +++ poxml/antlr/antlr/ParserSharedInputState.hpp | 42 --- poxml/antlr/antlr/RecognitionException.h | 78 +++++ poxml/antlr/antlr/RecognitionException.hpp | 78 ----- poxml/antlr/antlr/RefCount.h | 87 ++++++ poxml/antlr/antlr/RefCount.hpp | 87 ------ poxml/antlr/antlr/SemanticException.h | 52 ++++ poxml/antlr/antlr/SemanticException.hpp | 52 ---- poxml/antlr/antlr/String.h | 47 +++ poxml/antlr/antlr/String.hpp | 47 --- poxml/antlr/antlr/Token.h | 106 +++++++ poxml/antlr/antlr/Token.hpp | 106 ------- poxml/antlr/antlr/TokenBuffer.h | 141 +++++++++ poxml/antlr/antlr/TokenBuffer.hpp | 141 --------- poxml/antlr/antlr/TokenStream.h | 54 ++++ poxml/antlr/antlr/TokenStream.hpp | 54 ---- poxml/antlr/antlr/TokenStreamBasicFilter.h | 35 +++ poxml/antlr/antlr/TokenStreamBasicFilter.hpp | 35 --- poxml/antlr/antlr/TokenStreamException.h | 19 ++ poxml/antlr/antlr/TokenStreamException.hpp | 19 -- poxml/antlr/antlr/TokenStreamHiddenTokenFilter.h | 84 ++++++ poxml/antlr/antlr/TokenStreamHiddenTokenFilter.hpp | 84 ------ poxml/antlr/antlr/TokenStreamIOException.h | 22 ++ poxml/antlr/antlr/TokenStreamIOException.hpp | 22 -- .../antlr/antlr/TokenStreamRecognitionException.h | 21 ++ .../antlr/TokenStreamRecognitionException.hpp | 21 -- poxml/antlr/antlr/TokenStreamRetryException.h | 17 ++ poxml/antlr/antlr/TokenStreamRetryException.hpp | 17 -- poxml/antlr/antlr/TokenStreamSelector.h | 78 +++++ poxml/antlr/antlr/TokenStreamSelector.hpp | 78 ----- poxml/antlr/antlr/TreeParser.h | 159 ++++++++++ poxml/antlr/antlr/TreeParser.hpp | 159 ---------- poxml/antlr/antlr/TreeParserSharedInputState.h | 34 +++ poxml/antlr/antlr/TreeParserSharedInputState.hpp | 34 --- poxml/antlr/antlr/config.h | 168 +++++++++++ poxml/antlr/antlr/config.hpp | 168 ----------- poxml/antlr/src/ANTLRException.cpp | 2 +- poxml/antlr/src/ASTFactory.cpp | 4 +- poxml/antlr/src/ASTRefCount.cpp | 4 +- poxml/antlr/src/BaseAST.cpp | 2 +- poxml/antlr/src/BitSet.cpp | 2 +- poxml/antlr/src/CharBuffer.cpp | 2 +- poxml/antlr/src/CharScanner.cpp | 6 +- poxml/antlr/src/CommonAST.cpp | 4 +- poxml/antlr/src/CommonASTWithHiddenTokens.cpp | 6 +- poxml/antlr/src/CommonHiddenStreamToken.cpp | 2 +- poxml/antlr/src/CommonToken.cpp | 4 +- poxml/antlr/src/InputBuffer.cpp | 2 +- poxml/antlr/src/LLkParser.cpp | 2 +- poxml/antlr/src/LexerSharedInputState.cpp | 4 +- poxml/antlr/src/MismatchedCharException.cpp | 4 +- poxml/antlr/src/MismatchedTokenException.cpp | 4 +- poxml/antlr/src/NoViableAltException.cpp | 4 +- poxml/antlr/src/NoViableAltForCharException.cpp | 4 +- poxml/antlr/src/Parser.cpp | 10 +- poxml/antlr/src/ParserSharedInputState.cpp | 2 +- poxml/antlr/src/RecognitionException.cpp | 4 +- poxml/antlr/src/String.cpp | 2 +- poxml/antlr/src/Token.cpp | 4 +- poxml/antlr/src/TokenBuffer.cpp | 2 +- poxml/antlr/src/TokenStreamBasicFilter.cpp | 2 +- poxml/antlr/src/TokenStreamHiddenTokenFilter.cpp | 4 +- poxml/antlr/src/TokenStreamSelector.cpp | 4 +- poxml/antlr/src/TreeParser.cpp | 6 +- poxml/antlr/src/TreeParserSharedInputState.cpp | 2 +- poxml/gettext.g | 8 +- poxml/po2xml.cpp | 8 +- poxml/swappo.cpp | 4 +- poxml/transxx.cpp | 4 +- umbrello/umbrello/Makefile.am | 2 +- 189 files changed, 6048 insertions(+), 6048 deletions(-) delete mode 100644 kbabel/datatools/accelerators/main.cc create mode 100644 kbabel/datatools/accelerators/main.cpp delete mode 100644 kbabel/datatools/arguments/main.cc create mode 100644 kbabel/datatools/arguments/main.cpp delete mode 100644 kbabel/datatools/context/main.cc create mode 100644 kbabel/datatools/context/main.cpp delete mode 100644 kbabel/datatools/equations/main.cc create mode 100644 kbabel/datatools/equations/main.cpp delete mode 100644 kbabel/datatools/length/main.cc create mode 100644 kbabel/datatools/length/main.cpp delete mode 100644 kbabel/datatools/not-translated/main.cc create mode 100644 kbabel/datatools/not-translated/main.cpp delete mode 100644 kbabel/datatools/pluralforms/main.cc create mode 100644 kbabel/datatools/pluralforms/main.cpp delete mode 100644 kbabel/datatools/punctuation/main.cc create mode 100644 kbabel/datatools/punctuation/main.cpp delete mode 100644 kbabel/datatools/regexp/main.cc create mode 100644 kbabel/datatools/regexp/main.cpp delete mode 100644 kbabel/datatools/setfuzzy/main.cc create mode 100644 kbabel/datatools/setfuzzy/main.cpp delete mode 100644 kbabel/datatools/whitespace/main.cc create mode 100644 kbabel/datatools/whitespace/main.cpp delete mode 100644 kbabel/datatools/xml/main.cc create mode 100644 kbabel/datatools/xml/main.cpp delete mode 100644 kbabel/kbabeldict/modules/dbsearchengine/makemsgdb.C create mode 100644 kbabel/kbabeldict/modules/dbsearchengine/makemsgdb.cpp create mode 100644 poxml/GettextLexer.h delete mode 100644 poxml/GettextLexer.hpp create mode 100644 poxml/GettextParser.h delete mode 100644 poxml/GettextParser.hpp create mode 100644 poxml/GettextParserTokenTypes.h delete mode 100644 poxml/GettextParserTokenTypes.hpp create mode 100644 poxml/antlr/antlr/ANTLRException.h delete mode 100644 poxml/antlr/antlr/ANTLRException.hpp create mode 100644 poxml/antlr/antlr/AST.h delete mode 100644 poxml/antlr/antlr/AST.hpp create mode 100644 poxml/antlr/antlr/ASTArray.h delete mode 100644 poxml/antlr/antlr/ASTArray.hpp create mode 100644 poxml/antlr/antlr/ASTFactory.h delete mode 100644 poxml/antlr/antlr/ASTFactory.hpp create mode 100644 poxml/antlr/antlr/ASTNULLType.h delete mode 100644 poxml/antlr/antlr/ASTNULLType.hpp create mode 100644 poxml/antlr/antlr/ASTPair.h delete mode 100644 poxml/antlr/antlr/ASTPair.hpp create mode 100644 poxml/antlr/antlr/ASTRefCount.h delete mode 100644 poxml/antlr/antlr/ASTRefCount.hpp create mode 100644 poxml/antlr/antlr/BaseAST.h delete mode 100644 poxml/antlr/antlr/BaseAST.hpp create mode 100644 poxml/antlr/antlr/BitSet.h delete mode 100644 poxml/antlr/antlr/BitSet.hpp create mode 100644 poxml/antlr/antlr/CharBuffer.h delete mode 100644 poxml/antlr/antlr/CharBuffer.hpp create mode 100644 poxml/antlr/antlr/CharScanner.h delete mode 100644 poxml/antlr/antlr/CharScanner.hpp create mode 100644 poxml/antlr/antlr/CharStreamException.h delete mode 100644 poxml/antlr/antlr/CharStreamException.hpp create mode 100644 poxml/antlr/antlr/CharStreamIOException.h delete mode 100644 poxml/antlr/antlr/CharStreamIOException.hpp create mode 100644 poxml/antlr/antlr/CircularQueue.h delete mode 100644 poxml/antlr/antlr/CircularQueue.hpp create mode 100644 poxml/antlr/antlr/CommonAST.h delete mode 100644 poxml/antlr/antlr/CommonAST.hpp create mode 100644 poxml/antlr/antlr/CommonASTWithHiddenTokens.h delete mode 100644 poxml/antlr/antlr/CommonASTWithHiddenTokens.hpp create mode 100644 poxml/antlr/antlr/CommonHiddenStreamToken.h delete mode 100644 poxml/antlr/antlr/CommonHiddenStreamToken.hpp create mode 100644 poxml/antlr/antlr/CommonToken.h delete mode 100644 poxml/antlr/antlr/CommonToken.hpp create mode 100644 poxml/antlr/antlr/InputBuffer.h delete mode 100644 poxml/antlr/antlr/InputBuffer.hpp create mode 100644 poxml/antlr/antlr/LLkParser.h delete mode 100644 poxml/antlr/antlr/LLkParser.hpp create mode 100644 poxml/antlr/antlr/LexerSharedInputState.h delete mode 100644 poxml/antlr/antlr/LexerSharedInputState.hpp create mode 100644 poxml/antlr/antlr/MismatchedCharException.h delete mode 100644 poxml/antlr/antlr/MismatchedCharException.hpp create mode 100644 poxml/antlr/antlr/MismatchedTokenException.h delete mode 100644 poxml/antlr/antlr/MismatchedTokenException.hpp create mode 100644 poxml/antlr/antlr/NoViableAltException.h delete mode 100644 poxml/antlr/antlr/NoViableAltException.hpp create mode 100644 poxml/antlr/antlr/NoViableAltForCharException.h delete mode 100644 poxml/antlr/antlr/NoViableAltForCharException.hpp create mode 100644 poxml/antlr/antlr/Parser.h delete mode 100644 poxml/antlr/antlr/Parser.hpp create mode 100644 poxml/antlr/antlr/ParserSharedInputState.h delete mode 100644 poxml/antlr/antlr/ParserSharedInputState.hpp create mode 100644 poxml/antlr/antlr/RecognitionException.h delete mode 100644 poxml/antlr/antlr/RecognitionException.hpp create mode 100644 poxml/antlr/antlr/RefCount.h delete mode 100644 poxml/antlr/antlr/RefCount.hpp create mode 100644 poxml/antlr/antlr/SemanticException.h delete mode 100644 poxml/antlr/antlr/SemanticException.hpp create mode 100644 poxml/antlr/antlr/String.h delete mode 100644 poxml/antlr/antlr/String.hpp create mode 100644 poxml/antlr/antlr/Token.h delete mode 100644 poxml/antlr/antlr/Token.hpp create mode 100644 poxml/antlr/antlr/TokenBuffer.h delete mode 100644 poxml/antlr/antlr/TokenBuffer.hpp create mode 100644 poxml/antlr/antlr/TokenStream.h delete mode 100644 poxml/antlr/antlr/TokenStream.hpp create mode 100644 poxml/antlr/antlr/TokenStreamBasicFilter.h delete mode 100644 poxml/antlr/antlr/TokenStreamBasicFilter.hpp create mode 100644 poxml/antlr/antlr/TokenStreamException.h delete mode 100644 poxml/antlr/antlr/TokenStreamException.hpp create mode 100644 poxml/antlr/antlr/TokenStreamHiddenTokenFilter.h delete mode 100644 poxml/antlr/antlr/TokenStreamHiddenTokenFilter.hpp create mode 100644 poxml/antlr/antlr/TokenStreamIOException.h delete mode 100644 poxml/antlr/antlr/TokenStreamIOException.hpp create mode 100644 poxml/antlr/antlr/TokenStreamRecognitionException.h delete mode 100644 poxml/antlr/antlr/TokenStreamRecognitionException.hpp create mode 100644 poxml/antlr/antlr/TokenStreamRetryException.h delete mode 100644 poxml/antlr/antlr/TokenStreamRetryException.hpp create mode 100644 poxml/antlr/antlr/TokenStreamSelector.h delete mode 100644 poxml/antlr/antlr/TokenStreamSelector.hpp create mode 100644 poxml/antlr/antlr/TreeParser.h delete mode 100644 poxml/antlr/antlr/TreeParser.hpp create mode 100644 poxml/antlr/antlr/TreeParserSharedInputState.h delete mode 100644 poxml/antlr/antlr/TreeParserSharedInputState.hpp create mode 100644 poxml/antlr/antlr/config.h delete mode 100644 poxml/antlr/antlr/config.hpp diff --git a/kapptemplate/existing.module b/kapptemplate/existing.module index 01a4e710..500f5adf 100644 --- a/kapptemplate/existing.module +++ b/kapptemplate/existing.module @@ -20,7 +20,7 @@ function GetCurrentSource # Now, find C++ source and header files CUR_PWD=$PWD; cd $SOURCE_LOCATION; - EXISTING_SOURCE=`/bin/ls -x *.C *.cpp *.cc`; + EXISTING_SOURCE=`/bin/ls -x *.cpp`; EXISTING_HEADER=`/bin/ls -x *.h`; cd $CUR_PWD; diff --git a/kbabel/Makefile.am b/kbabel/Makefile.am index c38a56f3..bb902d4f 100644 --- a/kbabel/Makefile.am +++ b/kbabel/Makefile.am @@ -4,5 +4,5 @@ SUBDIRS = common filters datatools kbabeldict commonui catalogmanager kbabel add messages: rc.cpp $(EXTRACTRC) `find . -name \*.rc -o -name \*.ui` >> rc.cpp - $(XGETTEXT) `find . -name \*.cpp -o -name \*.cc` -o $(podir)/kbabel.pot + $(XGETTEXT) `find . -name \*.cpp` -o $(podir)/kbabel.pot diff --git a/kbabel/common/libgettext/CMakeLists.txt b/kbabel/common/libgettext/CMakeLists.txt index 6e118d64..a82d9826 100644 --- a/kbabel/common/libgettext/CMakeLists.txt +++ b/kbabel/common/libgettext/CMakeLists.txt @@ -17,7 +17,7 @@ include_directories( ) -##### pofiles.cc (source) ####################### +##### pofiles.cpp (source) ####################### add_custom_command( OUTPUT pofiles.cpp COMMAND ${LEX_EXECUTABLE} -+ -opofiles.cpp ${CMAKE_CURRENT_SOURCE_DIR}/pofiles.ll diff --git a/kbabel/common/libgettext/Makefile.am b/kbabel/common/libgettext/Makefile.am index 6f5f4fe2..304e2537 100644 --- a/kbabel/common/libgettext/Makefile.am +++ b/kbabel/common/libgettext/Makefile.am @@ -5,13 +5,13 @@ INCLUDES=$(all_includes) #LEX_OUTPUT_ROOT = lex.GettextBase #AM_LFLAGS = -+ -CLEANFILES = pofiles.cc +CLEANFILES = pofiles.cpp noinst_LTLIBRARIES = libgettext.la -libgettext_la_SOURCES = pofiles.cc +libgettext_la_SOURCES = pofiles.cpp -pofiles.cc: $(srcdir)/pofiles.ll - $(LEX) -+ -opofiles.cc $(srcdir)/pofiles.ll +pofiles.cpp: $(srcdir)/pofiles.ll + $(LEX) -+ -opofiles.cpp $(srcdir)/pofiles.ll noinst_HEADERS = tokens.h pofiles.h diff --git a/kbabel/datatools/accelerators/CMakeLists.txt b/kbabel/datatools/accelerators/CMakeLists.txt index 9e9567db..5dcfc21e 100644 --- a/kbabel/datatools/accelerators/CMakeLists.txt +++ b/kbabel/datatools/accelerators/CMakeLists.txt @@ -34,7 +34,7 @@ tde_create_translated_desktop( ##### kbabel_accelstool (module) ################ tde_add_kpart( kbabel_accelstool AUTOMOC - SOURCES main.cc + SOURCES main.cpp LINK kbabelcommon-shared DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/kbabel/datatools/accelerators/Makefile.am b/kbabel/datatools/accelerators/Makefile.am index 5ee57aae..4eff4d91 100644 --- a/kbabel/datatools/accelerators/Makefile.am +++ b/kbabel/datatools/accelerators/Makefile.am @@ -6,7 +6,7 @@ kbabel_accelstool_la_LIBADD = $(LIB_TDEIO) ../../common/libkbabelcommon.la kde_module_LTLIBRARIES = kbabel_accelstool.la -kbabel_accelstool_la_SOURCES = main.cc +kbabel_accelstool_la_SOURCES = main.cpp kbabel_accelstool_la_LDFLAGS = $(all_libraries) -avoid-version -module -no-undefined diff --git a/kbabel/datatools/accelerators/main.cc b/kbabel/datatools/accelerators/main.cc deleted file mode 100644 index 0c7cae3a..00000000 --- a/kbabel/datatools/accelerators/main.cc +++ /dev/null @@ -1,137 +0,0 @@ -/* This file is part of KBabel - based Copyright (C) 1998, 1999 Torben Weis - 2002 Stanislav Visnovsky - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the TQt library by Trolltech AS, Norway (or with modified versions - of TQt that use the same license as TQt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - TQt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. - -*/ - -#include -#include "catalogitem.h" -#include "catalogsettings.h" -#include "main.h" - -#include -#include -#include -#include -#include - -/*************************************************** - * - * Factory - * - ***************************************************/ - -K_EXPORT_COMPONENT_FACTORY( kbabel_accelstool, KGenericFactory ( "kbabeldatatool" ) ) - -using namespace KBabel; - -AcceleratorTool::AcceleratorTool( TQObject* parent, const char* name, const TQStringList & ) - : KDataTool( parent, name ), _cache_origin( 0 ) -{ - // bogus translation just for allowing the translation - i18n("what check found errors","accelerator"); -} - -bool AcceleratorTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) -{ - if ( command != "validate" ) - { - kdDebug(KBABEL) << "Accelerator Tool does only accept the command 'validate'" << endl; - kdDebug(KBABEL) << " The commands " << command << " is not accepted" << endl; - return FALSE; - } - - // Check wether we can accept the data - if ( datatype != "CatalogItem" ) - { - kdDebug(KBABEL) << "Accelerator Tool only accepts datatype CatalogItem" << endl; - return FALSE; - } - - if ( mimetype != "application/x-kbabel-catalogitem" ) - { - kdDebug(KBABEL) << "Accelerator Tool only accepts mimetype application/x-kbabel-catalogitem" << endl; - return FALSE; - } - - if( command == "validate" ) - { - CatalogItem* item = (CatalogItem*)(data); - - if( _cache_origin != item->project() ) - { - _context = item->project()->miscSettings().contextInfo; - _marker = item->project()->miscSettings().accelMarker; - _cache_origin = item->project(); - } - - bool hasError = false; - - if(!item->isUntranslated()) - { - // FIXME: this should care about plural forms in msgid - TQString lineid=item->msgid().first(); - lineid.replace( _context, ""); - lineid.replace(TQRegExp("\\n"),""); - lineid.simplifyWhiteSpace(); - TQString regStr(_marker); - regStr+="[^\\s]"; - TQRegExp reg(regStr); - - TQStringList str = item->msgstr(true); - for( TQStringList::Iterator form = str.begin() ; form != str.end(); form++ ) - { - TQString linestr=(*form); - linestr.simplifyWhiteSpace(); - - int n = lineid.contains(reg); - if( _marker == '&' ) - n = n - lineid.contains(TQRegExp("(&[a-z,A-Z,\\-,0-9,#]*;)|(&&(?!&+))")); - int m = linestr.contains(reg); - if( _marker == '&' ) - m = m - linestr.contains(TQRegExp("(&[a-z,A-Z,\\-,0-9,#]*;)|(&&(?!&+))")); - hasError = hasError || ( n<=1 && m != n); - } - } - - if(hasError) - { - item->appendError( "Accelerator" ); - } - else - { - item->removeError( "Accelerator" ); - } - - return !hasError; - } - return FALSE; -} - -#include "main.moc" diff --git a/kbabel/datatools/accelerators/main.cpp b/kbabel/datatools/accelerators/main.cpp new file mode 100644 index 00000000..0c7cae3a --- /dev/null +++ b/kbabel/datatools/accelerators/main.cpp @@ -0,0 +1,137 @@ +/* This file is part of KBabel + based Copyright (C) 1998, 1999 Torben Weis + 2002 Stanislav Visnovsky + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the TQt library by Trolltech AS, Norway (or with modified versions + of TQt that use the same license as TQt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + TQt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. + +*/ + +#include +#include "catalogitem.h" +#include "catalogsettings.h" +#include "main.h" + +#include +#include +#include +#include +#include + +/*************************************************** + * + * Factory + * + ***************************************************/ + +K_EXPORT_COMPONENT_FACTORY( kbabel_accelstool, KGenericFactory ( "kbabeldatatool" ) ) + +using namespace KBabel; + +AcceleratorTool::AcceleratorTool( TQObject* parent, const char* name, const TQStringList & ) + : KDataTool( parent, name ), _cache_origin( 0 ) +{ + // bogus translation just for allowing the translation + i18n("what check found errors","accelerator"); +} + +bool AcceleratorTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) +{ + if ( command != "validate" ) + { + kdDebug(KBABEL) << "Accelerator Tool does only accept the command 'validate'" << endl; + kdDebug(KBABEL) << " The commands " << command << " is not accepted" << endl; + return FALSE; + } + + // Check wether we can accept the data + if ( datatype != "CatalogItem" ) + { + kdDebug(KBABEL) << "Accelerator Tool only accepts datatype CatalogItem" << endl; + return FALSE; + } + + if ( mimetype != "application/x-kbabel-catalogitem" ) + { + kdDebug(KBABEL) << "Accelerator Tool only accepts mimetype application/x-kbabel-catalogitem" << endl; + return FALSE; + } + + if( command == "validate" ) + { + CatalogItem* item = (CatalogItem*)(data); + + if( _cache_origin != item->project() ) + { + _context = item->project()->miscSettings().contextInfo; + _marker = item->project()->miscSettings().accelMarker; + _cache_origin = item->project(); + } + + bool hasError = false; + + if(!item->isUntranslated()) + { + // FIXME: this should care about plural forms in msgid + TQString lineid=item->msgid().first(); + lineid.replace( _context, ""); + lineid.replace(TQRegExp("\\n"),""); + lineid.simplifyWhiteSpace(); + TQString regStr(_marker); + regStr+="[^\\s]"; + TQRegExp reg(regStr); + + TQStringList str = item->msgstr(true); + for( TQStringList::Iterator form = str.begin() ; form != str.end(); form++ ) + { + TQString linestr=(*form); + linestr.simplifyWhiteSpace(); + + int n = lineid.contains(reg); + if( _marker == '&' ) + n = n - lineid.contains(TQRegExp("(&[a-z,A-Z,\\-,0-9,#]*;)|(&&(?!&+))")); + int m = linestr.contains(reg); + if( _marker == '&' ) + m = m - linestr.contains(TQRegExp("(&[a-z,A-Z,\\-,0-9,#]*;)|(&&(?!&+))")); + hasError = hasError || ( n<=1 && m != n); + } + } + + if(hasError) + { + item->appendError( "Accelerator" ); + } + else + { + item->removeError( "Accelerator" ); + } + + return !hasError; + } + return FALSE; +} + +#include "main.moc" diff --git a/kbabel/datatools/arguments/CMakeLists.txt b/kbabel/datatools/arguments/CMakeLists.txt index a767a0e6..7a532ce2 100644 --- a/kbabel/datatools/arguments/CMakeLists.txt +++ b/kbabel/datatools/arguments/CMakeLists.txt @@ -34,7 +34,7 @@ tde_create_translated_desktop( ##### kbabel_argstool (module) ####################### tde_add_kpart( kbabel_argstool AUTOMOC - SOURCES main.cc + SOURCES main.cpp LINK kbabelcommon-shared DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/kbabel/datatools/arguments/Makefile.am b/kbabel/datatools/arguments/Makefile.am index ab4e2f01..104b9c8d 100644 --- a/kbabel/datatools/arguments/Makefile.am +++ b/kbabel/datatools/arguments/Makefile.am @@ -6,7 +6,7 @@ kbabel_argstool_la_LIBADD = $(LIB_TDEIO) ../../common/libkbabelcommon.la kde_module_LTLIBRARIES = kbabel_argstool.la -kbabel_argstool_la_SOURCES = main.cc +kbabel_argstool_la_SOURCES = main.cpp kbabel_argstool_la_LDFLAGS = $(all_libraries) -avoid-version -module -no-undefined diff --git a/kbabel/datatools/arguments/main.cc b/kbabel/datatools/arguments/main.cc deleted file mode 100644 index b6c3fa5a..00000000 --- a/kbabel/datatools/arguments/main.cc +++ /dev/null @@ -1,277 +0,0 @@ -/* This file is part of KBabel - based Copyright (C) 1998, 1999 Torben Weis - 2002-2003 Stanislav Visnovsky - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the TQt library by Trolltech AS, Norway (or with modified versions - of TQt that use the same license as TQt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - TQt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. - -*/ - -#include -#include "catalogitem.h" -#include "catalogsettings.h" -#include "main.h" - -#include -#include -#include -#include -#include - -/*************************************************** - * - * Factory - * - ***************************************************/ - -K_EXPORT_COMPONENT_FACTORY( kbabel_argstool, KGenericFactory ( "kbabeldatatool" ) ) - -using namespace KBabel; - -ArgumentTool::ArgumentTool( TQObject* parent, const char* name, const TQStringList & ) - : KDataTool( parent, name ), _cache_origin( 0 ) -{ - i18n( "what check found errors","arguments"); -} - -bool ArgumentTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) -{ - if ( command != "validate" ) - { - kdDebug(KBABEL) << "Argument Tool does only accept the command 'validate' and 'shortcut'" << endl; - kdDebug(KBABEL) << " The commands " << command << " is not accepted" << endl; - return FALSE; - } - - // Check wether we can accept the data - if ( datatype != "CatalogItem" ) - { - kdDebug(KBABEL) << "Argument Tool only accepts datatype CatalogItem" << endl; - return FALSE; - } - - if ( mimetype != "application/x-kbabel-catalogitem" ) - { - kdDebug(KBABEL) << "Argument Tool only accepts mimetype application/x-kbabel-catalogitem" << endl; - return FALSE; - } - - if( command == "validate" ) - { - CatalogItem* item = (CatalogItem*)(data); - - if( item->isNoCformat() ) return true; - bool hasError = false; - - if( _cache_origin != item->project() ) - { - _context = item->project()->miscSettings().contextInfo; - _checkPlurals = item->project()->identitySettings().checkPluralArgument; - _cache_origin = item->project(); - } - - if(!item->isUntranslated()) - { - - TQString formatChars="dioxXucsfeEgGp%"; - - if( _checkPlurals ) formatChars+="n"; - - // FIXME: this should care about plural forms in msgid - TQString line=item->msgid().first(); - TQStringList argList; - -// if( isPluralForm() ) - { - // FIXME: this is KDE specific - if( line.startsWith("_n:" )) - { - // truncate text after first \n to get args only once - line = line.mid(0,line.find("\\n")); - } - } - line.replace(_context, ""); - line.replace(TQRegExp("\\n"),""); - line.simplifyWhiteSpace(); - - // flag, for GNU only we can allow reordering - bool non_gnu = (item->pluralForm() == KDESpecific); - - int index=line.find(TQRegExp("%.")); - - while(index>=0) - { - int endIndex=line.find(TQRegExp("[^\\d]"),index+1); - if(endIndex<0) - { - endIndex=line.length(); - } - else if( formatChars.contains(line[endIndex]) ) - { - endIndex++; - } - - if(endIndex - index > 1 ) { - TQString arg = line.mid(index,endIndex-index); - if( arg.contains( TQRegExp("\\d") ) ) { - non_gnu = true; - } - argList.append(arg); - - } - - index=line.find(TQRegExp("%."),endIndex); - } - - if( item->pluralForm()==KDESpecific) - { - // FIXME: this is KDE specific - if( _checkPlurals && line.startsWith("_n:" ) && !argList.contains("%n") ) - { - argList.append("%n"); - } - } - - // generate for each plural form to be checked separately - line=item->msgstr().first(); - TQStringList lines; - - // FIXME; this is KDE specific - if( item->pluralForm() == KDESpecific ) - { - lines = TQStringList::split("\\n",line); - } - else - { - lines.append(line); - } - - TQStringList argCache = argList; - TQStringList foundArgs; - - for(TQStringList::Iterator i = lines.begin() ; i!=lines.end() ; i++) - { - // initialize for the next plural form - foundArgs.clear(); - argList = argCache; - - line=(*i); - - line.replace(TQRegExp("\\n"),""); - - TQRegExp argdesc( - "%((["+formatChars+"])" - +"|(\\d)+" - +"|(\\d)+\\$(["+formatChars+"])" - +")" ) ; - index = -1; - - do { - - index = argdesc.search( line, index+1 ); - - if( index == -1 ) break; - - // do not add a redundant argument, if it is non GNU - if( !non_gnu || !foundArgs.contains( argdesc.cap(0) ) ) - foundArgs.append( argdesc.cap( 0 ) ); - } while( true ); - - // now, compare the list - argList = argCache; - - if( non_gnu ) { - for ( TQStringList::Iterator it = foundArgs.begin(); it != foundArgs.end(); ++it ) { - if( argList.find( *it ) == argList.end() ) { - hasError = true; - break; - } else { - argList.remove( *it ); - } - } - - if( ! argList.isEmpty() ) { - hasError = true; - } - } - else - { - // handle GNU with replacements - TQStringList::Iterator oit = argList.begin(); - for ( TQStringList::Iterator it = foundArgs.begin(); it != foundArgs.end(); ++it , ++oit) { - if( *it == *oit ) { - // argument is the same, mark as used - *oit = TQString(); - } else { - // try to strip replacement - int index = (*it).find( '$' ); - if( index == -1 ) { - // there is no replacement, this is wrong - hasError = true; - break; - } - TQString place = (*it).mid( 1, index-1 ); - TQString arg = (*it).right( index ); - arg[0] = '%'; - TQStringList::Iterator a = argList.at( place.toInt()-1 ); - if( a != argList.end() && (*a) == arg ) - { - (*a) = TQString(); - } - else - { - // duplicate or index is too high - hasError = true; - } - } - } - - for ( TQStringList::Iterator it = argList.begin(); it != argList.end(); ++it) { - if( ! (*it).isNull () ) { - // argument is the same, mark as used - hasError = true; - break; - } - } - } - } - } - - if(hasError) - { - item->appendError( "Arguments" ); - } - else - { - item->removeError( "Arguments" ); - } - - return !hasError; - } - return FALSE; -} - -#include "main.moc" diff --git a/kbabel/datatools/arguments/main.cpp b/kbabel/datatools/arguments/main.cpp new file mode 100644 index 00000000..b6c3fa5a --- /dev/null +++ b/kbabel/datatools/arguments/main.cpp @@ -0,0 +1,277 @@ +/* This file is part of KBabel + based Copyright (C) 1998, 1999 Torben Weis + 2002-2003 Stanislav Visnovsky + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the TQt library by Trolltech AS, Norway (or with modified versions + of TQt that use the same license as TQt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + TQt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. + +*/ + +#include +#include "catalogitem.h" +#include "catalogsettings.h" +#include "main.h" + +#include +#include +#include +#include +#include + +/*************************************************** + * + * Factory + * + ***************************************************/ + +K_EXPORT_COMPONENT_FACTORY( kbabel_argstool, KGenericFactory ( "kbabeldatatool" ) ) + +using namespace KBabel; + +ArgumentTool::ArgumentTool( TQObject* parent, const char* name, const TQStringList & ) + : KDataTool( parent, name ), _cache_origin( 0 ) +{ + i18n( "what check found errors","arguments"); +} + +bool ArgumentTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) +{ + if ( command != "validate" ) + { + kdDebug(KBABEL) << "Argument Tool does only accept the command 'validate' and 'shortcut'" << endl; + kdDebug(KBABEL) << " The commands " << command << " is not accepted" << endl; + return FALSE; + } + + // Check wether we can accept the data + if ( datatype != "CatalogItem" ) + { + kdDebug(KBABEL) << "Argument Tool only accepts datatype CatalogItem" << endl; + return FALSE; + } + + if ( mimetype != "application/x-kbabel-catalogitem" ) + { + kdDebug(KBABEL) << "Argument Tool only accepts mimetype application/x-kbabel-catalogitem" << endl; + return FALSE; + } + + if( command == "validate" ) + { + CatalogItem* item = (CatalogItem*)(data); + + if( item->isNoCformat() ) return true; + bool hasError = false; + + if( _cache_origin != item->project() ) + { + _context = item->project()->miscSettings().contextInfo; + _checkPlurals = item->project()->identitySettings().checkPluralArgument; + _cache_origin = item->project(); + } + + if(!item->isUntranslated()) + { + + TQString formatChars="dioxXucsfeEgGp%"; + + if( _checkPlurals ) formatChars+="n"; + + // FIXME: this should care about plural forms in msgid + TQString line=item->msgid().first(); + TQStringList argList; + +// if( isPluralForm() ) + { + // FIXME: this is KDE specific + if( line.startsWith("_n:" )) + { + // truncate text after first \n to get args only once + line = line.mid(0,line.find("\\n")); + } + } + line.replace(_context, ""); + line.replace(TQRegExp("\\n"),""); + line.simplifyWhiteSpace(); + + // flag, for GNU only we can allow reordering + bool non_gnu = (item->pluralForm() == KDESpecific); + + int index=line.find(TQRegExp("%.")); + + while(index>=0) + { + int endIndex=line.find(TQRegExp("[^\\d]"),index+1); + if(endIndex<0) + { + endIndex=line.length(); + } + else if( formatChars.contains(line[endIndex]) ) + { + endIndex++; + } + + if(endIndex - index > 1 ) { + TQString arg = line.mid(index,endIndex-index); + if( arg.contains( TQRegExp("\\d") ) ) { + non_gnu = true; + } + argList.append(arg); + + } + + index=line.find(TQRegExp("%."),endIndex); + } + + if( item->pluralForm()==KDESpecific) + { + // FIXME: this is KDE specific + if( _checkPlurals && line.startsWith("_n:" ) && !argList.contains("%n") ) + { + argList.append("%n"); + } + } + + // generate for each plural form to be checked separately + line=item->msgstr().first(); + TQStringList lines; + + // FIXME; this is KDE specific + if( item->pluralForm() == KDESpecific ) + { + lines = TQStringList::split("\\n",line); + } + else + { + lines.append(line); + } + + TQStringList argCache = argList; + TQStringList foundArgs; + + for(TQStringList::Iterator i = lines.begin() ; i!=lines.end() ; i++) + { + // initialize for the next plural form + foundArgs.clear(); + argList = argCache; + + line=(*i); + + line.replace(TQRegExp("\\n"),""); + + TQRegExp argdesc( + "%((["+formatChars+"])" + +"|(\\d)+" + +"|(\\d)+\\$(["+formatChars+"])" + +")" ) ; + index = -1; + + do { + + index = argdesc.search( line, index+1 ); + + if( index == -1 ) break; + + // do not add a redundant argument, if it is non GNU + if( !non_gnu || !foundArgs.contains( argdesc.cap(0) ) ) + foundArgs.append( argdesc.cap( 0 ) ); + } while( true ); + + // now, compare the list + argList = argCache; + + if( non_gnu ) { + for ( TQStringList::Iterator it = foundArgs.begin(); it != foundArgs.end(); ++it ) { + if( argList.find( *it ) == argList.end() ) { + hasError = true; + break; + } else { + argList.remove( *it ); + } + } + + if( ! argList.isEmpty() ) { + hasError = true; + } + } + else + { + // handle GNU with replacements + TQStringList::Iterator oit = argList.begin(); + for ( TQStringList::Iterator it = foundArgs.begin(); it != foundArgs.end(); ++it , ++oit) { + if( *it == *oit ) { + // argument is the same, mark as used + *oit = TQString(); + } else { + // try to strip replacement + int index = (*it).find( '$' ); + if( index == -1 ) { + // there is no replacement, this is wrong + hasError = true; + break; + } + TQString place = (*it).mid( 1, index-1 ); + TQString arg = (*it).right( index ); + arg[0] = '%'; + TQStringList::Iterator a = argList.at( place.toInt()-1 ); + if( a != argList.end() && (*a) == arg ) + { + (*a) = TQString(); + } + else + { + // duplicate or index is too high + hasError = true; + } + } + } + + for ( TQStringList::Iterator it = argList.begin(); it != argList.end(); ++it) { + if( ! (*it).isNull () ) { + // argument is the same, mark as used + hasError = true; + break; + } + } + } + } + } + + if(hasError) + { + item->appendError( "Arguments" ); + } + else + { + item->removeError( "Arguments" ); + } + + return !hasError; + } + return FALSE; +} + +#include "main.moc" diff --git a/kbabel/datatools/context/CMakeLists.txt b/kbabel/datatools/context/CMakeLists.txt index c448cca1..94781fef 100644 --- a/kbabel/datatools/context/CMakeLists.txt +++ b/kbabel/datatools/context/CMakeLists.txt @@ -34,7 +34,7 @@ tde_create_translated_desktop( ##### kbabel_contexttool (module) ############### tde_add_kpart( kbabel_contexttool AUTOMOC - SOURCES main.cc + SOURCES main.cpp LINK kbabelcommon-shared DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/kbabel/datatools/context/Makefile.am b/kbabel/datatools/context/Makefile.am index 3b56628a..6dca7415 100644 --- a/kbabel/datatools/context/Makefile.am +++ b/kbabel/datatools/context/Makefile.am @@ -6,7 +6,7 @@ kbabel_contexttool_la_LIBADD = $(LIB_TDEIO) ../../common/libkbabelcommon.la kde_module_LTLIBRARIES = kbabel_contexttool.la -kbabel_contexttool_la_SOURCES = main.cc +kbabel_contexttool_la_SOURCES = main.cpp kbabel_contexttool_la_LDFLAGS = $(all_libraries) -avoid-version -module -no-undefined diff --git a/kbabel/datatools/context/main.cc b/kbabel/datatools/context/main.cc deleted file mode 100644 index 0fb989d2..00000000 --- a/kbabel/datatools/context/main.cc +++ /dev/null @@ -1,115 +0,0 @@ -/* This file is part of KBabel - based Copyright (C) 1998, 1999 Torben Weis - 2002 Stanislav Visnovsky - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the TQt library by Trolltech AS, Norway (or with modified versions - of TQt that use the same license as TQt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - TQt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. - -*/ - -#include -#include "catalogitem.h" -#include "catalogsettings.h" -#include "main.h" - -#include -#include -#include -#include -#include -#include - -/*************************************************** - * - * Factory - * - ***************************************************/ - -K_EXPORT_COMPONENT_FACTORY( kbabel_contexttool, KGenericFactory ( "kbabeldatatool" ) ) - -using namespace KBabel; - -ContextTool::ContextTool( TQObject* parent, const char* name, const TQStringList & ) - : KDataTool( parent, name ), _cache_origin( 0 ) -{ - i18n("what check found errors","context info"); -} - -bool ContextTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) -{ - if ( command != "validate" ) - { - kdDebug(KBABEL) << "Context Tool does only accept the command 'validate' and 'shortcut'" << endl; - kdDebug(KBABEL) << " The commands " << command << " is not accepted" << endl; - return FALSE; - } - - // Check wether we can accept the data - if ( datatype != "CatalogItem" ) - { - kdDebug(KBABEL) << "Context Tool only accepts datatype CatalogItem" << endl; - return FALSE; - } - - if ( mimetype != "application/x-kbabel-catalogitem" ) - { - kdDebug(KBABEL) << "Context Tool only accepts mimetype application/x-kbabel-catalogitem" << endl; - return FALSE; - } - - if( command == "validate" ) - { - CatalogItem* item = (CatalogItem*)(data); - - if( _cache_origin != item->project() ) - { - _context = item->project()->miscSettings().contextInfo; - _cache_origin = item->project(); - } - - bool hasError = false; - - if(!item->isUntranslated() && item->msgid().first().contains(_context) - && item->msgstr().first().contains(_context) ) - { - hasError = true; - } - - if(hasError) - { - item->appendError( "context info" ); - } - else - { - item->removeError( "context info" ); - } - - return !hasError; - } - return FALSE; -} - -#include "main.moc" diff --git a/kbabel/datatools/context/main.cpp b/kbabel/datatools/context/main.cpp new file mode 100644 index 00000000..0fb989d2 --- /dev/null +++ b/kbabel/datatools/context/main.cpp @@ -0,0 +1,115 @@ +/* This file is part of KBabel + based Copyright (C) 1998, 1999 Torben Weis + 2002 Stanislav Visnovsky + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the TQt library by Trolltech AS, Norway (or with modified versions + of TQt that use the same license as TQt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + TQt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. + +*/ + +#include +#include "catalogitem.h" +#include "catalogsettings.h" +#include "main.h" + +#include +#include +#include +#include +#include +#include + +/*************************************************** + * + * Factory + * + ***************************************************/ + +K_EXPORT_COMPONENT_FACTORY( kbabel_contexttool, KGenericFactory ( "kbabeldatatool" ) ) + +using namespace KBabel; + +ContextTool::ContextTool( TQObject* parent, const char* name, const TQStringList & ) + : KDataTool( parent, name ), _cache_origin( 0 ) +{ + i18n("what check found errors","context info"); +} + +bool ContextTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) +{ + if ( command != "validate" ) + { + kdDebug(KBABEL) << "Context Tool does only accept the command 'validate' and 'shortcut'" << endl; + kdDebug(KBABEL) << " The commands " << command << " is not accepted" << endl; + return FALSE; + } + + // Check wether we can accept the data + if ( datatype != "CatalogItem" ) + { + kdDebug(KBABEL) << "Context Tool only accepts datatype CatalogItem" << endl; + return FALSE; + } + + if ( mimetype != "application/x-kbabel-catalogitem" ) + { + kdDebug(KBABEL) << "Context Tool only accepts mimetype application/x-kbabel-catalogitem" << endl; + return FALSE; + } + + if( command == "validate" ) + { + CatalogItem* item = (CatalogItem*)(data); + + if( _cache_origin != item->project() ) + { + _context = item->project()->miscSettings().contextInfo; + _cache_origin = item->project(); + } + + bool hasError = false; + + if(!item->isUntranslated() && item->msgid().first().contains(_context) + && item->msgstr().first().contains(_context) ) + { + hasError = true; + } + + if(hasError) + { + item->appendError( "context info" ); + } + else + { + item->removeError( "context info" ); + } + + return !hasError; + } + return FALSE; +} + +#include "main.moc" diff --git a/kbabel/datatools/equations/CMakeLists.txt b/kbabel/datatools/equations/CMakeLists.txt index f7b60f01..e4dd4a39 100644 --- a/kbabel/datatools/equations/CMakeLists.txt +++ b/kbabel/datatools/equations/CMakeLists.txt @@ -34,7 +34,7 @@ tde_create_translated_desktop( ##### kbabel_equationstool (module) ############# tde_add_kpart( kbabel_equationstool AUTOMOC - SOURCES main.cc + SOURCES main.cpp LINK kbabelcommon-shared DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/kbabel/datatools/equations/Makefile.am b/kbabel/datatools/equations/Makefile.am index dac35e6f..48b0f6bc 100644 --- a/kbabel/datatools/equations/Makefile.am +++ b/kbabel/datatools/equations/Makefile.am @@ -6,7 +6,7 @@ kbabel_equationstool_la_LIBADD = $(LIB_TDEIO) ../../common/libkbabelcommon.la kde_module_LTLIBRARIES = kbabel_equationstool.la -kbabel_equationstool_la_SOURCES = main.cc +kbabel_equationstool_la_SOURCES = main.cpp kbabel_equationstool_la_LDFLAGS = $(all_libraries) -avoid-version -module -no-undefined diff --git a/kbabel/datatools/equations/main.cc b/kbabel/datatools/equations/main.cc deleted file mode 100644 index c0dbbba2..00000000 --- a/kbabel/datatools/equations/main.cc +++ /dev/null @@ -1,113 +0,0 @@ -/* This file is part of KBabel - based Copyright (C) 1998, 1999 Torben Weis - 2002 Stanislav Visnovsky - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the TQt library by Trolltech AS, Norway (or with modified versions - of TQt that use the same license as TQt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - TQt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. - -*/ - -#include -#include "catalogitem.h" -#include "catalogsettings.h" -#include "main.h" - -#include -#include -#include -#include -#include -#include - -/*************************************************** - * - * Factory - * - ***************************************************/ - -K_EXPORT_COMPONENT_FACTORY( kbabel_equationstool, KGenericFactory ( "kbabeldatatool" ) ) - -using namespace KBabel; - -EquationsTool::EquationsTool( TQObject* parent, const char* name, const TQStringList & ) - : KDataTool( parent, name ), _equation("^[a-zA-Z0-9]+=.+") -{ - i18n("what check found errors","equations"); -} - -bool EquationsTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) -{ - if ( command != "validate" ) - { - kdDebug(KBABEL) << "Equations Tool does only accept the command 'validate' and 'shortcut'" << endl; - kdDebug(KBABEL) << " The commands " << command << " is not accepted" << endl; - return FALSE; - } - - // Check wether we can accept the data - if ( datatype != "CatalogItem" ) - { - kdDebug(KBABEL) << "Equations Tool only accepts datatype CatalogItem" << endl; - return FALSE; - } - - if ( mimetype != "application/x-kbabel-catalogitem" ) - { - kdDebug(KBABEL) << "Equations Tool only accepts mimetype application/x-kbabel-catalogitem" << endl; - return FALSE; - } - - if( command == "validate" ) - { - CatalogItem* item = (CatalogItem*)(data); - - bool hasError = false; - - if(!item->isUntranslated() && !item->msgid().first().contains('\n') - && item->msgid().first().contains(_equation)) - { - int index = item->msgid().first().find('='); - TQString left = item->msgid().first().left(index); - index = item->msgstr().first().find('='); - if(left != item->msgstr().first().left(index)) - hasError = true; - } - - if(hasError) - { - item->appendError( "equations" ); - } - else - { - item->removeError( "equations" ); - } - - return !hasError; - } - return FALSE; -} - -#include "main.moc" diff --git a/kbabel/datatools/equations/main.cpp b/kbabel/datatools/equations/main.cpp new file mode 100644 index 00000000..c0dbbba2 --- /dev/null +++ b/kbabel/datatools/equations/main.cpp @@ -0,0 +1,113 @@ +/* This file is part of KBabel + based Copyright (C) 1998, 1999 Torben Weis + 2002 Stanislav Visnovsky + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the TQt library by Trolltech AS, Norway (or with modified versions + of TQt that use the same license as TQt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + TQt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. + +*/ + +#include +#include "catalogitem.h" +#include "catalogsettings.h" +#include "main.h" + +#include +#include +#include +#include +#include +#include + +/*************************************************** + * + * Factory + * + ***************************************************/ + +K_EXPORT_COMPONENT_FACTORY( kbabel_equationstool, KGenericFactory ( "kbabeldatatool" ) ) + +using namespace KBabel; + +EquationsTool::EquationsTool( TQObject* parent, const char* name, const TQStringList & ) + : KDataTool( parent, name ), _equation("^[a-zA-Z0-9]+=.+") +{ + i18n("what check found errors","equations"); +} + +bool EquationsTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) +{ + if ( command != "validate" ) + { + kdDebug(KBABEL) << "Equations Tool does only accept the command 'validate' and 'shortcut'" << endl; + kdDebug(KBABEL) << " The commands " << command << " is not accepted" << endl; + return FALSE; + } + + // Check wether we can accept the data + if ( datatype != "CatalogItem" ) + { + kdDebug(KBABEL) << "Equations Tool only accepts datatype CatalogItem" << endl; + return FALSE; + } + + if ( mimetype != "application/x-kbabel-catalogitem" ) + { + kdDebug(KBABEL) << "Equations Tool only accepts mimetype application/x-kbabel-catalogitem" << endl; + return FALSE; + } + + if( command == "validate" ) + { + CatalogItem* item = (CatalogItem*)(data); + + bool hasError = false; + + if(!item->isUntranslated() && !item->msgid().first().contains('\n') + && item->msgid().first().contains(_equation)) + { + int index = item->msgid().first().find('='); + TQString left = item->msgid().first().left(index); + index = item->msgstr().first().find('='); + if(left != item->msgstr().first().left(index)) + hasError = true; + } + + if(hasError) + { + item->appendError( "equations" ); + } + else + { + item->removeError( "equations" ); + } + + return !hasError; + } + return FALSE; +} + +#include "main.moc" diff --git a/kbabel/datatools/length/CMakeLists.txt b/kbabel/datatools/length/CMakeLists.txt index 8750dbc5..df075cad 100644 --- a/kbabel/datatools/length/CMakeLists.txt +++ b/kbabel/datatools/length/CMakeLists.txt @@ -34,7 +34,7 @@ tde_create_translated_desktop( ##### kbabel_lengthtool (module) ################ tde_add_kpart( kbabel_lengthtool AUTOMOC - SOURCES main.cc + SOURCES main.cpp LINK kbabelcommon-shared DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/kbabel/datatools/length/Makefile.am b/kbabel/datatools/length/Makefile.am index 2359a95b..dc8e2867 100644 --- a/kbabel/datatools/length/Makefile.am +++ b/kbabel/datatools/length/Makefile.am @@ -6,7 +6,7 @@ kbabel_lengthtool_la_LIBADD = $(LIB_TDEIO) ../../common/libkbabelcommon.la kde_module_LTLIBRARIES = kbabel_lengthtool.la -kbabel_lengthtool_la_SOURCES = main.cc +kbabel_lengthtool_la_SOURCES = main.cpp kbabel_lengthtool_la_LDFLAGS = $(all_libraries) -avoid-version -module -no-undefined diff --git a/kbabel/datatools/length/main.cc b/kbabel/datatools/length/main.cc deleted file mode 100644 index f1c295eb..00000000 --- a/kbabel/datatools/length/main.cc +++ /dev/null @@ -1,142 +0,0 @@ -/* This file is part of KBabel - based Copyright (C) 1998, 1999 Torben Weis - 2002 Stanislav Visnovsky - 2003 Dwayne Bailey - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the TQt library by Trolltech AS, Norway (or with modified versions - of TQt that use the same license as TQt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - TQt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. - -*/ - -#include -#include "catalog.h" -#include "catalogitem.h" -#include "catalogsettings.h" -#include "main.h" -#include - -#include -#include -#include -#include -#include -#include - -/*************************************************** - * - * Factory - * - ***************************************************/ - -K_EXPORT_COMPONENT_FACTORY( kbabel_lengthtool, KGenericFactory ( "kbabeldatatool" ) ) - -using namespace KBabel; - -LengthTool::LengthTool( TQObject* parent, const char* name, const TQStringList & ) - : KDataTool( parent, name ), _cache_origin( 0 ) -{ - i18n("which check found errors","translation has inconsistent length"); -} - -bool LengthTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) -{ - - if ( command != "validate" ) - { - kdDebug(KBABEL) << "Length Tool only accepts the 'validate' command" << endl; - kdDebug(KBABEL) << " The command " << command << " is not accepted" << endl; - return false; - } - - // Check wether we can accept the data - if ( datatype != "CatalogItem" ) - { - kdDebug(KBABEL) << "Length Tool only accept the CatalogItem datatype" << endl; - return false; - } - - if ( mimetype != "application/x-kbabel-catalogitem" ) - { - kdDebug(KBABEL) << "Length Tool only accept the 'application/x-kbabel-catalogitem' mimetype" << endl; - return false; - } - - if( command == "validate" ) - { - - CatalogItem* item = (CatalogItem*)(data); - bool hasError = false; - TQStringList str, id; - - if(!item->isUntranslated()) { - - if( _cache_origin != item->project() ) - { - _context = item->project()->miscSettings().contextInfo; - _plurals = item->project()->miscSettings().singularPlural; - _cache_origin = item->project(); - } - - //Ensure KDE plural forms are in a StringList - if( item->pluralForm() == KDESpecific ) { - str = TQStringList::split( "\\n", item->msgstr().first(), true ); - id = TQStringList::split( "\\n", - item->msgid().first().replace( TQRegExp(_plurals), ""), true ); - } else { - str = item->msgstr(); - id = item->msgid(); - } - - //Check for translations that are too short or too long - //This may not be totally correct but we check both - //the singular and plural forms against each translated plural. - //FIXME: replace 10% check with configurable setting or a statistical - //based expected length relationship - int idlen, strlen; - for( TQStringList::Iterator i = id.begin() ; i != id.end() ; i++ ) { - TQString iditem = (*i); - idlen = iditem.replace( TQRegExp(_context),"").length(); - for( TQStringList::Iterator j = str.begin() ; j != str.end() ; j++ ) { - TQString stritem = (*j); - strlen = stritem.length(); - hasError = hasError || (strlen < (0.1 * idlen)) - || (strlen > (10 * idlen)); - } - } - - } - - if(hasError) - item->appendError( "translation has inconsistant length" ); - else - item->removeError( "translation has inconsistant length" ); - - return !hasError; - } - return false; -} - -#include "main.moc" diff --git a/kbabel/datatools/length/main.cpp b/kbabel/datatools/length/main.cpp new file mode 100644 index 00000000..f1c295eb --- /dev/null +++ b/kbabel/datatools/length/main.cpp @@ -0,0 +1,142 @@ +/* This file is part of KBabel + based Copyright (C) 1998, 1999 Torben Weis + 2002 Stanislav Visnovsky + 2003 Dwayne Bailey + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the TQt library by Trolltech AS, Norway (or with modified versions + of TQt that use the same license as TQt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + TQt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. + +*/ + +#include +#include "catalog.h" +#include "catalogitem.h" +#include "catalogsettings.h" +#include "main.h" +#include + +#include +#include +#include +#include +#include +#include + +/*************************************************** + * + * Factory + * + ***************************************************/ + +K_EXPORT_COMPONENT_FACTORY( kbabel_lengthtool, KGenericFactory ( "kbabeldatatool" ) ) + +using namespace KBabel; + +LengthTool::LengthTool( TQObject* parent, const char* name, const TQStringList & ) + : KDataTool( parent, name ), _cache_origin( 0 ) +{ + i18n("which check found errors","translation has inconsistent length"); +} + +bool LengthTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) +{ + + if ( command != "validate" ) + { + kdDebug(KBABEL) << "Length Tool only accepts the 'validate' command" << endl; + kdDebug(KBABEL) << " The command " << command << " is not accepted" << endl; + return false; + } + + // Check wether we can accept the data + if ( datatype != "CatalogItem" ) + { + kdDebug(KBABEL) << "Length Tool only accept the CatalogItem datatype" << endl; + return false; + } + + if ( mimetype != "application/x-kbabel-catalogitem" ) + { + kdDebug(KBABEL) << "Length Tool only accept the 'application/x-kbabel-catalogitem' mimetype" << endl; + return false; + } + + if( command == "validate" ) + { + + CatalogItem* item = (CatalogItem*)(data); + bool hasError = false; + TQStringList str, id; + + if(!item->isUntranslated()) { + + if( _cache_origin != item->project() ) + { + _context = item->project()->miscSettings().contextInfo; + _plurals = item->project()->miscSettings().singularPlural; + _cache_origin = item->project(); + } + + //Ensure KDE plural forms are in a StringList + if( item->pluralForm() == KDESpecific ) { + str = TQStringList::split( "\\n", item->msgstr().first(), true ); + id = TQStringList::split( "\\n", + item->msgid().first().replace( TQRegExp(_plurals), ""), true ); + } else { + str = item->msgstr(); + id = item->msgid(); + } + + //Check for translations that are too short or too long + //This may not be totally correct but we check both + //the singular and plural forms against each translated plural. + //FIXME: replace 10% check with configurable setting or a statistical + //based expected length relationship + int idlen, strlen; + for( TQStringList::Iterator i = id.begin() ; i != id.end() ; i++ ) { + TQString iditem = (*i); + idlen = iditem.replace( TQRegExp(_context),"").length(); + for( TQStringList::Iterator j = str.begin() ; j != str.end() ; j++ ) { + TQString stritem = (*j); + strlen = stritem.length(); + hasError = hasError || (strlen < (0.1 * idlen)) + || (strlen > (10 * idlen)); + } + } + + } + + if(hasError) + item->appendError( "translation has inconsistant length" ); + else + item->removeError( "translation has inconsistant length" ); + + return !hasError; + } + return false; +} + +#include "main.moc" diff --git a/kbabel/datatools/not-translated/CMakeLists.txt b/kbabel/datatools/not-translated/CMakeLists.txt index 59d36138..41da20a1 100644 --- a/kbabel/datatools/not-translated/CMakeLists.txt +++ b/kbabel/datatools/not-translated/CMakeLists.txt @@ -34,7 +34,7 @@ tde_create_translated_desktop( ##### kbabel_nottranslatedtool (module) ######### tde_add_kpart( kbabel_nottranslatedtool AUTOMOC - SOURCES main.cc + SOURCES main.cpp LINK kbabelcommon-shared DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/kbabel/datatools/not-translated/Makefile.am b/kbabel/datatools/not-translated/Makefile.am index 40299023..52a88ca9 100644 --- a/kbabel/datatools/not-translated/Makefile.am +++ b/kbabel/datatools/not-translated/Makefile.am @@ -6,7 +6,7 @@ kbabel_nottranslatedtool_la_LIBADD = $(LIB_TDEIO) ../../common/libkbabelcommon.l kde_module_LTLIBRARIES = kbabel_nottranslatedtool.la -kbabel_nottranslatedtool_la_SOURCES = main.cc +kbabel_nottranslatedtool_la_SOURCES = main.cpp kbabel_nottranslatedtool_la_LDFLAGS = $(all_libraries) -avoid-version -module -no-undefined diff --git a/kbabel/datatools/not-translated/main.cc b/kbabel/datatools/not-translated/main.cc deleted file mode 100644 index 68093191..00000000 --- a/kbabel/datatools/not-translated/main.cc +++ /dev/null @@ -1,129 +0,0 @@ -/* This file is part of KBabel - based Copyright (C) 1998, 1999 Torben Weis - 2002 Stanislav Visnovsky - 2003 Dwayne Bailey - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the TQt library by Trolltech AS, Norway (or with modified versions - of TQt that use the same license as TQt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - TQt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. - -*/ - -#include -#include "catalog.h" -#include "catalogitem.h" -#include "catalogsettings.h" -#include "main.h" - -#include -#include -#include -#include -#include -#include - -/*************************************************** - * - * Factory - * - ***************************************************/ - -K_EXPORT_COMPONENT_FACTORY( kbabel_nottranslatedtool, KGenericFactory ( "kbabeldatatool" ) ) - -using namespace KBabel; - -NotTranslatedTool::NotTranslatedTool( TQObject* parent, const char* name, const TQStringList & ) - : KDataTool( parent, name ) , _cache_origin( 0 ) -{ - i18n("which check found errors","English text in translation"); -} - -bool NotTranslatedTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) -{ - - if ( command != "validate" ) - { - kdDebug(KBABEL) << "Not Translated Tool only accepts the 'validate' command" << endl; - kdDebug(KBABEL) << " The command " << command << " is not accepted" << endl; - return false; - } - - // Check wether we can accept the data - if ( datatype != "CatalogItem" ) - { - kdDebug(KBABEL) << "Not Translated Tool only accept the CatalogItem datatype" << endl; - return false; - } - - if ( mimetype != "application/x-kbabel-catalogitem" ) - { - kdDebug(KBABEL) << "Not Translated Tool only accept the 'application/x-kbabel-catalogitem' mimetype" << endl; - return false; - } - - if( command == "validate" ) - { - CatalogItem* item = (CatalogItem*)(data); - bool hasError = false; - - if(!item->isUntranslated()) { - if( _cache_origin != item->project() ) - { - _context = item->project()->miscSettings().contextInfo; - _plurals = item->project()->miscSettings().singularPlural; - _cache_origin = item->project(); - } - - //FIXME Expand this to do substring matching of non-translation - TQStringList id, str; - if( item->pluralForm() == KDESpecific ) { - str = TQStringList::split( "\\n", item->msgstr().first(), true ); - id = TQStringList::split( "\\n", - item->msgid().first().replace( TQRegExp(_plurals), ""), true ); - } else { - str = item->msgstr(); - id = item->msgid(); - } - for( TQStringList::Iterator i = id.begin() ; i != id.end() ; i++ ) { - TQString id_str = (*i).replace( TQRegExp(_context), ""); - for( TQStringList::Iterator j = str.begin() ; j != str.end() ; j++ ) { - TQString str_str = (*j); - hasError = hasError || ( id_str == str_str ); - } - } - - } - - if(hasError) - item->appendError( "english text in translation" ); - else - item->removeError( "english text in translation" ); - - return !hasError; - } - return false; -} - -#include "main.moc" diff --git a/kbabel/datatools/not-translated/main.cpp b/kbabel/datatools/not-translated/main.cpp new file mode 100644 index 00000000..68093191 --- /dev/null +++ b/kbabel/datatools/not-translated/main.cpp @@ -0,0 +1,129 @@ +/* This file is part of KBabel + based Copyright (C) 1998, 1999 Torben Weis + 2002 Stanislav Visnovsky + 2003 Dwayne Bailey + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the TQt library by Trolltech AS, Norway (or with modified versions + of TQt that use the same license as TQt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + TQt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. + +*/ + +#include +#include "catalog.h" +#include "catalogitem.h" +#include "catalogsettings.h" +#include "main.h" + +#include +#include +#include +#include +#include +#include + +/*************************************************** + * + * Factory + * + ***************************************************/ + +K_EXPORT_COMPONENT_FACTORY( kbabel_nottranslatedtool, KGenericFactory ( "kbabeldatatool" ) ) + +using namespace KBabel; + +NotTranslatedTool::NotTranslatedTool( TQObject* parent, const char* name, const TQStringList & ) + : KDataTool( parent, name ) , _cache_origin( 0 ) +{ + i18n("which check found errors","English text in translation"); +} + +bool NotTranslatedTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) +{ + + if ( command != "validate" ) + { + kdDebug(KBABEL) << "Not Translated Tool only accepts the 'validate' command" << endl; + kdDebug(KBABEL) << " The command " << command << " is not accepted" << endl; + return false; + } + + // Check wether we can accept the data + if ( datatype != "CatalogItem" ) + { + kdDebug(KBABEL) << "Not Translated Tool only accept the CatalogItem datatype" << endl; + return false; + } + + if ( mimetype != "application/x-kbabel-catalogitem" ) + { + kdDebug(KBABEL) << "Not Translated Tool only accept the 'application/x-kbabel-catalogitem' mimetype" << endl; + return false; + } + + if( command == "validate" ) + { + CatalogItem* item = (CatalogItem*)(data); + bool hasError = false; + + if(!item->isUntranslated()) { + if( _cache_origin != item->project() ) + { + _context = item->project()->miscSettings().contextInfo; + _plurals = item->project()->miscSettings().singularPlural; + _cache_origin = item->project(); + } + + //FIXME Expand this to do substring matching of non-translation + TQStringList id, str; + if( item->pluralForm() == KDESpecific ) { + str = TQStringList::split( "\\n", item->msgstr().first(), true ); + id = TQStringList::split( "\\n", + item->msgid().first().replace( TQRegExp(_plurals), ""), true ); + } else { + str = item->msgstr(); + id = item->msgid(); + } + for( TQStringList::Iterator i = id.begin() ; i != id.end() ; i++ ) { + TQString id_str = (*i).replace( TQRegExp(_context), ""); + for( TQStringList::Iterator j = str.begin() ; j != str.end() ; j++ ) { + TQString str_str = (*j); + hasError = hasError || ( id_str == str_str ); + } + } + + } + + if(hasError) + item->appendError( "english text in translation" ); + else + item->removeError( "english text in translation" ); + + return !hasError; + } + return false; +} + +#include "main.moc" diff --git a/kbabel/datatools/pluralforms/CMakeLists.txt b/kbabel/datatools/pluralforms/CMakeLists.txt index 2a86d0c3..80b3f102 100644 --- a/kbabel/datatools/pluralforms/CMakeLists.txt +++ b/kbabel/datatools/pluralforms/CMakeLists.txt @@ -34,7 +34,7 @@ tde_create_translated_desktop( ##### kbabel_pluraltool (module) ################ tde_add_kpart( kbabel_pluraltool AUTOMOC - SOURCES main.cc + SOURCES main.cpp LINK kbabelcommon-shared DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/kbabel/datatools/pluralforms/Makefile.am b/kbabel/datatools/pluralforms/Makefile.am index 951e08cb..53ea610d 100644 --- a/kbabel/datatools/pluralforms/Makefile.am +++ b/kbabel/datatools/pluralforms/Makefile.am @@ -6,7 +6,7 @@ kbabel_pluraltool_la_LIBADD = $(LIB_TDEIO) ../../common/libkbabelcommon.la kde_module_LTLIBRARIES = kbabel_pluraltool.la -kbabel_pluraltool_la_SOURCES = main.cc +kbabel_pluraltool_la_SOURCES = main.cpp kbabel_pluraltool_la_LDFLAGS = $(all_libraries) -avoid-version -module -no-undefined diff --git a/kbabel/datatools/pluralforms/main.cc b/kbabel/datatools/pluralforms/main.cc deleted file mode 100644 index 693a843b..00000000 --- a/kbabel/datatools/pluralforms/main.cc +++ /dev/null @@ -1,129 +0,0 @@ -/* This file is part of KBabel - based Copyright (C) 1998, 1999 Torben Weis - 2002 Stanislav Visnovsky - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the TQt library by Trolltech AS, Norway (or with modified versions - of TQt that use the same license as TQt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - TQt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. - -*/ - -#include -#include "catalog.h" -#include "catalogitem.h" -#include "catalogsettings.h" -#include "main.h" - -#include -#include -#include -#include -#include -#include - -/*************************************************** - * - * Factory - * - ***************************************************/ - -K_EXPORT_COMPONENT_FACTORY( kbabel_pluraltool, KGenericFactory ( "kbabeldatatool" ) ) - -using namespace KBabel; - -PluralsTool::PluralsTool( TQObject* parent, const char* name, const TQStringList & ) - : KDataTool( parent, name ), _cache_origin( 0 ), _neededForms(-1) -{ - i18n("what check found errors", "plural forms"); -} - -bool PluralsTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) -{ - if ( command != "validate" ) - { - kdDebug(KBABEL) << "Plural Forms Tool does only accept the command 'validate' and 'shortcut'" << endl; - kdDebug(KBABEL) << " The commands " << command << " is not accepted" << endl; - return FALSE; - } - - // Check wether we can accept the data - if ( datatype != "CatalogItem" ) - { - kdDebug(KBABEL) << "Plural Forms Tool only accepts datatype CatalogItem" << endl; - return FALSE; - } - - if ( mimetype != "application/x-kbabel-catalogitem" ) - { - kdDebug(KBABEL) << "Plural Forms Tool only accepts mimetype application/x-kbabel-catalogitem" << endl; - return FALSE; - } - - if( command == "validate" ) - { - if( _neededForms < 0 ) - { - Catalog* cat = new Catalog(this); - _neededForms = cat->defaultNumberOfPluralForms(); - delete cat; - } - - CatalogItem* item = (CatalogItem*)(data); - - if( _cache_origin != item->project() ) - { - _plurals = item->project()->miscSettings().singularPlural; - _cache_origin = item->project(); - } - - bool hasError = false; - - if(!item->isUntranslated() && item->pluralForm() == KDESpecific ) - { - if(_neededForms <= 0 || item->msgstr().first().contains(_plurals)) - { - hasError = true; - } - else if( item->msgstr().first().contains(TQString("\\n"))+1 != _neededForms ) - { - hasError = true; - } - } - - if(hasError) - { - item->appendError( "plural forms" ); - } - else - { - item->removeError( "plural forms" ); - } - - return !hasError; - } - return FALSE; -} - -#include "main.moc" diff --git a/kbabel/datatools/pluralforms/main.cpp b/kbabel/datatools/pluralforms/main.cpp new file mode 100644 index 00000000..693a843b --- /dev/null +++ b/kbabel/datatools/pluralforms/main.cpp @@ -0,0 +1,129 @@ +/* This file is part of KBabel + based Copyright (C) 1998, 1999 Torben Weis + 2002 Stanislav Visnovsky + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the TQt library by Trolltech AS, Norway (or with modified versions + of TQt that use the same license as TQt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + TQt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. + +*/ + +#include +#include "catalog.h" +#include "catalogitem.h" +#include "catalogsettings.h" +#include "main.h" + +#include +#include +#include +#include +#include +#include + +/*************************************************** + * + * Factory + * + ***************************************************/ + +K_EXPORT_COMPONENT_FACTORY( kbabel_pluraltool, KGenericFactory ( "kbabeldatatool" ) ) + +using namespace KBabel; + +PluralsTool::PluralsTool( TQObject* parent, const char* name, const TQStringList & ) + : KDataTool( parent, name ), _cache_origin( 0 ), _neededForms(-1) +{ + i18n("what check found errors", "plural forms"); +} + +bool PluralsTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) +{ + if ( command != "validate" ) + { + kdDebug(KBABEL) << "Plural Forms Tool does only accept the command 'validate' and 'shortcut'" << endl; + kdDebug(KBABEL) << " The commands " << command << " is not accepted" << endl; + return FALSE; + } + + // Check wether we can accept the data + if ( datatype != "CatalogItem" ) + { + kdDebug(KBABEL) << "Plural Forms Tool only accepts datatype CatalogItem" << endl; + return FALSE; + } + + if ( mimetype != "application/x-kbabel-catalogitem" ) + { + kdDebug(KBABEL) << "Plural Forms Tool only accepts mimetype application/x-kbabel-catalogitem" << endl; + return FALSE; + } + + if( command == "validate" ) + { + if( _neededForms < 0 ) + { + Catalog* cat = new Catalog(this); + _neededForms = cat->defaultNumberOfPluralForms(); + delete cat; + } + + CatalogItem* item = (CatalogItem*)(data); + + if( _cache_origin != item->project() ) + { + _plurals = item->project()->miscSettings().singularPlural; + _cache_origin = item->project(); + } + + bool hasError = false; + + if(!item->isUntranslated() && item->pluralForm() == KDESpecific ) + { + if(_neededForms <= 0 || item->msgstr().first().contains(_plurals)) + { + hasError = true; + } + else if( item->msgstr().first().contains(TQString("\\n"))+1 != _neededForms ) + { + hasError = true; + } + } + + if(hasError) + { + item->appendError( "plural forms" ); + } + else + { + item->removeError( "plural forms" ); + } + + return !hasError; + } + return FALSE; +} + +#include "main.moc" diff --git a/kbabel/datatools/punctuation/CMakeLists.txt b/kbabel/datatools/punctuation/CMakeLists.txt index b325342f..d096dcf5 100644 --- a/kbabel/datatools/punctuation/CMakeLists.txt +++ b/kbabel/datatools/punctuation/CMakeLists.txt @@ -34,7 +34,7 @@ tde_create_translated_desktop( ##### kbabel_punctuationtool (module) ########### tde_add_kpart( kbabel_punctuationtool AUTOMOC - SOURCES main.cc + SOURCES main.cpp LINK kbabelcommon-shared DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/kbabel/datatools/punctuation/Makefile.am b/kbabel/datatools/punctuation/Makefile.am index 1aceb053..c30ada47 100644 --- a/kbabel/datatools/punctuation/Makefile.am +++ b/kbabel/datatools/punctuation/Makefile.am @@ -6,7 +6,7 @@ kbabel_punctuationtool_la_LIBADD = $(LIB_TDEIO) ../../common/libkbabelcommon.la kde_module_LTLIBRARIES = kbabel_punctuationtool.la -kbabel_punctuationtool_la_SOURCES = main.cc +kbabel_punctuationtool_la_SOURCES = main.cpp kbabel_punctuationtool_la_LDFLAGS = $(all_libraries) -avoid-version -module -no-undefined diff --git a/kbabel/datatools/punctuation/main.cc b/kbabel/datatools/punctuation/main.cc deleted file mode 100644 index 6d779518..00000000 --- a/kbabel/datatools/punctuation/main.cc +++ /dev/null @@ -1,157 +0,0 @@ -/* This file is part of KBabel - based Copyright (C) 1998, 1999 Torben Weis - 2003 Stanislav Visnovsky - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the TQt library by Trolltech AS, Norway (or with modified versions - of TQt that use the same license as TQt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - TQt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. - -*/ - -#include -#include "catalogitem.h" -#include "catalogsettings.h" -#include "main.h" - -#include -#include -#include -#include -#include - -/*************************************************** - * - * Factory - * - ***************************************************/ - -K_EXPORT_COMPONENT_FACTORY( kbabel_punctuationtool, KGenericFactory ( "kbabeldatatool" ) ) - -using namespace KBabel; - -PunctuationTool::PunctuationTool( TQObject* parent, const char* name, const TQStringList & ) - : KDataTool( parent, name ) -{ - // bogus translation just for allowing the translation - i18n("what check found errors","punctuation"); -} - -bool PunctuationTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) -{ - if ( command != "validate" ) - { - kdDebug(KBABEL) << "Punctuation Tool does only accept the command 'validate'" << endl; - kdDebug(KBABEL) << " The commands " << command << " is not accepted" << endl; - return FALSE; - } - - // Check wether we can accept the data - if ( datatype != "CatalogItem" ) - { - kdDebug(KBABEL) << "Punctuation Tool only accepts datatype CatalogItem" << endl; - return FALSE; - } - - if ( mimetype != "application/x-kbabel-catalogitem" ) - { - kdDebug(KBABEL) << "Punctuation Tool only accepts mimetype application/x-kbabel-catalogitem" << endl; - return FALSE; - } - - if( command == "validate" ) - { - CatalogItem* item = (CatalogItem*)(data); - - bool hasError = false; - - if(!item->isUntranslated()) - { - TQString lineid=item->msgid().first(); - - // lookup punctuation in original text - TQRegExp punc("[\\.!\\?:]+$"); - int i = lineid.find(punc); - - TQString t(""); - - if( i != -1 ) t = lineid.right(lineid.length()-i); - - if( item->pluralForm() != NoPluralForm ) - { - // check, that both plural forms contain the same punctuation - TQString pl = *(item->msgid().at(1)); - int j = pl.find(punc); - - TQString tp(""); - if( j != -1 ) tp = pl.right(pl.length()-j); - - if( tp != t ) - { - kdWarning() << "Singular and plural form do not have the same punctuation" << endl; - } - } - - TQStringList forms = item->msgstr(true); - if( item->pluralForm() == KDESpecific ) { - forms = TQStringList::split("\\n",*item->msgstr(true).at(0)); - } - - for( TQStringList::Iterator form = forms.begin() ; form != forms.end(); form++ ) - { - TQString linestr=(*form); - - int j = linestr.find(punc); - - // there is no punctuation in original, but one in the translation - if( i == -1 && j != i ) - { - hasError = true; - break; - } - - // there is punctuation in original, but not same as in the translation - if( i != -1 && linestr.right(linestr.length()-j) != t ) - { - hasError = true; - break; - } - } - } - - if(hasError) - { - item->appendError( "punctuation" ); - } - else - { - item->removeError( "punctuation" ); - } - - return !hasError; - } - return FALSE; -} - -#include "main.moc" diff --git a/kbabel/datatools/punctuation/main.cpp b/kbabel/datatools/punctuation/main.cpp new file mode 100644 index 00000000..6d779518 --- /dev/null +++ b/kbabel/datatools/punctuation/main.cpp @@ -0,0 +1,157 @@ +/* This file is part of KBabel + based Copyright (C) 1998, 1999 Torben Weis + 2003 Stanislav Visnovsky + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the TQt library by Trolltech AS, Norway (or with modified versions + of TQt that use the same license as TQt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + TQt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. + +*/ + +#include +#include "catalogitem.h" +#include "catalogsettings.h" +#include "main.h" + +#include +#include +#include +#include +#include + +/*************************************************** + * + * Factory + * + ***************************************************/ + +K_EXPORT_COMPONENT_FACTORY( kbabel_punctuationtool, KGenericFactory ( "kbabeldatatool" ) ) + +using namespace KBabel; + +PunctuationTool::PunctuationTool( TQObject* parent, const char* name, const TQStringList & ) + : KDataTool( parent, name ) +{ + // bogus translation just for allowing the translation + i18n("what check found errors","punctuation"); +} + +bool PunctuationTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) +{ + if ( command != "validate" ) + { + kdDebug(KBABEL) << "Punctuation Tool does only accept the command 'validate'" << endl; + kdDebug(KBABEL) << " The commands " << command << " is not accepted" << endl; + return FALSE; + } + + // Check wether we can accept the data + if ( datatype != "CatalogItem" ) + { + kdDebug(KBABEL) << "Punctuation Tool only accepts datatype CatalogItem" << endl; + return FALSE; + } + + if ( mimetype != "application/x-kbabel-catalogitem" ) + { + kdDebug(KBABEL) << "Punctuation Tool only accepts mimetype application/x-kbabel-catalogitem" << endl; + return FALSE; + } + + if( command == "validate" ) + { + CatalogItem* item = (CatalogItem*)(data); + + bool hasError = false; + + if(!item->isUntranslated()) + { + TQString lineid=item->msgid().first(); + + // lookup punctuation in original text + TQRegExp punc("[\\.!\\?:]+$"); + int i = lineid.find(punc); + + TQString t(""); + + if( i != -1 ) t = lineid.right(lineid.length()-i); + + if( item->pluralForm() != NoPluralForm ) + { + // check, that both plural forms contain the same punctuation + TQString pl = *(item->msgid().at(1)); + int j = pl.find(punc); + + TQString tp(""); + if( j != -1 ) tp = pl.right(pl.length()-j); + + if( tp != t ) + { + kdWarning() << "Singular and plural form do not have the same punctuation" << endl; + } + } + + TQStringList forms = item->msgstr(true); + if( item->pluralForm() == KDESpecific ) { + forms = TQStringList::split("\\n",*item->msgstr(true).at(0)); + } + + for( TQStringList::Iterator form = forms.begin() ; form != forms.end(); form++ ) + { + TQString linestr=(*form); + + int j = linestr.find(punc); + + // there is no punctuation in original, but one in the translation + if( i == -1 && j != i ) + { + hasError = true; + break; + } + + // there is punctuation in original, but not same as in the translation + if( i != -1 && linestr.right(linestr.length()-j) != t ) + { + hasError = true; + break; + } + } + } + + if(hasError) + { + item->appendError( "punctuation" ); + } + else + { + item->removeError( "punctuation" ); + } + + return !hasError; + } + return FALSE; +} + +#include "main.moc" diff --git a/kbabel/datatools/regexp/CMakeLists.txt b/kbabel/datatools/regexp/CMakeLists.txt index 77e4553b..e75b53a4 100644 --- a/kbabel/datatools/regexp/CMakeLists.txt +++ b/kbabel/datatools/regexp/CMakeLists.txt @@ -36,7 +36,7 @@ install( FILES regexplist.xml DESTINATION ${DATA_INSTALL_DIR}/kbabel ) ##### kbabel_regexptool (module) ################ tde_add_kpart( kbabel_regexptool AUTOMOC - SOURCES main.cc + SOURCES main.cpp LINK kbabelcommon-shared DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/kbabel/datatools/regexp/Makefile.am b/kbabel/datatools/regexp/Makefile.am index 42ebe1cb..cc574668 100644 --- a/kbabel/datatools/regexp/Makefile.am +++ b/kbabel/datatools/regexp/Makefile.am @@ -6,7 +6,7 @@ kbabel_regexptool_la_LIBADD = $(LIB_TDEIO) ../../common/libkbabelcommon.la kde_module_LTLIBRARIES = kbabel_regexptool.la -kbabel_regexptool_la_SOURCES = main.cc +kbabel_regexptool_la_SOURCES = main.cpp kbabel_regexptool_la_LDFLAGS = $(all_libraries) -avoid-version -module -no-undefined diff --git a/kbabel/datatools/regexp/main.cc b/kbabel/datatools/regexp/main.cc deleted file mode 100644 index e500728e..00000000 --- a/kbabel/datatools/regexp/main.cc +++ /dev/null @@ -1,181 +0,0 @@ -/* Copyright (C) 2005 Albert Cervera i Areny - - Based on Copyright (C) 1998, 1999 Torben Weis - 2002 Stanislav Visnovsky - 2003 Dwayne Bailey - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include -#include "catalog.h" -#include "catalogitem.h" -#include "catalogsettings.h" -#include "main.h" -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/*************************************************** - * - * Factory - * - ***************************************************/ - -K_EXPORT_COMPONENT_FACTORY( kbabel_regexptool, KGenericFactory ( "kbabeldatatool" ) ) - -using namespace KBabel; - -RegExpTool::RegExpTool( TQObject* parent, const char* name, const TQStringList & ) - : KDataTool( parent, name ) -{ - i18n("which check found errors","translation has inconsistent length"); - loadExpressions(); - if ( ! _error.isNull() ) - KMessageBox::error( (TQWidget*)parent, i18n( "Error loading data (%1)" ).arg( _error ) ); -} - -bool RegExpTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) -{ - if ( command != "validate" ) - { - kdDebug(KBABEL) << "RegExpTool only accepts the 'validate' command" << endl; - kdDebug(KBABEL) << " The command " << command << " is not accepted" << endl; - return false; - } - // Check wether we can accept the data - if ( datatype != "CatalogItem" ) - { - kdDebug(KBABEL) << "RegExpTool only accepts the CatalogItem datatype" << endl; - return false; - } - if ( mimetype != "application/x-kbabel-catalogitem" ) - { - kdDebug(KBABEL) << "RegExpTool only accepts the 'application/x-kbabel-catalogitem' mimetype" << endl; - return false; - } - - bool hasError = false; - if( command == "validate" ) - { - CatalogItem* item = (CatalogItem*)(data); - - if(!item->isUntranslated()) { - ExpressionList::Iterator it( _list.begin() ); - ExpressionList::Iterator end( _list.end() ); - TQStringList msgs = item->msgstr(); - TQStringList results; - for ( ; it != end; ++it ) { - results.clear(); - results = msgs.grep( (*it).regExp() ); - if ( results.size() > 0 ) { - hasError = true; - break; - } - } - } - if(hasError) { - item->appendError( "regexp" ); - } else { - item->removeError( "regexp" ); - } - } - return !hasError; -} - - -void RegExpTool::loadExpressions() -{ - // TODO: Change file path - TQFile file( TQDir::homeDirPath() + "/.trinity/share/apps/kbabel/regexplist.xml" ); - TQDomDocument doc; - - if ( ! file.open( IO_ReadOnly ) ) { - kdDebug() << "File not found" << endl; - _error = i18n( "File not found" ); - return; - } - if ( ! doc.setContent( &file ) ) { - kdDebug() << "Could not set content of xml file" << endl; - _error = i18n( "The file is not a XML" ); - return; - } - file.close(); - - TQDomElement docElem = doc.documentElement(); - TQDomNode n = docElem.firstChild(); - while( !n.isNull() ) { - TQDomElement e = n.toElement(); - if( !e.isNull() ) - elementToExpression( e ); - if ( ! _error.isNull() ) - break; - n = n.nextSibling(); - } -} - -void RegExpTool::elementToExpression( const TQDomElement& e ) -{ - TQString name; - TQString exp; - bool cs = false; //Expressions are case insensitive by default - - if ( e.tagName().compare( "item" ) != 0 ) { - _error = i18n( "Expected tag 'item'" ); - return; - } - - TQDomNode n = e.firstChild(); - if ( n.isNull() ) { - _error = i18n( "First child of 'item' is not a node" ); - return; - } - - TQDomElement el = n.toElement(); - if ( el.isNull() || el.tagName().compare( "name" ) != 0 ) { - _error = i18n( "Expected tag 'name'" ); - return; - } - name = el.text(); - - n = n.nextSibling(); - el = n.toElement(); - if ( el.isNull() || el.tagName().compare( "exp" ) != 0 ) { - _error = i18n( "Expected tag 'exp'" ); - return; - } - exp = el.text(); - - n = n.nextSibling(); - el = n.toElement(); - if ( ! el.isNull() ) - cs = true; - - kdDebug(KBABEL) << "RegExpTool: Adding expression: " << name << endl; - _list.append( Expression( name, TQRegExp( exp, cs ) ) ); -} - -#include "main.moc" diff --git a/kbabel/datatools/regexp/main.cpp b/kbabel/datatools/regexp/main.cpp new file mode 100644 index 00000000..e500728e --- /dev/null +++ b/kbabel/datatools/regexp/main.cpp @@ -0,0 +1,181 @@ +/* Copyright (C) 2005 Albert Cervera i Areny + + Based on Copyright (C) 1998, 1999 Torben Weis + 2002 Stanislav Visnovsky + 2003 Dwayne Bailey + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include +#include "catalog.h" +#include "catalogitem.h" +#include "catalogsettings.h" +#include "main.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/*************************************************** + * + * Factory + * + ***************************************************/ + +K_EXPORT_COMPONENT_FACTORY( kbabel_regexptool, KGenericFactory ( "kbabeldatatool" ) ) + +using namespace KBabel; + +RegExpTool::RegExpTool( TQObject* parent, const char* name, const TQStringList & ) + : KDataTool( parent, name ) +{ + i18n("which check found errors","translation has inconsistent length"); + loadExpressions(); + if ( ! _error.isNull() ) + KMessageBox::error( (TQWidget*)parent, i18n( "Error loading data (%1)" ).arg( _error ) ); +} + +bool RegExpTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) +{ + if ( command != "validate" ) + { + kdDebug(KBABEL) << "RegExpTool only accepts the 'validate' command" << endl; + kdDebug(KBABEL) << " The command " << command << " is not accepted" << endl; + return false; + } + // Check wether we can accept the data + if ( datatype != "CatalogItem" ) + { + kdDebug(KBABEL) << "RegExpTool only accepts the CatalogItem datatype" << endl; + return false; + } + if ( mimetype != "application/x-kbabel-catalogitem" ) + { + kdDebug(KBABEL) << "RegExpTool only accepts the 'application/x-kbabel-catalogitem' mimetype" << endl; + return false; + } + + bool hasError = false; + if( command == "validate" ) + { + CatalogItem* item = (CatalogItem*)(data); + + if(!item->isUntranslated()) { + ExpressionList::Iterator it( _list.begin() ); + ExpressionList::Iterator end( _list.end() ); + TQStringList msgs = item->msgstr(); + TQStringList results; + for ( ; it != end; ++it ) { + results.clear(); + results = msgs.grep( (*it).regExp() ); + if ( results.size() > 0 ) { + hasError = true; + break; + } + } + } + if(hasError) { + item->appendError( "regexp" ); + } else { + item->removeError( "regexp" ); + } + } + return !hasError; +} + + +void RegExpTool::loadExpressions() +{ + // TODO: Change file path + TQFile file( TQDir::homeDirPath() + "/.trinity/share/apps/kbabel/regexplist.xml" ); + TQDomDocument doc; + + if ( ! file.open( IO_ReadOnly ) ) { + kdDebug() << "File not found" << endl; + _error = i18n( "File not found" ); + return; + } + if ( ! doc.setContent( &file ) ) { + kdDebug() << "Could not set content of xml file" << endl; + _error = i18n( "The file is not a XML" ); + return; + } + file.close(); + + TQDomElement docElem = doc.documentElement(); + TQDomNode n = docElem.firstChild(); + while( !n.isNull() ) { + TQDomElement e = n.toElement(); + if( !e.isNull() ) + elementToExpression( e ); + if ( ! _error.isNull() ) + break; + n = n.nextSibling(); + } +} + +void RegExpTool::elementToExpression( const TQDomElement& e ) +{ + TQString name; + TQString exp; + bool cs = false; //Expressions are case insensitive by default + + if ( e.tagName().compare( "item" ) != 0 ) { + _error = i18n( "Expected tag 'item'" ); + return; + } + + TQDomNode n = e.firstChild(); + if ( n.isNull() ) { + _error = i18n( "First child of 'item' is not a node" ); + return; + } + + TQDomElement el = n.toElement(); + if ( el.isNull() || el.tagName().compare( "name" ) != 0 ) { + _error = i18n( "Expected tag 'name'" ); + return; + } + name = el.text(); + + n = n.nextSibling(); + el = n.toElement(); + if ( el.isNull() || el.tagName().compare( "exp" ) != 0 ) { + _error = i18n( "Expected tag 'exp'" ); + return; + } + exp = el.text(); + + n = n.nextSibling(); + el = n.toElement(); + if ( ! el.isNull() ) + cs = true; + + kdDebug(KBABEL) << "RegExpTool: Adding expression: " << name << endl; + _list.append( Expression( name, TQRegExp( exp, cs ) ) ); +} + +#include "main.moc" diff --git a/kbabel/datatools/regexp/regexplist.xml b/kbabel/datatools/regexp/regexplist.xml index 72f647cb..39624092 100644 --- a/kbabel/datatools/regexp/regexplist.xml +++ b/kbabel/datatools/regexp/regexplist.xml @@ -10,7 +10,7 @@ ... - Right now the file should be copied to ~/.trinity/share/apps/kbabel/regexplist.xml. I'm sorry this cannot be configured but hope it will in the future. By the time if you need another location you have to modify the source code (main.cc) + Right now the file should be copied to ~/.trinity/share/apps/kbabel/regexplist.xml. I'm sorry this cannot be configured but hope it will in the future. By the time if you need another location you have to modify the source code (main.cpp) You'll see in the example that most expressions start with '(^| |\\t)+' and then a word. This is to ensure it _is_ a word. Using the usual expressions to ensure we pick up a whole word doesn't work for the catalan language. Anyway, if you need to match a tab be sure you use the '\\t' expression. @@ -300,4 +300,4 @@ - \ No newline at end of file + diff --git a/kbabel/datatools/setfuzzy/CMakeLists.txt b/kbabel/datatools/setfuzzy/CMakeLists.txt index 864a5030..5ccf8bac 100644 --- a/kbabel/datatools/setfuzzy/CMakeLists.txt +++ b/kbabel/datatools/setfuzzy/CMakeLists.txt @@ -34,7 +34,7 @@ tde_create_translated_desktop( ##### kbabel_setfuzzytool (module) ############## tde_add_kpart( kbabel_setfuzzytool AUTOMOC - SOURCES main.cc + SOURCES main.cpp LINK kbabelcommon-shared DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/kbabel/datatools/setfuzzy/Makefile.am b/kbabel/datatools/setfuzzy/Makefile.am index f1a5b8bc..1b84cb02 100644 --- a/kbabel/datatools/setfuzzy/Makefile.am +++ b/kbabel/datatools/setfuzzy/Makefile.am @@ -6,7 +6,7 @@ kbabel_setfuzzytool_la_LIBADD = ../../common/libkbabelcommon.la kde_module_LTLIBRARIES = kbabel_setfuzzytool.la -kbabel_setfuzzytool_la_SOURCES = main.cc +kbabel_setfuzzytool_la_SOURCES = main.cpp kbabel_setfuzzytool_la_LDFLAGS = $(all_libraries) -avoid-version -module -no-undefined diff --git a/kbabel/datatools/setfuzzy/main.cc b/kbabel/datatools/setfuzzy/main.cc deleted file mode 100644 index 7bc0ed16..00000000 --- a/kbabel/datatools/setfuzzy/main.cc +++ /dev/null @@ -1,98 +0,0 @@ -/* This file is part of KBabel - based Copyright (C) 1998, 1999 Torben Weis - 2003 Stanislav Visnovsky - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the TQt library by Trolltech AS, Norway (or with modified versions - of TQt that use the same license as TQt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - TQt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. - -*/ - -#include -#include "catalog.h" -#include "main.h" - -#include -#include -#include -#include - -/*************************************************** - * - * Factory - * - ***************************************************/ - -K_EXPORT_COMPONENT_FACTORY( kbabel_setfuzzytool, KGenericFactory ( "kbabeldatatool" ) ) - -using namespace KBabel; - -SetFuzzyTool::SetFuzzyTool( TQObject* parent, const char* name, const TQStringList & ) - : KDataTool( parent, name ) -{ -} - -bool SetFuzzyTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) -{ - if ( command != "allfuzzy" ) - { - kdDebug(KBABEL) << "Fuzzy Toggling Tool does only accept the command 'allfuzzy'" << endl; - kdDebug(KBABEL) << " The commands " << command << " is not accepted" << endl; - return FALSE; - } - - // Check wether we can accept the data - if ( datatype != "Catalog" ) - { - kdDebug(KBABEL) << "Fuzzy Toggling Tool only accepts datatype Catalog" << endl; - return FALSE; - } - - if ( mimetype != "application/x-kbabel-catalog" ) - { - kdDebug(KBABEL) << "Plural Forms Tool only accepts mimetype application/x-kbabel-catalog" << endl; - return FALSE; - } - - if( command == "allfuzzy" ) - { - Catalog* catalog = (Catalog*)(data); - - catalog->applyBeginCommand(0,Msgstr,0); - - for( uint index=0; index < catalog->numberOfEntries(); index++ ) - { - if( !catalog->isUntranslated(index) ) - { - catalog->setFuzzy(index,true); - } - } - - catalog->applyEndCommand(0,Msgstr,0); - } - return TRUE; -} - -#include "main.moc" diff --git a/kbabel/datatools/setfuzzy/main.cpp b/kbabel/datatools/setfuzzy/main.cpp new file mode 100644 index 00000000..7bc0ed16 --- /dev/null +++ b/kbabel/datatools/setfuzzy/main.cpp @@ -0,0 +1,98 @@ +/* This file is part of KBabel + based Copyright (C) 1998, 1999 Torben Weis + 2003 Stanislav Visnovsky + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the TQt library by Trolltech AS, Norway (or with modified versions + of TQt that use the same license as TQt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + TQt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. + +*/ + +#include +#include "catalog.h" +#include "main.h" + +#include +#include +#include +#include + +/*************************************************** + * + * Factory + * + ***************************************************/ + +K_EXPORT_COMPONENT_FACTORY( kbabel_setfuzzytool, KGenericFactory ( "kbabeldatatool" ) ) + +using namespace KBabel; + +SetFuzzyTool::SetFuzzyTool( TQObject* parent, const char* name, const TQStringList & ) + : KDataTool( parent, name ) +{ +} + +bool SetFuzzyTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) +{ + if ( command != "allfuzzy" ) + { + kdDebug(KBABEL) << "Fuzzy Toggling Tool does only accept the command 'allfuzzy'" << endl; + kdDebug(KBABEL) << " The commands " << command << " is not accepted" << endl; + return FALSE; + } + + // Check wether we can accept the data + if ( datatype != "Catalog" ) + { + kdDebug(KBABEL) << "Fuzzy Toggling Tool only accepts datatype Catalog" << endl; + return FALSE; + } + + if ( mimetype != "application/x-kbabel-catalog" ) + { + kdDebug(KBABEL) << "Plural Forms Tool only accepts mimetype application/x-kbabel-catalog" << endl; + return FALSE; + } + + if( command == "allfuzzy" ) + { + Catalog* catalog = (Catalog*)(data); + + catalog->applyBeginCommand(0,Msgstr,0); + + for( uint index=0; index < catalog->numberOfEntries(); index++ ) + { + if( !catalog->isUntranslated(index) ) + { + catalog->setFuzzy(index,true); + } + } + + catalog->applyEndCommand(0,Msgstr,0); + } + return TRUE; +} + +#include "main.moc" diff --git a/kbabel/datatools/whitespace/CMakeLists.txt b/kbabel/datatools/whitespace/CMakeLists.txt index 13f1c0f1..94784981 100644 --- a/kbabel/datatools/whitespace/CMakeLists.txt +++ b/kbabel/datatools/whitespace/CMakeLists.txt @@ -34,7 +34,7 @@ tde_create_translated_desktop( ##### kbabel_whitespacetool (module) ############ tde_add_kpart( kbabel_whitespacetool AUTOMOC - SOURCES main.cc + SOURCES main.cpp LINK kbabelcommon-shared DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/kbabel/datatools/whitespace/Makefile.am b/kbabel/datatools/whitespace/Makefile.am index eb3937fb..890d8dc1 100644 --- a/kbabel/datatools/whitespace/Makefile.am +++ b/kbabel/datatools/whitespace/Makefile.am @@ -6,7 +6,7 @@ kbabel_whitespacetool_la_LIBADD = $(LIB_TDEIO) ../../common/libkbabelcommon.la kde_module_LTLIBRARIES = kbabel_whitespacetool.la -kbabel_whitespacetool_la_SOURCES = main.cc +kbabel_whitespacetool_la_SOURCES = main.cpp kbabel_whitespacetool_la_LDFLAGS = $(all_libraries) -avoid-version -module -no-undefined diff --git a/kbabel/datatools/whitespace/main.cc b/kbabel/datatools/whitespace/main.cc deleted file mode 100644 index 06558211..00000000 --- a/kbabel/datatools/whitespace/main.cc +++ /dev/null @@ -1,144 +0,0 @@ -/* This file is part of KBabel - based Copyright (C) 1998, 1999 Torben Weis - 2002 Stanislav Visnovsky - 2003 Dwayne Bailey - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the TQt library by Trolltech AS, Norway (or with modified versions - of TQt that use the same license as TQt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - TQt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. - -*/ - -#include -#include "catalog.h" -#include "catalogitem.h" -#include "catalogsettings.h" -#include "main.h" - -#include -#include -#include -#include -#include -#include - -/*************************************************** - * - * Factory - * - ***************************************************/ - -K_EXPORT_COMPONENT_FACTORY( kbabel_whitespacetool, KGenericFactory ( "kbabeldatatool" ) ) - -using namespace KBabel; - -WhitespaceTool::WhitespaceTool( TQObject* parent, const char* name, const TQStringList & ) - : KDataTool( parent, name ), _cache_origin( 0 ), _equation("^[a-zA-Z0-9]+=") -{ - i18n("which check found errors","whitespace only translation"); -} - -bool WhitespaceTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) -{ - - if ( command != "validate" ) - { - kdDebug(KBABEL) << "Whitespace Tool only accepts the 'validate' command" << endl; - kdDebug(KBABEL) << " The command " << command << " is not accepted" << endl; - return false; - } - - // Check wether we can accept the data - if ( datatype != "CatalogItem" ) - { - kdDebug(KBABEL) << "Whitespace Tool only accept the CatalogItem datatype" << endl; - return false; - } - - if ( mimetype != "application/x-kbabel-catalogitem" ) - { - kdDebug(KBABEL) << "Whitespace Tool only accept the 'application/x-kbabel-catalogitem' mimetype" << endl; - return false; - } - - if( command == "validate" ) - { - - CatalogItem* item = (CatalogItem*)(data); - bool hasIdError = false; - bool hasStrError = false; - TQRegExp _whitespace("^\\s+$"); - TQStringList str, id; - - if(!item->isUntranslated()) { - if( _cache_origin != item->project() ) - { - _plurals = item->project()->miscSettings().singularPlural; - _cache_origin = item->project(); - } - - //Ensure KDE plural forms are in a StringList - //FIXME Eliminate context information and this could become a generic message splitter - if( item->pluralForm() == KDESpecific ) { - str = TQStringList::split( "\\n", item->msgstr().first(), true ); - id = TQStringList::split( "\\n", - item->msgid().first().replace( TQRegExp(_plurals), ""), true ); - } else { - str = item->msgstr(); - id = item->msgid(); - } - - //Strip equations - id.first().replace( TQRegExp(_equation), ""); - str.first().replace( TQRegExp(_equation), ""); - - //Ignore Messages with blank msgid components - for( TQStringList::Iterator it = id.begin() ; it != id.end() ; it++ ) { - TQString resultstring = (*it); - hasIdError = hasIdError || resultstring.contains(_whitespace); - } - if( hasIdError ) return true; - - //Check each TQString in the List is not whitespace - for( TQStringList::Iterator it = str.begin() ; it != str.end() ; it++ ) { - TQString resultstring = (*it); - hasStrError = hasStrError || resultstring.contains(_whitespace); - } - - } - - if(hasStrError) { - item->appendError( "whitespace translation" ); - return false; - } else { - item->removeError( "whitespace translation" ); - return true; - } - - } - return false; -} - -#include "main.moc" diff --git a/kbabel/datatools/whitespace/main.cpp b/kbabel/datatools/whitespace/main.cpp new file mode 100644 index 00000000..06558211 --- /dev/null +++ b/kbabel/datatools/whitespace/main.cpp @@ -0,0 +1,144 @@ +/* This file is part of KBabel + based Copyright (C) 1998, 1999 Torben Weis + 2002 Stanislav Visnovsky + 2003 Dwayne Bailey + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the TQt library by Trolltech AS, Norway (or with modified versions + of TQt that use the same license as TQt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + TQt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. + +*/ + +#include +#include "catalog.h" +#include "catalogitem.h" +#include "catalogsettings.h" +#include "main.h" + +#include +#include +#include +#include +#include +#include + +/*************************************************** + * + * Factory + * + ***************************************************/ + +K_EXPORT_COMPONENT_FACTORY( kbabel_whitespacetool, KGenericFactory ( "kbabeldatatool" ) ) + +using namespace KBabel; + +WhitespaceTool::WhitespaceTool( TQObject* parent, const char* name, const TQStringList & ) + : KDataTool( parent, name ), _cache_origin( 0 ), _equation("^[a-zA-Z0-9]+=") +{ + i18n("which check found errors","whitespace only translation"); +} + +bool WhitespaceTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) +{ + + if ( command != "validate" ) + { + kdDebug(KBABEL) << "Whitespace Tool only accepts the 'validate' command" << endl; + kdDebug(KBABEL) << " The command " << command << " is not accepted" << endl; + return false; + } + + // Check wether we can accept the data + if ( datatype != "CatalogItem" ) + { + kdDebug(KBABEL) << "Whitespace Tool only accept the CatalogItem datatype" << endl; + return false; + } + + if ( mimetype != "application/x-kbabel-catalogitem" ) + { + kdDebug(KBABEL) << "Whitespace Tool only accept the 'application/x-kbabel-catalogitem' mimetype" << endl; + return false; + } + + if( command == "validate" ) + { + + CatalogItem* item = (CatalogItem*)(data); + bool hasIdError = false; + bool hasStrError = false; + TQRegExp _whitespace("^\\s+$"); + TQStringList str, id; + + if(!item->isUntranslated()) { + if( _cache_origin != item->project() ) + { + _plurals = item->project()->miscSettings().singularPlural; + _cache_origin = item->project(); + } + + //Ensure KDE plural forms are in a StringList + //FIXME Eliminate context information and this could become a generic message splitter + if( item->pluralForm() == KDESpecific ) { + str = TQStringList::split( "\\n", item->msgstr().first(), true ); + id = TQStringList::split( "\\n", + item->msgid().first().replace( TQRegExp(_plurals), ""), true ); + } else { + str = item->msgstr(); + id = item->msgid(); + } + + //Strip equations + id.first().replace( TQRegExp(_equation), ""); + str.first().replace( TQRegExp(_equation), ""); + + //Ignore Messages with blank msgid components + for( TQStringList::Iterator it = id.begin() ; it != id.end() ; it++ ) { + TQString resultstring = (*it); + hasIdError = hasIdError || resultstring.contains(_whitespace); + } + if( hasIdError ) return true; + + //Check each TQString in the List is not whitespace + for( TQStringList::Iterator it = str.begin() ; it != str.end() ; it++ ) { + TQString resultstring = (*it); + hasStrError = hasStrError || resultstring.contains(_whitespace); + } + + } + + if(hasStrError) { + item->appendError( "whitespace translation" ); + return false; + } else { + item->removeError( "whitespace translation" ); + return true; + } + + } + return false; +} + +#include "main.moc" diff --git a/kbabel/datatools/xml/CMakeLists.txt b/kbabel/datatools/xml/CMakeLists.txt index 0fa9676d..ea47a588 100644 --- a/kbabel/datatools/xml/CMakeLists.txt +++ b/kbabel/datatools/xml/CMakeLists.txt @@ -34,7 +34,7 @@ tde_create_translated_desktop( ##### kbabel_xmltool (module) ################### tde_add_kpart( kbabel_xmltool AUTOMOC - SOURCES main.cc + SOURCES main.cpp LINK kbabelcommon-shared DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/kbabel/datatools/xml/Makefile.am b/kbabel/datatools/xml/Makefile.am index 3f116709..2fd2c28d 100644 --- a/kbabel/datatools/xml/Makefile.am +++ b/kbabel/datatools/xml/Makefile.am @@ -6,7 +6,7 @@ kbabel_xmltool_la_LIBADD = $(LIB_TDEIO) ../../common/libkbabelcommon.la kde_module_LTLIBRARIES = kbabel_xmltool.la -kbabel_xmltool_la_SOURCES = main.cc +kbabel_xmltool_la_SOURCES = main.cpp kbabel_xmltool_la_LDFLAGS = $(all_libraries) -avoid-version -module -no-undefined diff --git a/kbabel/datatools/xml/main.cc b/kbabel/datatools/xml/main.cc deleted file mode 100644 index 59342c0d..00000000 --- a/kbabel/datatools/xml/main.cc +++ /dev/null @@ -1,206 +0,0 @@ -/* This file is part of KBabel - based Copyright (C) 1998, 1999 Torben Weis - 2002-2003 Stanislav Visnovsky - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - - In addition, as a special exception, the copyright holders give - permission to link the code of this program with any edition of - the TQt library by Trolltech AS, Norway (or with modified versions - of TQt that use the same license as TQt), and distribute linked - combinations including the two. You must obey the GNU General - Public License in all respects for all of the code used other than - TQt. If you modify this file, you may extend this exception to - your version of the file, but you are not obligated to do so. If - you do not wish to do so, delete this exception statement from - your version. - -*/ - -#include -#include "catalogitem.h" -#include "catalogsettings.h" -#include "main.h" - -#include - -#include -#include -#include -#include -#include -#include - -/*************************************************** - * - * Factory - * - ***************************************************/ - -K_EXPORT_COMPONENT_FACTORY( kbabel_xmltool, KGenericFactory ( "kbabeldatatool" ) ) - -using namespace KBabel; - -XMLTool::XMLTool( TQObject* parent, const char* name, const TQStringList & ) - : KDataTool( parent, name ), _cache_origin( 0 ) -{ - i18n( "what check found errors", "XML tags" ); -} - -bool XMLTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) -{ - if ( command != "validate" ) - { - kdDebug(KBABEL) << "XML Tool does only accept the command 'validate' and 'shortcut'" << endl; - kdDebug(KBABEL) << " The commands " << command << " is not accepted" << endl; - return FALSE; - } - - // Check wether we can accept the data - if ( datatype != "CatalogItem" ) - { - kdDebug(KBABEL) << "XML Tool only accepts datatype CatalogItem" << endl; - return FALSE; - } - - if ( mimetype != "application/x-kbabel-catalogitem" ) - { - kdDebug(KBABEL) << "XML Tool only accepts mimetype application/x-kbabel-catalogitem" << endl; - return FALSE; - } - - if( command == "validate" ) - { - CatalogItem* item = (CatalogItem*)(data); - - if( _cache_origin != item->project() ) - { - _context = item->project()->miscSettings().contextInfo; - _cache_origin = item->project(); - } - - uint correctnessLevel = 0; - TQString msgid = item->msgid().first(); - msgid.replace( "\\\"", "\"" ); // Change '\"' to '"' - msgid.replace( TQRegExp( "&(?![a-zA-Z0-9]+;)" ), "&" ); - msgid.replace( _context, "" ); - msgid.replace("\n",""); // delete newlines - - if( _levelCache.contains(msgid) ) - { - correctnessLevel = _levelCache[msgid]; - } - else - { - // identify the level of correctness - if( isFullyCompliant(msgid) ) - { - correctnessLevel = 0; - } - else if( isNonCaseCompliant(msgid) ) - { - correctnessLevel = 1; - } - else if( isNonCaseWithoutCommonCompliant(msgid) ) - { - correctnessLevel = 2; - } - else - { - correctnessLevel = 3; - } - - _levelCache[msgid] = correctnessLevel; - } - - bool hasError = false; - - if(!item->isUntranslated()) - { - TQStringList str = item->msgstr(true); - for( TQStringList::Iterator form = str.begin() ; form != str.end() ; form++ ) - { - TQString text=(*form); - text.replace( "\\\"", "\"" ); // Change '\"' to '"' - text.replace( TQRegExp( "&(?![a-zA-Z0-9]+;)" ), "&" ); - - // isNonCaseWithoutCommonCompliant can fail - // even though higher level checks works - // see case 2. - switch( correctnessLevel ) - { - case 0: hasError = !isFullyCompliant(text); break; - case 1: hasError = !isNonCaseCompliant(text); break; - case 2: hasError = !isNonCaseWithoutCommonCompliant(text); - if (hasError) - { - hasError = !isNonCaseCompliant(text) || - !isFullyCompliant(text); - } - break; - case 3: hasError = false; break; // the original is broken - default: kdWarning() << "No compliance level, this should not happen" << endl; - } - } - } - - if(hasError) - { - item->appendError( "XML tags" ); - } - else - { - item->removeError( "XML tags" ); - } - - return !hasError; - } - return FALSE; -} - -bool XMLTool::isFullyCompliant( const TQString& text) -{ - TQDomDocument doc; - return doc.setContent("" + text + "" ); -} - -bool XMLTool::isNonCaseCompliant( const TQString& text) -{ - TQDomDocument doc; - TQString test = text.lower(); - return doc.setContent("" + test + "" ); -} - -bool XMLTool::isNonCaseWithoutCommonCompliant( const TQString& text) -{ - TQDomDocument doc; - TQString test = text.lower(); - TQRegExp rx( "(
)|(
)|(

)||(<\\w+@(\\w+.)*\\w+>)" ); - test.replace( rx, "" ); - - TQString a; - do - { - a = test; - test.replace( TQRegExp("<[^_:A-Za-z/]"), "" ); - } while( a!=test); - - test.replace( TQRegExp("<$"), "" ); - - return doc.setContent("" + test + "" ); -} - -#include "main.moc" diff --git a/kbabel/datatools/xml/main.cpp b/kbabel/datatools/xml/main.cpp new file mode 100644 index 00000000..59342c0d --- /dev/null +++ b/kbabel/datatools/xml/main.cpp @@ -0,0 +1,206 @@ +/* This file is part of KBabel + based Copyright (C) 1998, 1999 Torben Weis + 2002-2003 Stanislav Visnovsky + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the TQt library by Trolltech AS, Norway (or with modified versions + of TQt that use the same license as TQt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + TQt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. + +*/ + +#include +#include "catalogitem.h" +#include "catalogsettings.h" +#include "main.h" + +#include + +#include +#include +#include +#include +#include +#include + +/*************************************************** + * + * Factory + * + ***************************************************/ + +K_EXPORT_COMPONENT_FACTORY( kbabel_xmltool, KGenericFactory ( "kbabeldatatool" ) ) + +using namespace KBabel; + +XMLTool::XMLTool( TQObject* parent, const char* name, const TQStringList & ) + : KDataTool( parent, name ), _cache_origin( 0 ) +{ + i18n( "what check found errors", "XML tags" ); +} + +bool XMLTool::run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype ) +{ + if ( command != "validate" ) + { + kdDebug(KBABEL) << "XML Tool does only accept the command 'validate' and 'shortcut'" << endl; + kdDebug(KBABEL) << " The commands " << command << " is not accepted" << endl; + return FALSE; + } + + // Check wether we can accept the data + if ( datatype != "CatalogItem" ) + { + kdDebug(KBABEL) << "XML Tool only accepts datatype CatalogItem" << endl; + return FALSE; + } + + if ( mimetype != "application/x-kbabel-catalogitem" ) + { + kdDebug(KBABEL) << "XML Tool only accepts mimetype application/x-kbabel-catalogitem" << endl; + return FALSE; + } + + if( command == "validate" ) + { + CatalogItem* item = (CatalogItem*)(data); + + if( _cache_origin != item->project() ) + { + _context = item->project()->miscSettings().contextInfo; + _cache_origin = item->project(); + } + + uint correctnessLevel = 0; + TQString msgid = item->msgid().first(); + msgid.replace( "\\\"", "\"" ); // Change '\"' to '"' + msgid.replace( TQRegExp( "&(?![a-zA-Z0-9]+;)" ), "&" ); + msgid.replace( _context, "" ); + msgid.replace("\n",""); // delete newlines + + if( _levelCache.contains(msgid) ) + { + correctnessLevel = _levelCache[msgid]; + } + else + { + // identify the level of correctness + if( isFullyCompliant(msgid) ) + { + correctnessLevel = 0; + } + else if( isNonCaseCompliant(msgid) ) + { + correctnessLevel = 1; + } + else if( isNonCaseWithoutCommonCompliant(msgid) ) + { + correctnessLevel = 2; + } + else + { + correctnessLevel = 3; + } + + _levelCache[msgid] = correctnessLevel; + } + + bool hasError = false; + + if(!item->isUntranslated()) + { + TQStringList str = item->msgstr(true); + for( TQStringList::Iterator form = str.begin() ; form != str.end() ; form++ ) + { + TQString text=(*form); + text.replace( "\\\"", "\"" ); // Change '\"' to '"' + text.replace( TQRegExp( "&(?![a-zA-Z0-9]+;)" ), "&" ); + + // isNonCaseWithoutCommonCompliant can fail + // even though higher level checks works + // see case 2. + switch( correctnessLevel ) + { + case 0: hasError = !isFullyCompliant(text); break; + case 1: hasError = !isNonCaseCompliant(text); break; + case 2: hasError = !isNonCaseWithoutCommonCompliant(text); + if (hasError) + { + hasError = !isNonCaseCompliant(text) || + !isFullyCompliant(text); + } + break; + case 3: hasError = false; break; // the original is broken + default: kdWarning() << "No compliance level, this should not happen" << endl; + } + } + } + + if(hasError) + { + item->appendError( "XML tags" ); + } + else + { + item->removeError( "XML tags" ); + } + + return !hasError; + } + return FALSE; +} + +bool XMLTool::isFullyCompliant( const TQString& text) +{ + TQDomDocument doc; + return doc.setContent("" + text + "" ); +} + +bool XMLTool::isNonCaseCompliant( const TQString& text) +{ + TQDomDocument doc; + TQString test = text.lower(); + return doc.setContent("" + test + "" ); +} + +bool XMLTool::isNonCaseWithoutCommonCompliant( const TQString& text) +{ + TQDomDocument doc; + TQString test = text.lower(); + TQRegExp rx( "(
)|(


)|(

)||(<\\w+@(\\w+.)*\\w+>)" ); + test.replace( rx, "" ); + + TQString a; + do + { + a = test; + test.replace( TQRegExp("<[^_:A-Za-z/]"), "" ); + } while( a!=test); + + test.replace( TQRegExp("<$"), "" ); + + return doc.setContent("" + test + "" ); +} + +#include "main.moc" diff --git a/kbabel/kbabeldict/modules/dbsearchengine/makemsgdb.C b/kbabel/kbabeldict/modules/dbsearchengine/makemsgdb.C deleted file mode 100644 index a83d947b..00000000 --- a/kbabel/kbabeldict/modules/dbsearchengine/makemsgdb.C +++ /dev/null @@ -1,327 +0,0 @@ -#include -#include -#include -#include -#include - -void removechar (char *s, int c) -{ - int i, l; - l = strlen (s); - if ((c >= l) || (c < 0)) - return; - for (i = c; i < l; i++) - s[i] = s[i + 1]; -} -void removeallc (char *s, char c) -{ - char *pos; - while ((pos = strchr (s, c)) != 0) - removechar (s, (long int) pos - (long int) s); - -} - -void normalizestr (char *s) -{ - char *pos; - while ((pos = strstr (s, "#~")) != 0) { - removechar (s, (long int) pos - (long int) s); - removechar (s, (long int) pos - (long int) s); - } - while (strchr (s, ' ') == s) - removechar (s, 0); -} - -void freadline(char *buff,FILE *f) -{ -char c; -while ((fread(&c,1,1,f)==1) && (c!='\n')) - { - *buff=c; - buff++; - } -*buff=0; - -} - -int makePoDb(const char* sourceName,const char* outputName) -{ -static bool open = false; -int m=0,n=0,h=0; -GDBM_FILE db; -datum key,value; -char *s,a[20000],b[2000],k[2000],v[2000]; -int i,*np,nmax=0,co=-1,oldref[2000]; -long int tim; -FILE *mlf; -bool nextIsFuzzy; -bool isAMsgId=true; -/* char keystring[1000],valuestring[1000]; */ - -/*Read headers, refnum end other info */ -db = gdbm_open((char *)outputName,1024,GDBM_READER,0666,0); -mlf = fopen(sourceName,"r"); -if(strrchr(sourceName,'/')!=0) -sourceName=strrchr(sourceName,'/')+1; - -if(!(db==0)) - { - printf("ciao\n"); - key.dptr=a; - strcpy(a,"__@REFNUM__"); - key.dsize=strlen(a)+1; - value = gdbm_fetch(db,key); - np=(int*)value.dptr; - nmax=*np; - for(i=0;i",oldref[co],*re); - if(oldref[r]==*re) - { - modif=true; - // fprintf(stderr,"Yes\n"); - *re=(nmax-1); - } //else fprintf(stderr,"No\n"); - } - // fprintf(stderr,"qui\n"); - if(!modif) - md=nr; - // fprintf(stderr,"modif %s\n",modif ? "true":"false"); - } - } - - } - - if(!exist) - { - int oldlen=(long int)os-(long int)oldvalue.dptr-4; - memcpy(a+4,oldvalue.dptr+4,oldlen); -// fprintf(stderr,"***!exist Old len is %d+4 1st str is %s\n",oldlen,a+4); - v++; - t=(int *)a; - *t=v; - // fprintf(stderr,"b=%s",b); - strcpy(a+4+oldlen,b); - re=(int *)(a+4+oldlen+strlen(b)+1); - *re=1; - re++; - *re=nmax-1; - //fprintf(stderr,"a+4=%s a+4+oldlen=%s",a+4,a+4+oldlen); - value.dptr=a; - value.dsize=oldlen+strlen(b)+1+4+8; - gdbm_store(db,key,value,GDBM_REPLACE); - n++; - } else - { - if(!modif) - { -// fprintf(stderr,"grossa crisi %d\n",*md); -// fprintf(stderr,"Old num of ref \n"); - int oldlen1=(long int)(md)-(long int)(oldvalue.dptr)-4; - int oldlen2=(long int)(os)-(long int)(md)-4; //-4 because nr - memcpy(a+4,oldvalue.dptr+4,oldlen1); - memcpy(a+4+oldlen1+8,oldvalue.dptr+4+oldlen1+4,oldlen2); - re=(int *)(a+4+oldlen1); - *re=(*md )+1; - // *re++; - re++; - *re=nmax-1; - t=(int *)a; - *t=v; - value.dptr=a; - value.dsize=oldlen1+oldlen2+4+8; - gdbm_store(db,key,value,GDBM_REPLACE); - n++; - } - else //if (modif) - { - value.dptr=oldvalue.dptr; - value.dsize=oldvalue.dsize; - gdbm_store(db,key,value,GDBM_REPLACE); - } - } - - h++; - } else { - - m++; - } - } - } - - } - - - } - - fclose(mlf); - gdbm_close(db); - open=false; - printf("new Key in database %d\n old key found %d\n value added %d\n",m,h,n); - return m+n; -} - - - -main(int argc,char **argv) -{ -int i; -for(i=1;i +#include +#include +#include +#include + +void removechar (char *s, int c) +{ + int i, l; + l = strlen (s); + if ((c >= l) || (c < 0)) + return; + for (i = c; i < l; i++) + s[i] = s[i + 1]; +} +void removeallc (char *s, char c) +{ + char *pos; + while ((pos = strchr (s, c)) != 0) + removechar (s, (long int) pos - (long int) s); + +} + +void normalizestr (char *s) +{ + char *pos; + while ((pos = strstr (s, "#~")) != 0) { + removechar (s, (long int) pos - (long int) s); + removechar (s, (long int) pos - (long int) s); + } + while (strchr (s, ' ') == s) + removechar (s, 0); +} + +void freadline(char *buff,FILE *f) +{ +char c; +while ((fread(&c,1,1,f)==1) && (c!='\n')) + { + *buff=c; + buff++; + } +*buff=0; + +} + +int makePoDb(const char* sourceName,const char* outputName) +{ +static bool open = false; +int m=0,n=0,h=0; +GDBM_FILE db; +datum key,value; +char *s,a[20000],b[2000],k[2000],v[2000]; +int i,*np,nmax=0,co=-1,oldref[2000]; +long int tim; +FILE *mlf; +bool nextIsFuzzy; +bool isAMsgId=true; +/* char keystring[1000],valuestring[1000]; */ + +/*Read headers, refnum end other info */ +db = gdbm_open((char *)outputName,1024,GDBM_READER,0666,0); +mlf = fopen(sourceName,"r"); +if(strrchr(sourceName,'/')!=0) +sourceName=strrchr(sourceName,'/')+1; + +if(!(db==0)) + { + printf("ciao\n"); + key.dptr=a; + strcpy(a,"__@REFNUM__"); + key.dsize=strlen(a)+1; + value = gdbm_fetch(db,key); + np=(int*)value.dptr; + nmax=*np; + for(i=0;i",oldref[co],*re); + if(oldref[r]==*re) + { + modif=true; + // fprintf(stderr,"Yes\n"); + *re=(nmax-1); + } //else fprintf(stderr,"No\n"); + } + // fprintf(stderr,"qui\n"); + if(!modif) + md=nr; + // fprintf(stderr,"modif %s\n",modif ? "true":"false"); + } + } + + } + + if(!exist) + { + int oldlen=(long int)os-(long int)oldvalue.dptr-4; + memcpy(a+4,oldvalue.dptr+4,oldlen); +// fprintf(stderr,"***!exist Old len is %d+4 1st str is %s\n",oldlen,a+4); + v++; + t=(int *)a; + *t=v; + // fprintf(stderr,"b=%s",b); + strcpy(a+4+oldlen,b); + re=(int *)(a+4+oldlen+strlen(b)+1); + *re=1; + re++; + *re=nmax-1; + //fprintf(stderr,"a+4=%s a+4+oldlen=%s",a+4,a+4+oldlen); + value.dptr=a; + value.dsize=oldlen+strlen(b)+1+4+8; + gdbm_store(db,key,value,GDBM_REPLACE); + n++; + } else + { + if(!modif) + { +// fprintf(stderr,"grossa crisi %d\n",*md); +// fprintf(stderr,"Old num of ref \n"); + int oldlen1=(long int)(md)-(long int)(oldvalue.dptr)-4; + int oldlen2=(long int)(os)-(long int)(md)-4; //-4 because nr + memcpy(a+4,oldvalue.dptr+4,oldlen1); + memcpy(a+4+oldlen1+8,oldvalue.dptr+4+oldlen1+4,oldlen2); + re=(int *)(a+4+oldlen1); + *re=(*md )+1; + // *re++; + re++; + *re=nmax-1; + t=(int *)a; + *t=v; + value.dptr=a; + value.dsize=oldlen1+oldlen2+4+8; + gdbm_store(db,key,value,GDBM_REPLACE); + n++; + } + else //if (modif) + { + value.dptr=oldvalue.dptr; + value.dsize=oldvalue.dsize; + gdbm_store(db,key,value,GDBM_REPLACE); + } + } + + h++; + } else { + + m++; + } + } + } + + } + + + } + + fclose(mlf); + gdbm_close(db); + open=false; + printf("new Key in database %d\n old key found %d\n value added %d\n",m,h,n); + return m+n; +} + + + +main(int argc,char **argv) +{ +int i; +for(i=1;i "GettextLexer.cpp"$ */ -#include "GettextLexer.hpp" -#include "antlr/CharBuffer.hpp" -#include "antlr/TokenStreamException.hpp" -#include "antlr/TokenStreamIOException.hpp" -#include "antlr/TokenStreamRecognitionException.hpp" -#include "antlr/CharStreamException.hpp" -#include "antlr/CharStreamIOException.hpp" -#include "antlr/NoViableAltForCharException.hpp" +#include "GettextLexer.h" +#include "antlr/CharBuffer.h" +#include "antlr/TokenStreamException.h" +#include "antlr/TokenStreamIOException.h" +#include "antlr/TokenStreamRecognitionException.h" +#include "antlr/CharStreamException.h" +#include "antlr/CharStreamIOException.h" +#include "antlr/NoViableAltForCharException.h" #line 1 "gettext.g" diff --git a/poxml/GettextLexer.h b/poxml/GettextLexer.h new file mode 100644 index 00000000..22634ddc --- /dev/null +++ b/poxml/GettextLexer.h @@ -0,0 +1,47 @@ +#ifndef INC_GettextLexer_hpp_ +#define INC_GettextLexer_hpp_ + +#line 2 "gettext.g" + +#include +using namespace std; +#include "parser.h" + +#line 11 "GettextLexer.h" +#include "antlr/config.h" +/* $ANTLR 2.7.1: "gettext.g" -> "GettextLexer.h"$ */ +#include "antlr/CommonToken.h" +#include "antlr/InputBuffer.h" +#include "antlr/BitSet.h" +#include "GettextParserTokenTypes.h" +#include "antlr/CharScanner.h" +class GettextLexer : public ANTLR_USE_NAMESPACE(antlr)CharScanner, public GettextParserTokenTypes + { +#line 1 "gettext.g" +#line 22 "GettextLexer.h" +private: + void initLiterals(); +public: + bool getCaseSensitiveLiterals() const; +public: + GettextLexer(ANTLR_USE_NAMESPACE(std)istream& in); + GettextLexer(ANTLR_USE_NAMESPACE(antlr)InputBuffer& ib); + GettextLexer(const ANTLR_USE_NAMESPACE(antlr)LexerSharedInputState& state); + ANTLR_USE_NAMESPACE(antlr)RefToken nextToken(); + public: void mWS(bool _createToken); + public: void mL_BRACKET(bool _createToken); + public: void mR_BRACKET(bool _createToken); + public: void mT_INT(bool _createToken); + public: void mT_COMMENT(bool _createToken); + public: void mMSG_TAG(bool _createToken); + public: void mT_STRING(bool _createToken); + protected: void mESC(bool _createToken); +private: + + static const unsigned long _tokenSet_0_data_[]; + static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_0; + static const unsigned long _tokenSet_1_data_[]; + static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_1; +}; + +#endif /*INC_GettextLexer_hpp_*/ diff --git a/poxml/GettextLexer.hpp b/poxml/GettextLexer.hpp deleted file mode 100644 index 951ad423..00000000 --- a/poxml/GettextLexer.hpp +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef INC_GettextLexer_hpp_ -#define INC_GettextLexer_hpp_ - -#line 2 "gettext.g" - -#include -using namespace std; -#include "parser.h" - -#line 11 "GettextLexer.hpp" -#include "antlr/config.hpp" -/* $ANTLR 2.7.1: "gettext.g" -> "GettextLexer.hpp"$ */ -#include "antlr/CommonToken.hpp" -#include "antlr/InputBuffer.hpp" -#include "antlr/BitSet.hpp" -#include "GettextParserTokenTypes.hpp" -#include "antlr/CharScanner.hpp" -class GettextLexer : public ANTLR_USE_NAMESPACE(antlr)CharScanner, public GettextParserTokenTypes - { -#line 1 "gettext.g" -#line 22 "GettextLexer.hpp" -private: - void initLiterals(); -public: - bool getCaseSensitiveLiterals() const; -public: - GettextLexer(ANTLR_USE_NAMESPACE(std)istream& in); - GettextLexer(ANTLR_USE_NAMESPACE(antlr)InputBuffer& ib); - GettextLexer(const ANTLR_USE_NAMESPACE(antlr)LexerSharedInputState& state); - ANTLR_USE_NAMESPACE(antlr)RefToken nextToken(); - public: void mWS(bool _createToken); - public: void mL_BRACKET(bool _createToken); - public: void mR_BRACKET(bool _createToken); - public: void mT_INT(bool _createToken); - public: void mT_COMMENT(bool _createToken); - public: void mMSG_TAG(bool _createToken); - public: void mT_STRING(bool _createToken); - protected: void mESC(bool _createToken); -private: - - static const unsigned long _tokenSet_0_data_[]; - static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_0; - static const unsigned long _tokenSet_1_data_[]; - static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_1; -}; - -#endif /*INC_GettextLexer_hpp_*/ diff --git a/poxml/GettextParser.cpp b/poxml/GettextParser.cpp index fda1066a..7bcc74e9 100644 --- a/poxml/GettextParser.cpp +++ b/poxml/GettextParser.cpp @@ -1,14 +1,14 @@ /* $ANTLR 2.7.1: "gettext.g" -> "GettextParser.cpp"$ */ -#include "GettextParser.hpp" -#include "antlr/NoViableAltException.hpp" -#include "antlr/SemanticException.hpp" +#include "GettextParser.h" +#include "antlr/NoViableAltException.h" +#include "antlr/SemanticException.h" #line 12 "gettext.g" #include -#include "GettextLexer.hpp" -#include "GettextParser.hpp" -#include "antlr/AST.hpp" -#include "antlr/CommonAST.hpp" +#include "GettextLexer.h" +#include "GettextParser.h" +#include "antlr/AST.h" +#include "antlr/CommonAST.h" /* int main() diff --git a/poxml/GettextParser.h b/poxml/GettextParser.h new file mode 100644 index 00000000..6d48b8a3 --- /dev/null +++ b/poxml/GettextParser.h @@ -0,0 +1,53 @@ +#ifndef INC_GettextParser_hpp_ +#define INC_GettextParser_hpp_ + +#line 2 "gettext.g" + +#include +using namespace std; +#include "parser.h" + +#line 11 "GettextParser.h" +#include "antlr/config.h" +/* $ANTLR 2.7.1: "gettext.g" -> "GettextParser.h"$ */ +#include "antlr/TokenStream.h" +#include "antlr/TokenBuffer.h" +#include "GettextParserTokenTypes.h" +#include "antlr/LLkParser.h" + +class GettextParser : public ANTLR_USE_NAMESPACE(antlr)LLkParser, public GettextParserTokenTypes + { +#line 1 "gettext.g" +#line 22 "GettextParser.h" +protected: + GettextParser(ANTLR_USE_NAMESPACE(antlr)TokenBuffer& tokenBuf, int k); +public: + GettextParser(ANTLR_USE_NAMESPACE(antlr)TokenBuffer& tokenBuf); +protected: + GettextParser(ANTLR_USE_NAMESPACE(antlr)TokenStream& lexer, int k); +public: + GettextParser(ANTLR_USE_NAMESPACE(antlr)TokenStream& lexer); + GettextParser(const ANTLR_USE_NAMESPACE(antlr)ParserSharedInputState& state); + public: MsgList file(); + public: string comment(); + public: MsgBlock file_block(); + public: string msgid(); + public: string msgstr(); + public: string msgid_plural(); + public: string msgstr_plural(); +private: + static const char* _tokenNames[]; + + static const unsigned long _tokenSet_0_data_[]; + static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_0; + static const unsigned long _tokenSet_1_data_[]; + static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_1; + static const unsigned long _tokenSet_2_data_[]; + static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_2; + static const unsigned long _tokenSet_3_data_[]; + static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_3; + static const unsigned long _tokenSet_4_data_[]; + static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_4; +}; + +#endif /*INC_GettextParser_hpp_*/ diff --git a/poxml/GettextParser.hpp b/poxml/GettextParser.hpp deleted file mode 100644 index 46b2b137..00000000 --- a/poxml/GettextParser.hpp +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef INC_GettextParser_hpp_ -#define INC_GettextParser_hpp_ - -#line 2 "gettext.g" - -#include -using namespace std; -#include "parser.h" - -#line 11 "GettextParser.hpp" -#include "antlr/config.hpp" -/* $ANTLR 2.7.1: "gettext.g" -> "GettextParser.hpp"$ */ -#include "antlr/TokenStream.hpp" -#include "antlr/TokenBuffer.hpp" -#include "GettextParserTokenTypes.hpp" -#include "antlr/LLkParser.hpp" - -class GettextParser : public ANTLR_USE_NAMESPACE(antlr)LLkParser, public GettextParserTokenTypes - { -#line 1 "gettext.g" -#line 22 "GettextParser.hpp" -protected: - GettextParser(ANTLR_USE_NAMESPACE(antlr)TokenBuffer& tokenBuf, int k); -public: - GettextParser(ANTLR_USE_NAMESPACE(antlr)TokenBuffer& tokenBuf); -protected: - GettextParser(ANTLR_USE_NAMESPACE(antlr)TokenStream& lexer, int k); -public: - GettextParser(ANTLR_USE_NAMESPACE(antlr)TokenStream& lexer); - GettextParser(const ANTLR_USE_NAMESPACE(antlr)ParserSharedInputState& state); - public: MsgList file(); - public: string comment(); - public: MsgBlock file_block(); - public: string msgid(); - public: string msgstr(); - public: string msgid_plural(); - public: string msgstr_plural(); -private: - static const char* _tokenNames[]; - - static const unsigned long _tokenSet_0_data_[]; - static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_0; - static const unsigned long _tokenSet_1_data_[]; - static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_1; - static const unsigned long _tokenSet_2_data_[]; - static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_2; - static const unsigned long _tokenSet_3_data_[]; - static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_3; - static const unsigned long _tokenSet_4_data_[]; - static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_4; -}; - -#endif /*INC_GettextParser_hpp_*/ diff --git a/poxml/GettextParserTokenTypes.h b/poxml/GettextParserTokenTypes.h new file mode 100644 index 00000000..d6107c3d --- /dev/null +++ b/poxml/GettextParserTokenTypes.h @@ -0,0 +1,22 @@ +#ifndef INC_GettextParserTokenTypes_hpp_ +#define INC_GettextParserTokenTypes_hpp_ + +/* $ANTLR 2.7.1: "gettext.g" -> "GettextParserTokenTypes.h"$ */ +struct GettextParserTokenTypes { + enum { + EOF_ = 1, + T_MSGID = 4, + T_COMMENT = 5, + T_STRING = 6, + T_MSGID_PLURAL = 7, + T_MSGSTR = 8, + L_BRACKET = 9, + T_INT = 10, + R_BRACKET = 11, + WS = 12, + MSG_TAG = 13, + ESC = 14, + NULL_TREE_LOOKAHEAD = 3 + }; +}; +#endif /*INC_GettextParserTokenTypes_hpp_*/ diff --git a/poxml/GettextParserTokenTypes.hpp b/poxml/GettextParserTokenTypes.hpp deleted file mode 100644 index 05fd7408..00000000 --- a/poxml/GettextParserTokenTypes.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef INC_GettextParserTokenTypes_hpp_ -#define INC_GettextParserTokenTypes_hpp_ - -/* $ANTLR 2.7.1: "gettext.g" -> "GettextParserTokenTypes.hpp"$ */ -struct GettextParserTokenTypes { - enum { - EOF_ = 1, - T_MSGID = 4, - T_COMMENT = 5, - T_STRING = 6, - T_MSGID_PLURAL = 7, - T_MSGSTR = 8, - L_BRACKET = 9, - T_INT = 10, - R_BRACKET = 11, - WS = 12, - MSG_TAG = 13, - ESC = 14, - NULL_TREE_LOOKAHEAD = 3 - }; -}; -#endif /*INC_GettextParserTokenTypes_hpp_*/ diff --git a/poxml/antlr/README b/poxml/antlr/README index 6ca0913b..1f6d902d 100644 --- a/poxml/antlr/README +++ b/poxml/antlr/README @@ -64,7 +64,7 @@ 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 +Also in the antlr subdirectory there's a file config.h. 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! diff --git a/poxml/antlr/TODO b/poxml/antlr/TODO index 51d104c3..0b97e6e5 100644 --- a/poxml/antlr/TODO +++ b/poxml/antlr/TODO @@ -10,7 +10,7 @@ * On Thu, Sep 21, 2000 at 12:33:48AM -0700, John Lambert wrote: > 1) The literal EOF is not defined and causes the define of EOF_CHAR in - > CharScanner.hpp to fail. + > CharScanner.h to fail. ANTLR with STL Port. Changing the EOF define to char_traits::eof() breaks things for gcc-2.95.2. Fix this in next release portably. diff --git a/poxml/antlr/antlr/ANTLRException.h b/poxml/antlr/antlr/ANTLRException.h new file mode 100644 index 00000000..7f8415e5 --- /dev/null +++ b/poxml/antlr/antlr/ANTLRException.h @@ -0,0 +1,60 @@ +#ifndef INC_ANTLRException_hpp__ +#define INC_ANTLRException_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +#include "antlr/config.h" +#include +#include + +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/ANTLRException.hpp b/poxml/antlr/antlr/ANTLRException.hpp deleted file mode 100644 index efbe0d7f..00000000 --- a/poxml/antlr/antlr/ANTLRException.hpp +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef INC_ANTLRException_hpp__ -#define INC_ANTLRException_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -#include "antlr/config.hpp" -#include -#include - -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.h b/poxml/antlr/antlr/AST.h new file mode 100644 index 00000000..c8610fdd --- /dev/null +++ b/poxml/antlr/antlr/AST.h @@ -0,0 +1,108 @@ +#ifndef INC_AST_hpp__ +#define INC_AST_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +#include "antlr/config.h" +#include "antlr/ASTRefCount.h" +#include "antlr/Token.h" +#include +#include + +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 findAll(RefAST t)=0; + virtual ANTLR_USE_NAMESPACE(std)vector 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/AST.hpp b/poxml/antlr/antlr/AST.hpp deleted file mode 100644 index a36ffd15..00000000 --- a/poxml/antlr/antlr/AST.hpp +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef INC_AST_hpp__ -#define INC_AST_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -#include "antlr/config.hpp" -#include "antlr/ASTRefCount.hpp" -#include "antlr/Token.hpp" -#include -#include - -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 findAll(RefAST t)=0; - virtual ANTLR_USE_NAMESPACE(std)vector 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.h b/poxml/antlr/antlr/ASTArray.h new file mode 100644 index 00000000..9e7fc51d --- /dev/null +++ b/poxml/antlr/antlr/ASTArray.h @@ -0,0 +1,63 @@ +#ifndef INC_ASTArray_hpp__ +#define INC_ASTArray_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +#include "antlr/config.h" +#include "antlr/AST.h" + +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 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/ASTArray.hpp b/poxml/antlr/antlr/ASTArray.hpp deleted file mode 100644 index 5203acf0..00000000 --- a/poxml/antlr/antlr/ASTArray.hpp +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef INC_ASTArray_hpp__ -#define INC_ASTArray_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -#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 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.h b/poxml/antlr/antlr/ASTFactory.h new file mode 100644 index 00000000..72cc08b1 --- /dev/null +++ b/poxml/antlr/antlr/ASTFactory.h @@ -0,0 +1,113 @@ +#ifndef INC_ASTFactory_hpp__ +#define INC_ASTFactory_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +#include "antlr/config.h" +#include "antlr/AST.h" +#include "antlr/ASTArray.h" +#include "antlr/ASTPair.h" + +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 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/ASTFactory.hpp b/poxml/antlr/antlr/ASTFactory.hpp deleted file mode 100644 index 584cee6d..00000000 --- a/poxml/antlr/antlr/ASTFactory.hpp +++ /dev/null @@ -1,113 +0,0 @@ -#ifndef INC_ASTFactory_hpp__ -#define INC_ASTFactory_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -#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 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.h b/poxml/antlr/antlr/ASTNULLType.h new file mode 100644 index 00000000..f4e3b7a9 --- /dev/null +++ b/poxml/antlr/antlr/ASTNULLType.h @@ -0,0 +1,72 @@ +#ifndef INC_ASTNULLType_hpp__ +#define INC_ASTNULLType_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +#include "antlr/config.h" +#include "antlr/AST.h" + +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 findAll(RefAST tree) + {return ANTLR_USE_NAMESPACE(std)vector();} + ANTLR_USE_NAMESPACE(std)vector findAllPartial(RefAST subtree) + {return ANTLR_USE_NAMESPACE(std)vector();} + RefAST getFirstChild() const { return this; } + RefAST getNextSibling() const { return this; } + ANTLR_USE_NAMESPACE(std)string getText() const { return ""; } + 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/ASTNULLType.hpp b/poxml/antlr/antlr/ASTNULLType.hpp deleted file mode 100644 index 8f3faa46..00000000 --- a/poxml/antlr/antlr/ASTNULLType.hpp +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef INC_ASTNULLType_hpp__ -#define INC_ASTNULLType_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -#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 findAll(RefAST tree) - {return ANTLR_USE_NAMESPACE(std)vector();} - ANTLR_USE_NAMESPACE(std)vector findAllPartial(RefAST subtree) - {return ANTLR_USE_NAMESPACE(std)vector();} - RefAST getFirstChild() const { return this; } - RefAST getNextSibling() const { return this; } - ANTLR_USE_NAMESPACE(std)string getText() const { return ""; } - 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.h b/poxml/antlr/antlr/ASTPair.h new file mode 100644 index 00000000..67756087 --- /dev/null +++ b/poxml/antlr/antlr/ASTPair.h @@ -0,0 +1,77 @@ +#ifndef INC_ASTPair_hpp__ +#define INC_ASTPair_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ +#include "antlr/config.h" +#include "antlr/AST.h" + +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/ASTPair.hpp b/poxml/antlr/antlr/ASTPair.hpp deleted file mode 100644 index eb7629ba..00000000 --- a/poxml/antlr/antlr/ASTPair.hpp +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef INC_ASTPair_hpp__ -#define INC_ASTPair_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ -#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.h b/poxml/antlr/antlr/ASTRefCount.h new file mode 100644 index 00000000..d181af5f --- /dev/null +++ b/poxml/antlr/antlr/ASTRefCount.h @@ -0,0 +1,104 @@ +#ifndef INC_ASTRefCount_hpp__ +# define INC_ASTRefCount_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +# include "antlr/config.h" + +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 ASTRefCount +{ +private: + ASTRef* ref; + +public: + ASTRefCount(const AST* p=0) + : ref(p ? ASTRef::getRef(p) : 0) + { + } + ASTRefCount(const ASTRefCount& other) + : ref(other.ref ? other.ref->increment() : 0) + { + } + ~ASTRefCount() + { + if (ref && ref->decrement()) delete ref; + } + ASTRefCount& operator=(AST* other) + { + ASTRef* tmp=ASTRef::getRef(other); + if (ref && ref->decrement()) delete ref; + ref=tmp; + return *this; + } + ASTRefCount& operator=(const ASTRefCount& 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(ref->ptr) : 0; } + T* operator->() const + { return ref ? static_cast(ref->ptr) : 0; } + T* get() const + { return ref ? static_cast(ref->ptr) : 0; } +}; + +typedef ASTRefCount RefAST; + +ANTLR_END_NAMESPACE + +#endif //INC_ASTRefCount_hpp__ diff --git a/poxml/antlr/antlr/ASTRefCount.hpp b/poxml/antlr/antlr/ASTRefCount.hpp deleted file mode 100644 index cb44128b..00000000 --- a/poxml/antlr/antlr/ASTRefCount.hpp +++ /dev/null @@ -1,104 +0,0 @@ -#ifndef INC_ASTRefCount_hpp__ -# define INC_ASTRefCount_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -# 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 ASTRefCount -{ -private: - ASTRef* ref; - -public: - ASTRefCount(const AST* p=0) - : ref(p ? ASTRef::getRef(p) : 0) - { - } - ASTRefCount(const ASTRefCount& other) - : ref(other.ref ? other.ref->increment() : 0) - { - } - ~ASTRefCount() - { - if (ref && ref->decrement()) delete ref; - } - ASTRefCount& operator=(AST* other) - { - ASTRef* tmp=ASTRef::getRef(other); - if (ref && ref->decrement()) delete ref; - ref=tmp; - return *this; - } - ASTRefCount& operator=(const ASTRefCount& 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(ref->ptr) : 0; } - T* operator->() const - { return ref ? static_cast(ref->ptr) : 0; } - T* get() const - { return ref ? static_cast(ref->ptr) : 0; } -}; - -typedef ASTRefCount RefAST; - -ANTLR_END_NAMESPACE - -#endif //INC_ASTRefCount_hpp__ diff --git a/poxml/antlr/antlr/BaseAST.h b/poxml/antlr/antlr/BaseAST.h new file mode 100644 index 00000000..5593f8e6 --- /dev/null +++ b/poxml/antlr/antlr/BaseAST.h @@ -0,0 +1,106 @@ +#ifndef INC_BaseAST_hpp__ +#define INC_BaseAST_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +#include "antlr/config.h" +#include "antlr/AST.h" + +ANTLR_BEGIN_NAMESPACE(antlr) + +class BaseAST; +typedef ASTRefCount 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 tokenNames; + +public: + virtual void addChild(RefAST c); + +private: + void doWorkForFindAll(ANTLR_USE_NAMESPACE(std)vector& 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 findAll(RefAST t); + virtual ANTLR_USE_NAMESPACE(std)vector 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& 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/BaseAST.hpp b/poxml/antlr/antlr/BaseAST.hpp deleted file mode 100644 index 7b93c1ef..00000000 --- a/poxml/antlr/antlr/BaseAST.hpp +++ /dev/null @@ -1,106 +0,0 @@ -#ifndef INC_BaseAST_hpp__ -#define INC_BaseAST_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -#include "antlr/config.hpp" -#include "antlr/AST.hpp" - -ANTLR_BEGIN_NAMESPACE(antlr) - -class BaseAST; -typedef ASTRefCount 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 tokenNames; - -public: - virtual void addChild(RefAST c); - -private: - void doWorkForFindAll(ANTLR_USE_NAMESPACE(std)vector& 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 findAll(RefAST t); - virtual ANTLR_USE_NAMESPACE(std)vector 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& 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.h b/poxml/antlr/antlr/BitSet.h new file mode 100644 index 00000000..e1223523 --- /dev/null +++ b/poxml/antlr/antlr/BitSet.h @@ -0,0 +1,50 @@ +#ifndef INC_BitSet_hpp__ +#define INC_BitSet_hpp__ + +#include "antlr/config.h" +#include +#include + +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, + * which should probably be changed to a wrapper around bitset, once + * bitset is more widely available. + * + * @author Terence Parr, MageLang Institute + * @author
Pete Wells + */ +class BitSet { +private: + ANTLR_USE_NAMESPACE(std)vector 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 toArray() const; +}; + +ANTLR_END_NAMESPACE + +#endif //INC_BitSet_hpp__ diff --git a/poxml/antlr/antlr/BitSet.hpp b/poxml/antlr/antlr/BitSet.hpp deleted file mode 100644 index 4eb400c7..00000000 --- a/poxml/antlr/antlr/BitSet.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef INC_BitSet_hpp__ -#define INC_BitSet_hpp__ - -#include "antlr/config.hpp" -#include -#include - -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, - * which should probably be changed to a wrapper around bitset, once - * bitset is more widely available. - * - * @author Terence Parr, MageLang Institute - * @author
Pete Wells - */ -class BitSet { -private: - ANTLR_USE_NAMESPACE(std)vector 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 toArray() const; -}; - -ANTLR_END_NAMESPACE - -#endif //INC_BitSet_hpp__ diff --git a/poxml/antlr/antlr/CharBuffer.h b/poxml/antlr/antlr/CharBuffer.h new file mode 100644 index 00000000..d67d6b24 --- /dev/null +++ b/poxml/antlr/antlr/CharBuffer.h @@ -0,0 +1,75 @@ +#ifndef INC_CharBuffer_hpp__ +#define INC_CharBuffer_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +/**A Stream of characters fed to the lexer from a InputStream that can + * be rewound via mark()/rewind() methods. + *

+ * 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. + *

+ * + * @see antlr.CharQueue + */ + +#include "antlr/config.h" +#include "antlr/InputBuffer.h" +#include + +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/CharBuffer.hpp b/poxml/antlr/antlr/CharBuffer.hpp deleted file mode 100644 index 45d467bb..00000000 --- a/poxml/antlr/antlr/CharBuffer.hpp +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef INC_CharBuffer_hpp__ -#define INC_CharBuffer_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -/**A Stream of characters fed to the lexer from a InputStream that can - * be rewound via mark()/rewind() methods. - *

- * 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. - *

- * - * @see antlr.CharQueue - */ - -#include "antlr/config.hpp" -#include "antlr/InputBuffer.hpp" -#include - -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.h b/poxml/antlr/antlr/CharScanner.h new file mode 100644 index 00000000..a2537964 --- /dev/null +++ b/poxml/antlr/antlr/CharScanner.h @@ -0,0 +1,266 @@ +#ifndef INC_CharScanner_hpp__ +#define INC_CharScanner_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * $Id$ + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +#include +#include "antlr/config.h" +#include "antlr/TokenStream.h" +#include "antlr/RecognitionException.h" +#include "antlr/InputBuffer.h" +#include "antlr/BitSet.h" +#include "antlr/LexerSharedInputState.h" +#include +#include + +ANTLR_BEGIN_NAMESPACE(antlr) + +class CharScanner; + +class CharScannerLiteralsLess : public ANTLR_USE_NAMESPACE(std)binary_function { +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 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/CharScanner.hpp b/poxml/antlr/antlr/CharScanner.hpp deleted file mode 100644 index 102d28e0..00000000 --- a/poxml/antlr/antlr/CharScanner.hpp +++ /dev/null @@ -1,266 +0,0 @@ -#ifndef INC_CharScanner_hpp__ -#define INC_CharScanner_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * $Id$ - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -#include -#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 -#include - -ANTLR_BEGIN_NAMESPACE(antlr) - -class CharScanner; - -class CharScannerLiteralsLess : public ANTLR_USE_NAMESPACE(std)binary_function { -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 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.h b/poxml/antlr/antlr/CharStreamException.h new file mode 100644 index 00000000..4febc19c --- /dev/null +++ b/poxml/antlr/antlr/CharStreamException.h @@ -0,0 +1,18 @@ +#ifndef INC_CharStreamException_hpp__ +#define INC_CharStreamException_hpp__ + +#include "antlr/config.h" +#include "antlr/ANTLRException.h" + +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/CharStreamException.hpp b/poxml/antlr/antlr/CharStreamException.hpp deleted file mode 100644 index 33f52061..00000000 --- a/poxml/antlr/antlr/CharStreamException.hpp +++ /dev/null @@ -1,18 +0,0 @@ -#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.h b/poxml/antlr/antlr/CharStreamIOException.h new file mode 100644 index 00000000..3b861065 --- /dev/null +++ b/poxml/antlr/antlr/CharStreamIOException.h @@ -0,0 +1,20 @@ +#ifndef INC_CharStreamIOException_hpp__ +#define INC_CharStreamIOException_hpp__ + +#include "antlr/config.h" +#include "antlr/CharStreamException.h" + +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/CharStreamIOException.hpp b/poxml/antlr/antlr/CharStreamIOException.hpp deleted file mode 100644 index 1a8b1d1e..00000000 --- a/poxml/antlr/antlr/CharStreamIOException.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#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.h b/poxml/antlr/antlr/CircularQueue.h new file mode 100644 index 00000000..1534719b --- /dev/null +++ b/poxml/antlr/antlr/CircularQueue.h @@ -0,0 +1,88 @@ +#ifndef INC_CircularQueue_hpp__ +#define INC_CircularQueue_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +#include "antlr/config.h" +#include + +ANTLR_BEGIN_NAMESPACE(antlr) + +// Resize every 5000 items +#define OFFSET_MAX_RESIZE 5000 + +template +class CircularQueue { +private: + ANTLR_USE_NAMESPACE(std)vector 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/CircularQueue.hpp b/poxml/antlr/antlr/CircularQueue.hpp deleted file mode 100644 index eadf8d42..00000000 --- a/poxml/antlr/antlr/CircularQueue.hpp +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef INC_CircularQueue_hpp__ -#define INC_CircularQueue_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -#include "antlr/config.hpp" -#include - -ANTLR_BEGIN_NAMESPACE(antlr) - -// Resize every 5000 items -#define OFFSET_MAX_RESIZE 5000 - -template -class CircularQueue { -private: - ANTLR_USE_NAMESPACE(std)vector 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.h b/poxml/antlr/antlr/CommonAST.h new file mode 100644 index 00000000..7e7658ef --- /dev/null +++ b/poxml/antlr/antlr/CommonAST.h @@ -0,0 +1,68 @@ +#ifndef INC_CommonAST_hpp__ +#define INC_CommonAST_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +#include "antlr/config.h" +#include "antlr/BaseAST.h" + +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 RefCommonAST; + +ANTLR_END_NAMESPACE + +#endif //INC_CommonAST_hpp__ diff --git a/poxml/antlr/antlr/CommonAST.hpp b/poxml/antlr/antlr/CommonAST.hpp deleted file mode 100644 index c7ab7313..00000000 --- a/poxml/antlr/antlr/CommonAST.hpp +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef INC_CommonAST_hpp__ -#define INC_CommonAST_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -#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 RefCommonAST; - -ANTLR_END_NAMESPACE - -#endif //INC_CommonAST_hpp__ diff --git a/poxml/antlr/antlr/CommonASTWithHiddenTokens.h b/poxml/antlr/antlr/CommonASTWithHiddenTokens.h new file mode 100644 index 00000000..6385a0fc --- /dev/null +++ b/poxml/antlr/antlr/CommonASTWithHiddenTokens.h @@ -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.h" +#include "antlr/CommonAST.h" + +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 RefCommonASTWithHiddenTokens; + +ANTLR_END_NAMESPACE + +#endif //INC_CommonASTWithHiddenTokens_hpp__ diff --git a/poxml/antlr/antlr/CommonASTWithHiddenTokens.hpp b/poxml/antlr/antlr/CommonASTWithHiddenTokens.hpp deleted file mode 100644 index 11e030e7..00000000 --- a/poxml/antlr/antlr/CommonASTWithHiddenTokens.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#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 RefCommonASTWithHiddenTokens; - -ANTLR_END_NAMESPACE - -#endif //INC_CommonASTWithHiddenTokens_hpp__ diff --git a/poxml/antlr/antlr/CommonHiddenStreamToken.h b/poxml/antlr/antlr/CommonHiddenStreamToken.h new file mode 100644 index 00000000..3ebb437f --- /dev/null +++ b/poxml/antlr/antlr/CommonHiddenStreamToken.h @@ -0,0 +1,30 @@ +#ifndef INC_CommonHiddenStreamToken_hpp__ +#define INC_CommonHiddenStreamToken_hpp__ + +#include "antlr/config.h" +#include "antlr/CommonToken.h" + +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/CommonHiddenStreamToken.hpp b/poxml/antlr/antlr/CommonHiddenStreamToken.hpp deleted file mode 100644 index 50ff2354..00000000 --- a/poxml/antlr/antlr/CommonHiddenStreamToken.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#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.h b/poxml/antlr/antlr/CommonToken.h new file mode 100644 index 00000000..19a4e868 --- /dev/null +++ b/poxml/antlr/antlr/CommonToken.h @@ -0,0 +1,77 @@ +#ifndef INC_CommonToken_hpp__ +#define INC_CommonToken_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +#include "antlr/config.h" +#include "antlr/Token.h" +#include + +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/CommonToken.hpp b/poxml/antlr/antlr/CommonToken.hpp deleted file mode 100644 index 669aa535..00000000 --- a/poxml/antlr/antlr/CommonToken.hpp +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef INC_CommonToken_hpp__ -#define INC_CommonToken_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -#include "antlr/config.hpp" -#include "antlr/Token.hpp" -#include - -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.h b/poxml/antlr/antlr/InputBuffer.h new file mode 100644 index 00000000..ae206ecd --- /dev/null +++ b/poxml/antlr/antlr/InputBuffer.h @@ -0,0 +1,158 @@ +#ifndef INC_InputBuffer_hpp__ +#define INC_InputBuffer_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +/**A Stream of characters fed to the lexer from a InputStream that can + * be rewound via mark()/rewind() methods. + *

+ * 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. + *

+ * + * @see antlr.CharQueue + */ + +#include "antlr/config.h" +#include "antlr/CircularQueue.h" +#include + +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 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/InputBuffer.hpp b/poxml/antlr/antlr/InputBuffer.hpp deleted file mode 100644 index 96e62191..00000000 --- a/poxml/antlr/antlr/InputBuffer.hpp +++ /dev/null @@ -1,158 +0,0 @@ -#ifndef INC_InputBuffer_hpp__ -#define INC_InputBuffer_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -/**A Stream of characters fed to the lexer from a InputStream that can - * be rewound via mark()/rewind() methods. - *

- * 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. - *

- * - * @see antlr.CharQueue - */ - -#include "antlr/config.hpp" -#include "antlr/CircularQueue.hpp" -#include - -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 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.h b/poxml/antlr/antlr/LLkParser.h new file mode 100644 index 00000000..2936ddfc --- /dev/null +++ b/poxml/antlr/antlr/LLkParser.h @@ -0,0 +1,82 @@ +#ifndef INC_LLkParser_hpp__ +#define INC_LLkParser_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +#include "antlr/config.h" +#include "antlr/Parser.h" + +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. + *

+ * 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/LLkParser.hpp b/poxml/antlr/antlr/LLkParser.hpp deleted file mode 100644 index 8b8db188..00000000 --- a/poxml/antlr/antlr/LLkParser.hpp +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef INC_LLkParser_hpp__ -#define INC_LLkParser_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -#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. - *

- * 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.h b/poxml/antlr/antlr/LexerSharedInputState.h new file mode 100644 index 00000000..b0792044 --- /dev/null +++ b/poxml/antlr/antlr/LexerSharedInputState.h @@ -0,0 +1,49 @@ +#ifndef INC_LexerSharedInputState_hpp__ +#define INC_LexerSharedInputState_hpp__ + +#include "antlr/config.h" +#include "antlr/InputBuffer.h" +#include "antlr/RefCount.h" +#include + +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 LexerSharedInputState; + +inline InputBuffer& LexerInputState::getInput() +{ + return *input; +} + +ANTLR_END_NAMESPACE + +#endif //INC_LexerSharedInputState_hpp__ diff --git a/poxml/antlr/antlr/LexerSharedInputState.hpp b/poxml/antlr/antlr/LexerSharedInputState.hpp deleted file mode 100644 index dba2a5f4..00000000 --- a/poxml/antlr/antlr/LexerSharedInputState.hpp +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef INC_LexerSharedInputState_hpp__ -#define INC_LexerSharedInputState_hpp__ - -#include "antlr/config.hpp" -#include "antlr/InputBuffer.hpp" -#include "antlr/RefCount.hpp" -#include - -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 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 index bafa1347..9150b0cb 100644 --- a/poxml/antlr/antlr/Makefile.am +++ b/poxml/antlr/antlr/Makefile.am @@ -1,45 +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 + ANTLRException.h \ + AST.h \ + ASTArray.h \ + ASTFactory.h \ + ASTNULLType.h \ + ASTPair.h \ + ASTRefCount.h \ + BaseAST.h \ + BitSet.h \ + CharBuffer.h \ + CharScanner.h \ + CharStreamException.h \ + CharStreamIOException.h \ + CircularQueue.h \ + CommonAST.h \ + CommonASTWithHiddenTokens.h \ + CommonHiddenStreamToken.h \ + CommonToken.h \ + InputBuffer.h \ + LLkParser.h \ + LexerSharedInputState.h \ + MismatchedCharException.h \ + MismatchedTokenException.h \ + NoViableAltException.h \ + NoViableAltForCharException.h \ + Parser.h \ + ParserSharedInputState.h \ + RecognitionException.h \ + RefCount.h \ + SemanticException.h \ + String.h \ + Token.h \ + TokenBuffer.h \ + TokenStream.h \ + TokenStreamBasicFilter.h \ + TokenStreamException.h \ + TokenStreamHiddenTokenFilter.h \ + TokenStreamIOException.h \ + TokenStreamRecognitionException.h \ + TokenStreamRetryException.h \ + TokenStreamSelector.h \ + TreeParser.h \ + TreeParserSharedInputState.h \ + config.h diff --git a/poxml/antlr/antlr/MismatchedCharException.h b/poxml/antlr/antlr/MismatchedCharException.h new file mode 100644 index 00000000..72e694af --- /dev/null +++ b/poxml/antlr/antlr/MismatchedCharException.h @@ -0,0 +1,127 @@ +#ifndef INC_MismatchedCharException_hpp__ +#define INC_MismatchedCharException_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +#include "antlr/config.h" +#include "antlr/RecognitionException.h" +#include "antlr/BitSet.h" +#include "antlr/CharScanner.h" + +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/MismatchedCharException.hpp b/poxml/antlr/antlr/MismatchedCharException.hpp deleted file mode 100644 index ea923a9d..00000000 --- a/poxml/antlr/antlr/MismatchedCharException.hpp +++ /dev/null @@ -1,127 +0,0 @@ -#ifndef INC_MismatchedCharException_hpp__ -#define INC_MismatchedCharException_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -#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.h b/poxml/antlr/antlr/MismatchedTokenException.h new file mode 100644 index 00000000..600086a5 --- /dev/null +++ b/poxml/antlr/antlr/MismatchedTokenException.h @@ -0,0 +1,167 @@ +#ifndef INC_MismatchedTokenException_hpp__ +#define INC_MismatchedTokenException_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +#include "antlr/config.h" +#include "antlr/RecognitionException.h" +#include "antlr/BitSet.h" +#include "antlr/Token.h" +#include "antlr/AST.h" +#include + +ANTLR_BEGIN_NAMESPACE(antlr) + +class MismatchedTokenException : public RecognitionException { +private: + // Token names array for formatting + ANTLR_USE_NAMESPACE(std)vector 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& tokenNames_, + RefAST node_, + int lower, + int upper_, + bool matchNot + ); + + // Expected token / not token + MismatchedTokenException( + const ANTLR_USE_NAMESPACE(std)vector& tokenNames_, + RefAST node_, + int expecting_, + bool matchNot + ); + + // Expected BitSet / not BitSet + MismatchedTokenException( + const ANTLR_USE_NAMESPACE(std)vector& tokenNames_, + RefAST node_, + BitSet set_, + bool matchNot + ); + + // Expected range / not range + MismatchedTokenException( + const ANTLR_USE_NAMESPACE(std)vector& 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& 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& 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/MismatchedTokenException.hpp b/poxml/antlr/antlr/MismatchedTokenException.hpp deleted file mode 100644 index ae4a82cd..00000000 --- a/poxml/antlr/antlr/MismatchedTokenException.hpp +++ /dev/null @@ -1,167 +0,0 @@ -#ifndef INC_MismatchedTokenException_hpp__ -#define INC_MismatchedTokenException_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -#include "antlr/config.hpp" -#include "antlr/RecognitionException.hpp" -#include "antlr/BitSet.hpp" -#include "antlr/Token.hpp" -#include "antlr/AST.hpp" -#include - -ANTLR_BEGIN_NAMESPACE(antlr) - -class MismatchedTokenException : public RecognitionException { -private: - // Token names array for formatting - ANTLR_USE_NAMESPACE(std)vector 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& tokenNames_, - RefAST node_, - int lower, - int upper_, - bool matchNot - ); - - // Expected token / not token - MismatchedTokenException( - const ANTLR_USE_NAMESPACE(std)vector& tokenNames_, - RefAST node_, - int expecting_, - bool matchNot - ); - - // Expected BitSet / not BitSet - MismatchedTokenException( - const ANTLR_USE_NAMESPACE(std)vector& tokenNames_, - RefAST node_, - BitSet set_, - bool matchNot - ); - - // Expected range / not range - MismatchedTokenException( - const ANTLR_USE_NAMESPACE(std)vector& 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& 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& 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.h b/poxml/antlr/antlr/NoViableAltException.h new file mode 100644 index 00000000..6bcc6cfb --- /dev/null +++ b/poxml/antlr/antlr/NoViableAltException.h @@ -0,0 +1,71 @@ +#ifndef INC_NoViableAltException_hpp__ +#define INC_NoViableAltException_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +#include "antlr/config.h" +#include "antlr/RecognitionException.h" +#include "antlr/Token.h" +#include "antlr/AST.h" + +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/NoViableAltException.hpp b/poxml/antlr/antlr/NoViableAltException.hpp deleted file mode 100644 index f85bcf96..00000000 --- a/poxml/antlr/antlr/NoViableAltException.hpp +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef INC_NoViableAltException_hpp__ -#define INC_NoViableAltException_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -#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.h b/poxml/antlr/antlr/NoViableAltForCharException.h new file mode 100644 index 00000000..cc5f6930 --- /dev/null +++ b/poxml/antlr/antlr/NoViableAltForCharException.h @@ -0,0 +1,64 @@ +#ifndef INC_NoViableAltForCharException_hpp__ +#define INC_NoViableAltForCharException_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Institute + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Institute + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +#include "antlr/config.h" +#include "antlr/RecognitionException.h" +#include "antlr/CharScanner.h" + +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/NoViableAltForCharException.hpp b/poxml/antlr/antlr/NoViableAltForCharException.hpp deleted file mode 100644 index 756e9c7f..00000000 --- a/poxml/antlr/antlr/NoViableAltForCharException.hpp +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef INC_NoViableAltForCharException_hpp__ -#define INC_NoViableAltForCharException_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Institute - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Institute - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -#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.h b/poxml/antlr/antlr/Parser.h new file mode 100644 index 00000000..fab69bfe --- /dev/null +++ b/poxml/antlr/antlr/Parser.h @@ -0,0 +1,213 @@ +#ifndef INC_Parser_hpp__ +#define INC_Parser_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +#include "antlr/config.h" +#include "antlr/BitSet.h" +#include "antlr/TokenBuffer.h" +#include "antlr/RecognitionException.h" +#include "antlr/ASTFactory.h" +#include "antlr/ParserSharedInputState.h" + +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... + * + *

+ * During guess 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 mark) before the try block. + * Guessing is started by: + *

    + *
  1. saving the lookahead cache. + *
  2. marking the current position in the TokenBuffer. + *
  3. increasing the guessing level. + *
+ * + * After guessing, the parser state is restored by: + *
    + *
  1. restoring the lookahead cache. + *
  2. rewinding the TokenBuffer. + *
  3. decreasing the guessing level. + *
+ * + * @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 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 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 t. + * 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* 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/Parser.hpp b/poxml/antlr/antlr/Parser.hpp deleted file mode 100644 index 767953d3..00000000 --- a/poxml/antlr/antlr/Parser.hpp +++ /dev/null @@ -1,213 +0,0 @@ -#ifndef INC_Parser_hpp__ -#define INC_Parser_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -#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... - * - *

- * During guess 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 mark) before the try block. - * Guessing is started by: - *

    - *
  1. saving the lookahead cache. - *
  2. marking the current position in the TokenBuffer. - *
  3. increasing the guessing level. - *
- * - * After guessing, the parser state is restored by: - *
    - *
  1. restoring the lookahead cache. - *
  2. rewinding the TokenBuffer. - *
  3. decreasing the guessing level. - *
- * - * @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 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 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 t. - * 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* 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.h b/poxml/antlr/antlr/ParserSharedInputState.h new file mode 100644 index 00000000..bcc45171 --- /dev/null +++ b/poxml/antlr/antlr/ParserSharedInputState.h @@ -0,0 +1,42 @@ +#ifndef INC_ParserSharedInputState_hpp__ +#define INC_ParserSharedInputState_hpp__ + +#include "antlr/config.h" +#include "antlr/TokenBuffer.h" +#include "antlr/RefCount.h" +#include + +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 ParserSharedInputState; + +ANTLR_END_NAMESPACE + +#endif //INC_ParserSharedInputState_hpp__ diff --git a/poxml/antlr/antlr/ParserSharedInputState.hpp b/poxml/antlr/antlr/ParserSharedInputState.hpp deleted file mode 100644 index b5599954..00000000 --- a/poxml/antlr/antlr/ParserSharedInputState.hpp +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef INC_ParserSharedInputState_hpp__ -#define INC_ParserSharedInputState_hpp__ - -#include "antlr/config.hpp" -#include "antlr/TokenBuffer.hpp" -#include "antlr/RefCount.hpp" -#include - -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 ParserSharedInputState; - -ANTLR_END_NAMESPACE - -#endif //INC_ParserSharedInputState_hpp__ diff --git a/poxml/antlr/antlr/RecognitionException.h b/poxml/antlr/antlr/RecognitionException.h new file mode 100644 index 00000000..b7102f17 --- /dev/null +++ b/poxml/antlr/antlr/RecognitionException.h @@ -0,0 +1,78 @@ +#ifndef INC_RecognitionException_hpp__ +#define INC_RecognitionException_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +#include "antlr/config.h" +#include "antlr/ANTLRException.h" + +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/RecognitionException.hpp b/poxml/antlr/antlr/RecognitionException.hpp deleted file mode 100644 index c6439111..00000000 --- a/poxml/antlr/antlr/RecognitionException.hpp +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef INC_RecognitionException_hpp__ -#define INC_RecognitionException_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -#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.h b/poxml/antlr/antlr/RefCount.h new file mode 100644 index 00000000..12e0bdf6 --- /dev/null +++ b/poxml/antlr/antlr/RefCount.h @@ -0,0 +1,87 @@ +#ifndef INC_RefCount_hpp__ +#define INC_RefCount_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +#include "antlr/config.h" + +ANTLR_BEGIN_NAMESPACE(antlr) + +template +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& other) + : ref(other.ref ? other.ref->increment() : 0) + { + } + ~RefCount() + { + if (ref && ref->decrement()) delete ref; + } + RefCount& operator=(const RefCount& 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/RefCount.hpp b/poxml/antlr/antlr/RefCount.hpp deleted file mode 100644 index 9306576b..00000000 --- a/poxml/antlr/antlr/RefCount.hpp +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef INC_RefCount_hpp__ -#define INC_RefCount_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -#include "antlr/config.hpp" - -ANTLR_BEGIN_NAMESPACE(antlr) - -template -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& other) - : ref(other.ref ? other.ref->increment() : 0) - { - } - ~RefCount() - { - if (ref && ref->decrement()) delete ref; - } - RefCount& operator=(const RefCount& 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.h b/poxml/antlr/antlr/SemanticException.h new file mode 100644 index 00000000..77eae0e4 --- /dev/null +++ b/poxml/antlr/antlr/SemanticException.h @@ -0,0 +1,52 @@ +#ifndef INC_SemanticException_hpp__ +#define INC_SemanticException_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +#include "antlr/config.h" +#include "antlr/RecognitionException.h" + +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/SemanticException.hpp b/poxml/antlr/antlr/SemanticException.hpp deleted file mode 100644 index 3f1a9447..00000000 --- a/poxml/antlr/antlr/SemanticException.hpp +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef INC_SemanticException_hpp__ -#define INC_SemanticException_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -#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.h b/poxml/antlr/antlr/String.h new file mode 100644 index 00000000..863454a7 --- /dev/null +++ b/poxml/antlr/antlr/String.h @@ -0,0 +1,47 @@ +#ifndef INC_String_hpp__ +#define INC_String_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +#include "antlr/config.h" +#include + +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/String.hpp b/poxml/antlr/antlr/String.hpp deleted file mode 100644 index 5fac82d6..00000000 --- a/poxml/antlr/antlr/String.hpp +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef INC_String_hpp__ -#define INC_String_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -#include "antlr/config.hpp" -#include - -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.h b/poxml/antlr/antlr/Token.h new file mode 100644 index 00000000..6951528d --- /dev/null +++ b/poxml/antlr/antlr/Token.h @@ -0,0 +1,106 @@ +#ifndef INC_Token_hpp__ +#define INC_Token_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +#include "antlr/config.h" +#include "antlr/RefCount.h" +#include + +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 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, ""); + + 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/Token.hpp b/poxml/antlr/antlr/Token.hpp deleted file mode 100644 index b85551c3..00000000 --- a/poxml/antlr/antlr/Token.hpp +++ /dev/null @@ -1,106 +0,0 @@ -#ifndef INC_Token_hpp__ -#define INC_Token_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -#include "antlr/config.hpp" -#include "antlr/RefCount.hpp" -#include - -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 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, ""); - - 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.h b/poxml/antlr/antlr/TokenBuffer.h new file mode 100644 index 00000000..2afcdfa6 --- /dev/null +++ b/poxml/antlr/antlr/TokenBuffer.h @@ -0,0 +1,141 @@ +#ifndef INC_TokenBuffer_hpp__ +#define INC_TokenBuffer_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +#include "antlr/config.h" +#include "antlr/TokenStream.h" +#include "antlr/CircularQueue.h" + +ANTLR_BEGIN_NAMESPACE(antlr) + +/**A Stream of Token objects fed to the parser from a TokenStream that can + * be rewound via mark()/rewind() methods. + *

+ * 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. + *

+ * + * @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 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/TokenBuffer.hpp b/poxml/antlr/antlr/TokenBuffer.hpp deleted file mode 100644 index b7c1b25f..00000000 --- a/poxml/antlr/antlr/TokenBuffer.hpp +++ /dev/null @@ -1,141 +0,0 @@ -#ifndef INC_TokenBuffer_hpp__ -#define INC_TokenBuffer_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -#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. - *

- * 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. - *

- * - * @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 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.h b/poxml/antlr/antlr/TokenStream.h new file mode 100644 index 00000000..5e09b307 --- /dev/null +++ b/poxml/antlr/antlr/TokenStream.h @@ -0,0 +1,54 @@ +#ifndef INC_TokenStream_hpp__ +#define INC_TokenStream_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +/**This interface allows any object to pretend it is a stream + * of tokens. + * @author Terence Parr, MageLang Institute + */ + +#include "antlr/config.h" +#include "antlr/Token.h" + +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/TokenStream.hpp b/poxml/antlr/antlr/TokenStream.hpp deleted file mode 100644 index e8436419..00000000 --- a/poxml/antlr/antlr/TokenStream.hpp +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef INC_TokenStream_hpp__ -#define INC_TokenStream_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -/**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.h b/poxml/antlr/antlr/TokenStreamBasicFilter.h new file mode 100644 index 00000000..af172bc8 --- /dev/null +++ b/poxml/antlr/antlr/TokenStreamBasicFilter.h @@ -0,0 +1,35 @@ +#ifndef INC_TokenStreamBasicFilter_hpp__ +#define INC_TokenStreamBasicFilter_hpp__ + +#include "antlr/config.h" +#include "antlr/BitSet.h" +#include "antlr/TokenStream.h" + +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/TokenStreamBasicFilter.hpp b/poxml/antlr/antlr/TokenStreamBasicFilter.hpp deleted file mode 100644 index 5438878b..00000000 --- a/poxml/antlr/antlr/TokenStreamBasicFilter.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#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.h b/poxml/antlr/antlr/TokenStreamException.h new file mode 100644 index 00000000..c923330d --- /dev/null +++ b/poxml/antlr/antlr/TokenStreamException.h @@ -0,0 +1,19 @@ +#ifndef INC_TokenStreamException_hpp__ +#define INC_TokenStreamException_hpp__ + +#include "antlr/config.h" +#include "antlr/ANTLRException.h" + +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/TokenStreamException.hpp b/poxml/antlr/antlr/TokenStreamException.hpp deleted file mode 100644 index 2dc96776..00000000 --- a/poxml/antlr/antlr/TokenStreamException.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#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.h b/poxml/antlr/antlr/TokenStreamHiddenTokenFilter.h new file mode 100644 index 00000000..4acc93e3 --- /dev/null +++ b/poxml/antlr/antlr/TokenStreamHiddenTokenFilter.h @@ -0,0 +1,84 @@ +#ifndef INC_TokenStreamHiddenTokenFilter_hpp__ +#define INC_TokenStreamHiddenTokenFilter_hpp__ + +#include "antlr/config.h" +#include "antlr/TokenStreamBasicFilter.h" + +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/TokenStreamHiddenTokenFilter.hpp b/poxml/antlr/antlr/TokenStreamHiddenTokenFilter.hpp deleted file mode 100644 index 47aad001..00000000 --- a/poxml/antlr/antlr/TokenStreamHiddenTokenFilter.hpp +++ /dev/null @@ -1,84 +0,0 @@ -#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.h b/poxml/antlr/antlr/TokenStreamIOException.h new file mode 100644 index 00000000..7d13bc1d --- /dev/null +++ b/poxml/antlr/antlr/TokenStreamIOException.h @@ -0,0 +1,22 @@ +#ifndef INC_TokenStreamIOException_hpp__ +#define INC_TokenStreamIOException_hpp__ + +#include "antlr/config.h" +#include "antlr/TokenStreamException.h" +#include + +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/TokenStreamIOException.hpp b/poxml/antlr/antlr/TokenStreamIOException.hpp deleted file mode 100644 index 9ac6d759..00000000 --- a/poxml/antlr/antlr/TokenStreamIOException.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef INC_TokenStreamIOException_hpp__ -#define INC_TokenStreamIOException_hpp__ - -#include "antlr/config.hpp" -#include "antlr/TokenStreamException.hpp" -#include - -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.h b/poxml/antlr/antlr/TokenStreamRecognitionException.h new file mode 100644 index 00000000..7d3e2ae7 --- /dev/null +++ b/poxml/antlr/antlr/TokenStreamRecognitionException.h @@ -0,0 +1,21 @@ +#ifndef INC_TokenStreamRecognitionException_hpp__ +#define INC_TokenStreamRecognitionException_hpp__ + +#include "antlr/config.h" +#include "antlr/TokenStreamException.h" +#include + +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/TokenStreamRecognitionException.hpp b/poxml/antlr/antlr/TokenStreamRecognitionException.hpp deleted file mode 100644 index 4aa4609f..00000000 --- a/poxml/antlr/antlr/TokenStreamRecognitionException.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef INC_TokenStreamRecognitionException_hpp__ -#define INC_TokenStreamRecognitionException_hpp__ - -#include "antlr/config.hpp" -#include "antlr/TokenStreamException.hpp" -#include - -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.h b/poxml/antlr/antlr/TokenStreamRetryException.h new file mode 100644 index 00000000..c4664ef3 --- /dev/null +++ b/poxml/antlr/antlr/TokenStreamRetryException.h @@ -0,0 +1,17 @@ +#ifndef INC_TokenStreamRetryException_hpp__ +#define INC_TokenStreamRetryException_hpp__ + +#include "antlr/config.h" +#include "antlr/TokenStreamException.h" + +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/TokenStreamRetryException.hpp b/poxml/antlr/antlr/TokenStreamRetryException.hpp deleted file mode 100644 index a940d8c4..00000000 --- a/poxml/antlr/antlr/TokenStreamRetryException.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#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.h b/poxml/antlr/antlr/TokenStreamSelector.h new file mode 100644 index 00000000..14b1b22a --- /dev/null +++ b/poxml/antlr/antlr/TokenStreamSelector.h @@ -0,0 +1,78 @@ +#ifndef INC_TokenStreamSelector_hpp__ +#define INC_TokenStreamSelector_hpp__ + +#include "antlr/config.h" +#include "antlr/TokenStream.h" +#include +#include + +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 lessp; + typedef ANTLR_USE_NAMESPACE(std)map inputStreamNames_coll; +#else + typedef ANTLR_USE_NAMESPACE(std)map 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 > streamStack_coll; +#else + typedef ANTLR_USE_NAMESPACE(std)stack 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/TokenStreamSelector.hpp b/poxml/antlr/antlr/TokenStreamSelector.hpp deleted file mode 100644 index 7e7d7398..00000000 --- a/poxml/antlr/antlr/TokenStreamSelector.hpp +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef INC_TokenStreamSelector_hpp__ -#define INC_TokenStreamSelector_hpp__ - -#include "antlr/config.hpp" -#include "antlr/TokenStream.hpp" -#include -#include - -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 lessp; - typedef ANTLR_USE_NAMESPACE(std)map inputStreamNames_coll; -#else - typedef ANTLR_USE_NAMESPACE(std)map 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 > streamStack_coll; -#else - typedef ANTLR_USE_NAMESPACE(std)stack 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.h b/poxml/antlr/antlr/TreeParser.h new file mode 100644 index 00000000..28f13b42 --- /dev/null +++ b/poxml/antlr/antlr/TreeParser.h @@ -0,0 +1,159 @@ +#ifndef INC_TreeParser_hpp__ +#define INC_TreeParser_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ +#include "antlr/config.h" +#include "antlr/AST.h" +#include "antlr/ASTFactory.h" +#include "antlr/BitSet.h" +#include "antlr/RecognitionException.h" +#include "antlr/TreeParserSharedInputState.h" + +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 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 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/TreeParser.hpp b/poxml/antlr/antlr/TreeParser.hpp deleted file mode 100644 index ed474bd1..00000000 --- a/poxml/antlr/antlr/TreeParser.hpp +++ /dev/null @@ -1,159 +0,0 @@ -#ifndef INC_TreeParser_hpp__ -#define INC_TreeParser_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ -#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 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 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.h b/poxml/antlr/antlr/TreeParserSharedInputState.h new file mode 100644 index 00000000..49180eb9 --- /dev/null +++ b/poxml/antlr/antlr/TreeParserSharedInputState.h @@ -0,0 +1,34 @@ +#ifndef INC_TreeParserSharedInputState_hpp__ +#define INC_TreeParserSharedInputState_hpp__ + +#include "antlr/config.h" +#include "antlr/RefCount.h" + +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 TreeParserSharedInputState; + +ANTLR_END_NAMESPACE + +#endif //INC_TreeParserSharedInputState_hpp__ diff --git a/poxml/antlr/antlr/TreeParserSharedInputState.hpp b/poxml/antlr/antlr/TreeParserSharedInputState.hpp deleted file mode 100644 index 8f7b0922..00000000 --- a/poxml/antlr/antlr/TreeParserSharedInputState.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#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 TreeParserSharedInputState; - -ANTLR_END_NAMESPACE - -#endif //INC_TreeParserSharedInputState_hpp__ diff --git a/poxml/antlr/antlr/config.h b/poxml/antlr/antlr/config.h new file mode 100644 index 00000000..8ac94a3a --- /dev/null +++ b/poxml/antlr/antlr/config.h @@ -0,0 +1,168 @@ +#ifndef INC_config_hpp__ +#define INC_config_hpp__ + +/** + * SOFTWARE RIGHTS + *

+ * ANTLR 2.6.0 MageLang Insitute, 1999 + *

+ * 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 ANTLR gang: + * @version ANTLR 2.6.0 MageLang Insitute, 1999 + * @author Terence Parr, MageLang Institute + * @author
John Lilley, Empathy Software + * @author
Pete Wells + */ + +/* + * 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 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 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 +#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/antlr/config.hpp b/poxml/antlr/antlr/config.hpp deleted file mode 100644 index 8ac94a3a..00000000 --- a/poxml/antlr/antlr/config.hpp +++ /dev/null @@ -1,168 +0,0 @@ -#ifndef INC_config_hpp__ -#define INC_config_hpp__ - -/** - * SOFTWARE RIGHTS - *

- * ANTLR 2.6.0 MageLang Insitute, 1999 - *

- * 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 ANTLR gang: - * @version ANTLR 2.6.0 MageLang Insitute, 1999 - * @author Terence Parr, MageLang Institute - * @author
John Lilley, Empathy Software - * @author
Pete Wells - */ - -/* - * 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 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 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 -#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/src/ANTLRException.cpp b/poxml/antlr/src/ANTLRException.cpp index 42632e71..5b2dc93c 100644 --- a/poxml/antlr/src/ANTLRException.cpp +++ b/poxml/antlr/src/ANTLRException.cpp @@ -30,7 +30,7 @@ * @author
Pete Wells */ -#include "antlr/ANTLRException.hpp" +#include "antlr/ANTLRException.h" ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/ASTFactory.cpp b/poxml/antlr/src/ASTFactory.cpp index e44386f7..fbe717fd 100644 --- a/poxml/antlr/src/ASTFactory.cpp +++ b/poxml/antlr/src/ASTFactory.cpp @@ -30,8 +30,8 @@ * @author
Pete Wells */ -#include "antlr/ASTFactory.hpp" -#include "antlr/CommonAST.hpp" +#include "antlr/ASTFactory.h" +#include "antlr/CommonAST.h" ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/ASTRefCount.cpp b/poxml/antlr/src/ASTRefCount.cpp index 1da98306..2498d759 100644 --- a/poxml/antlr/src/ASTRefCount.cpp +++ b/poxml/antlr/src/ASTRefCount.cpp @@ -1,5 +1,5 @@ -#include "antlr/ASTRefCount.hpp" -#include "antlr/AST.hpp" +#include "antlr/ASTRefCount.h" +#include "antlr/AST.h" ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/BaseAST.cpp b/poxml/antlr/src/BaseAST.cpp index 4080e0e8..ddb129ef 100644 --- a/poxml/antlr/src/BaseAST.cpp +++ b/poxml/antlr/src/BaseAST.cpp @@ -30,7 +30,7 @@ * @author
Pete Wells */ -#include "antlr/BaseAST.hpp" +#include "antlr/BaseAST.h" ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/BitSet.cpp b/poxml/antlr/src/BitSet.cpp index 69e70a68..32750009 100644 --- a/poxml/antlr/src/BitSet.cpp +++ b/poxml/antlr/src/BitSet.cpp @@ -1,4 +1,4 @@ -#include "antlr/BitSet.hpp" +#include "antlr/BitSet.h" #include ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/CharBuffer.cpp b/poxml/antlr/src/CharBuffer.cpp index a43eb153..312af533 100644 --- a/poxml/antlr/src/CharBuffer.cpp +++ b/poxml/antlr/src/CharBuffer.cpp @@ -43,7 +43,7 @@ * @see antlr.CharQueue */ -#include "antlr/CharBuffer.hpp" +#include "antlr/CharBuffer.h" ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/CharScanner.cpp b/poxml/antlr/src/CharScanner.cpp index ff40138d..8374651e 100644 --- a/poxml/antlr/src/CharScanner.cpp +++ b/poxml/antlr/src/CharScanner.cpp @@ -30,9 +30,9 @@ * @author
Pete Wells */ -#include "antlr/CharScanner.hpp" -#include "antlr/CommonToken.hpp" -#include "antlr/MismatchedCharException.hpp" +#include "antlr/CharScanner.h" +#include "antlr/CommonToken.h" +#include "antlr/MismatchedCharException.h" #include #ifdef HAS_NOT_CCTYPE_H diff --git a/poxml/antlr/src/CommonAST.cpp b/poxml/antlr/src/CommonAST.cpp index 3a4067e3..0204b452 100644 --- a/poxml/antlr/src/CommonAST.cpp +++ b/poxml/antlr/src/CommonAST.cpp @@ -30,8 +30,8 @@ * @author
Pete Wells */ -#include "antlr/config.hpp" -#include "antlr/CommonAST.hpp" +#include "antlr/config.h" +#include "antlr/CommonAST.h" ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/CommonASTWithHiddenTokens.cpp b/poxml/antlr/src/CommonASTWithHiddenTokens.cpp index d6c242d2..6b0213fe 100644 --- a/poxml/antlr/src/CommonASTWithHiddenTokens.cpp +++ b/poxml/antlr/src/CommonASTWithHiddenTokens.cpp @@ -1,6 +1,6 @@ -#include "antlr/config.hpp" -#include "antlr/CommonASTWithHiddenTokens.hpp" -#include "antlr/CommonHiddenStreamToken.hpp" +#include "antlr/config.h" +#include "antlr/CommonASTWithHiddenTokens.h" +#include "antlr/CommonHiddenStreamToken.h" ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/CommonHiddenStreamToken.cpp b/poxml/antlr/src/CommonHiddenStreamToken.cpp index d33927cc..ea3ab8e9 100644 --- a/poxml/antlr/src/CommonHiddenStreamToken.cpp +++ b/poxml/antlr/src/CommonHiddenStreamToken.cpp @@ -1,4 +1,4 @@ -#include "antlr/CommonHiddenStreamToken.hpp" +#include "antlr/CommonHiddenStreamToken.h" ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/CommonToken.cpp b/poxml/antlr/src/CommonToken.cpp index ff60bd79..262536ca 100644 --- a/poxml/antlr/src/CommonToken.cpp +++ b/poxml/antlr/src/CommonToken.cpp @@ -30,8 +30,8 @@ * @author
Pete Wells */ -#include "antlr/CommonToken.hpp" -#include "antlr/String.hpp" +#include "antlr/CommonToken.h" +#include "antlr/String.h" ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/InputBuffer.cpp b/poxml/antlr/src/InputBuffer.cpp index 058c32ab..3eb6732b 100644 --- a/poxml/antlr/src/InputBuffer.cpp +++ b/poxml/antlr/src/InputBuffer.cpp @@ -43,7 +43,7 @@ * @see antlr.CharQueue */ -#include "antlr/InputBuffer.hpp" +#include "antlr/InputBuffer.h" ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/LLkParser.cpp b/poxml/antlr/src/LLkParser.cpp index 2f21cd8b..647d6562 100644 --- a/poxml/antlr/src/LLkParser.cpp +++ b/poxml/antlr/src/LLkParser.cpp @@ -30,7 +30,7 @@ * @author
Pete Wells */ -#include "antlr/LLkParser.hpp" +#include "antlr/LLkParser.h" #include ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/LexerSharedInputState.cpp b/poxml/antlr/src/LexerSharedInputState.cpp index a95f33a8..3099a839 100644 --- a/poxml/antlr/src/LexerSharedInputState.cpp +++ b/poxml/antlr/src/LexerSharedInputState.cpp @@ -1,5 +1,5 @@ -#include "antlr/LexerSharedInputState.hpp" -#include "antlr/CharBuffer.hpp" +#include "antlr/LexerSharedInputState.h" +#include "antlr/CharBuffer.h" ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/MismatchedCharException.cpp b/poxml/antlr/src/MismatchedCharException.cpp index 4dede0e8..06e730d0 100644 --- a/poxml/antlr/src/MismatchedCharException.cpp +++ b/poxml/antlr/src/MismatchedCharException.cpp @@ -30,8 +30,8 @@ * @author
Pete Wells */ -#include "antlr/MismatchedCharException.hpp" -#include "antlr/String.hpp" +#include "antlr/MismatchedCharException.h" +#include "antlr/String.h" ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/MismatchedTokenException.cpp b/poxml/antlr/src/MismatchedTokenException.cpp index b8b10808..1ac2f9cb 100644 --- a/poxml/antlr/src/MismatchedTokenException.cpp +++ b/poxml/antlr/src/MismatchedTokenException.cpp @@ -30,8 +30,8 @@ * @author
Pete Wells */ -#include "antlr/MismatchedTokenException.hpp" -#include "antlr/String.hpp" +#include "antlr/MismatchedTokenException.h" +#include "antlr/String.h" ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/NoViableAltException.cpp b/poxml/antlr/src/NoViableAltException.cpp index 433f4325..46fcbd08 100644 --- a/poxml/antlr/src/NoViableAltException.cpp +++ b/poxml/antlr/src/NoViableAltException.cpp @@ -30,8 +30,8 @@ * @author
Pete Wells */ -#include "antlr/NoViableAltException.hpp" -#include "antlr/String.hpp" +#include "antlr/NoViableAltException.h" +#include "antlr/String.h" ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/NoViableAltForCharException.cpp b/poxml/antlr/src/NoViableAltForCharException.cpp index 2ff9120f..9765da58 100644 --- a/poxml/antlr/src/NoViableAltForCharException.cpp +++ b/poxml/antlr/src/NoViableAltForCharException.cpp @@ -30,8 +30,8 @@ * @author
Pete Wells */ -#include "antlr/NoViableAltForCharException.hpp" -#include "antlr/String.hpp" +#include "antlr/NoViableAltForCharException.h" +#include "antlr/String.h" ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/Parser.cpp b/poxml/antlr/src/Parser.cpp index 5a0388d4..115bf228 100644 --- a/poxml/antlr/src/Parser.cpp +++ b/poxml/antlr/src/Parser.cpp @@ -30,12 +30,12 @@ * @author
Pete Wells */ -#include "antlr/Parser.hpp" +#include "antlr/Parser.h" -#include "antlr/BitSet.hpp" -#include "antlr/TokenBuffer.hpp" -#include "antlr/MismatchedTokenException.hpp" -//#include "antlr/ASTFactory.hpp" +#include "antlr/BitSet.h" +#include "antlr/TokenBuffer.h" +#include "antlr/MismatchedTokenException.h" +//#include "antlr/ASTFactory.h" #include #include diff --git a/poxml/antlr/src/ParserSharedInputState.cpp b/poxml/antlr/src/ParserSharedInputState.cpp index 102aba87..1f70f5ef 100644 --- a/poxml/antlr/src/ParserSharedInputState.cpp +++ b/poxml/antlr/src/ParserSharedInputState.cpp @@ -1,4 +1,4 @@ -#include "antlr/ParserSharedInputState.hpp" +#include "antlr/ParserSharedInputState.h" ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/RecognitionException.cpp b/poxml/antlr/src/RecognitionException.cpp index 1d1bd53d..cd1c9fd1 100644 --- a/poxml/antlr/src/RecognitionException.cpp +++ b/poxml/antlr/src/RecognitionException.cpp @@ -30,8 +30,8 @@ * @author
Pete Wells */ -#include "antlr/RecognitionException.hpp" -#include "antlr/String.hpp" +#include "antlr/RecognitionException.h" +#include "antlr/String.h" ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/String.cpp b/poxml/antlr/src/String.cpp index 6d9df7a5..79d8cd27 100644 --- a/poxml/antlr/src/String.cpp +++ b/poxml/antlr/src/String.cpp @@ -30,7 +30,7 @@ * @author
Pete Wells */ -#include "antlr/String.hpp" +#include "antlr/String.h" #ifdef HAS_NOT_CSTDIO_H #include diff --git a/poxml/antlr/src/Token.cpp b/poxml/antlr/src/Token.cpp index f307774f..2da6c313 100644 --- a/poxml/antlr/src/Token.cpp +++ b/poxml/antlr/src/Token.cpp @@ -30,8 +30,8 @@ * @author
Pete Wells */ -#include "antlr/Token.hpp" -#include "antlr/String.hpp" +#include "antlr/Token.h" +#include "antlr/String.h" ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/TokenBuffer.cpp b/poxml/antlr/src/TokenBuffer.cpp index ded5df9b..312d14a2 100644 --- a/poxml/antlr/src/TokenBuffer.cpp +++ b/poxml/antlr/src/TokenBuffer.cpp @@ -30,7 +30,7 @@ * @author
Pete Wells */ -#include "antlr/TokenBuffer.hpp" +#include "antlr/TokenBuffer.h" ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/TokenStreamBasicFilter.cpp b/poxml/antlr/src/TokenStreamBasicFilter.cpp index 71257f46..c2bfcdcf 100644 --- a/poxml/antlr/src/TokenStreamBasicFilter.cpp +++ b/poxml/antlr/src/TokenStreamBasicFilter.cpp @@ -1,4 +1,4 @@ -#include "antlr/TokenStreamBasicFilter.hpp" +#include "antlr/TokenStreamBasicFilter.h" ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/TokenStreamHiddenTokenFilter.cpp b/poxml/antlr/src/TokenStreamHiddenTokenFilter.cpp index 827ca382..72af82cb 100644 --- a/poxml/antlr/src/TokenStreamHiddenTokenFilter.cpp +++ b/poxml/antlr/src/TokenStreamHiddenTokenFilter.cpp @@ -1,5 +1,5 @@ -#include "antlr/TokenStreamHiddenTokenFilter.hpp" -#include "antlr/CommonHiddenStreamToken.hpp" +#include "antlr/TokenStreamHiddenTokenFilter.h" +#include "antlr/CommonHiddenStreamToken.h" ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/TokenStreamSelector.cpp b/poxml/antlr/src/TokenStreamSelector.cpp index 2e6527a8..073a8f44 100644 --- a/poxml/antlr/src/TokenStreamSelector.cpp +++ b/poxml/antlr/src/TokenStreamSelector.cpp @@ -1,5 +1,5 @@ -#include "antlr/TokenStreamSelector.hpp" -#include "antlr/TokenStreamRetryException.hpp" +#include "antlr/TokenStreamSelector.h" +#include "antlr/TokenStreamRetryException.h" ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/antlr/src/TreeParser.cpp b/poxml/antlr/src/TreeParser.cpp index 6d302737..1e83bd77 100644 --- a/poxml/antlr/src/TreeParser.cpp +++ b/poxml/antlr/src/TreeParser.cpp @@ -29,9 +29,9 @@ * @author
John Lilley, Empathy Software * @author
Pete Wells */ -#include "antlr/TreeParser.hpp" -#include "antlr/ASTNULLType.hpp" -#include "antlr/MismatchedTokenException.hpp" +#include "antlr/TreeParser.h" +#include "antlr/ASTNULLType.h" +#include "antlr/MismatchedTokenException.h" #include #include diff --git a/poxml/antlr/src/TreeParserSharedInputState.cpp b/poxml/antlr/src/TreeParserSharedInputState.cpp index 89f1d5dc..be7adebb 100644 --- a/poxml/antlr/src/TreeParserSharedInputState.cpp +++ b/poxml/antlr/src/TreeParserSharedInputState.cpp @@ -1,4 +1,4 @@ -#include "antlr/TreeParserSharedInputState.hpp" +#include "antlr/TreeParserSharedInputState.h" ANTLR_BEGIN_NAMESPACE(antlr) diff --git a/poxml/gettext.g b/poxml/gettext.g index 8da92334..1e0a3b34 100644 --- a/poxml/gettext.g +++ b/poxml/gettext.g @@ -11,10 +11,10 @@ options { { #include -#include "GettextLexer.hpp" -#include "GettextParser.hpp" -#include "antlr/AST.hpp" -#include "antlr/CommonAST.hpp" +#include "GettextLexer.h" +#include "GettextParser.h" +#include "antlr/AST.h" +#include "antlr/CommonAST.h" /* int main() diff --git a/poxml/po2xml.cpp b/poxml/po2xml.cpp index e43f464a..65c4e013 100644 --- a/poxml/po2xml.cpp +++ b/poxml/po2xml.cpp @@ -7,10 +7,10 @@ #include #include -#include "GettextLexer.hpp" -#include "GettextParser.hpp" -#include "antlr/AST.hpp" -#include "antlr/CommonAST.hpp" +#include "GettextLexer.h" +#include "GettextParser.h" +#include "antlr/AST.h" +#include "antlr/CommonAST.h" using namespace std; diff --git a/poxml/swappo.cpp b/poxml/swappo.cpp index 8e2e8344..16e7ee7f 100644 --- a/poxml/swappo.cpp +++ b/poxml/swappo.cpp @@ -1,8 +1,8 @@ #include using namespace std; -#include "GettextParser.hpp" +#include "GettextParser.h" #include -#include "GettextLexer.hpp" +#include "GettextLexer.h" int main(int argc, char **argv) { diff --git a/poxml/transxx.cpp b/poxml/transxx.cpp index 1ffff4a8..61338b91 100644 --- a/poxml/transxx.cpp +++ b/poxml/transxx.cpp @@ -1,8 +1,8 @@ #include using namespace std; -#include "GettextParser.hpp" +#include "GettextParser.h" #include -#include "GettextLexer.hpp" +#include "GettextLexer.h" #include #include diff --git a/umbrello/umbrello/Makefile.am b/umbrello/umbrello/Makefile.am index a68fd709..c9687f27 100644 --- a/umbrello/umbrello/Makefile.am +++ b/umbrello/umbrello/Makefile.am @@ -140,7 +140,7 @@ umbrello_LDFLAGS = $(all_libraries) $(KDE_RPATH) -export-dynamic messages: rc.cpp $(PREPARETIPS) > tips.txt $(EXTRACTRC) *.rc codegenerators/*.ui dialogs/*.ui > ./rc.cpp - LIST=`find . -name \*.h -o -name \*.hh -o -name \*.txt -o -name \*.H -o -name \*.hxx -o -name \*.hpp -o -name \*.cpp -o -name \*.cc -o -name \*.cxx -o -name \*.ecpp -o -name \*.C`; \ + LIST=`find . -name \*.h -o -name \*.txt -o -name \*.cpp`; \ if test -n "$$LIST"; then \ $(XGETTEXT) $$LIST -o $(podir)/umbrello.pot; \ fi -- cgit v1.2.1