From: <ibr...@us...> - 2013-06-26 14:55:25
|
Revision: 4659 http://sourceforge.net/p/tora/code/4659 Author: ibre5041 Date: 2013-06-26 14:55:18 +0000 (Wed, 26 Jun 2013) Log Message: ----------- refectoring test Modified Paths: -------------- branches/tora3/extlibs/parsing.cpp/PLSQLGuiLexer.g branches/tora3/extlibs/parsing.cpp/t0.cpp branches/tora3/src/editor/tocustomlexer.h branches/tora3/src/parsing/tsqllexeroracle2.cc Modified: branches/tora3/extlibs/parsing.cpp/PLSQLGuiLexer.g =================================================================== --- branches/tora3/extlibs/parsing.cpp/PLSQLGuiLexer.g 2013-06-26 14:51:58 UTC (rev 4658) +++ branches/tora3/extlibs/parsing.cpp/PLSQLGuiLexer.g 2013-06-26 14:55:18 UTC (rev 4659) @@ -31,6 +31,7 @@ tokens { DOUBLE_PERIOD; SQLPLUS_COMMAND; + SQLPLUS_SOLIDUS; } @lexer::includes @@ -66,9 +67,13 @@ */ } +@lexer::context { + void advanceInput(); +} + @lexer::members { - - void advanceInput() + //@lexer::members + void PLSQLGuiLexer::advanceInput() { RecognizerSharedStateType *state = get_state(); state->set_tokenStartCharIndex(getCharIndex()); @@ -1144,13 +1149,30 @@ ; //{ Rule #360 <NEWLINE> -//fragment +fragment NEWLINE : '\r' (options{greedy=true;}: '\n')? | '\n' ; //} +LINE + : n=NEWLINE + { + $n->set_type(NEWLINE); + get_tokSource()->enqueueToken($n); + advanceInput(); + } + ( + s=SPACE? + { + $s->set_type(SPACE); + get_tokSource()->enqueueToken($n); + advanceInput(); + } + )? + ; + //{ Rule #522 <SPACE> //fragment SPACE Modified: branches/tora3/extlibs/parsing.cpp/t0.cpp =================================================================== --- branches/tora3/extlibs/parsing.cpp/t0.cpp 2013-06-26 14:51:58 UTC (rev 4658) +++ branches/tora3/extlibs/parsing.cpp/t0.cpp 2013-06-26 14:55:18 UTC (rev 4659) @@ -170,7 +170,7 @@ { T = tstream->_LA(1); PLSQLGuiLexerTraits::CommonTokenType const* token = tstream->_LT(1); - ANTLR_UINT8 const *name = lxr->getTokenName(T); + ANTLR_UINT8 const *name = (ANTLR_UINT8 const*)""; //lxr->getTokenName(T); printf("%d %s\t\"%s\"\n", T, Modified: branches/tora3/src/editor/tocustomlexer.h =================================================================== --- branches/tora3/src/editor/tocustomlexer.h 2013-06-26 14:51:58 UTC (rev 4658) +++ branches/tora3/src/editor/tocustomlexer.h 2013-06-26 14:55:18 UTC (rev 4659) @@ -110,6 +110,12 @@ toCustomLexerPriv *worker; }; +/* Utility class for @ref toCustomLexer + * Instance of this class "lives" within background thread + * and dispatches signals from/to the main thread + * + * NOTE: this class could by nested, but QT does not support it + */ class toCustomLexerPriv: public QObject { Q_OBJECT; friend class toCustomLexer; Modified: branches/tora3/src/parsing/tsqllexeroracle2.cc =================================================================== --- branches/tora3/src/parsing/tsqllexeroracle2.cc 2013-06-26 14:51:58 UTC (rev 4658) +++ branches/tora3/src/parsing/tsqllexeroracle2.cc 2013-06-26 14:55:18 UTC (rev 4659) @@ -34,6 +34,10 @@ Antlr3Impl::PLSQLGuiLexer *lxr; Antlr3Impl::PLSQLGuiLexerTraits::TokenStreamType* tstream; + User::PLSQLLexerTraits::InputStreamType* pinput; + User::PLSQLLexer *plxr; + User::PLSQLLexerTraits::TokenStreamType* ptstream; + unsigned lastLine, lastColumn, lastIndex; mutable Token retvalLA; @@ -65,21 +69,25 @@ input->setUcaseLA(true); // ignore case - if (input == NULL) + pinput = new User::PLSQLTraits::InputStreamType( + (const ANTLR_UINT8 *)QBAinput.data(), + ANTLR_ENC_UTF8, + QBAinput.size(), //strlen(data.c_str()), + (ANTLR_UINT8*)QBAname.data()); + + pinput->setUcaseLA(true); // ignore case + + if (input == NULL || pinput == NULL ) { // TODO throw here throw Exception(); exit(ANTLR_ERR_NOMEM); } - // Our input stream is now open and all set to go, so we can create a new instance of our - // lexer and set the lexer input to our input stream: - // (file | memory | ?) --> inputstream -> lexer --> tokenstream --> parser ( --> treeparser )? - // - lxr = new PLSQLGuiLexer(input); // CLexerNew is generated by ANTLR - //lxr->pLexer->input->charPositionInLine = 0; // fix off-by-one error for getCharPositionInLine for the 1st row + lxr = new PLSQLGuiLexer(input); + plxr = new User::PLSQLLexer(pinput); - if ( lxr == NULL ) + if ( lxr == NULL || plxr == NULL) { // TODO throw here throw Exception(); @@ -87,8 +95,9 @@ } tstream = new PLSQLGuiLexerTraits::TokenStreamType(ANTLR_SIZE_HINT, lxr->get_tokSource()); + ptstream = new User::PLSQLTraits::TokenStreamType(ANTLR_SIZE_HINT, plxr->get_tokSource()); - if (tstream == NULL) + if (tstream == NULL || ptstream == NULL) { // TODO throw here //_mState = P_ERROR; @@ -131,6 +140,16 @@ tstream = NULL; lxr = NULL; input = NULL; + + if( ptstream) + delete ptstream; + if( plxr) + delete plxr; + if( pinput) + delete pinput; + ptstream = NULL; + plxr = NULL; + pinput = NULL; } int OracleGuiLexer::size() const @@ -289,6 +308,11 @@ { case Token::L_PL_INTRODUCER: { + User::PLSQLParser *psr = new User::PLSQLParser(ptstream); + User::PLSQLParser::seq_of_statements_return r = psr->seq_of_statements(); + + delete psr; + /* bool exitLoop = false; bool createFound = start->getText().compare("CREATE", Qt::CaseInsensitive) == 0; bool functionFound = start->getText().compare("FUNCTION", Qt::CaseInsensitive) == 0; @@ -352,6 +376,7 @@ break; } } + */ break; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |