From cea1eb23c8a0c8088bd1db9baad0567c3dbdbfa0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Dejan=20Jovanovi=C4=87?= Date: Tue, 2 Feb 2010 21:00:02 +0000 Subject: [PATCH] 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. --- src/parser/antlr_parser.cpp | 6 +++--- src/parser/antlr_parser.h | 2 +- src/parser/cvc/cvc_parser.g | 7 +++---- src/parser/smt/smt_parser.g | 7 +++---- 4 files changed, 10 insertions(+), 12 deletions(-) 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"); -- 2.30.2