diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2006-08-18 17:32:55 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2006-08-18 17:32:55 +0000 |
commit | b50974ac75c25036c7ae40e9f439dc898c751dec (patch) | |
tree | 52e434b158d0d126aafaf15b2fb02e48180fb59d /llvm/lib/AsmParser/llvmAsmParser.y.cvs | |
parent | 27665c1331c865f5a7dee3f4e4f3b54cb85d5c82 (diff) | |
download | bcm5719-llvm-b50974ac75c25036c7ae40e9f439dc898c751dec.tar.gz bcm5719-llvm-b50974ac75c25036c7ae40e9f439dc898c751dec.zip |
Add a comment about the mechanisms used to rid AsmParser of exceptions.
llvm-svn: 29769
Diffstat (limited to 'llvm/lib/AsmParser/llvmAsmParser.y.cvs')
-rw-r--r-- | llvm/lib/AsmParser/llvmAsmParser.y.cvs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/AsmParser/llvmAsmParser.y.cvs b/llvm/lib/AsmParser/llvmAsmParser.y.cvs index f09b99a5f03..6a8a0f40d88 100644 --- a/llvm/lib/AsmParser/llvmAsmParser.y.cvs +++ b/llvm/lib/AsmParser/llvmAsmParser.y.cvs @@ -27,9 +27,19 @@ #include <list> #include <utility> +// The following is a gross hack. In order to rid the libAsmParser library of +// exceptions, we have to have a way of getting the yyparse function to go into +// an error situation. So, whenever we want an error to occur, the GenerateError +// function (see bottom of file) sets TriggerError. Then, at the end of each +// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR +// (a goto) to put YACC in error state. Furthermore, several calls to +// GenerateError are made from inside productions and they must simulate the +// previous exception behavior by exiting the production immediately. We have +// replaced these with the GEN_ERROR macro which calls GeneratError and then +// immediately invokes YYERROR. This would be so much cleaner if it was a +// recursive descent parser. static bool TriggerError = false; #define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYERROR; } } - #define GEN_ERROR(msg) { GenerateError(msg); YYERROR; } int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit |