summaryrefslogtreecommitdiff
path: root/src/parser/smt2/smt2_input.cpp
diff options
context:
space:
mode:
authorChristopher L. Conway <christopherleeconway@gmail.com>2010-04-29 16:53:19 +0000
committerChristopher L. Conway <christopherleeconway@gmail.com>2010-04-29 16:53:19 +0000
commit194c5b6f04c7c9bec8c0f23b88ac8d0f0094186a (patch)
tree20faf669228e725a7521311841a13b5ddbb71a78 /src/parser/smt2/smt2_input.cpp
parentb99ec8f0f659884d30c5fa1a9312addd07e75059 (diff)
First draft implementation of SMT v2 parser
Diffstat (limited to 'src/parser/smt2/smt2_input.cpp')
-rw-r--r--src/parser/smt2/smt2_input.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/parser/smt2/smt2_input.cpp b/src/parser/smt2/smt2_input.cpp
new file mode 100644
index 000000000..5db4a9bd7
--- /dev/null
+++ b/src/parser/smt2/smt2_input.cpp
@@ -0,0 +1,67 @@
+/********************* */
+/** smt2_input.cpp
+ ** Original author: cconway
+ ** Major contributors: none
+ ** Minor contributors (to current version): mdeters
+ ** This file is part of the CVC4 prototype.
+ ** Copyright (c) 2009, 2010 The Analysis of Computer Systems Group (ACSys)
+ ** Courant Institute of Mathematical Sciences
+ ** New York University
+ ** See the file COPYING in the top-level source directory for licensing
+ ** information.
+ **
+ ** [[ Add file-specific comments here ]]
+ **/
+
+#include <antlr3.h>
+
+#include "smt2_input.h"
+#include "expr/expr_manager.h"
+#include "parser/parser.h"
+#include "parser/parser_exception.h"
+#include "parser/smt2/generated/Smt2Lexer.h"
+#include "parser/smt2/generated/Smt2Parser.h"
+
+namespace CVC4 {
+namespace parser {
+
+/* Use lookahead=2 */
+Smt2Input::Smt2Input(AntlrInputStream *inputStream) :
+ Input(inputStream, 2) {
+ pANTLR3_INPUT_STREAM input = inputStream->getAntlr3InputStream();
+ AlwaysAssert( input != NULL );
+
+ d_pSmt2Lexer = Smt2LexerNew(input);
+ if( d_pSmt2Lexer == NULL ) {
+ throw ParserException("Failed to create SMT2 lexer.");
+ }
+
+ setAntlr3Lexer( d_pSmt2Lexer->pLexer );
+
+ pANTLR3_COMMON_TOKEN_STREAM tokenStream = getTokenStream();
+ AlwaysAssert( tokenStream != NULL );
+
+ d_pSmt2Parser = Smt2ParserNew(tokenStream);
+ if( d_pSmt2Parser == NULL ) {
+ throw ParserException("Failed to create SMT2 parser.");
+ }
+
+ setAntlr3Parser(d_pSmt2Parser->pParser);
+}
+
+
+Smt2Input::~Smt2Input() {
+ d_pSmt2Lexer->free(d_pSmt2Lexer);
+ d_pSmt2Parser->free(d_pSmt2Parser);
+}
+
+Command* Smt2Input::parseCommand() throw (ParserException) {
+ return d_pSmt2Parser->parseCommand(d_pSmt2Parser);
+}
+
+Expr Smt2Input::parseExpr() throw (ParserException) {
+ return d_pSmt2Parser->parseExpr(d_pSmt2Parser);
+}
+
+}/* CVC4::parser namespace */
+}/* CVC4 namespace */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback