-/** \file\r
- * This C source file was generated by $ANTLR version 3.2 Sep 23, 2009 12:02:23\r
- *\r
- * - From the grammar source file : Lang.g\r
- * - On : 2010-02-24 13:27:55\r
- * - for the lexer : LangLexerLexer *\r
- * Editing it, at least manually, is not wise. \r
- *\r
- * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.\r
- *\r
- *\r
-*/\r
-// [The "BSD licence"]\r
-// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC\r
-// http://www.temporal-wave.com\r
-// http://www.linkedin.com/in/jimidle\r
-//\r
-// All rights reserved.\r
-//\r
-// Redistribution and use in source and binary forms, with or without\r
-// modification, are permitted provided that the following conditions\r
-// are met:\r
-// 1. Redistributions of source code must retain the above copyright\r
-// notice, this list of conditions and the following disclaimer.\r
-// 2. Redistributions in binary form must reproduce the above copyright\r
-// notice, this list of conditions and the following disclaimer in the\r
-// documentation and/or other materials provided with the distribution.\r
-// 3. The name of the author may not be used to endorse or promote products\r
-// derived from this software without specific prior written permission.\r
-//\r
-// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\r
-// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\r
-// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\r
-// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
-// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\r
-// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\r
-/* -----------------------------------------\r
- * Include the ANTLR3 generated header file.\r
- */\r
-#include "LangLexer.h"\r
-/* ----------------------------------------- */\r
-\r
-\r
-/** String literals used by LangLexer that we must do things like MATCHS() with.\r
- * C will normally just lay down 8 bit characters, and you can use L"xxx" to\r
- * get wchar_t, but wchar_t is 16 bits on Windows, which is not UTF32 and so\r
- * we perform this little trick of defining the literals as arrays of UINT32\r
- * and passing in the address of these.\r
- */\r
-static ANTLR3_UCHAR lit_1[] = { 0x69, 0x6E, 0x74, ANTLR3_STRING_TERMINATOR};\r
-static ANTLR3_UCHAR lit_2[] = { 0x66, 0x6C, 0x6F, 0x61, 0x74, ANTLR3_STRING_TERMINATOR};\r
-\r
-\r
-\r
-\r
-/* MACROS that hide the C interface implementations from the\r
- * generated code, which makes it a little more understandable to the human eye.\r
- * I am very much against using C pre-processor macros for function calls and bits\r
- * of code as you cannot see what is happening when single stepping in debuggers\r
- * and so on. The exception (in my book at least) is for generated code, where you are\r
- * not maintaining it, but may wish to read and understand it. If you single step it, you know that input()\r
- * hides some indirect calls, but is always referring to the input stream. This is\r
- * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig\r
- * the runtime interfaces without changing the generated code too often, without\r
- * confusing the reader of the generated output, who may not wish to know the gory\r
- * details of the interface inheritance.\r
- */\r
- \r
-#define CTX ctx\r
-\r
-/* Aids in accessing scopes for grammar programmers\r
- */\r
-#undef SCOPE_TYPE\r
-#undef SCOPE_STACK\r
-#undef SCOPE_TOP\r
-#define SCOPE_TYPE(scope) pLangLexer_##scope##_SCOPE\r
-#define SCOPE_STACK(scope) pLangLexer_##scope##Stack\r
-#define SCOPE_TOP(scope) ctx->pLangLexer_##scope##Top\r
-#define SCOPE_SIZE(scope) ctx->pLangLexer_##scope##Stack_limit\r
-#define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i))\r
-\r
- \r
-/* Macros for accessing things in a lexer\r
- */\r
-#undef LEXER\r
-#undef RECOGNIZER \r
-#undef RULEMEMO \r
-#undef GETCHARINDEX\r
-#undef GETLINE\r
-#undef GETCHARPOSITIONINLINE\r
-#undef EMIT\r
-#undef EMITNEW\r
-#undef MATCHC\r
-#undef MATCHS\r
-#undef MATCHRANGE\r
-#undef LTOKEN\r
-#undef HASFAILED\r
-#undef FAILEDFLAG\r
-#undef INPUT\r
-#undef STRSTREAM\r
-#undef LA\r
-#undef HASEXCEPTION\r
-#undef EXCEPTION\r
-#undef CONSTRUCTEX\r
-#undef CONSUME\r
-#undef LRECOVER\r
-#undef MARK\r
-#undef REWIND\r
-#undef REWINDLAST\r
-#undef BACKTRACKING\r
-#undef MATCHANY\r
-#undef MEMOIZE\r
-#undef HAVEPARSEDRULE\r
-#undef GETTEXT\r
-#undef INDEX\r
-#undef SEEK\r
-#undef PUSHSTREAM\r
-#undef POPSTREAM\r
-#undef SETTEXT\r
-#undef SETTEXT8\r
-\r
-#define LEXER ctx->pLexer\r
-#define RECOGNIZER LEXER->rec\r
-#define LEXSTATE RECOGNIZER->state\r
-#define TOKSOURCE LEXSTATE->tokSource\r
-#define GETCHARINDEX() LEXER->getCharIndex(LEXER)\r
-#define GETLINE() LEXER->getLine(LEXER)\r
-#define GETTEXT() LEXER->getText(LEXER)\r
-#define GETCHARPOSITIONINLINE() LEXER->getCharPositionInLine(LEXER)\r
-#define EMIT() LEXSTATE->type = _type; LEXER->emit(LEXER)\r
-#define EMITNEW(t) LEXER->emitNew(LEXER, t)\r
-#define MATCHC(c) LEXER->matchc(LEXER, c)\r
-#define MATCHS(s) LEXER->matchs(LEXER, s)\r
-#define MATCHRANGE(c1,c2) LEXER->matchRange(LEXER, c1, c2)\r
-#define MATCHANY() LEXER->matchAny(LEXER)\r
-#define LTOKEN LEXSTATE->token\r
-#define HASFAILED() (LEXSTATE->failed == ANTLR3_TRUE)\r
-#define BACKTRACKING LEXSTATE->backtracking\r
-#define FAILEDFLAG LEXSTATE->failed\r
-#define INPUT LEXER->input\r
-#define STRSTREAM INPUT\r
-#define ISTREAM INPUT->istream\r
-#define INDEX() ISTREAM->index(ISTREAM)\r
-#define SEEK(n) ISTREAM->seek(ISTREAM, n)\r
-#define EOF_TOKEN &(LEXSTATE->tokSource->eofToken)\r
-#define HASEXCEPTION() (LEXSTATE->error == ANTLR3_TRUE)\r
-#define EXCEPTION LEXSTATE->exception\r
-#define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER)\r
-#define LRECOVER() LEXER->recover(LEXER)\r
-#define MARK() ISTREAM->mark(ISTREAM)\r
-#define REWIND(m) ISTREAM->rewind(ISTREAM, m)\r
-#define REWINDLAST() ISTREAM->rewindLast(ISTREAM)\r
-#define MEMOIZE(ri,si) RECOGNIZER->memoize(RECOGNIZER, ri, si)\r
-#define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r)\r
-#define PUSHSTREAM(str) LEXER->pushCharStream(LEXER, str)\r
-#define POPSTREAM() LEXER->popCharStream(LEXER)\r
-#define SETTEXT(str) LEXSTATE->text = str\r
-#define SKIP() LEXSTATE->token = &(TOKSOURCE->skipToken)\r
-#define USER1 LEXSTATE->user1\r
-#define USER2 LEXSTATE->user2\r
-#define USER3 LEXSTATE->user3\r
-#define CUSTOM LEXSTATE->custom\r
-#define RULEMEMO LEXSTATE->ruleMemo\r
-#define DBG RECOGNIZER->debugger\r
-\r
-/* If we have been told we can rely on the standard 8 bit or 16 bit input\r
- * stream, then we can define our macros to use the direct pointers\r
- * in the input object, which is much faster than indirect calls. This\r
- * is really only significant to lexers with a lot of fragment rules (which\r
- * do not place LA(1) in a temporary at the moment) and even then\r
- * only if there is a lot of input (order of say 1M or so).\r
- */\r
-#if defined(ANTLR3_INLINE_INPUT_ASCII) || defined(ANTLR3_INLINE_INPUT_UTF16)\r
-\r
-# ifdef ANTLR3_INLINE_INPUT_ASCII\r
-\r
-/* 8 bit "ASCII" (actually any 8 bit character set) */\r
-\r
-# define NEXTCHAR ((pANTLR3_UINT8)(INPUT->nextChar))\r
-# define DATAP ((pANTLR3_UINT8)(INPUT->data))\r
-\r
-# else\r
-\r
-# define NEXTCHAR ((pANTLR3_UINT16)(INPUT->nextChar)) \r
-# define DATAP ((pANTLR3_UINT16)(INPUT->data))\r
-\r
-# endif\r
-\r
-# define LA(n) ((NEXTCHAR + n) > (DATAP + INPUT->sizeBuf) ? ANTLR3_CHARSTREAM_EOF : (ANTLR3_UCHAR)(*(NEXTCHAR + n - 1)))\r
-# define CONSUME() \\r
-{ \\r
- if (NEXTCHAR < (DATAP + INPUT->sizeBuf)) \\r
- { \\r
- INPUT->charPositionInLine++; \\r
- if ((ANTLR3_UCHAR)(*NEXTCHAR) == INPUT->newlineChar) \\r
- { \\r
- INPUT->line++; \\r
- INPUT->charPositionInLine = 0; \\r
- INPUT->currentLine = (void *)(NEXTCHAR + 1); \\r
- } \\r
- INPUT->nextChar = (void *)(NEXTCHAR + 1); \\r
- } \\r
-}\r
-\r
-#else\r
-\r
-// Pick up the input character by calling the input stream implementation.\r
-//\r
-#define CONSUME() INPUT->istream->consume(INPUT->istream)\r
-#define LA(n) INPUT->istream->_LA(INPUT->istream, n)\r
-\r
-#endif\r
-#define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt\r
-\r
-/* The 4 tokens defined below may well clash with your own #defines or token types. If so\r
- * then for the present you must use different names for your defines as these are hard coded\r
- * in the code generator. It would be better not to use such names internally, and maybe\r
- * we can change this in a forthcoming release. I deliberately do not #undef these\r
- * here as this will at least give you a redefined error somewhere if they clash.\r
- */\r
-#define UP ANTLR3_TOKEN_UP\r
-#define DOWN ANTLR3_TOKEN_DOWN\r
-#define EOR ANTLR3_TOKEN_EOR\r
-#define INVALID ANTLR3_TOKEN_INVALID\r
-\r
-\r
-/* =============================================================================\r
- * Functions to create and destroy scopes. First come the rule scopes, followed\r
- * by the global declared scopes.\r
- */\r
-\r
-\r
-\r
-/* ============================================================================= */\r
-\r
-/* =============================================================================\r
- * Start of recognizer\r
- */\r
-\r
-\r
-/* Forward declare the locally static matching functions we have generated and any predicate functions.\r
- */\r
-static ANTLR3_INLINE void mT__10 (pLangLexer ctx);\r
-static ANTLR3_INLINE void mINTTYPE (pLangLexer ctx);\r
-static ANTLR3_INLINE void mFLOATTYPE (pLangLexer ctx);\r
-static ANTLR3_INLINE void mID (pLangLexer ctx);\r
-static ANTLR3_INLINE void mINT (pLangLexer ctx);\r
-static ANTLR3_INLINE void mWS (pLangLexer ctx);\r
-static ANTLR3_INLINE void mTokens (pLangLexer ctx);\r
-static void LangLexerFree(pLangLexer ctx);\r
-\r
-/* =========================================================================\r
- * Lexer matching rules end.\r
- * =========================================================================\r
- */\r
-\r
-\r
-\r
-static void\r
-LangLexerFree (pLangLexer ctx)\r
-{\r
- LEXER->free(LEXER);\r
- \r
- ANTLR3_FREE(ctx);\r
-}\r
-\r
-/** \brief Name of the grammar file that generated this code\r
- */\r
-static const char fileName[] = "Lang.g";\r
-\r
-/** \brief Return the name of the grammar file that generated this code.\r
- */\r
-static const char * getGrammarFileName()\r
-{\r
- return fileName;\r
-}\r
-\r
-/** \brief Create a new lexer called LangLexer\r
- *\r
- * \param[in] instream Pointer to an initialized input stream\r
- * \return \r
- * - Success pLangLexer initialized for the lex start\r
- * - Fail NULL\r
- */\r
-ANTLR3_API pLangLexer LangLexerNew \r
-(pANTLR3_INPUT_STREAM instream)\r
-{\r
- // See if we can create a new lexer with the standard constructor\r
- //\r
- return LangLexerNewSSD(instream, NULL);\r
-}\r
-\r
-/** \brief Create a new lexer called LangLexer\r
- *\r
- * \param[in] instream Pointer to an initialized input stream\r
- * \param[state] state Previously created shared recognizer stat\r
- * \return \r
- * - Success pLangLexer initialized for the lex start\r
- * - Fail NULL\r
- */\r
-ANTLR3_API pLangLexer LangLexerNewSSD \r
-(pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state)\r
-{\r
- pLangLexer ctx; // Context structure we will build and return\r
-\r
- ctx = (pLangLexer) ANTLR3_CALLOC(1, sizeof(LangLexer));\r
-\r
- if (ctx == NULL)\r
- {\r
- // Failed to allocate memory for lexer context\r
- return NULL;\r
- }\r
-\r
- /* -------------------------------------------------------------------\r
- * Memory for basic structure is allocated, now to fill in\r
- * in base ANTLR3 structures. We initialize the function pointers\r
- * for the standard ANTLR3 lexer function set, but upon return\r
- * from here, the programmer may set the pointers to provide custom\r
- * implementations of each function. \r
- *\r
- * We don't use the macros defined in LangLexer.h here so you can get a sense\r
- * of what goes where.\r
- */\r
- \r
- /* Create a base lexer, using the supplied input stream\r
- */\r
- ctx->pLexer = antlr3LexerNewStream(ANTLR3_SIZE_HINT, instream, state);\r
- \r
- /* Check that we allocated the memory correctly\r
- */\r
- if (ctx->pLexer == NULL)\r
- {\r
- ANTLR3_FREE(ctx);\r
- return NULL;\r
- }\r
- /* Install the implementation of our LangLexer interface\r
- */\r
- ctx->mT__10 = mT__10;\r
- ctx->mINTTYPE = mINTTYPE;\r
- ctx->mFLOATTYPE = mFLOATTYPE;\r
- ctx->mID = mID;\r
- ctx->mINT = mINT;\r
- ctx->mWS = mWS;\r
- ctx->mTokens = mTokens;\r
- \r
- /** When the nextToken() call is made to this lexer's pANTLR3_TOKEN_SOURCE\r
- * it will call mTokens() in this generated code, and will pass it the ctx\r
- * pointer of this lexer, not the context of the base lexer, so store that now.\r
- */\r
- ctx->pLexer->ctx = ctx;\r
- \r
- /**Install the token matching function\r
- */\r
- ctx->pLexer->mTokens = (void (*) (void *))(mTokens);\r
- \r
- ctx->getGrammarFileName = getGrammarFileName;\r
- ctx->free = LangLexerFree;\r
-\r
- \r
- \r
-\r
-\r
- /* Return the newly built lexer to the caller\r
- */\r
- return ctx;\r
-}\r
- \r
-\r
-/* =========================================================================\r
- * Functions to match the lexer grammar defined tokens from the input stream\r
- */\r
-\r
-// Comes from: 7:7: ( ';' )\r
-/** \brief Lexer rule generated by ANTLR3\r
- *\r
- * $ANTLR start T__10\r
- *\r
- * Looks to match the characters the constitute the token T__10\r
- * from the attached input stream.\r
- *\r
- *\r
- * \remark\r
- * - lexer->error == ANTLR3_TRUE if an exception was thrown.\r
- */\r
-static ANTLR3_INLINE\r
-void mT__10(pLangLexer ctx)\r
-{\r
- ANTLR3_UINT32 _type;\r
-\r
- _type = T__10;\r
- \r
- \r
- // Lang.g:7:7: ( ';' )\r
- // Lang.g:7:9: ';'\r
- {\r
- MATCHC(';'); \r
- if (HASEXCEPTION())\r
- {\r
- goto ruleT__10Ex;\r
- }\r
-\r
-\r
- }\r
-\r
- LEXSTATE->type = _type;\r
-\r
- // This is where rules clean up and exit\r
- //\r
- goto ruleT__10Ex; /* Prevent compiler warnings */\r
- ruleT__10Ex: ;\r
-\r
-}\r
-// $ANTLR end T__10\r
-\r
-// Comes from: 30:13: ( 'int' )\r
-/** \brief Lexer rule generated by ANTLR3\r
- *\r
- * $ANTLR start INTTYPE\r
- *\r
- * Looks to match the characters the constitute the token INTTYPE\r
- * from the attached input stream.\r
- *\r
- *\r
- * \remark\r
- * - lexer->error == ANTLR3_TRUE if an exception was thrown.\r
- */\r
-static ANTLR3_INLINE\r
-void mINTTYPE(pLangLexer ctx)\r
-{\r
- ANTLR3_UINT32 _type;\r
-\r
- _type = INTTYPE;\r
- \r
- \r
- // Lang.g:30:13: ( 'int' )\r
- // Lang.g:30:15: 'int'\r
- {\r
- MATCHS(lit_1); \r
- if (HASEXCEPTION())\r
- {\r
- goto ruleINTTYPEEx;\r
- }\r
-\r
-\r
-\r
- }\r
-\r
- LEXSTATE->type = _type;\r
-\r
- // This is where rules clean up and exit\r
- //\r
- goto ruleINTTYPEEx; /* Prevent compiler warnings */\r
- ruleINTTYPEEx: ;\r
-\r
-}\r
-// $ANTLR end INTTYPE\r
-\r
-// Comes from: 31:13: ( 'float' )\r
-/** \brief Lexer rule generated by ANTLR3\r
- *\r
- * $ANTLR start FLOATTYPE\r
- *\r
- * Looks to match the characters the constitute the token FLOATTYPE\r
- * from the attached input stream.\r
- *\r
- *\r
- * \remark\r
- * - lexer->error == ANTLR3_TRUE if an exception was thrown.\r
- */\r
-static ANTLR3_INLINE\r
-void mFLOATTYPE(pLangLexer ctx)\r
-{\r
- ANTLR3_UINT32 _type;\r
-\r
- _type = FLOATTYPE;\r
- \r
- \r
- // Lang.g:31:13: ( 'float' )\r
- // Lang.g:31:15: 'float'\r
- {\r
- MATCHS(lit_2); \r
- if (HASEXCEPTION())\r
- {\r
- goto ruleFLOATTYPEEx;\r
- }\r
-\r
-\r
-\r
- }\r
-\r
- LEXSTATE->type = _type;\r
-\r
- // This is where rules clean up and exit\r
- //\r
- goto ruleFLOATTYPEEx; /* Prevent compiler warnings */\r
- ruleFLOATTYPEEx: ;\r
-\r
-}\r
-// $ANTLR end FLOATTYPE\r
-\r
-// Comes from: 32:8: ( ( 'a' .. 'z' )+ )\r
-/** \brief Lexer rule generated by ANTLR3\r
- *\r
- * $ANTLR start ID\r
- *\r
- * Looks to match the characters the constitute the token ID\r
- * from the attached input stream.\r
- *\r
- *\r
- * \remark\r
- * - lexer->error == ANTLR3_TRUE if an exception was thrown.\r
- */\r
-static ANTLR3_INLINE\r
-void mID(pLangLexer ctx)\r
-{\r
- ANTLR3_UINT32 _type;\r
-\r
- _type = ID;\r
- \r
- \r
- // Lang.g:32:8: ( ( 'a' .. 'z' )+ )\r
- // Lang.g:32:10: ( 'a' .. 'z' )+\r
- {\r
- // Lang.g:32:10: ( 'a' .. 'z' )+\r
- {\r
- int cnt1=0;\r
-\r
- for (;;)\r
- {\r
- int alt1=2;\r
- switch ( LA(1) ) \r
- {\r
- case 'a':\r
- case 'b':\r
- case 'c':\r
- case 'd':\r
- case 'e':\r
- case 'f':\r
- case 'g':\r
- case 'h':\r
- case 'i':\r
- case 'j':\r
- case 'k':\r
- case 'l':\r
- case 'm':\r
- case 'n':\r
- case 'o':\r
- case 'p':\r
- case 'q':\r
- case 'r':\r
- case 's':\r
- case 't':\r
- case 'u':\r
- case 'v':\r
- case 'w':\r
- case 'x':\r
- case 'y':\r
- case 'z':\r
- {\r
- alt1=1;\r
- }\r
- break;\r
-\r
- }\r
-\r
- switch (alt1) \r
- {\r
- case 1:\r
- // Lang.g:32:10: 'a' .. 'z'\r
- {\r
- MATCHRANGE('a', 'z'); \r
- if (HASEXCEPTION())\r
- {\r
- goto ruleIDEx;\r
- }\r
-\r
-\r
- }\r
- break;\r
-\r
- default:\r
- \r
- if ( cnt1 >= 1 )\r
- {\r
- goto loop1;\r
- }\r
- /* mismatchedSetEx()\r
- */\r
- CONSTRUCTEX();\r
- EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION;\r
- EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME;\r
-\r
-\r
- goto ruleIDEx;\r
- }\r
- cnt1++;\r
- }\r
- loop1: ; /* Jump to here if this rule does not match */\r
- }\r
-\r
- }\r
-\r
- LEXSTATE->type = _type;\r
-\r
- // This is where rules clean up and exit\r
- //\r
- goto ruleIDEx; /* Prevent compiler warnings */\r
- ruleIDEx: ;\r
-\r
-}\r
-// $ANTLR end ID\r
-\r
-// Comes from: 33:9: ( ( '0' .. '9' )+ )\r
-/** \brief Lexer rule generated by ANTLR3\r
- *\r
- * $ANTLR start INT\r
- *\r
- * Looks to match the characters the constitute the token INT\r
- * from the attached input stream.\r
- *\r
- *\r
- * \remark\r
- * - lexer->error == ANTLR3_TRUE if an exception was thrown.\r
- */\r
-static ANTLR3_INLINE\r
-void mINT(pLangLexer ctx)\r
-{\r
- ANTLR3_UINT32 _type;\r
-\r
- _type = INT;\r
- \r
- \r
- // Lang.g:33:9: ( ( '0' .. '9' )+ )\r
- // Lang.g:33:11: ( '0' .. '9' )+\r
- {\r
- // Lang.g:33:11: ( '0' .. '9' )+\r
- {\r
- int cnt2=0;\r
-\r
- for (;;)\r
- {\r
- int alt2=2;\r
- switch ( LA(1) ) \r
- {\r
- case '0':\r
- case '1':\r
- case '2':\r
- case '3':\r
- case '4':\r
- case '5':\r
- case '6':\r
- case '7':\r
- case '8':\r
- case '9':\r
- {\r
- alt2=1;\r
- }\r
- break;\r
-\r
- }\r
-\r
- switch (alt2) \r
- {\r
- case 1:\r
- // Lang.g:33:11: '0' .. '9'\r
- {\r
- MATCHRANGE('0', '9'); \r
- if (HASEXCEPTION())\r
- {\r
- goto ruleINTEx;\r
- }\r
-\r
-\r
- }\r
- break;\r
-\r
- default:\r
- \r
- if ( cnt2 >= 1 )\r
- {\r
- goto loop2;\r
- }\r
- /* mismatchedSetEx()\r
- */\r
- CONSTRUCTEX();\r
- EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION;\r
- EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME;\r
-\r
-\r
- goto ruleINTEx;\r
- }\r
- cnt2++;\r
- }\r
- loop2: ; /* Jump to here if this rule does not match */\r
- }\r
-\r
- }\r
-\r
- LEXSTATE->type = _type;\r
-\r
- // This is where rules clean up and exit\r
- //\r
- goto ruleINTEx; /* Prevent compiler warnings */\r
- ruleINTEx: ;\r
-\r
-}\r
-// $ANTLR end INT\r
-\r
-// Comes from: 34:8: ( ( ' ' | '\\n' | '\\r' ) )\r
-/** \brief Lexer rule generated by ANTLR3\r
- *\r
- * $ANTLR start WS\r
- *\r
- * Looks to match the characters the constitute the token WS\r
- * from the attached input stream.\r
- *\r
- *\r
- * \remark\r
- * - lexer->error == ANTLR3_TRUE if an exception was thrown.\r
- */\r
-static ANTLR3_INLINE\r
-void mWS(pLangLexer ctx)\r
-{\r
- ANTLR3_UINT32 _type;\r
-\r
- _type = WS;\r
- \r
- \r
- // Lang.g:34:8: ( ( ' ' | '\\n' | '\\r' ) )\r
- // Lang.g:34:10: ( ' ' | '\\n' | '\\r' )\r
- {\r
- if ( LA(1) == '\n' || LA(1) == '\r' || LA(1) == ' ' )\r
- {\r
- CONSUME();\r
-\r
- }\r
- else \r
- {\r
- CONSTRUCTEX();\r
- EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION;\r
- EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME;\r
-\r
- LRECOVER(); goto ruleWSEx;\r
- }\r
-\r
- {\r
- LEXSTATE->channel=HIDDEN;\r
- }\r
-\r
- }\r
-\r
- LEXSTATE->type = _type;\r
-\r
- // This is where rules clean up and exit\r
- //\r
- goto ruleWSEx; /* Prevent compiler warnings */\r
- ruleWSEx: ;\r
-\r
-}\r
-// $ANTLR end WS\r
-\r
-/** This is the entry point in to the lexer from an object that\r
- * wants to generate the next token, such as a pCOMMON_TOKEN_STREAM\r
- */\r
-static void \r
-mTokens(pLangLexer ctx)\r
-{\r
- {\r
- // Lang.g:1:8: ( T__10 | INTTYPE | FLOATTYPE | ID | INT | WS )\r
- \r
- ANTLR3_UINT32 alt3;\r
-\r
- alt3=6;\r
-\r
- switch ( LA(1) ) \r
- {\r
- case ';':\r
- {\r
- alt3=1;\r
- }\r
- break;\r
- case 'i':\r
- {\r
- switch ( LA(2) ) \r
- {\r
- case 'n':\r
- {\r
- switch ( LA(3) ) \r
- {\r
- case 't':\r
- {\r
- switch ( LA(4) ) \r
- {\r
- case 'a':\r
- case 'b':\r
- case 'c':\r
- case 'd':\r
- case 'e':\r
- case 'f':\r
- case 'g':\r
- case 'h':\r
- case 'i':\r
- case 'j':\r
- case 'k':\r
- case 'l':\r
- case 'm':\r
- case 'n':\r
- case 'o':\r
- case 'p':\r
- case 'q':\r
- case 'r':\r
- case 's':\r
- case 't':\r
- case 'u':\r
- case 'v':\r
- case 'w':\r
- case 'x':\r
- case 'y':\r
- case 'z':\r
- {\r
- alt3=4;\r
- }\r
- break;\r
-\r
- default:\r
- alt3=2;}\r
-\r
- }\r
- break;\r
-\r
- default:\r
- alt3=4;}\r
-\r
- }\r
- break;\r
-\r
- default:\r
- alt3=4;}\r
-\r
- }\r
- break;\r
- case 'f':\r
- {\r
- switch ( LA(2) ) \r
- {\r
- case 'l':\r
- {\r
- switch ( LA(3) ) \r
- {\r
- case 'o':\r
- {\r
- switch ( LA(4) ) \r
- {\r
- case 'a':\r
- {\r
- switch ( LA(5) ) \r
- {\r
- case 't':\r
- {\r
- switch ( LA(6) ) \r
- {\r
- case 'a':\r
- case 'b':\r
- case 'c':\r
- case 'd':\r
- case 'e':\r
- case 'f':\r
- case 'g':\r
- case 'h':\r
- case 'i':\r
- case 'j':\r
- case 'k':\r
- case 'l':\r
- case 'm':\r
- case 'n':\r
- case 'o':\r
- case 'p':\r
- case 'q':\r
- case 'r':\r
- case 's':\r
- case 't':\r
- case 'u':\r
- case 'v':\r
- case 'w':\r
- case 'x':\r
- case 'y':\r
- case 'z':\r
- {\r
- alt3=4;\r
- }\r
- break;\r
-\r
- default:\r
- alt3=3;}\r
-\r
- }\r
- break;\r
-\r
- default:\r
- alt3=4;}\r
-\r
- }\r
- break;\r
-\r
- default:\r
- alt3=4;}\r
-\r
- }\r
- break;\r
-\r
- default:\r
- alt3=4;}\r
-\r
- }\r
- break;\r
-\r
- default:\r
- alt3=4;}\r
-\r
- }\r
- break;\r
- case 'a':\r
- case 'b':\r
- case 'c':\r
- case 'd':\r
- case 'e':\r
- case 'g':\r
- case 'h':\r
- case 'j':\r
- case 'k':\r
- case 'l':\r
- case 'm':\r
- case 'n':\r
- case 'o':\r
- case 'p':\r
- case 'q':\r
- case 'r':\r
- case 's':\r
- case 't':\r
- case 'u':\r
- case 'v':\r
- case 'w':\r
- case 'x':\r
- case 'y':\r
- case 'z':\r
- {\r
- alt3=4;\r
- }\r
- break;\r
- case '0':\r
- case '1':\r
- case '2':\r
- case '3':\r
- case '4':\r
- case '5':\r
- case '6':\r
- case '7':\r
- case '8':\r
- case '9':\r
- {\r
- alt3=5;\r
- }\r
- break;\r
- case '\n':\r
- case '\r':\r
- case ' ':\r
- {\r
- alt3=6;\r
- }\r
- break;\r
-\r
- default:\r
- CONSTRUCTEX();\r
- EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;\r
- EXCEPTION->message = (void *)"";\r
- EXCEPTION->decisionNum = 3;\r
- EXCEPTION->state = 0;\r
-\r
-\r
- goto ruleTokensEx;\r
- }\r
-\r
- switch (alt3) \r
- {\r
- case 1:\r
- // Lang.g:1:10: T__10\r
- {\r
- /* 1:10: T__10 */\r
- mT__10(ctx ); \r
- if (HASEXCEPTION())\r
- {\r
- goto ruleTokensEx;\r
- }\r
-\r
-\r
- }\r
- break;\r
- case 2:\r
- // Lang.g:1:16: INTTYPE\r
- {\r
- /* 1:16: INTTYPE */\r
- mINTTYPE(ctx ); \r
- if (HASEXCEPTION())\r
- {\r
- goto ruleTokensEx;\r
- }\r
-\r
-\r
- }\r
- break;\r
- case 3:\r
- // Lang.g:1:24: FLOATTYPE\r
- {\r
- /* 1:24: FLOATTYPE */\r
- mFLOATTYPE(ctx ); \r
- if (HASEXCEPTION())\r
- {\r
- goto ruleTokensEx;\r
- }\r
-\r
-\r
- }\r
- break;\r
- case 4:\r
- // Lang.g:1:34: ID\r
- {\r
- /* 1:34: ID */\r
- mID(ctx ); \r
- if (HASEXCEPTION())\r
- {\r
- goto ruleTokensEx;\r
- }\r
-\r
-\r
- }\r
- break;\r
- case 5:\r
- // Lang.g:1:37: INT\r
- {\r
- /* 1:37: INT */\r
- mINT(ctx ); \r
- if (HASEXCEPTION())\r
- {\r
- goto ruleTokensEx;\r
- }\r
-\r
-\r
- }\r
- break;\r
- case 6:\r
- // Lang.g:1:41: WS\r
- {\r
- /* 1:41: WS */\r
- mWS(ctx ); \r
- if (HASEXCEPTION())\r
- {\r
- goto ruleTokensEx;\r
- }\r
-\r
-\r
- }\r
- break;\r
-\r
- }\r
- }\r
-\r
- \r
- goto ruleTokensEx; /* Prevent compiler warnings */\r
-ruleTokensEx: ;\r
-}\r
-\r
-/* =========================================================================\r
- * Lexer matching rules end.\r
- * =========================================================================\r
- */\r
-/* End of Lexer code\r
- * ================================================\r
- * ================================================\r
- */ \r
-\r
-\r
-/* End of code\r
- * =============================================================================\r
- */\r
+/** \file
+ * This C source file was generated by $ANTLR version 3.2 Sep 23, 2009 12:02:23
+ *
+ * - From the grammar source file : Lang.g
+ * - On : 2010-02-24 13:27:55
+ * - for the lexer : LangLexerLexer *
+ * Editing it, at least manually, is not wise.
+ *
+ * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
+ *
+ *
+*/
+// [The "BSD licence"]
+// 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 "LangLexer.h"
+/* ----------------------------------------- */
+
+
+/** String literals used by LangLexer 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[] = { 0x69, 0x6E, 0x74, ANTLR3_STRING_TERMINATOR};
+static ANTLR3_UCHAR lit_2[] = { 0x66, 0x6C, 0x6F, 0x61, 0x74, 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) pLangLexer_##scope##_SCOPE
+#define SCOPE_STACK(scope) pLangLexer_##scope##Stack
+#define SCOPE_TOP(scope) ctx->pLangLexer_##scope##Top
+#define SCOPE_SIZE(scope) ctx->pLangLexer_##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 16 bit 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_ASCII) || defined(ANTLR3_INLINE_INPUT_UTF16)
+
+# ifdef ANTLR3_INLINE_INPUT_ASCII
+
+/* 8 bit "ASCII" (actually any 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 mT__10 (pLangLexer ctx);
+static ANTLR3_INLINE void mINTTYPE (pLangLexer ctx);
+static ANTLR3_INLINE void mFLOATTYPE (pLangLexer ctx);
+static ANTLR3_INLINE void mID (pLangLexer ctx);
+static ANTLR3_INLINE void mINT (pLangLexer ctx);
+static ANTLR3_INLINE void mWS (pLangLexer ctx);
+static ANTLR3_INLINE void mTokens (pLangLexer ctx);
+static void LangLexerFree(pLangLexer ctx);
+
+/* =========================================================================
+ * Lexer matching rules end.
+ * =========================================================================
+ */
+
+
+
+static void
+LangLexerFree (pLangLexer ctx)
+{
+ LEXER->free(LEXER);
+
+ ANTLR3_FREE(ctx);
+}
+
+/** \brief Name of the grammar file that generated this code
+ */
+static const char fileName[] = "Lang.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 LangLexer
+ *
+ * \param[in] instream Pointer to an initialized input stream
+ * \return
+ * - Success pLangLexer initialized for the lex start
+ * - Fail NULL
+ */
+ANTLR3_API pLangLexer LangLexerNew
+(pANTLR3_INPUT_STREAM instream)
+{
+ // See if we can create a new lexer with the standard constructor
+ //
+ return LangLexerNewSSD(instream, NULL);
+}
+
+/** \brief Create a new lexer called LangLexer
+ *
+ * \param[in] instream Pointer to an initialized input stream
+ * \param[state] state Previously created shared recognizer stat
+ * \return
+ * - Success pLangLexer initialized for the lex start
+ * - Fail NULL
+ */
+ANTLR3_API pLangLexer LangLexerNewSSD
+(pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state)
+{
+ pLangLexer ctx; // Context structure we will build and return
+
+ ctx = (pLangLexer) ANTLR3_CALLOC(1, sizeof(LangLexer));
+
+ 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 LangLexer.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 LangLexer interface
+ */
+ ctx->mT__10 = mT__10;
+ ctx->mINTTYPE = mINTTYPE;
+ ctx->mFLOATTYPE = mFLOATTYPE;
+ ctx->mID = mID;
+ ctx->mINT = mINT;
+ ctx->mWS = mWS;
+ 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 = LangLexerFree;
+
+
+
+
+
+ /* 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 T__10
+ *
+ * Looks to match the characters the constitute the token T__10
+ * from the attached input stream.
+ *
+ *
+ * \remark
+ * - lexer->error == ANTLR3_TRUE if an exception was thrown.
+ */
+static ANTLR3_INLINE
+void mT__10(pLangLexer ctx)
+{
+ ANTLR3_UINT32 _type;
+
+ _type = T__10;
+
+
+ // Lang.g:7:7: ( ';' )
+ // Lang.g:7:9: ';'
+ {
+ MATCHC(';');
+ if (HASEXCEPTION())
+ {
+ goto ruleT__10Ex;
+ }
+
+
+ }
+
+ LEXSTATE->type = _type;
+
+ // This is where rules clean up and exit
+ //
+ goto ruleT__10Ex; /* Prevent compiler warnings */
+ ruleT__10Ex: ;
+
+}
+// $ANTLR end T__10
+
+// Comes from: 30:13: ( 'int' )
+/** \brief Lexer rule generated by ANTLR3
+ *
+ * $ANTLR start INTTYPE
+ *
+ * Looks to match the characters the constitute the token INTTYPE
+ * from the attached input stream.
+ *
+ *
+ * \remark
+ * - lexer->error == ANTLR3_TRUE if an exception was thrown.
+ */
+static ANTLR3_INLINE
+void mINTTYPE(pLangLexer ctx)
+{
+ ANTLR3_UINT32 _type;
+
+ _type = INTTYPE;
+
+
+ // Lang.g:30:13: ( 'int' )
+ // Lang.g:30:15: 'int'
+ {
+ MATCHS(lit_1);
+ if (HASEXCEPTION())
+ {
+ goto ruleINTTYPEEx;
+ }
+
+
+
+ }
+
+ LEXSTATE->type = _type;
+
+ // This is where rules clean up and exit
+ //
+ goto ruleINTTYPEEx; /* Prevent compiler warnings */
+ ruleINTTYPEEx: ;
+
+}
+// $ANTLR end INTTYPE
+
+// Comes from: 31:13: ( 'float' )
+/** \brief Lexer rule generated by ANTLR3
+ *
+ * $ANTLR start FLOATTYPE
+ *
+ * Looks to match the characters the constitute the token FLOATTYPE
+ * from the attached input stream.
+ *
+ *
+ * \remark
+ * - lexer->error == ANTLR3_TRUE if an exception was thrown.
+ */
+static ANTLR3_INLINE
+void mFLOATTYPE(pLangLexer ctx)
+{
+ ANTLR3_UINT32 _type;
+
+ _type = FLOATTYPE;
+
+
+ // Lang.g:31:13: ( 'float' )
+ // Lang.g:31:15: 'float'
+ {
+ MATCHS(lit_2);
+ if (HASEXCEPTION())
+ {
+ goto ruleFLOATTYPEEx;
+ }
+
+
+
+ }
+
+ LEXSTATE->type = _type;
+
+ // This is where rules clean up and exit
+ //
+ goto ruleFLOATTYPEEx; /* Prevent compiler warnings */
+ ruleFLOATTYPEEx: ;
+
+}
+// $ANTLR end FLOATTYPE
+
+// Comes from: 32:8: ( ( 'a' .. 'z' )+ )
+/** \brief Lexer rule generated by ANTLR3
+ *
+ * $ANTLR start ID
+ *
+ * Looks to match the characters the constitute the token ID
+ * from the attached input stream.
+ *
+ *
+ * \remark
+ * - lexer->error == ANTLR3_TRUE if an exception was thrown.
+ */
+static ANTLR3_INLINE
+void mID(pLangLexer ctx)
+{
+ ANTLR3_UINT32 _type;
+
+ _type = ID;
+
+
+ // Lang.g:32:8: ( ( 'a' .. 'z' )+ )
+ // Lang.g:32:10: ( 'a' .. 'z' )+
+ {
+ // Lang.g:32:10: ( 'a' .. 'z' )+
+ {
+ int cnt1=0;
+
+ for (;;)
+ {
+ int alt1=2;
+ switch ( LA(1) )
+ {
+ 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':
+ {
+ alt1=1;
+ }
+ break;
+
+ }
+
+ switch (alt1)
+ {
+ case 1:
+ // Lang.g:32:10: 'a' .. 'z'
+ {
+ MATCHRANGE('a', 'z');
+ if (HASEXCEPTION())
+ {
+ goto ruleIDEx;
+ }
+
+
+ }
+ break;
+
+ default:
+
+ if ( cnt1 >= 1 )
+ {
+ goto loop1;
+ }
+ /* mismatchedSetEx()
+ */
+ CONSTRUCTEX();
+ EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION;
+ EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME;
+
+
+ goto ruleIDEx;
+ }
+ cnt1++;
+ }
+ loop1: ; /* Jump to here if this rule does not match */
+ }
+
+ }
+
+ LEXSTATE->type = _type;
+
+ // This is where rules clean up and exit
+ //
+ goto ruleIDEx; /* Prevent compiler warnings */
+ ruleIDEx: ;
+
+}
+// $ANTLR end ID
+
+// Comes from: 33:9: ( ( '0' .. '9' )+ )
+/** \brief Lexer rule generated by ANTLR3
+ *
+ * $ANTLR start INT
+ *
+ * Looks to match the characters the constitute the token INT
+ * from the attached input stream.
+ *
+ *
+ * \remark
+ * - lexer->error == ANTLR3_TRUE if an exception was thrown.
+ */
+static ANTLR3_INLINE
+void mINT(pLangLexer ctx)
+{
+ ANTLR3_UINT32 _type;
+
+ _type = INT;
+
+
+ // Lang.g:33:9: ( ( '0' .. '9' )+ )
+ // Lang.g:33:11: ( '0' .. '9' )+
+ {
+ // Lang.g:33:11: ( '0' .. '9' )+
+ {
+ int cnt2=0;
+
+ 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':
+ {
+ alt2=1;
+ }
+ break;
+
+ }
+
+ switch (alt2)
+ {
+ case 1:
+ // Lang.g:33:11: '0' .. '9'
+ {
+ MATCHRANGE('0', '9');
+ if (HASEXCEPTION())
+ {
+ goto ruleINTEx;
+ }
+
+
+ }
+ break;
+
+ default:
+
+ if ( cnt2 >= 1 )
+ {
+ goto loop2;
+ }
+ /* mismatchedSetEx()
+ */
+ CONSTRUCTEX();
+ EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION;
+ EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME;
+
+
+ goto ruleINTEx;
+ }
+ cnt2++;
+ }
+ loop2: ; /* Jump to here if this rule does not match */
+ }
+
+ }
+
+ LEXSTATE->type = _type;
+
+ // This is where rules clean up and exit
+ //
+ goto ruleINTEx; /* Prevent compiler warnings */
+ ruleINTEx: ;
+
+}
+// $ANTLR end INT
+
+// Comes from: 34:8: ( ( ' ' | '\\n' | '\\r' ) )
+/** \brief Lexer rule generated by ANTLR3
+ *
+ * $ANTLR start WS
+ *
+ * Looks to match the characters the constitute the token WS
+ * from the attached input stream.
+ *
+ *
+ * \remark
+ * - lexer->error == ANTLR3_TRUE if an exception was thrown.
+ */
+static ANTLR3_INLINE
+void mWS(pLangLexer ctx)
+{
+ ANTLR3_UINT32 _type;
+
+ _type = WS;
+
+
+ // Lang.g:34:8: ( ( ' ' | '\\n' | '\\r' ) )
+ // Lang.g:34:10: ( ' ' | '\\n' | '\\r' )
+ {
+ if ( LA(1) == '\n' || LA(1) == '\r' || LA(1) == ' ' )
+ {
+ CONSUME();
+
+ }
+ else
+ {
+ CONSTRUCTEX();
+ EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION;
+ EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME;
+
+ LRECOVER(); goto ruleWSEx;
+ }
+
+ {
+ LEXSTATE->channel=HIDDEN;
+ }
+
+ }
+
+ LEXSTATE->type = _type;
+
+ // This is where rules clean up and exit
+ //
+ goto ruleWSEx; /* Prevent compiler warnings */
+ ruleWSEx: ;
+
+}
+// $ANTLR end WS
+
+/** 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(pLangLexer ctx)
+{
+ {
+ // Lang.g:1:8: ( T__10 | INTTYPE | FLOATTYPE | ID | INT | WS )
+
+ ANTLR3_UINT32 alt3;
+
+ alt3=6;
+
+ switch ( LA(1) )
+ {
+ case ';':
+ {
+ alt3=1;
+ }
+ break;
+ case 'i':
+ {
+ switch ( LA(2) )
+ {
+ case 'n':
+ {
+ switch ( LA(3) )
+ {
+ case 't':
+ {
+ switch ( LA(4) )
+ {
+ 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':
+ {
+ alt3=4;
+ }
+ break;
+
+ default:
+ alt3=2;}
+
+ }
+ break;
+
+ default:
+ alt3=4;}
+
+ }
+ break;
+
+ default:
+ alt3=4;}
+
+ }
+ break;
+ case 'f':
+ {
+ switch ( LA(2) )
+ {
+ case 'l':
+ {
+ switch ( LA(3) )
+ {
+ case 'o':
+ {
+ switch ( LA(4) )
+ {
+ case 'a':
+ {
+ switch ( LA(5) )
+ {
+ case 't':
+ {
+ switch ( LA(6) )
+ {
+ 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':
+ {
+ alt3=4;
+ }
+ break;
+
+ default:
+ alt3=3;}
+
+ }
+ break;
+
+ default:
+ alt3=4;}
+
+ }
+ break;
+
+ default:
+ alt3=4;}
+
+ }
+ break;
+
+ default:
+ alt3=4;}
+
+ }
+ break;
+
+ default:
+ alt3=4;}
+
+ }
+ break;
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'g':
+ case 'h':
+ 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':
+ {
+ alt3=4;
+ }
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ {
+ alt3=5;
+ }
+ break;
+ case '\n':
+ case '\r':
+ case ' ':
+ {
+ alt3=6;
+ }
+ break;
+
+ default:
+ CONSTRUCTEX();
+ EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
+ EXCEPTION->message = (void *)"";
+ EXCEPTION->decisionNum = 3;
+ EXCEPTION->state = 0;
+
+
+ goto ruleTokensEx;
+ }
+
+ switch (alt3)
+ {
+ case 1:
+ // Lang.g:1:10: T__10
+ {
+ /* 1:10: T__10 */
+ mT__10(ctx );
+ if (HASEXCEPTION())
+ {
+ goto ruleTokensEx;
+ }
+
+
+ }
+ break;
+ case 2:
+ // Lang.g:1:16: INTTYPE
+ {
+ /* 1:16: INTTYPE */
+ mINTTYPE(ctx );
+ if (HASEXCEPTION())
+ {
+ goto ruleTokensEx;
+ }
+
+
+ }
+ break;
+ case 3:
+ // Lang.g:1:24: FLOATTYPE
+ {
+ /* 1:24: FLOATTYPE */
+ mFLOATTYPE(ctx );
+ if (HASEXCEPTION())
+ {
+ goto ruleTokensEx;
+ }
+
+
+ }
+ break;
+ case 4:
+ // Lang.g:1:34: ID
+ {
+ /* 1:34: ID */
+ mID(ctx );
+ if (HASEXCEPTION())
+ {
+ goto ruleTokensEx;
+ }
+
+
+ }
+ break;
+ case 5:
+ // Lang.g:1:37: INT
+ {
+ /* 1:37: INT */
+ mINT(ctx );
+ if (HASEXCEPTION())
+ {
+ goto ruleTokensEx;
+ }
+
+
+ }
+ break;
+ case 6:
+ // Lang.g:1:41: WS
+ {
+ /* 1:41: WS */
+ mWS(ctx );
+ if (HASEXCEPTION())
+ {
+ goto ruleTokensEx;
+ }
+
+
+ }
+ break;
+
+ }
+ }
+
+
+ goto ruleTokensEx; /* Prevent compiler warnings */
+ruleTokensEx: ;
+}
+
+/* =========================================================================
+ * Lexer matching rules end.
+ * =========================================================================
+ */
+/* End of Lexer code
+ * ================================================
+ * ================================================
+ */
+
+
+/* End of code
+ * =============================================================================
+ */