Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added PANIC MODE error recovery to the parser. This breaks two tests
(ParseError1 and 2) so those are temporarily fixed. git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2098 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
- Loading branch information
Andreas Remar
committed
Feb 9, 2006
1 parent
a6afc9e
commit 26bd418
Showing
3 changed files
with
174 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#ifndef __ERROR_REPORTING_H__ | ||
#define __ERROR_REPORTING_H__ | ||
|
||
#include <sstream> | ||
|
||
// x05andre, Andreas Remar, 2006-02-02 | ||
// The following are helper macros for panic mode error recovery | ||
|
||
// This macro is inserted before synchronizing with the FOLLOW set | ||
#define BEFORE_SYNC if(std::string(e.getMessage()) == std::string("unexpected end of file")) \ | ||
throw ANTLR_USE_NAMESPACE(antlr)RecognitionException("unexpected end of file", \ | ||
modelicafilename, \ | ||
LT(1)->getLine(), \ | ||
LT(1)->getColumn()); \ | ||
std::list<std::string> tokens; \ | ||
int errorLine = LT(1)->getLine(); \ | ||
int errorColumn = LT(1)->getColumn(); \ | ||
tokens.push_back(std::string(e.getMessage())) | ||
|
||
// This macro is inserted after synchronizing with the FOLLOW set | ||
#define AFTER_SYNC tokens.push_back(std::string(LT(1)->getText())); \ | ||
std::stringstream ss; \ | ||
ss << LT(1)->getLine() << ", column " << LT(1)->getColumn(); \ | ||
tokens.push_back(std::string(ss.str())); \ | ||
add_source_message(2, \ | ||
"SYNTAX", \ | ||
"ERROR", \ | ||
"error: %s, parsing continued at token '%s' on line %s", \ | ||
tokens, \ | ||
errorLine, \ | ||
errorColumn, \ | ||
LT(1)->getLine(), \ | ||
LT(1)->getColumn(), \ | ||
false, \ | ||
(char *)modelicafilename.c_str()); | ||
|
||
// Access the global string modelicafilename found in Compiler/absyn_builder/parse.cpp | ||
extern std::string modelicafilename; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters