1 /********************* */
3 ** Original author: mdeters
4 ** Major contributors: dejan
5 ** Minor contributors (to current version): cconway
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"
33 // Forward declarations
43 * The parser. The parser should be obtained by calling the static methods
44 * getNewParser, and should be deleted when done.
46 class CVC4_PUBLIC Parser
{
50 /** The input language option */
52 /** The SMTLIB input language */
54 /** The CVC4 input language */
56 /** Auto-detect the language */
60 static Parser
* getMemoryMappedParser(ExprManager
* em
, InputLanguage lang
, std::string filename
);
61 static Parser
* getNewParser(ExprManager
* em
, InputLanguage lang
, std::istream
& input
, std::string filename
);
69 * Parse the next command of the input. If EOF is encountered a EmptyCommand
70 * is returned and done flag is set.
72 Command
* parseNextCommand() throw(ParserException
, AssertionException
);
75 * Parse the next expression of the stream. If EOF is encountered a null
76 * expression is returned and done flag is set.
77 * @return the parsed expression
79 Expr
parseNextExpression() throw(ParserException
, AssertionException
);
82 * Check if we are done -- either the end of input has been reached, or some
83 * error has been encountered.
84 * @return true if parser is done
88 /** Enable semantic checks during parsing. */
91 /** Disable semantic checks during parsing. Disabling checks may lead to crashes on bad inputs. */
97 * Create a new parser.
98 * @param em the expression manager to usee
99 * @param lang the language to parse
100 * @param inputBuffer the input buffer to parse
101 * @param filename the filename to attach to the stream
102 * @param deleteInput wheather to delete the input
105 static Parser
* getNewParser(ExprManager
* em
, InputLanguage lang
, antlr::InputBuffer
* inputBuffer
, std::string filename
);
108 * Create a new parser given the actual antlr parser.
109 * @param antlrParser the antlr parser to user
111 Parser(antlr::InputBuffer
* inputBuffer
, AntlrParser
* antlrParser
, antlr::CharScanner
* antlrLexer
);
113 /** Sets the done flag */
114 void setDone(bool done
= true);
119 /** The antlr parser */
120 AntlrParser
* d_antlrParser
;
122 /** The entlr lexer */
123 antlr::CharScanner
* d_antlrLexer
;
125 /** The input stream we are using */
126 antlr::InputBuffer
* d_inputBuffer
;
128 /** Wherther to de-allocate the input */
130 }; // end of class Parser
132 }/* CVC4::parser namespace */
133 }/* CVC4 namespace */
135 #endif /* __CVC4__PARSER__PARSER_H */