From c26f38114fedde81effb938ffbedfe922d77a322 Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Tue, 7 Aug 2012 17:01:57 +1000 Subject: A whole bunch of clean up work around the place. - Make it a bit nicer to use the command-line - Remove the strategies we won't be using - Clean up some code around the place, generally --- impl/parser/EquationSystemLexer.c | 2087 ------------------------------------- 1 file changed, 2087 deletions(-) delete mode 100644 impl/parser/EquationSystemLexer.c (limited to 'impl/parser/EquationSystemLexer.c') diff --git a/impl/parser/EquationSystemLexer.c b/impl/parser/EquationSystemLexer.c deleted file mode 100644 index dc8b451..0000000 --- a/impl/parser/EquationSystemLexer.c +++ /dev/null @@ -1,2087 +0,0 @@ -/** \file - * This C source file was generated by $ANTLR version 3.4 - * - * - From the grammar source file : EquationSystem.g - * - On : 2012-07-12 15:47:53 - * - for the lexer : EquationSystemLexerLexer - * - * Editing it, at least manually, is not wise. - * - * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. - * - * -*/ -// [The "BSD license"] -// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC -// http://www.temporal-wave.com -// http://www.linkedin.com/in/jimidle -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// 3. The name of the author may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -/* ----------------------------------------- - * Include the ANTLR3 generated header file. - */ -#include "EquationSystemLexer.h" -/* ----------------------------------------- */ - - -/** String literals used by EquationSystemLexer that we must do things like MATCHS() with. - * C will normally just lay down 8 bit characters, and you can use L"xxx" to - * get wchar_t, but wchar_t is 16 bits on Windows, which is not UTF32 and so - * we perform this little trick of defining the literals as arrays of UINT32 - * and passing in the address of these. - */ -static ANTLR3_UCHAR lit_1[] = { 0x3E, 0x3D, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_2[] = { 0x67, 0x75, 0x61, 0x72, 0x64, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_3[] = { 0x6D, 0x61, 0x78, ANTLR3_STRING_TERMINATOR}; -static ANTLR3_UCHAR lit_4[] = { 0x6D, 0x69, 0x6E, ANTLR3_STRING_TERMINATOR}; - - - - - -/* MACROS that hide the C interface implementations from the - * generated code, which makes it a little more understandable to the human eye. - * I am very much against using C pre-processor macros for function calls and bits - * of code as you cannot see what is happening when single stepping in debuggers - * and so on. The exception (in my book at least) is for generated code, where you are - * not maintaining it, but may wish to read and understand it. If you single step it, you know that input() - * hides some indirect calls, but is always referring to the input stream. This is - * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig - * the runtime interfaces without changing the generated code too often, without - * confusing the reader of the generated output, who may not wish to know the gory - * details of the interface inheritance. - */ - -#define CTX ctx - -/* Aids in accessing scopes for grammar programmers - */ -#undef SCOPE_TYPE -#undef SCOPE_STACK -#undef SCOPE_TOP -#define SCOPE_TYPE(scope) pEquationSystemLexer_##scope##_SCOPE -#define SCOPE_STACK(scope) pEquationSystemLexer_##scope##Stack -#define SCOPE_TOP(scope) ctx->pEquationSystemLexer_##scope##Top -#define SCOPE_SIZE(scope) ctx->pEquationSystemLexer_##scope##Stack_limit -#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i)) - - -/* Macros for accessing things in a lexer - */ -#undef LEXER -#undef RECOGNIZER -#undef RULEMEMO -#undef GETCHARINDEX -#undef GETLINE -#undef GETCHARPOSITIONINLINE -#undef EMIT -#undef EMITNEW -#undef MATCHC -#undef MATCHS -#undef MATCHRANGE -#undef LTOKEN -#undef HASFAILED -#undef FAILEDFLAG -#undef INPUT -#undef STRSTREAM -#undef LA -#undef HASEXCEPTION -#undef EXCEPTION -#undef CONSTRUCTEX -#undef CONSUME -#undef LRECOVER -#undef MARK -#undef REWIND -#undef REWINDLAST -#undef BACKTRACKING -#undef MATCHANY -#undef MEMOIZE -#undef HAVEPARSEDRULE -#undef GETTEXT -#undef INDEX -#undef SEEK -#undef PUSHSTREAM -#undef POPSTREAM -#undef SETTEXT -#undef SETTEXT8 - -#define LEXER ctx->pLexer -#define RECOGNIZER LEXER->rec -#define LEXSTATE RECOGNIZER->state -#define TOKSOURCE LEXSTATE->tokSource -#define GETCHARINDEX() LEXER->getCharIndex(LEXER) -#define GETLINE() LEXER->getLine(LEXER) -#define GETTEXT() LEXER->getText(LEXER) -#define GETCHARPOSITIONINLINE() LEXER->getCharPositionInLine(LEXER) -#define EMIT() LEXSTATE->type = _type; LEXER->emit(LEXER) -#define EMITNEW(t) LEXER->emitNew(LEXER, t) -#define MATCHC(c) LEXER->matchc(LEXER, c) -#define MATCHS(s) LEXER->matchs(LEXER, s) -#define MATCHRANGE(c1,c2) LEXER->matchRange(LEXER, c1, c2) -#define MATCHANY() LEXER->matchAny(LEXER) -#define LTOKEN LEXSTATE->token -#define HASFAILED() (LEXSTATE->failed == ANTLR3_TRUE) -#define BACKTRACKING LEXSTATE->backtracking -#define FAILEDFLAG LEXSTATE->failed -#define INPUT LEXER->input -#define STRSTREAM INPUT -#define ISTREAM INPUT->istream -#define INDEX() ISTREAM->index(ISTREAM) -#define SEEK(n) ISTREAM->seek(ISTREAM, n) -#define EOF_TOKEN &(LEXSTATE->tokSource->eofToken) -#define HASEXCEPTION() (LEXSTATE->error == ANTLR3_TRUE) -#define EXCEPTION LEXSTATE->exception -#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER) -#define LRECOVER() LEXER->recover(LEXER) -#define MARK() ISTREAM->mark(ISTREAM) -#define REWIND(m) ISTREAM->rewind(ISTREAM, m) -#define REWINDLAST() ISTREAM->rewindLast(ISTREAM) -#define MEMOIZE(ri,si) RECOGNIZER->memoize(RECOGNIZER, ri, si) -#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r) -#define PUSHSTREAM(str) LEXER->pushCharStream(LEXER, str) -#define POPSTREAM() LEXER->popCharStream(LEXER) -#define SETTEXT(str) LEXSTATE->text = str -#define SKIP() LEXSTATE->token = &(TOKSOURCE->skipToken) -#define USER1 LEXSTATE->user1 -#define USER2 LEXSTATE->user2 -#define USER3 LEXSTATE->user3 -#define CUSTOM LEXSTATE->custom -#define RULEMEMO LEXSTATE->ruleMemo -#define DBG RECOGNIZER->debugger - -/* If we have been told we can rely on the standard 8 bit or UTF16 input - * stream, then we can define our macros to use the direct pointers - * in the input object, which is much faster than indirect calls. This - * is really only significant to lexers with a lot of fragment rules (which - * do not place LA(1) in a temporary at the moment) and even then - * only if there is a lot of input (order of say 1M or so). - */ -#if defined(ANTLR3_INLINE_INPUT_8BIT) || defined(ANTLR3_INLINE_INPUT_UTF16) - -# ifdef ANTLR3_INLINE_INPUT_8BIT - -/* 8 bit character set */ - -# define NEXTCHAR ((pANTLR3_UINT8)(INPUT->nextChar)) -# define DATAP ((pANTLR3_UINT8)(INPUT->data)) - -# else - -# define NEXTCHAR ((pANTLR3_UINT16)(INPUT->nextChar)) -# define DATAP ((pANTLR3_UINT16)(INPUT->data)) - -# endif - -# define LA(n) ((NEXTCHAR + n) > (DATAP + INPUT->sizeBuf) ? ANTLR3_CHARSTREAM_EOF : (ANTLR3_UCHAR)(*(NEXTCHAR + n - 1))) -# define CONSUME() \ -{ \ - if (NEXTCHAR < (DATAP + INPUT->sizeBuf)) \ - { \ - INPUT->charPositionInLine++; \ - if ((ANTLR3_UCHAR)(*NEXTCHAR) == INPUT->newlineChar) \ - { \ - INPUT->line++; \ - INPUT->charPositionInLine = 0; \ - INPUT->currentLine = (void *)(NEXTCHAR + 1); \ - } \ - INPUT->nextChar = (void *)(NEXTCHAR + 1); \ - } \ -} - -#else - -// Pick up the input character by calling the input stream implementation. -// -#define CONSUME() INPUT->istream->consume(INPUT->istream) -#define LA(n) INPUT->istream->_LA(INPUT->istream, n) - -#endif - -#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt - -/* The 4 tokens defined below may well clash with your own #defines or token types. If so - * then for the present you must use different names for your defines as these are hard coded - * in the code generator. It would be better not to use such names internally, and maybe - * we can change this in a forthcoming release. I deliberately do not #undef these - * here as this will at least give you a redefined error somewhere if they clash. - */ -#define UP ANTLR3_TOKEN_UP -#define DOWN ANTLR3_TOKEN_DOWN -#define EOR ANTLR3_TOKEN_EOR -#define INVALID ANTLR3_TOKEN_INVALID - - -/* ============================================================================= - * Functions to create and destroy scopes. First come the rule scopes, followed - * by the global declared scopes. - */ - - - -/* ============================================================================= */ - -/* ============================================================================= - * Start of recognizer - */ - -/* Forward declare the locally static matching functions we have generated and any predicate functions. - */ -static ANTLR3_INLINE - void - mCOMMA (pEquationSystemLexer ctx); -static ANTLR3_INLINE - void - mGREATER_EQUAL (pEquationSystemLexer ctx); -static ANTLR3_INLINE - void - mGUARD (pEquationSystemLexer ctx); -static ANTLR3_INLINE - void - mMAXIMUM (pEquationSystemLexer ctx); -static ANTLR3_INLINE - void - mMINIMUM (pEquationSystemLexer ctx); -static ANTLR3_INLINE - void - mMULT (pEquationSystemLexer ctx); -static ANTLR3_INLINE - void - mNEWLINE (pEquationSystemLexer ctx); -static ANTLR3_INLINE - void - mPLUS (pEquationSystemLexer ctx); -static ANTLR3_INLINE - void - mQUESTION_MARK (pEquationSystemLexer ctx); -static ANTLR3_INLINE - void - mSUB (pEquationSystemLexer ctx); -static ANTLR3_INLINE - void - mT__19 (pEquationSystemLexer ctx); -static ANTLR3_INLINE - void - mT__20 (pEquationSystemLexer ctx); -static ANTLR3_INLINE - void - mT__21 (pEquationSystemLexer ctx); -static ANTLR3_INLINE - void - mT__22 (pEquationSystemLexer ctx); -static ANTLR3_INLINE - void - mNUMBER (pEquationSystemLexer ctx); -static ANTLR3_INLINE - void - mVARIABLE (pEquationSystemLexer ctx); -static ANTLR3_INLINE - void - mWHITESPACE (pEquationSystemLexer ctx); -static ANTLR3_INLINE - void - mDIGIT (pEquationSystemLexer ctx); -static ANTLR3_INLINE - void - mLETTER (pEquationSystemLexer ctx); -static ANTLR3_INLINE - void - mTokens (pEquationSystemLexer ctx); -static void EquationSystemLexerFree(pEquationSystemLexer ctx); - -/* ========================================================================= - * Lexer matching rules end. - * ========================================================================= - */ - - - -static void -EquationSystemLexerFree (pEquationSystemLexer ctx) -{ - LEXER->free(LEXER); - - ANTLR3_FREE(ctx); -} - -static void -EquationSystemLexerReset (pEquationSystemLexer ctx) -{ - RECOGNIZER->reset(RECOGNIZER); -} - -/** \brief Name of the grammar file that generated this code - */ -static const char fileName[] = "EquationSystem.g"; - -/** \brief Return the name of the grammar file that generated this code. - */ -static const char * getGrammarFileName() -{ - return fileName; -} - -/** \brief Create a new lexer called EquationSystemLexer - * - * \param[in] instream Pointer to an initialized input stream - * \return - * - Success pEquationSystemLexer initialized for the lex start - * - Fail NULL - */ -ANTLR3_API pEquationSystemLexer EquationSystemLexerNew -( -pANTLR3_INPUT_STREAM - instream) -{ - // See if we can create a new lexer with the standard constructor - // - return EquationSystemLexerNewSSD(instream, NULL); -} - -/** \brief Create a new lexer called EquationSystemLexer - * - * \param[in] instream Pointer to an initialized input stream - * \param[state] state Previously created shared recognizer stat - * \return - * - Success pEquationSystemLexer initialized for the lex start - * - Fail NULL - */ -ANTLR3_API pEquationSystemLexer EquationSystemLexerNewSSD -(pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state) -{ - pEquationSystemLexer ctx; // Context structure we will build and return - - ctx = (pEquationSystemLexer) ANTLR3_CALLOC(1, sizeof(EquationSystemLexer)); - - if (ctx == NULL) - { - // Failed to allocate memory for lexer context - return NULL; - } - - /* ------------------------------------------------------------------- - * Memory for basic structure is allocated, now to fill in - * in base ANTLR3 structures. We initialize the function pointers - * for the standard ANTLR3 lexer function set, but upon return - * from here, the programmer may set the pointers to provide custom - * implementations of each function. - * - * We don't use the macros defined in EquationSystemLexer.h here so you can get a sense - * of what goes where. - */ - - /* Create a base lexer, using the supplied input stream - */ - ctx->pLexer = antlr3LexerNewStream(ANTLR3_SIZE_HINT, instream, state); - - /* Check that we allocated the memory correctly - */ - if (ctx->pLexer == NULL) - { - ANTLR3_FREE(ctx); - return NULL; - } - /* Install the implementation of our EquationSystemLexer interface - */ - ctx->mCOMMA = mCOMMA; - ctx->mGREATER_EQUAL = mGREATER_EQUAL; - ctx->mGUARD = mGUARD; - ctx->mMAXIMUM = mMAXIMUM; - ctx->mMINIMUM = mMINIMUM; - ctx->mMULT = mMULT; - ctx->mNEWLINE = mNEWLINE; - ctx->mPLUS = mPLUS; - ctx->mQUESTION_MARK = mQUESTION_MARK; - ctx->mSUB = mSUB; - ctx->mT__19 = mT__19; - ctx->mT__20 = mT__20; - ctx->mT__21 = mT__21; - ctx->mT__22 = mT__22; - ctx->mNUMBER = mNUMBER; - ctx->mVARIABLE = mVARIABLE; - ctx->mWHITESPACE = mWHITESPACE; - ctx->mDIGIT = mDIGIT; - ctx->mLETTER = mLETTER; - ctx->mTokens = mTokens; - - /** When the nextToken() call is made to this lexer's pANTLR3_TOKEN_SOURCE - * it will call mTokens() in this generated code, and will pass it the ctx - * pointer of this lexer, not the context of the base lexer, so store that now. - */ - ctx->pLexer->ctx = ctx; - - /**Install the token matching function - */ - ctx->pLexer->mTokens = (void (*) (void *))(mTokens); - - ctx->getGrammarFileName = getGrammarFileName; - ctx->free = EquationSystemLexerFree; - ctx->reset = EquationSystemLexerReset; - - - /* Return the newly built lexer to the caller - */ - return ctx; -} -/* ========================================================================= - * Functions to match the lexer grammar defined tokens from the input stream - */ - -// Comes from: 7:7: ( ';' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start COMMA - * - * Looks to match the characters the constitute the token COMMA - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mCOMMA(pEquationSystemLexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = COMMA; - - - // EquationSystem.g:7:7: ( ';' ) - // EquationSystem.g:7:9: ';' - { - MATCHC(';'); - if (HASEXCEPTION()) - { - goto ruleCOMMAEx; - } - - - } - - LEXSTATE->type = _type; - // This is where rules clean up and exit - // - goto ruleCOMMAEx; /* Prevent compiler warnings */ - ruleCOMMAEx: ; - -} -// $ANTLR end COMMA - -// Comes from: 8:15: ( '>=' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start GREATER_EQUAL - * - * Looks to match the characters the constitute the token GREATER_EQUAL - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mGREATER_EQUAL(pEquationSystemLexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = GREATER_EQUAL; - - - // EquationSystem.g:8:15: ( '>=' ) - // EquationSystem.g:8:17: '>=' - { - MATCHS(lit_1); - if (HASEXCEPTION()) - { - goto ruleGREATER_EQUALEx; - } - - - - - } - - LEXSTATE->type = _type; - // This is where rules clean up and exit - // - goto ruleGREATER_EQUALEx; /* Prevent compiler warnings */ - ruleGREATER_EQUALEx: ; - -} -// $ANTLR end GREATER_EQUAL - -// Comes from: 9:7: ( 'guard' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start GUARD - * - * Looks to match the characters the constitute the token GUARD - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mGUARD(pEquationSystemLexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = GUARD; - - - // EquationSystem.g:9:7: ( 'guard' ) - // EquationSystem.g:9:9: 'guard' - { - MATCHS(lit_2); - if (HASEXCEPTION()) - { - goto ruleGUARDEx; - } - - - - - } - - LEXSTATE->type = _type; - // This is where rules clean up and exit - // - goto ruleGUARDEx; /* Prevent compiler warnings */ - ruleGUARDEx: ; - -} -// $ANTLR end GUARD - -// Comes from: 10:9: ( 'max' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start MAXIMUM - * - * Looks to match the characters the constitute the token MAXIMUM - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mMAXIMUM(pEquationSystemLexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = MAXIMUM; - - - // EquationSystem.g:10:9: ( 'max' ) - // EquationSystem.g:10:11: 'max' - { - MATCHS(lit_3); - if (HASEXCEPTION()) - { - goto ruleMAXIMUMEx; - } - - - - - } - - LEXSTATE->type = _type; - // This is where rules clean up and exit - // - goto ruleMAXIMUMEx; /* Prevent compiler warnings */ - ruleMAXIMUMEx: ; - -} -// $ANTLR end MAXIMUM - -// Comes from: 11:9: ( 'min' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start MINIMUM - * - * Looks to match the characters the constitute the token MINIMUM - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mMINIMUM(pEquationSystemLexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = MINIMUM; - - - // EquationSystem.g:11:9: ( 'min' ) - // EquationSystem.g:11:11: 'min' - { - MATCHS(lit_4); - if (HASEXCEPTION()) - { - goto ruleMINIMUMEx; - } - - - - - } - - LEXSTATE->type = _type; - // This is where rules clean up and exit - // - goto ruleMINIMUMEx; /* Prevent compiler warnings */ - ruleMINIMUMEx: ; - -} -// $ANTLR end MINIMUM - -// Comes from: 12:6: ( '*' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start MULT - * - * Looks to match the characters the constitute the token MULT - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mMULT(pEquationSystemLexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = MULT; - - - // EquationSystem.g:12:6: ( '*' ) - // EquationSystem.g:12:8: '*' - { - MATCHC('*'); - if (HASEXCEPTION()) - { - goto ruleMULTEx; - } - - - } - - LEXSTATE->type = _type; - // This is where rules clean up and exit - // - goto ruleMULTEx; /* Prevent compiler warnings */ - ruleMULTEx: ; - -} -// $ANTLR end MULT - -// Comes from: 13:9: ( '\\n' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start NEWLINE - * - * Looks to match the characters the constitute the token NEWLINE - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mNEWLINE(pEquationSystemLexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = NEWLINE; - - - // EquationSystem.g:13:9: ( '\\n' ) - // EquationSystem.g:13:11: '\\n' - { - MATCHC('\n'); - if (HASEXCEPTION()) - { - goto ruleNEWLINEEx; - } - - - } - - LEXSTATE->type = _type; - // This is where rules clean up and exit - // - goto ruleNEWLINEEx; /* Prevent compiler warnings */ - ruleNEWLINEEx: ; - -} -// $ANTLR end NEWLINE - -// Comes from: 14:6: ( '+' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start PLUS - * - * Looks to match the characters the constitute the token PLUS - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mPLUS(pEquationSystemLexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = PLUS; - - - // EquationSystem.g:14:6: ( '+' ) - // EquationSystem.g:14:8: '+' - { - MATCHC('+'); - if (HASEXCEPTION()) - { - goto rulePLUSEx; - } - - - } - - LEXSTATE->type = _type; - // This is where rules clean up and exit - // - goto rulePLUSEx; /* Prevent compiler warnings */ - rulePLUSEx: ; - -} -// $ANTLR end PLUS - -// Comes from: 15:15: ( '?' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start QUESTION_MARK - * - * Looks to match the characters the constitute the token QUESTION_MARK - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mQUESTION_MARK(pEquationSystemLexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = QUESTION_MARK; - - - // EquationSystem.g:15:15: ( '?' ) - // EquationSystem.g:15:17: '?' - { - MATCHC('?'); - if (HASEXCEPTION()) - { - goto ruleQUESTION_MARKEx; - } - - - } - - LEXSTATE->type = _type; - // This is where rules clean up and exit - // - goto ruleQUESTION_MARKEx; /* Prevent compiler warnings */ - ruleQUESTION_MARKEx: ; - -} -// $ANTLR end QUESTION_MARK - -// Comes from: 16:5: ( '-' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start SUB - * - * Looks to match the characters the constitute the token SUB - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mSUB(pEquationSystemLexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = SUB; - - - // EquationSystem.g:16:5: ( '-' ) - // EquationSystem.g:16:7: '-' - { - MATCHC('-'); - if (HASEXCEPTION()) - { - goto ruleSUBEx; - } - - - } - - LEXSTATE->type = _type; - // This is where rules clean up and exit - // - goto ruleSUBEx; /* Prevent compiler warnings */ - ruleSUBEx: ; - -} -// $ANTLR end SUB - -// Comes from: 17:7: ( '(' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__19 - * - * Looks to match the characters the constitute the token T__19 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__19(pEquationSystemLexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__19; - - - // EquationSystem.g:17:7: ( '(' ) - // EquationSystem.g:17:9: '(' - { - MATCHC('('); - if (HASEXCEPTION()) - { - goto ruleT__19Ex; - } - - - } - - LEXSTATE->type = _type; - // This is where rules clean up and exit - // - goto ruleT__19Ex; /* Prevent compiler warnings */ - ruleT__19Ex: ; - -} -// $ANTLR end T__19 - -// Comes from: 18:7: ( ')' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__20 - * - * Looks to match the characters the constitute the token T__20 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__20(pEquationSystemLexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__20; - - - // EquationSystem.g:18:7: ( ')' ) - // EquationSystem.g:18:9: ')' - { - MATCHC(')'); - if (HASEXCEPTION()) - { - goto ruleT__20Ex; - } - - - } - - LEXSTATE->type = _type; - // This is where rules clean up and exit - // - goto ruleT__20Ex; /* Prevent compiler warnings */ - ruleT__20Ex: ; - -} -// $ANTLR end T__20 - -// Comes from: 19:7: ( ',' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__21 - * - * Looks to match the characters the constitute the token T__21 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__21(pEquationSystemLexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__21; - - - // EquationSystem.g:19:7: ( ',' ) - // EquationSystem.g:19:9: ',' - { - MATCHC(','); - if (HASEXCEPTION()) - { - goto ruleT__21Ex; - } - - - } - - LEXSTATE->type = _type; - // This is where rules clean up and exit - // - goto ruleT__21Ex; /* Prevent compiler warnings */ - ruleT__21Ex: ; - -} -// $ANTLR end T__21 - -// Comes from: 20:7: ( '=' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start T__22 - * - * Looks to match the characters the constitute the token T__22 - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mT__22(pEquationSystemLexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = T__22; - - - // EquationSystem.g:20:7: ( '=' ) - // EquationSystem.g:20:9: '=' - { - MATCHC('='); - if (HASEXCEPTION()) - { - goto ruleT__22Ex; - } - - - } - - LEXSTATE->type = _type; - // This is where rules clean up and exit - // - goto ruleT__22Ex; /* Prevent compiler warnings */ - ruleT__22Ex: ; - -} -// $ANTLR end T__22 - -// Comes from: 37:8: ( ( DIGIT )+ ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start NUMBER - * - * Looks to match the characters the constitute the token NUMBER - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mNUMBER(pEquationSystemLexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = NUMBER; - - - // EquationSystem.g:37:8: ( ( DIGIT )+ ) - // EquationSystem.g:37:10: ( DIGIT )+ - { - // EquationSystem.g:37:10: ( DIGIT )+ - { - int cnt1=0; - - for (;;) - { - int alt1=2; - switch ( LA(1) ) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - alt1=1; - } - break; - - } - - switch (alt1) - { - case 1: - // EquationSystem.g: - { - if ( ((LA(1) >= '0') && (LA(1) <= '9')) ) - { - CONSUME(); - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - LRECOVER(); - goto ruleNUMBEREx; - } - - - } - break; - - default: - - if ( cnt1 >= 1 ) - { - goto loop1; - } - /* mismatchedSetEx() - */ - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME; - - - goto ruleNUMBEREx; - } - cnt1++; - } - loop1: ; /* Jump to here if this rule does not match */ - } - - } - - LEXSTATE->type = _type; - // This is where rules clean up and exit - // - goto ruleNUMBEREx; /* Prevent compiler warnings */ - ruleNUMBEREx: ; - -} -// $ANTLR end NUMBER - -// Comes from: 38:9: ( ( LETTER ) ( LETTER | DIGIT )* ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start VARIABLE - * - * Looks to match the characters the constitute the token VARIABLE - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mVARIABLE(pEquationSystemLexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = VARIABLE; - - - // EquationSystem.g:38:9: ( ( LETTER ) ( LETTER | DIGIT )* ) - // EquationSystem.g:38:11: ( LETTER ) ( LETTER | DIGIT )* - { - if ( ((LA(1) >= 'a') && (LA(1) <= 'z')) ) - { - CONSUME(); - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - LRECOVER(); - goto ruleVARIABLEEx; - } - - - // EquationSystem.g:38:20: ( LETTER | DIGIT )* - - for (;;) - { - int alt2=2; - switch ( LA(1) ) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': - { - alt2=1; - } - break; - - } - - switch (alt2) - { - case 1: - // EquationSystem.g: - { - if ( ((LA(1) >= '0') && (LA(1) <= '9')) || ((LA(1) >= 'a') && (LA(1) <= 'z')) ) - { - CONSUME(); - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - LRECOVER(); - goto ruleVARIABLEEx; - } - - - } - break; - - default: - goto loop2; /* break out of the loop */ - break; - } - } - loop2: ; /* Jump out to here if this rule does not match */ - - - } - - LEXSTATE->type = _type; - // This is where rules clean up and exit - // - goto ruleVARIABLEEx; /* Prevent compiler warnings */ - ruleVARIABLEEx: ; - -} -// $ANTLR end VARIABLE - -// Comes from: 39:12: ( ( '\\t' | ' ' | '\\u000C' )+ ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start WHITESPACE - * - * Looks to match the characters the constitute the token WHITESPACE - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mWHITESPACE(pEquationSystemLexer ctx) -{ - ANTLR3_UINT32 _type; - - _type = WHITESPACE; - - - // EquationSystem.g:39:12: ( ( '\\t' | ' ' | '\\u000C' )+ ) - // EquationSystem.g:39:14: ( '\\t' | ' ' | '\\u000C' )+ - { - // EquationSystem.g:39:14: ( '\\t' | ' ' | '\\u000C' )+ - { - int cnt3=0; - - for (;;) - { - int alt3=2; - switch ( LA(1) ) - { - case '\t': - case '\f': - case ' ': - { - alt3=1; - } - break; - - } - - switch (alt3) - { - case 1: - // EquationSystem.g: - { - if ( LA(1) == '\t' || LA(1) == '\f' || LA(1) == ' ' ) - { - CONSUME(); - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - LRECOVER(); - goto ruleWHITESPACEEx; - } - - - } - break; - - default: - - if ( cnt3 >= 1 ) - { - goto loop3; - } - /* mismatchedSetEx() - */ - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME; - - - goto ruleWHITESPACEEx; - } - cnt3++; - } - loop3: ; /* Jump to here if this rule does not match */ - } - - { - - LEXSTATE->channel = HIDDEN; - - } - - - } - - LEXSTATE->type = _type; - // This is where rules clean up and exit - // - goto ruleWHITESPACEEx; /* Prevent compiler warnings */ - ruleWHITESPACEEx: ; - -} -// $ANTLR end WHITESPACE - -// Comes from: 46:7: ( '0' .. '9' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start DIGIT - * - * Looks to match the characters the constitute the token DIGIT - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mDIGIT(pEquationSystemLexer ctx) -{ - ANTLR3_UINT32 _type; - - - // EquationSystem.g:46:7: ( '0' .. '9' ) - // EquationSystem.g: - { - if ( ((LA(1) >= '0') && (LA(1) <= '9')) ) - { - CONSUME(); - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - LRECOVER(); - goto ruleDIGITEx; - } - - - } - - - // This is where rules clean up and exit - // - goto ruleDIGITEx; /* Prevent compiler warnings */ - ruleDIGITEx: ; - -} -// $ANTLR end DIGIT - -// Comes from: 48:7: ( 'a' .. 'z' ) -/** \brief Lexer rule generated by ANTLR3 - * - * $ANTLR start LETTER - * - * Looks to match the characters the constitute the token LETTER - * from the attached input stream. - * - * - * \remark - * - lexer->error == ANTLR3_TRUE if an exception was thrown. - */ -static ANTLR3_INLINE -void mLETTER(pEquationSystemLexer ctx) -{ - ANTLR3_UINT32 _type; - - - // EquationSystem.g:48:7: ( 'a' .. 'z' ) - // EquationSystem.g: - { - if ( ((LA(1) >= 'a') && (LA(1) <= 'z')) ) - { - CONSUME(); - } - else - { - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; - EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; - - LRECOVER(); - goto ruleLETTEREx; - } - - - } - - - // This is where rules clean up and exit - // - goto ruleLETTEREx; /* Prevent compiler warnings */ - ruleLETTEREx: ; - -} -// $ANTLR end LETTER - -/** This is the entry point in to the lexer from an object that - * wants to generate the next token, such as a pCOMMON_TOKEN_STREAM - */ -static void -mTokens(pEquationSystemLexer ctx) -{ - { - // EquationSystem.g:1:8: ( COMMA | GREATER_EQUAL | GUARD | MAXIMUM | MINIMUM | MULT | NEWLINE | PLUS | QUESTION_MARK | SUB | T__19 | T__20 | T__21 | T__22 | NUMBER | VARIABLE | WHITESPACE ) - - ANTLR3_UINT32 alt4; - - alt4=17; - - switch ( LA(1) ) - { - case ';': - { - alt4=1; - } - break; - case '>': - { - alt4=2; - } - break; - case 'g': - { - switch ( LA(2) ) - { - case 'u': - { - switch ( LA(3) ) - { - case 'a': - { - switch ( LA(4) ) - { - case 'r': - { - switch ( LA(5) ) - { - case 'd': - { - switch ( LA(6) ) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': - { - alt4=16; - } - break; - - default: - alt4=3; - } - - } - break; - - default: - alt4=16; - } - - } - break; - - default: - alt4=16; - } - - } - break; - - default: - alt4=16; - } - - } - break; - - default: - alt4=16; - } - - } - break; - case 'm': - { - switch ( LA(2) ) - { - case 'a': - { - switch ( LA(3) ) - { - case 'x': - { - switch ( LA(4) ) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': - { - alt4=16; - } - break; - - default: - alt4=4; - } - - } - break; - - default: - alt4=16; - } - - } - break; - case 'i': - { - switch ( LA(3) ) - { - case 'n': - { - switch ( LA(4) ) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': - { - alt4=16; - } - break; - - default: - alt4=5; - } - - } - break; - - default: - alt4=16; - } - - } - break; - - default: - alt4=16; - } - - } - break; - case '*': - { - alt4=6; - } - break; - case '\n': - { - alt4=7; - } - break; - case '+': - { - alt4=8; - } - break; - case '?': - { - alt4=9; - } - break; - case '-': - { - alt4=10; - } - break; - case '(': - { - alt4=11; - } - break; - case ')': - { - alt4=12; - } - break; - case ',': - { - alt4=13; - } - break; - case '=': - { - alt4=14; - } - break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - alt4=15; - } - break; - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': - { - alt4=16; - } - break; - case '\t': - case '\f': - case ' ': - { - alt4=17; - } - break; - - default: - CONSTRUCTEX(); - EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; - EXCEPTION->message = (void *)""; - EXCEPTION->decisionNum = 4; - EXCEPTION->state = 0; - - - goto ruleTokensEx; - - } - - switch (alt4) - { - case 1: - // EquationSystem.g:1:10: COMMA - { - /* 1:10: COMMA */ - mCOMMA(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - - } - break; - case 2: - // EquationSystem.g:1:16: GREATER_EQUAL - { - /* 1:16: GREATER_EQUAL */ - mGREATER_EQUAL(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - - } - break; - case 3: - // EquationSystem.g:1:30: GUARD - { - /* 1:30: GUARD */ - mGUARD(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - - } - break; - case 4: - // EquationSystem.g:1:36: MAXIMUM - { - /* 1:36: MAXIMUM */ - mMAXIMUM(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - - } - break; - case 5: - // EquationSystem.g:1:44: MINIMUM - { - /* 1:44: MINIMUM */ - mMINIMUM(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - - } - break; - case 6: - // EquationSystem.g:1:52: MULT - { - /* 1:52: MULT */ - mMULT(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - - } - break; - case 7: - // EquationSystem.g:1:57: NEWLINE - { - /* 1:57: NEWLINE */ - mNEWLINE(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - - } - break; - case 8: - // EquationSystem.g:1:65: PLUS - { - /* 1:65: PLUS */ - mPLUS(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - - } - break; - case 9: - // EquationSystem.g:1:70: QUESTION_MARK - { - /* 1:70: QUESTION_MARK */ - mQUESTION_MARK(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - - } - break; - case 10: - // EquationSystem.g:1:84: SUB - { - /* 1:84: SUB */ - mSUB(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - - } - break; - case 11: - // EquationSystem.g:1:88: T__19 - { - /* 1:88: T__19 */ - mT__19(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - - } - break; - case 12: - // EquationSystem.g:1:94: T__20 - { - /* 1:94: T__20 */ - mT__20(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - - } - break; - case 13: - // EquationSystem.g:1:100: T__21 - { - /* 1:100: T__21 */ - mT__21(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - - } - break; - case 14: - // EquationSystem.g:1:106: T__22 - { - /* 1:106: T__22 */ - mT__22(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - - } - break; - case 15: - // EquationSystem.g:1:112: NUMBER - { - /* 1:112: NUMBER */ - mNUMBER(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - - } - break; - case 16: - // EquationSystem.g:1:119: VARIABLE - { - /* 1:119: VARIABLE */ - mVARIABLE(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - - } - break; - case 17: - // EquationSystem.g:1:128: WHITESPACE - { - /* 1:128: WHITESPACE */ - mWHITESPACE(ctx ); - if (HASEXCEPTION()) - { - goto ruleTokensEx; - } - - - - } - break; - - } - } - - - goto ruleTokensEx; /* Prevent compiler warnings */ -ruleTokensEx: ; -} - -/* ========================================================================= - * Lexer matching rules end. - * ========================================================================= - */ -/* End of Lexer code - * ================================================ - * ================================================ - */ - - -/* End of code - * ============================================================================= - */ -- cgit v1.2.3