1 /********************* */
3 ** Original author: mdeters
4 ** Major contributors: dejan
5 ** Minor contributors (to current version): none
6 ** This file is part of the CVC4 prototype.
7 ** Copyright (c) 2009, 2010 The Analysis of Computer Systems Group (ACSys)
8 ** Courant Institute of Mathematical Sciences
10 ** See the file COPYING in the top-level source directory for licensing
13 ** Parser abstraction.
16 #ifndef __CVC4__PARSER__PARSER_H
17 #define __CVC4__PARSER__PARSER_H
22 #include "cvc4_config.h"
23 #include "parser/parser_exception.h"
24 #include "util/Assert.h"
32 // Forward declarations
42 * The parser. The parser should be obtained by calling the static methods
43 * getNewParser, and should be deleted when done.
45 class CVC4_PUBLIC Parser
{
49 /** The input language option */
51 /** The SMTLIB input language */
53 /** The CVC4 input language */
55 /** Auto-detect the language */
59 static Parser
* getNewParser(ExprManager
* em
, InputLanguage lang
, std::string filename
);
60 static Parser
* getNewParser(ExprManager
* em
, InputLanguage lang
, std::istream
& input
);
68 * Parse the next command of the input. If EOF is encountered a EmptyCommand
69 * is returned and done flag is set.
71 Command
* parseNextCommand() throw(ParserException
, AssertionException
);
74 * Parse the next expression of the stream. If EOF is encountered a null
75 * expression is returned and done flag is set.
76 * @return the parsed expression
78 Expr
parseNextExpression() throw(ParserException
, AssertionException
);
81 * Check if we are done -- either the end of input has been reached, or some
82 * error has been encountered.
83 * @return true if parser is done
87 /** Enable semantic checks during parsing. */
90 /** Disable semantic checks during parsing. Disabling checks may lead to crashes on bad inputs. */
96 * Create a new parser.
97 * @param em the expression manager to usee
98 * @param lang the language to parse
99 * @param input the input stream to parse
100 * @param filename the filename to attach to the stream
101 * @param deleteInput wheather to delete the input
104 static Parser
* getNewParser(ExprManager
* em
, InputLanguage lang
, std::istream
* input
, std::string filename
, bool deleteInput
);
107 * Create a new parser given the actual antlr parser.
108 * @param antlrParser the antlr parser to user
110 Parser(std::istream
* input
, AntlrParser
* antlrParser
, antlr::CharScanner
* antlrLexer
, bool deleteInput
);
112 /** Sets the done flag */
113 void setDone(bool done
= true);
118 /** The antlr parser */
119 AntlrParser
* d_antlrParser
;
121 /** The entlr lexer */
122 antlr::CharScanner
* d_antlrLexer
;
124 /** The input stream we are using */
125 std::istream
* d_input
;
127 /** Wherther to de-allocate the input */
129 }; // end of class Parser
131 }/* CVC4::parser namespace */
132 }/* CVC4 namespace */
134 #endif /* __CVC4__PARSER__PARSER_H */