+++ /dev/null
-#ifndef PBLACKBOX_H\r
-#define PBLACKBOX_H\r
-\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
-/* Completely rewritten by Chris Uzdavinis (chris@atdesk.com) for MR23 */\r
-\r
-#include "pcctscfg.h"\r
-\r
-#include "pccts_iostream.h"\r
-\r
-PCCTS_NAMESPACE_STD\r
-\r
-// MR20 Added #include for "DLexerBase.h"\r
-\r
-#include "DLexerBase.h"\r
-\r
-//\r
-// The default buffer size of the lexer is given by the\r
-// second argument of the lexer's ctor. It is optional\r
-// and defaults to 2000\r
-//\r
-\r
-template<class Lexer, class Parser, class Token>\r
-class DllExportPCCTS ParserBlackBox {\r
-private:\r
- // no copy construction allowed\r
- ParserBlackBox(ParserBlackBox const &);\r
-\r
- // no copy assignment allowed\r
- ParserBlackBox & operator=(ParserBlackBox const &);\r
- \r
-protected:\r
- DLGFileInput *in;\r
- Lexer *scan;\r
- _ANTLRTokenPtr tok;\r
- ANTLRTokenBuffer *pipe;\r
- Parser *_parser;\r
- FILE *file;\r
- int openByBlackBox; /* MR21 Don't close what we haven't opened */\r
-public:\r
- \r
- ParserBlackBox(FILE *f)\r
- : in(0)\r
- , scan(0)\r
- , tok(0)\r
- , pipe(0)\r
- , _parser(0)\r
- , file(0)\r
- , openByBlackBox(0)\r
- {\r
- if (f == NULL)\r
- {\r
- cerr << "invalid file pointer\n"; \r
- }\r
- else\r
- {\r
- openByBlackBox = 0; /* MR21a */\r
- file = f;\r
- in = new DLGFileInput(f);\r
- scan = new Lexer(in);\r
- pipe = new ANTLRTokenBuffer(scan);\r
- tok = new Token;\r
- scan->setToken(tok);\r
- _parser = new Parser(pipe);\r
- _parser->init();\r
- }\r
- }\r
- ParserBlackBox(char *fname)\r
- : in(0)\r
- , scan(0)\r
- , tok(0)\r
- , pipe(0)\r
- , _parser(0)\r
- , file(0)\r
- , openByBlackBox(0)\r
- {\r
- FILE *f = fopen(fname, "r");\r
- if ( f==NULL ) {\r
- openByBlackBox = 0;\r
- cerr << "cannot open " << fname << "\n"; return;\r
- }\r
- else {\r
- openByBlackBox = 1;\r
- file = f;\r
- in = new DLGFileInput(f);\r
- scan = new Lexer(in);\r
- pipe = new ANTLRTokenBuffer(scan);\r
- tok = new Token;\r
- scan->setToken(tok);\r
- _parser = new Parser(pipe);\r
- _parser->init();\r
- }\r
- }\r
- \r
- ~ParserBlackBox()\r
- {\r
- delete in; delete scan; delete pipe; delete _parser; delete tok;\r
- if (1 == openByBlackBox) {\r
- fclose(file);\r
- }\r
- }\r
-\r
- Parser *parser() { return _parser; }\r
- Lexer *getLexer() { return scan; }\r
-};\r
-\r
-#endif\r