This is an archive of the discontinued LLVM Phabricator instance.

[pseudo] Eliminate the dangling-else syntax ambiguity.
ClosedPublic

Authored by hokein on Jul 20 2022, 5:33 AM.

Details

Summary
  • the grammar ambiguity is eliminate by a guard;
  • modify the guard function signatures, now all parameters are folded in to a single object, avoid a long parameter list (as we will add more parameters in the near future);

Diff Detail

Event Timeline

hokein created this revision.Jul 20 2022, 5:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2022, 5:33 AM
hokein requested review of this revision.Jul 20 2022, 5:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2022, 5:33 AM
sammccall accepted this revision.Jul 20 2022, 12:58 PM
sammccall added inline comments.
clang-tools-extra/pseudo/include/clang-pseudo/Language.h
25

passing the position in the stream would be more general, there's no reason in particular that the amount of lookahead the guard needs is the same as what we have in GLR

OTOH as long as it *is* the same this is probably faster

clang-tools-extra/pseudo/lib/cxx/CXX.cpp
26–27

nit: I would suggest calling this conventionally P instead of Params, the bodies of these are really verbose

clang-tools-extra/pseudo/test/cxx/dangling-else.cpp
4

nit: place this all on one line so it's clear there's no indentation-based heuristics at play?

This revision is now accepted and ready to land.Jul 20 2022, 12:58 PM
hokein updated this revision to Diff 446388.Jul 21 2022, 1:37 AM
hokein marked 2 inline comments as done.

address comments.

clang-tools-extra/pseudo/include/clang-pseudo/Language.h
25

+1, agree. This'd requires some non-trivial changes in the GLR because we use Lookahead in the Reduce rather than the token stream index. I think it is better to do it in a followup patch. I added a FIXME.

This revision was landed with ongoing or failed builds.Jul 22 2022, 12:13 AM
This revision was automatically updated to reflect the committed changes.