[PATCH] D128486: [pseudo] Add error-recovery framework & brace-based recovery
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 27 14:04:46 PDT 2022
sammccall created this revision.
Herald added a subscriber: mgrang.
Herald added a project: All.
sammccall updated this revision to Diff 440376.
sammccall retitled this revision from "xxx recover" to "[pseudo] Add error-recovery framework & brace-based recovery".
sammccall edited the summary of this revision.
sammccall added a comment.
sammccall updated this revision to Diff 440379.
sammccall published this revision for review.
sammccall added a reviewer: hokein.
Herald added subscribers: cfe-commits, alextsao1999.
Herald added a project: clang-tools-extra.
add tests, clean up
sammccall added a comment.
reduce after final recovery
comments
The idea is:
- a parse failure is detected when all heads die when trying to shift the next token
- we can recover by choosing a nonterminal we're partway through parsing, and determining where it ends through nonlocal means (e.g. matching brackets)
- we can find candidates by walking up the stack from the (ex-)heads
- the token range is defined using heuristics attached to grammar rules
- the unparsed region is represented in the forest by an Opaque node
This patch has the core GLR functionality.
It does not allow recovery heuristics to be attached as extensions to
the grammar, but rather infers a brace-based heuristic.
Expected followups:
- make recovery heuristics grammar extensions (depends on D127448 <https://reviews.llvm.org/D127448>)
- add recover to our grammar for bracketed constructs and sequence nodes
- change the structure of our augmented `_ := start` rules to eliminate some special-cases in glrParse.
- (if I can work out how): avoid some spurious recovery cases described in comments
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D128486
Files:
clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRGraph.h
clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
clang-tools-extra/pseudo/lib/GLR.cpp
clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
clang-tools-extra/pseudo/lib/grammar/GrammarBNF.cpp
clang-tools-extra/pseudo/lib/grammar/LRGraph.cpp
clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp
clang-tools-extra/pseudo/test/cxx/empty-member-spec.cpp
clang-tools-extra/pseudo/test/cxx/recovery-init-list.cpp
clang-tools-extra/pseudo/unittests/GLRTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128486.440379.patch
Type: text/x-patch
Size: 40492 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220627/dbd729b8/attachment-0001.bin>
More information about the cfe-commits
mailing list