diff options
author | François Bobot <francois@bobot.eu> | 2012-06-22 15:11:37 +0000 |
---|---|---|
committer | François Bobot <francois@bobot.eu> | 2012-06-22 15:11:37 +0000 |
commit | 84c4269f3b9edb8de4134fe464dfc70679da2bb1 (patch) | |
tree | b0c8f33e04d925064ffa9d85f1caeb6a3ff745b2 /src/parser/tptp/tptp_input.cpp | |
parent | eda7d4df5481030d4e9cb6ef4a33d52afc8f7e0a (diff) |
TPTP: add parser for cnf and fof
- include directive works
- no keyword : 'fof', 'cnf', ... can be used for symbols name
- real -> unsorted -> real (for the one that appear, so no bijection bitween real and unsorted)
- same thing for string
But:
- string not distinct by projection to real, not sure if the current state of string theory make them distinct
- filtering in include is not done
- the result is not printed in the TPTP way (currently SMT2 way)
Diffstat (limited to 'src/parser/tptp/tptp_input.cpp')
-rw-r--r-- | src/parser/tptp/tptp_input.cpp | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/parser/tptp/tptp_input.cpp b/src/parser/tptp/tptp_input.cpp new file mode 100644 index 000000000..689f13a8b --- /dev/null +++ b/src/parser/tptp/tptp_input.cpp @@ -0,0 +1,74 @@ +/********************* */ +/*! \file tptp_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/tptp/tptp_input.h" +#include "expr/expr_manager.h" +#include "parser/input.h" +#include "parser/parser.h" +#include "parser/parser_exception.h" +#include "parser/tptp/tptp.h" +#include "parser/tptp/generated/TptpLexer.h" +#include "parser/tptp/generated/TptpParser.h" + +namespace CVC4 { +namespace parser { + +/* Use lookahead=1 */ +TptpInput::TptpInput(AntlrInputStream& inputStream) : + AntlrInput(inputStream, 1) { + pANTLR3_INPUT_STREAM input = inputStream.getAntlr3InputStream(); + AlwaysAssert( input != NULL ); + + d_pTptpLexer = TptpLexerNew(input); + if( d_pTptpLexer == NULL ) { + throw ParserException("Failed to create TPTP lexer."); + } + + setAntlr3Lexer( d_pTptpLexer->pLexer ); + + pANTLR3_COMMON_TOKEN_STREAM tokenStream = getTokenStream(); + AlwaysAssert( tokenStream != NULL ); + + d_pTptpParser = TptpParserNew(tokenStream); + if( d_pTptpParser == NULL ) { + throw ParserException("Failed to create TPTP parser."); + } + + setAntlr3Parser(d_pTptpParser->pParser); +} + + +TptpInput::~TptpInput() { + d_pTptpLexer->free(d_pTptpLexer); + d_pTptpParser->free(d_pTptpParser); +} + +Command* TptpInput::parseCommand() + throw (ParserException, TypeCheckingException, AssertionException) { + return d_pTptpParser->parseCommand(d_pTptpParser); +} + +Expr TptpInput::parseExpr() + throw (ParserException, TypeCheckingException, AssertionException) { + return d_pTptpParser->parseExpr(d_pTptpParser); +} + +}/* CVC4::parser namespace */ +}/* CVC4 namespace */ |