mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Reorganize interface parsing to be more consistent with other declarations. (#2646)
The comments in parse_node_kind.def capture the change being made here. Before: ``` // _external_: DeclaredName // InterfaceBodyStart // _external_: statements // InterfaceBodyEnd // InterfaceDefinition ``` After: ``` // InterfaceIntroducer // DeclaredName // InterfaceDefinitionStart // _external_: declarations // InterfaceDefinition ``` Really I just want to treat introduced things consistently. `var` defines my philosophy here: it doesn't always have a `DeclaredName`, so the `VarIntroducer` _must_ be the bounding node. By being consistent with that, I believe that overall the structure becomes easier to understand (that is, there are fewer inconsistencies to understand). This also adds InterfaceDeclaration, since I think it can be predicted we'll have that, and it's helpful for making recover consistent with HandleDeclarationError. Similarly, I'm also trying to standardize the loop processing a little with HandleDeclarationLoop. In the current approach, InterfaceDefinitionFinish isn't a necessary state, so I'm removing it.
This commit is contained in:
+8
-6
@@ -5,15 +5,17 @@
|
||||
// AUTOUPDATE
|
||||
// RUN: %{not} %{carbon-run-parser}
|
||||
// CHECK:STDOUT: [
|
||||
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'bar'},
|
||||
// CHECK:STDOUT: {kind: 'InterfaceDefinition', text: 'interface', has_error: yes, subtree_size: 2},
|
||||
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'foo'},
|
||||
// CHECK:STDOUT: {kind: 'InterfaceDefinition', text: 'interface', has_error: yes, subtree_size: 2},
|
||||
// CHECK:STDOUT: {kind: 'InterfaceIntroducer', text: 'interface'},
|
||||
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'Bar'},
|
||||
// CHECK:STDOUT: {kind: 'InterfaceDeclaration', text: 'interface', has_error: yes, subtree_size: 3},
|
||||
// CHECK:STDOUT: {kind: 'InterfaceIntroducer', text: 'interface'},
|
||||
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'Foo'},
|
||||
// CHECK:STDOUT: {kind: 'InterfaceDeclaration', text: 'interface', has_error: yes, subtree_size: 3},
|
||||
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
|
||||
// CHECK:STDOUT: ]
|
||||
|
||||
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/generics/interface/fail_missing_open_curly.carbon:[[@LINE+1]]:15: Expected `{` to start interface definition.
|
||||
interface bar baz {}
|
||||
interface Bar Baz {}
|
||||
|
||||
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/generics/interface/fail_missing_open_curly.carbon:[[@LINE+1]]:14: Expected `{` to start interface definition.
|
||||
interface foo
|
||||
interface Foo
|
||||
|
||||
Reference in New Issue
Block a user