parser.h

Go to the documentation of this file.
00001 /*****************************************************************************/
00002 /*!
00003  * \file parser.h
00004  * 
00005  * Author: Sergey Berezin
00006  * 
00007  * Created: Wed Feb  5 11:46:57 2003
00008  *
00009  * <hr>
00010  *
00011  * License to use, copy, modify, sell and/or distribute this software
00012  * and its documentation for any purpose is hereby granted without
00013  * royalty, subject to the terms and conditions defined in the \ref
00014  * LICENSE file provided with this distribution.
00015  * 
00016  * <hr>
00017  * 
00018  * The top-level API to the parser.  At this level, it is simply a
00019  * stream of commands (Expr's) terminated by an infinite sequence of
00020  * Null Expr.  It has a support to parse several different input
00021  * languages (as many as we care to implement), and may take a file
00022  * name, or an istream to read from (default: std::cin, or stdin).
00023  * Using iostream means no more worries about whether to close files
00024  * or not.
00025  */
00026 /*****************************************************************************/
00027 
00028 #ifndef _cvc3__parser_h_
00029 #define _cvc3__parser_h_
00030 
00031 #include "exception.h"
00032 #include "lang.h"
00033 
00034 namespace CVC3 {
00035 
00036   class ValidityChecker;
00037   class Expr;
00038   
00039   // Internal parser state and other data
00040   class ParserData;
00041 
00042   class Parser {
00043   private:
00044     ParserData* d_data;
00045     // Internal methods for constructing and destroying the actual parser
00046     void initParser();
00047     void deleteParser();
00048   public:
00049     // Constructors
00050     Parser(ValidityChecker* vc, InputLanguage lang,
00051      // The 'interactive' flag is ignored when fileName != ""
00052      bool interactive = true,
00053      const std::string& fileName = "");
00054     Parser(ValidityChecker* vc, InputLanguage lang, std::istream& is,
00055      bool interactive = false);
00056     // Destructor
00057     ~Parser();
00058     // Read the next command.  
00059     Expr next();
00060     // Check if we are done (end of input has been reached)
00061     bool done() const;
00062     // The same check can be done by using the class Parser's value as
00063     // a Boolean
00064     operator bool() const { return done(); }
00065     void printLocation(std::ostream & out) const;
00066     // Reset any local data that depends on validity checker
00067     void reset();
00068   }; // end of class Parser
00069 
00070   // The global pointer to ParserTemp.  Each instance of class Parser
00071   // sets this pointer before any calls to the lexer.  We do it this
00072   // way because flex and bison use global vars, and we want each
00073   // Parser object to appear independent.
00074   class ParserTemp;
00075   extern ParserTemp* parserTemp;
00076 
00077 } // end of namespace CVC3
00078 
00079 #endif

Generated on Wed Nov 18 16:13:30 2009 for CVC3 by  doxygen 1.5.2