Files
clang-p2996/clang-tools-extra/pseudo/test/glr-variant-start.cpp
Haojian Wu 1a65c491be [pseudo] Support parsing variant target symbols.
With this patch, we're able to parse smaller chunks of C++ code (statement,
declaration), rather than translation-unit.

The start symbol is listed in the grammar in a form of `_ :=
statement`, each start symbol has a dedicated state (`_ := • statement`).
We create and track all these separate states in the LRTable. When we
start parsing, we lookup the corresponding state to start the parser.

LR pasing table changes with this patch:
- number of states: 1467 -> 1471
- number of actions: 82891 -> 83578
- size of the table (bytes): 334248 -> 336996

Differential Revision: https://reviews.llvm.org/D125006
2022-05-16 10:38:16 +02:00

10 lines
471 B
C++

// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --start-symbol=statement-seq --print-forest | FileCheck %s
a + a;
// CHECK: statement-seq~expression-statement := expression ;
// CHECK-NEXT: ├─expression~additive-expression := additive-expression + multiplicative-expression
// CHECK-NEXT: │ ├─additive-expression~IDENTIFIER :=
// CHECK-NEXT: │ ├─+ :=
// CHECK-NEXT: │ └─multiplicative-expression~IDENTIFIER :=
// CHECK-NEXT: └─; :=