This is an archive of the discontinued LLVM Phabricator instance.

[syntax][pseudo] Introduce the spec C++ grammar.
ClosedPublic

Authored by hokein on Dec 16 2021, 12:41 AM.

Details

Summary

Also, add a dummy clang-pseudo tool (right now it accepts and parses the
grammar file).

Diff Detail

Event Timeline

hokein created this revision.Dec 16 2021, 12:41 AM
hokein requested review of this revision.Dec 16 2021, 12:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 16 2021, 12:41 AM
sammccall added inline comments.Dec 21 2021, 3:12 AM
clang/lib/Tooling/Syntax/Pseudo/cxx.bnf
13

translation-unit appears to be non-nullable in the grammar here

14

nit: adjusted

28

I think we should spell out what this is, or leave out the FIXME

29

This probably isn't a FIXME for the grammar right? If we're going with non-nullable rules, having the *parser* special-case _ as nullable seems more sensible.

31

Is this "default start symbol"?
I believe we conceptually want to be able to start parsing at other symbols too.

34

I'd suggest dropping the A.1 part, as it's version-specific

(e.g. gram.basic is currently A.4 at https://eel.is/c++draft/gram, which is a pretty common reference)

45

nit: gram.basic

clang/tools/clang-pseudo/ClangPseudo.cpp
2

Can we use this tool to drive lit tests?

42

nit: parse -> parsed

43

do you want to dump the grammar? (Behind a dump-grammar subcommand)

44

Diagnostics.empty() ? 0 : 2?

hokein updated this revision to Diff 401559.Jan 20 2022, 2:19 AM
hokein marked 7 inline comments as done.

address comments and add lit test to verify cxx.bnf

hokein updated this revision to Diff 401561.Jan 20 2022, 2:21 AM
hokein marked an inline comment as done.

add new line to eof

clang/lib/Tooling/Syntax/Pseudo/cxx.bnf
28

these FIXMEs probably should not live in the bnf grammar. removed them.

31

Technically, _ is the augmented symbol with the *real* start symbols coming on the right hand side -- this is a technique to make LR parsing life easier.

clang/tools/clang-pseudo/ClangPseudo.cpp
2

good idea. Refined the tool, now it supports check-grammar.

sammccall accepted this revision.Feb 2 2022, 8:06 AM
sammccall added inline comments.
clang/lib/Tooling/Syntax/Pseudo/cxx.bnf
41

nit: #! Custom might be more obvious than # !Custom

684

there should be a #! somewhere here

This revision is now accepted and ready to land.Feb 2 2022, 8:06 AM
hokein updated this revision to Diff 405904.Feb 4 2022, 2:49 AM
hokein marked 2 inline comments as done.

rebase and address comments.

This revision was landed with ongoing or failed builds.Feb 4 2022, 2:59 AM
This revision was automatically updated to reflect the committed changes.