[PATCH] D130550: [pseudo] Start rules are `_ := start-symbol EOF`, improve recovery.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 25 23:46:16 PDT 2022


sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, alextsao1999.
Herald added a project: clang-tools-extra.

Previously we were calling glrRecover() ad-hoc at the end of input.
Two main problems with this:

- glrRecover() on two separate code paths is inelegant
- We may have to recover several times in succession (e.g. to exit from nested scopes), so we need a loop at end-of-file

Having an actual shift action for an EOF terminal allows us to handle
both concerns in the main shift/recover/reduce loop.

This revealed a recovery design bug where recovery could enter a loop by
repeatedly choosing the same parent to identically recover from.
Addressed this by allowing each node to be used as a recovery base once.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130550

Files:
  clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
  clang-tools-extra/pseudo/lib/Forest.cpp
  clang-tools-extra/pseudo/lib/GLR.cpp
  clang-tools-extra/pseudo/lib/cxx/cxx.bnf
  clang-tools-extra/pseudo/lib/grammar/LRGraph.cpp
  clang-tools-extra/pseudo/test/lr-build-basic.test
  clang-tools-extra/pseudo/test/lr-build-conflicts.test
  clang-tools-extra/pseudo/unittests/ForestTest.cpp
  clang-tools-extra/pseudo/unittests/GLRTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130550.447580.patch
Type: text/x-patch
Size: 15815 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220726/720ce6af/attachment.bin>


More information about the cfe-commits mailing list