diff options
author | Morgan Deters <mdeters@gmail.com> | 2012-09-27 22:04:38 +0000 |
---|---|---|
committer | Morgan Deters <mdeters@gmail.com> | 2012-09-27 22:04:38 +0000 |
commit | ad0a71e2782bc291ba9f808d24df2e1d8ca1b41e (patch) | |
tree | 744a9ae0f10f6dd8837d7e0dcd8bd2b25d34e481 /src/parser/smt1/smt1_input.cpp | |
parent | 51daaee8eb1ee55ee3323c5395a95fd121fe87a8 (diff) |
* Rename SMT parts (printer, parser) to SMT1
* Change --lang smt to mean SMT-LIBv2
* --lang smt1 now means SMT-LIBv1
* SMT-LIBv2 parser now gives helpful error if input looks like v1
* SMT-LIBv1 parser now gives helpful error if input looks like v2
* CVC presentation language parser now gives helpful error if input
looks like either SMT-LIB v1 or v2
* Other associated changes
(this commit was certified error- and warning-free by the test-and-commit script.)
Diffstat (limited to 'src/parser/smt1/smt1_input.cpp')
-rw-r--r-- | src/parser/smt1/smt1_input.cpp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/parser/smt1/smt1_input.cpp b/src/parser/smt1/smt1_input.cpp new file mode 100644 index 000000000..4987cd793 --- /dev/null +++ b/src/parser/smt1/smt1_input.cpp @@ -0,0 +1,73 @@ +/********************* */ +/*! \file smt1_input.cpp + ** \verbatim + ** Original author: cconway + ** Major contributors: mdeters + ** Minor contributors (to current version): none + ** This file is part of the CVC4 prototype. + ** Copyright (c) 2009, 2010, 2011 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.\endverbatim + ** + ** \brief [[ Add file-specific comments here ]]. + ** + ** [[ Add file-specific comments here ]] + **/ + +#include <antlr3.h> + +#include "parser/smt1/smt1_input.h" +#include "expr/expr_manager.h" +#include "parser/input.h" +#include "parser/parser.h" +#include "parser/parser_exception.h" +#include "parser/smt1/generated/Smt1Lexer.h" +#include "parser/smt1/generated/Smt1Parser.h" + +namespace CVC4 { +namespace parser { + +/* Use lookahead=2 */ +Smt1Input::Smt1Input(AntlrInputStream& inputStream) : + AntlrInput(inputStream, 2) { + pANTLR3_INPUT_STREAM input = inputStream.getAntlr3InputStream(); + AlwaysAssert( input != NULL ); + + d_pSmt1Lexer = Smt1LexerNew(input); + if( d_pSmt1Lexer == NULL ) { + throw ParserException("Failed to create SMT lexer."); + } + + setAntlr3Lexer( d_pSmt1Lexer->pLexer ); + + pANTLR3_COMMON_TOKEN_STREAM tokenStream = getTokenStream(); + AlwaysAssert( tokenStream != NULL ); + + d_pSmt1Parser = Smt1ParserNew(tokenStream); + if( d_pSmt1Parser == NULL ) { + throw ParserException("Failed to create SMT parser."); + } + + setAntlr3Parser(d_pSmt1Parser->pParser); +} + + +Smt1Input::~Smt1Input() { + d_pSmt1Lexer->free(d_pSmt1Lexer); + d_pSmt1Parser->free(d_pSmt1Parser); +} + +Command* Smt1Input::parseCommand() + throw (ParserException, TypeCheckingException, AssertionException) { + return d_pSmt1Parser->parseCommand(d_pSmt1Parser); +} + +Expr Smt1Input::parseExpr() + throw (ParserException, TypeCheckingException, AssertionException) { + return d_pSmt1Parser->parseExpr(d_pSmt1Parser); +} + +}/* CVC4::parser namespace */ +}/* CVC4 namespace */ |