--- /dev/null
+/* DLGLexerBase.h\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-1998\r
+ */\r
+\r
+#ifndef DLGX_H\r
+#define DLGX_H\r
+\r
+#include "pcctscfg.h"\r
+#include "pccts_stdio.h"\r
+\r
+PCCTS_NAMESPACE_STD\r
+\r
+#include ATOKEN_H\r
+#include ATOKENSTREAM_H\r
+\r
+class ANTLRParser; // MR1\r
+\r
+/* must define what a char looks like; can make this a class too */\r
+typedef char DLGChar;\r
+\r
+/* Can have it as a class too: (ack this looks weird; is it right?)\r
+class DllExportPCCTS DLGChar {\r
+private:\r
+ int c;\r
+public:\r
+ DLGChar(int ch) { c = ch; }\r
+ int atom() { return c; }\r
+};\r
+*/\r
+\r
+/* user must subclass this */\r
+class DllExportPCCTS DLGInputStream {\r
+public:\r
+ virtual int nextChar() = 0;\r
+};\r
+\r
+/* Predefined char stream: Input from FILE */\r
+class DllExportPCCTS DLGFileInput : public DLGInputStream {\r
+private:\r
+ int found_eof;\r
+ FILE *input;\r
+public:\r
+ DLGFileInput(FILE *f) { input = f; found_eof = 0; }\r
+ int nextChar() {\r
+ int c;\r
+ if ( found_eof ) return EOF;\r
+ else {\r
+ c=getc(input);\r
+ if ( c==EOF ) found_eof = 1;\r
+ return c;\r
+ }\r
+ }\r
+ void DLGFileReset(FILE *f) {input=f; found_eof = 0; }; // MR11\r
+};\r
+\r
+// MR9 Suggested by Bruce Guenter (bruceg@qcc.sk.ca)\r
+// MR9 Make DLGStringInput const correct\r
+\r
+/* Predefined char stream: Input from string */\r
+class DllExportPCCTS DLGStringInput : public DLGInputStream {\r
+private:\r
+ const DLGChar *input; // MR9\r
+ const DLGChar *p; // MR9\r
+public:\r
+ DLGStringInput(const DLGChar *s) { input = s; p = &input[0];} // MR9\r
+ int nextChar()\r
+ {\r
+ if (*p) return (int) (unsigned char) *p++; // MR14\r
+ else return EOF;\r
+ }\r
+\r
+ void DLGStringReset(const DLGChar *s) {input=s; p= &input[0]; }; // MR11 // MR16\r
+};\r
+\r
+class DllExportPCCTS DLGState {\r
+public:\r
+ DLGInputStream *input;\r
+ int interactive;\r
+ int track_columns;\r
+ int auto_num;\r
+ int add_erase;\r
+ int lookc;\r
+ int char_full;\r
+ int begcol, endcol;\r
+ int line;\r
+ DLGChar *lextext, *begexpr, *endexpr;\r
+ int bufsize;\r
+ int bufovf;\r
+ DLGChar *nextpos;\r
+ int class_num;\r
+ int debugLexerFlag; // MR1\r
+ ANTLRParser *parser; // MR1\r
+};\r
+\r
+/* user must subclass this */\r
+class DllExportPCCTS DLGLexerBase : public ANTLRTokenStream {\r
+public:\r
+ virtual ANTLRTokenType erraction();\r
+\r
+protected:\r
+ DLGInputStream *input;\r
+ int interactive;\r
+ int track_columns;\r
+ DLGChar *_lextext; /* text of most recently matched token */\r
+ DLGChar *_begexpr; /* beginning of last reg expr recogn. */\r
+ DLGChar *_endexpr; /* beginning of last reg expr recogn. */\r
+ int _bufsize; /* number of characters in lextext */\r
+ int _begcol; /* column that first character of token is in*/\r
+ int _endcol; /* column that last character of token is in */\r
+ int _line; /* line current token is on */\r
+ int ch; /* character to determine next state */\r
+ int bufovf; /* indicates that buffer too small for text */\r
+ int charfull;\r
+ DLGChar *nextpos; /* points to next available position in lextext*/\r
+ int cl;\r
+ int automaton;\r
+ int add_erase;\r
+ DLGChar ebuf[70];\r
+ _ANTLRTokenPtr token_to_fill;\r
+\r
+ int debugLexerFlag; // MR1\r
+ ANTLRParser *parser; // MR1\r
+public:\r
+ virtual _ANTLRTokenPtr getToken(); // MR12 public\r
+ virtual void advance(void) = 0;\r
+ void skip(void); /* erase lextext, look for antoher token */\r
+ void more(void); /* keep lextext, look for another token */\r
+ void mode(int k); /* switch to automaton 'k' */\r
+ void saveState(DLGState *);\r
+ void restoreState(DLGState *);\r
+ virtual ANTLRTokenType nextTokenType(void)=0;/* get next token */\r
+ void replchar(DLGChar c); /* replace last recognized reg. expr. with\r
+ a character */\r
+ void replstr(const DLGChar *s); /* replace last recognized reg. expr. with\r
+ a string */ /* MR20 const */\r
+ virtual int err_in(); // MR1\r
+ virtual void errstd(const char *); // MR1 MR20 const\r
+ int line() { return _line; }\r
+ void set_line(int newValue) { _line=newValue; }; // MR1\r
+ virtual void newline() { _line++; }\r
+ DLGChar *lextext() { return _lextext; }\r
+\r
+ int begcol() { return _begcol; }\r
+ int endcol() { return _endcol; }\r
+ void set_begcol(int a) { _begcol=a; }\r
+ void set_endcol(int a) { _endcol=a; }\r
+ DLGChar *begexpr() { return _begexpr; }\r
+ DLGChar *endexpr() { return _endexpr; }\r
+ int bufsize() { return _bufsize; }\r
+\r
+ void setToken(ANTLRAbstractToken *t) { token_to_fill = t; }\r
+\r
+ void setInputStream(DLGInputStream *);\r
+ DLGLexerBase(DLGInputStream *in,\r
+ unsigned bufsize=2000,\r
+ int interactive=0,\r
+ int track_columns=0);\r
+ void reset(); // MR19\r
+ virtual ~DLGLexerBase() { delete [] _lextext; }\r
+ virtual void panic(const char *msg); // MR1 MR20 const\r
+ void trackColumns() {\r
+ track_columns = 1;\r
+ this->_begcol = 0;\r
+ this->_endcol = 0;\r
+ };\r
+ virtual ANTLRParser *setParser(ANTLRParser *p); // MR1\r
+ virtual ANTLRParser *getParser(); // MR1\r
+ virtual int debugLexer(int value); // MR1\r
+ int lexErrCount; // MR12\r
+};\r
+\r
+#endif\r