From: Dejan Jovanović Date: Tue, 2 Feb 2010 21:00:02 +0000 (+0000) Subject: Rethrow rewrite in antlr_parser. Taking LT(0) to locate the error causes the build... X-Git-Tag: cvc5-1.0.0~9313 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cea1eb23c8a0c8088bd1db9baad0567c3dbdbfa0;p=cvc5.git Rethrow rewrite in antlr_parser. Taking LT(0) to locate the error causes the build to break on 64-bit machines. Changed to LT(1), it works now, but i'll ask around how this actually works. --- diff --git a/src/parser/antlr_parser.cpp b/src/parser/antlr_parser.cpp index 961915523..dbaebf5a5 100644 --- a/src/parser/antlr_parser.cpp +++ b/src/parser/antlr_parser.cpp @@ -104,11 +104,11 @@ bool AntlrParser::isDeclared(string name, SymbolType type) { void AntlrParser::rethrow(antlr::SemanticException& e, string new_message) throw (antlr::SemanticException) { throw antlr::SemanticException(new_message, getFilename(), - LT(0).get()->getLine(), - LT(0).get()->getColumn()); + LT(1).get()->getLine(), + LT(1).get()->getColumn()); } -bool AntlrParser::checkDeclation(string varName, DeclarationCheck check) { +bool AntlrParser::checkDeclaration(string varName, DeclarationCheck check) { switch(check) { case CHECK_DECLARED: return isDeclared(varName, SYM_VARIABLE); diff --git a/src/parser/antlr_parser.h b/src/parser/antlr_parser.h index 5cbb7411e..3025d44da 100644 --- a/src/parser/antlr_parser.h +++ b/src/parser/antlr_parser.h @@ -114,7 +114,7 @@ protected: * @oaram check the kind of check to perform * @return true if the check holds */ - bool checkDeclation(std::string varName, DeclarationCheck check); + bool checkDeclaration(std::string varName, DeclarationCheck check); /** * Types of symbols. diff --git a/src/parser/cvc/cvc_parser.g b/src/parser/cvc/cvc_parser.g index cb9c9b160..1cbdbd067 100644 --- a/src/parser/cvc/cvc_parser.g +++ b/src/parser/cvc/cvc_parser.g @@ -87,10 +87,9 @@ identifierList[std::vector& idList, DeclarationCheck check = CHECK_ * Matches an identifier and returns a string. */ identifier[DeclarationCheck check = CHECK_NONE] returns [std::string id] - : x:IDENTIFIER { checkDeclation(x->getText(), check) }? - { - id = x->getText(); - } + : x:IDENTIFIER + { id = x->getText(); } + { checkDeclaration(id, check) }? exception catch [antlr::SemanticException& ex] { switch (check) { case CHECK_DECLARED: rethrow(ex, "Symbol " + id + " not declared"); diff --git a/src/parser/smt/smt_parser.g b/src/parser/smt/smt_parser.g index 84b38c5cf..0db89d4f1 100644 --- a/src/parser/smt/smt_parser.g +++ b/src/parser/smt/smt_parser.g @@ -96,10 +96,9 @@ benchAttribute returns [Command* smt_command = 0] * @return the id string */ identifier[DeclarationCheck check = CHECK_NONE] returns [std::string id] - : x:IDENTIFIER { checkDeclation(x->getText(), check) }? - { - id = x->getText(); - } + : x:IDENTIFIER + { id = x->getText(); } + { checkDeclaration(id, check) }? exception catch [antlr::SemanticException& ex] { switch (check) { case CHECK_DECLARED: rethrow(ex, "Symbol " + id + " not declared");