+++ /dev/null
-/* DLexer.h (formerly DLexer.cpp)\r
- *\r
- * This was renamed because the use of the .cpp extension caused problems\r
- * with IDEs.\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain. An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS. However, we do ask\r
- * that credit is given to us for developing PCCTS. By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc... If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS. In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1989-2000\r
- */\r
-\r
-#define ZZINC {if ( track_columns ) (++_endcol);}\r
-\r
-#define ZZGETC {ch = input->nextChar(); cl = ZZSHIFT(ch);}\r
-\r
-#define ZZNEWSTATE (newstate = dfa[state][cl])\r
-\r
-#ifndef ZZCOPY\r
-#define ZZCOPY \\r
- /* Truncate matching buffer to size (not an error) */ \\r
- if (nextpos < lastpos){ \\r
- *(nextpos++) = ch; \\r
- }else{ \\r
- bufovf = 1; \\r
- }\r
-#endif\r
-\r
-void DLGLexer::\r
-mode( int m )\r
-{\r
- /* points to base of dfa table */\r
- if (m<MAX_MODE){\r
- automaton = m;\r
- /* have to redo class since using different compression */\r
- cl = ZZSHIFT(ch);\r
- }else{\r
- sprintf((char *)ebuf,"Invalid automaton mode = %d ",m);\r
- errstd(ebuf);\r
- }\r
-}\r
-\r
-ANTLRTokenType DLGLexer::\r
-nextTokenType(void)\r
-{\r
- register int state, newstate;\r
- /* last space reserved for the null char */\r
- register DLGChar *lastpos;\r
- ANTLRTokenType tk;\r
-\r
-skip:\r
- bufovf = 0;\r
- lastpos = &_lextext[_bufsize-1];\r
- nextpos = _lextext;\r
- _begcol = _endcol+1;\r
-more:\r
- _begexpr = nextpos;\r
- if ( interactive ) {\r
- /* interactive version of automaton */\r
- /* if there is something in ch, process it */\r
- state = newstate = dfa_base[automaton];\r
- if (charfull){\r
- ZZINC;\r
- ZZCOPY;\r
- ZZNEWSTATE;\r
- }\r
- while (alternatives[newstate]){\r
- state = newstate;\r
- ZZGETC;\r
- ZZINC;\r
- ZZCOPY;\r
- ZZNEWSTATE;\r
- }\r
- /* figure out if last character really part of token */\r
- if ((state != dfa_base[automaton]) && (newstate == DfaStates)){\r
- charfull = 1;\r
- --nextpos;\r
- }else{\r
- charfull = 0;\r
- state = newstate;\r
- }\r
- *(nextpos) = '\0';\r
- /* Able to transition out of start state to some non err state?*/\r
- if ( state == dfa_base[automaton] ){\r
- /* make sure doesn't get stuck */\r
- advance();\r
- }\r
- }\r
- else { /* non-interactive version of automaton */\r
- if (!charfull)\r
- advance();\r
- else\r
- ZZINC;\r
- state = dfa_base[automaton];\r
- while (ZZNEWSTATE != DfaStates) {\r
- state = newstate;\r
- ZZCOPY;\r
- ZZGETC;\r
- ZZINC;\r
- }\r
- charfull = 1;\r
- if ( state == dfa_base[automaton] ){\r
- if (nextpos < lastpos){\r
- *(nextpos++) = ch;\r
- }else{\r
- bufovf = 1;\r
- }\r
- *nextpos = '\0';\r
- /* make sure doesn't get stuck */\r
- advance();\r
- }else{\r
- *nextpos = '\0';\r
- }\r
- }\r
- if ( track_columns ) _endcol -= charfull;\r
- _endexpr = nextpos -1;\r
- add_erase = 0;\r
-#ifdef OLD\r
- tk = (ANTLRTokenType)\r
- (*actions[accepts[state]])(this); // must pass this manually\r
- // actions is not a [] of pointers\r
- // to member functions.\r
-#endif\r
- tk = (this->*actions[accepts[state]])();\r
-\r
-// MR1\r
-// MR1 11-Apr-97 Help for tracking DLG results\r
-// MR1\r
-\r
-#ifdef DEBUG_LEXER\r
-\r
-/* MR1 */ if (debugLexerFlag) {\r
-/* MR1 */ if (parser != NULL) {\r
-/* MR1 */ /* MR23 */ printMessage(stdout, "\ntoken name=%s",parser->parserTokenName(tk));\r
-/* MR1 */ } else {\r
-/* MR1 */ /* MR23 */ printMessage(stdout, "\ntoken nnumber=%d",tk);\r
-/* MR1 */ };\r
-/* MR1 */ /* MR23 */ printMessage(stdout, " lextext=(%s) mode=%d",\r
-/* MR1 */ (_lextext[0]=='\n' && _lextext[1]==0) ?\r
-/* MR1 */ "newline" : _lextext,\r
-/* MR1 */ automaton);\r
-/* MR1 */ if (interactive && !charfull) {\r
-/* MR1 */ /* MR23 */ printMessage(stdout, " char=empty");\r
-/* MR1 */ } else {\r
-/* MR1 */ if (ch=='\n') {\r
-/* MR1 */ /* MR23 */ printMessage(stdout, " char=newline");\r
-/* MR1 */ } else {\r
-/* MR1 */ /* MR23 */ printMessage(stdout, " char=(%c)",ch);\r
-/* MR1 */ };\r
-/* MR1 */ };\r
-/* MR1 */ /* MR23 */ printMessage(stdout, " %s\n",\r
-/* MR1 */ (add_erase==1 ? "skip()" :\r
-/* MR1 */ add_erase==2 ? "more()" :\r
-/* MR1 */ ""));\r
-/* MR1 */ };\r
-\r
-#endif\r
-\r
- switch (add_erase) {\r
- case 1: goto skip;\r
- case 2: goto more;\r
- }\r
- return tk;\r
-}\r
-\r
-void DLGLexer::\r
-advance()\r
-{\r
- if ( input==NULL ) err_in();\r
- ZZGETC; charfull = 1; ZZINC;\r
-}\r