Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions Parse/TPTP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,10 @@ const int TPTP::PI = 102u;
/** Sigma function for existential quantification */
const int TPTP::SIGMA = 103u;

/**
* Create a parser, parse the input and return the parsed list of units.
* @since 13/07/2011 Manchester
*/
UnitList* TPTP::parse(istream& input)
{
Parse::TPTP parser(input);
parser.parse();
return parser.units();
}

Unit* TPTP::parseFormulaFromString(const std::string& str)
{
std::stringstream input(str+")."); // to fake endFOF, which creates the clause
Parse::TPTP parser(input);
Parse::TPTP parser(input, "<string>");
parser._lastInputType = UnitInputType::AXIOM;
parser._bools.push(true); // true is what fof/tff normally pushes (but we start "from the middle")
parser._strings.push("dummy_name");
Expand All @@ -101,9 +90,9 @@ Unit* TPTP::parseFormulaFromString(const std::string& str)
* Initialise a lexer.
* @since 27/07/2004 Torrevieja
*/
TPTP::TPTP(std::istream &in, UnitList::FIFO unitBuffer)
TPTP::TPTP(std::istream &in, std::filesystem::path path, UnitList::FIFO unitBuffer)
: _containsConjecture(false),
currentFile { &in, {}, {}, 1 },
currentFile { &in, {}, path, 1 },
_units(unitBuffer),
_isThf(false),
_containsPolymorphism(false),
Expand Down
4 changes: 2 additions & 2 deletions Parse/TPTP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,17 +317,17 @@ class TPTP
* @brief Construct a new TPTP parser.
*
* @param in is the stream with the raw input to read
* @param path is the path to the file backing the stream (or e.g. '<stdin>', '<string>')
* @param unitBuffer is FIFO of units to which newly parsed Clauses/Formulas
* will be added (via pushBack);
*
* if left unspecified, and empty fifo is created and used instead.
* (use this default behaviour if you do not want to collect formulas
* from multiple parser calls)
*/
TPTP(std::istream &in, UnitList::FIFO unitBuffer = UnitList::FIFO());
TPTP(std::istream &in, std::filesystem::path path, UnitList::FIFO unitBuffer = UnitList::FIFO());
~TPTP();
void parse();
static UnitList* parse(std::istream& str);
static Unit* parseFormulaFromString(const std::string& str);
/** Return the list of parsed units */
UnitList* units() const { return _units.list(); }
Expand Down
18 changes: 9 additions & 9 deletions Shell/UIHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ static bool hasEnding (std::string const &fullString, std::string const &ending)
}
}

void UIHelper::tryParseTPTP(istream& input)
void UIHelper::tryParseTPTP(istream& input, std::filesystem::path path)
{
LoadedPiece& curPiece = _loadedPieces.top();
Parse::TPTP parser(input,curPiece._units);
Parse::TPTP parser(input,path,curPiece._units);
try {
parser.parse();
curPiece._units = parser.unitBuffer();
Expand Down Expand Up @@ -239,7 +239,7 @@ void UIHelper::parseSingleLine(const std::string& lineToParse, Options::InputSyn
try {
switch (inputSyntax) {
case Options::InputSyntax::TPTP:
tryParseTPTP(stream);
tryParseTPTP(stream, "<string>");
break;
case Options::InputSyntax::SMTLIB2:
tryParseSMTLIB2(stream);
Expand Down Expand Up @@ -270,7 +270,7 @@ void resetParsing(ParsingRelatedException& exception, istream& input, std::strin
input.seekg(0);
}

void UIHelper::parseStream(std::istream& input, Options::InputSyntax inputSyntax, bool verbose, bool preferSMTonAuto)
void UIHelper::parseStream(std::istream& input, std::filesystem::path path, Options::InputSyntax inputSyntax, bool verbose, bool preferSMTonAuto)
{
switch (inputSyntax) {
case Options::InputSyntax::AUTO:
Expand All @@ -283,23 +283,23 @@ void UIHelper::parseStream(std::istream& input, Options::InputSyntax inputSyntax
tryParseSMTLIB2(input);
} catch (ParsingRelatedException& exception) {
resetParsing(exception,input,"TPTP");
tryParseTPTP(input);
tryParseTPTP(input, path);
}
} else {
if (verbose) {
addCommentSignForSZS(std::cout);
std::cout << "Running in auto input_syntax mode. Trying TPTP\n";
}
try {
tryParseTPTP(input);
tryParseTPTP(input, path);
} catch (ParsingRelatedException& exception) {
resetParsing(exception,input,"SMTLIB2");
tryParseSMTLIB2(input);
}
}
break;
case Options::InputSyntax::TPTP:
tryParseTPTP(input);
tryParseTPTP(input, path);
break;
case Options::InputSyntax::SMTLIB2:
tryParseSMTLIB2(input);
Expand All @@ -320,7 +320,7 @@ void UIHelper::parseStandardInput(Options::InputSyntax inputSyntax)
inputSyntax = Options::InputSyntax::TPTP;
}
try {
parseStream(cin,inputSyntax,false,false);
parseStream(cin, "<stdin>", inputSyntax,false,false);
} catch (ParsingRelatedException& exception) {
_loadedPieces.pop();
throw;
Expand All @@ -342,7 +342,7 @@ void UIHelper::parseFile(const std::string& inputFile, Options::InputSyntax inpu
}

try {
parseStream(input,inputSyntax,verbose,hasEnding(inputFile,"smt") || hasEnding(inputFile,"smt2"));
parseStream(input,inputFile,inputSyntax,verbose,hasEnding(inputFile,"smt") || hasEnding(inputFile,"smt2"));
} catch (ParsingRelatedException& exception) {
_loadedPieces.pop();
throw;
Expand Down
5 changes: 3 additions & 2 deletions Shell/UIHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#ifndef __UIHelper__
#define __UIHelper__

#include <filesystem>
#include <ostream>

#include "Forwards.hpp"
Expand Down Expand Up @@ -45,12 +46,12 @@ class UIHelper {
};
static Stack<LoadedPiece> _loadedPieces;

static void tryParseTPTP(std::istream& input);
static void tryParseTPTP(std::istream& input, std::filesystem::path path);
static void tryParseSMTLIB2(std::istream& input);
public:
static void parseSingleLine(const std::string& lineToParse, Options::InputSyntax inputSyntax);

static void parseStream(std::istream& input, Options::InputSyntax inputSyntax, bool verbose, bool preferSMTonAuto);
static void parseStream(std::istream& input, std::filesystem::path path, Options::InputSyntax inputSyntax, bool verbose, bool preferSMTonAuto);
static void parseStandardInput(Options::InputSyntax inputSyntax);
static void parseFile(const std::string& inputFile, Options::InputSyntax inputSyntax, bool verbose);

Expand Down