00001 /* 00002 * lib/lex/test-scanner.h 00003 * 00004 * Test and demo scanner class. 00005 * 00006 * Copyright (c) 2004 by Wolfgang Wieser ] wwieser (a) gmx <*> de [ 00007 * 00008 * This file may be distributed and/or modified under the terms of the 00009 * GNU General Public License version 2 as published by the Free Software 00010 * Foundation. (See COPYING.GPL for details.) 00011 * 00012 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00013 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00014 * 00015 */ 00016 00017 #ifndef _LIB_LEX_TEST_SCANNER_H_ 00018 #define _LIB_LEX_TEST_SCANNER_H_ 1 00019 00027 #include <lib/sconfig.h> /* MUST be first */ 00028 00029 #include <lib/lex/location.h> 00030 #include <lib/sourcepos/sparchive.h> 00031 00032 #include <stdio.h> /* because of FILE * (FIXME) */ 00033 00034 #define PREFIX_FlexScannerBase TEST_FlexScannerBase 00035 #include <lib/lex/scannerbase.h> 00036 #undef PREFIX_FlexScannerBase 00037 00038 #include "test-grammar.h" 00039 00040 00047 class TestScanner : public TEST_FlexScannerBase 00048 { 00049 friend int TEST_lex(void *); 00050 public: 00052 struct TestToken : TokenEntry 00053 { 00055 YYSTYPE lval; 00056 00058 bool MayBeCleared() const; 00060 void clear(bool force); 00061 00062 TestToken() : TokenEntry() {} 00063 ~TestToken() { clear(1); } 00064 }; 00065 00066 private: 00068 int nested_comment_warned; 00070 int newlines_in_ccomment; 00071 00073 int allow_nested_comments; 00074 00076 void reset(); 00078 TokenEntry *AllocTokenEntry() 00079 { return(new TestToken()); } 00080 00082 TestScanner(const TestScanner &); 00084 void operator=(const TestScanner &); 00085 public: 00086 TestScanner(); 00087 ~TestScanner(); 00088 }; 00089 00090 #endif /* _LIB_LEX_TEST_SCANNER_H_ */