Rethrow rewrite in antlr_parser. Taking LT(0) to locate the error causes the build...
authorDejan Jovanović <dejan.jovanovic@gmail.com>
Tue, 2 Feb 2010 21:00:02 +0000 (21:00 +0000)
committerDejan Jovanović <dejan.jovanovic@gmail.com>
Tue, 2 Feb 2010 21:00:02 +0000 (21:00 +0000)
src/parser/antlr_parser.cpp
src/parser/antlr_parser.h
src/parser/cvc/cvc_parser.g
src/parser/smt/smt_parser.g

index 961915523d60be83acaeb705f05cf375e5245b73..dbaebf5a5e6de32748ff51ec7fa44b52dcaf3488 100644 (file)
@@ -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);
index 5cbb7411efbe32b33e4c6a165ec8db268109a66c..3025d44da88d008f489a5e2287b9a94de41a4dd3 100644 (file)
@@ -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.
index cb9c9b1607155bd74e6aea82984ddb8e66f8dee5..1cbdbd067b3a86d1adc38a9dee063d0e83936da4 100644 (file)
@@ -87,10 +87,9 @@ identifierList[std::vector<std::string>& 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");
index 84b38c5cfe2efebd56e3da5befc6912444f0376e..0db89d4f1fdd8f32f1616ac8032db961c959d536 100644 (file)
@@ -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");