Descriptiongo/parser: avoid endless loop in case of internal error
Factored the error synchronization code into two functions
syncStmt and syncDecl. Because they may return w/o advancing
the scanner, there is potential for endless loops across
multiple parse functions; typically caused by an incorrect
token list in these functions (e.g., adding token.ELSE to
syncStmt will cause the parser to go into an endless loop
for test/syntax/semi7.go without this mechanism). This would
indicate a compiler bug, exposed only in an error situation
for very specific source files. Added a mechanism to force
scanner advance if an endless loop is detected. As a result,
error recovery will be less good in those cases, but the parser
reported a source error already and at least doesn't get stuck.
Patch Set 1 #Patch Set 2 : diff -r 097e02a1815a https://code.google.com/p/go #Patch Set 3 : diff -r 097e02a1815a https://code.google.com/p/go #Patch Set 4 : diff -r 097e02a1815a https://code.google.com/p/go #
Total comments: 1
Patch Set 5 : diff -r 7f518fff6a72 https://go.googlecode.com/hg/ #MessagesTotal messages: 3
|