1 /********************* -*- C++ -*- */
3 ** This file is part of the CVC4 prototype.
4 ** Copyright (c) 2009 The Analysis of Computer Systems Group (ACSys)
5 ** Courant Institute of Mathematical Sciences
7 ** See the file COPYING in the top-level source directory for licensing
10 ** Parser abstraction.
13 #ifndef __CVC4__PARSER__PARSER_H
14 #define __CVC4__PARSER__PARSER_H
19 #include "cvc4_config.h"
20 #include "parser_exception.h"
24 // Forward declarations
39 class CVC4_PUBLIC Parser
{
44 * Construct the parser that uses the given expression manager.
45 * @param em the expression manager.
47 Parser(ExprManager
* em
);
56 * Parse the next command of the input
58 virtual Command
* parseNextCommand() throw (ParserException
) = 0;
61 * Parse the next expression of the stream
63 virtual Expr
parseNextExpression() throw (ParserException
) = 0;
66 * Check if we are done -- either the end of input has been reached.
72 /** Sets the done flag */
73 void setDone(bool done
= true);
75 /** Expression manager the parser will be using */
76 ExprManager
* d_expr_manager
;
81 }; // end of class Parser
83 class CVC4_PUBLIC SmtParser
: public Parser
{
88 * Construct the parser that uses the given expression manager and parses
89 * from the given input stream.
90 * @param em the expression manager to use
91 * @param input the input stream to parse
93 SmtParser(ExprManager
* em
, std::istream
& input
);
96 * Construct the parser that uses the given expression manager and parses
98 * @param em the expression manager to use
99 * @param file_name the file to parse
101 SmtParser(ExprManager
* em
, const char* file_name
);
109 * Parses the next command. By default, the SMTLIB parser produces one
110 * CommandSequence command. If parsing is successful, we should be done
111 * after the first call to this command.
112 * @return the CommandSequence command that includes the whole benchmark
114 Command
* parseNextCommand() throw (ParserException
);
117 * Parses the next complete expression of the stream.
118 * @return the expression parsed
120 Expr
parseNextExpression() throw (ParserException
);
124 /** The ANTLR smt lexer */
125 AntlrSmtLexer
* d_antlr_lexer
;
127 /** The ANTLR smt parser */
128 AntlrSmtParser
* d_antlr_parser
;
130 /** The file stream we might be using */
131 std::ifstream d_input
;
134 class CVC4_PUBLIC CvcParser
: public Parser
{
139 * Construct the parser that uses the given expression manager and parses
140 * from the given input stream.
141 * @param em the expression manager to use
142 * @param input the input stream to parse
144 CvcParser(ExprManager
* em
, std::istream
& input
);
147 * Construct the parser that uses the given expression manager and parses
149 * @param em the expression manager to use
150 * @param file_name the file to parse
152 CvcParser(ExprManager
* em
, const char* file_name
);
160 * Parses the next command. By default, the SMTLIB parser produces one
161 * CommandSequence command. If parsing is successful, we should be done
162 * after the first call to this command.
163 * @return the CommandSequence command that includes the whole benchmark
165 Command
* parseNextCommand() throw (ParserException
);
168 * Parses the next complete expression of the stream.
169 * @return the expression parsed
171 Expr
parseNextExpression() throw (ParserException
);
175 /** The ANTLR smt lexer */
176 AntlrCvcLexer
* d_antlr_lexer
;
178 /** The ANTLR smt parser */
179 AntlrCvcParser
* d_antlr_parser
;
181 /** The file stream we might be using */
182 std::ifstream d_input
;
186 }/* CVC4::parser namespace */
187 }/* CVC4 namespace */
189 #endif /* __CVC4__PARSER__PARSER_H */