mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 09:34:42 +01:00
Refactor match parse nodes. (#6870)
Use the same node kind for the body of `case` and `default` handlers. We don't need to distinguish these in check, so don't create extra node kinds for them. In order to make the nodes properly delimited, make the label (`case ...` or `default`) nodes be children of the `=>` node rather than siblings. This allows us to use the node kind of the `=>` as the bracketing node for the complete handler, rather than having two different bracketing node kinds, one for each kind of label.
This commit is contained in:
@@ -34,13 +34,13 @@ fn f() -> i32 {
|
||||
// CHECK:STDOUT: {kind: 'InvalidParse', text: '{', has_error: yes},
|
||||
// CHECK:STDOUT: {kind: 'MatchCondition', text: 'match', has_error: yes, subtree_size: 3},
|
||||
// CHECK:STDOUT: {kind: 'MatchStatementStart', text: '{', subtree_size: 5},
|
||||
// CHECK:STDOUT: {kind: 'MatchDefaultIntroducer', text: 'default'},
|
||||
// CHECK:STDOUT: {kind: 'MatchDefaultEqualGreater', text: '=>'},
|
||||
// CHECK:STDOUT: {kind: 'MatchDefaultStart', text: '{', subtree_size: 3},
|
||||
// CHECK:STDOUT: {kind: 'MatchDefaultIntroducer', text: 'default'},
|
||||
// CHECK:STDOUT: {kind: 'MatchDefault', text: '=>', subtree_size: 2},
|
||||
// CHECK:STDOUT: {kind: 'MatchHandlerStart', text: '{', subtree_size: 3},
|
||||
// CHECK:STDOUT: {kind: 'ReturnStatementStart', text: 'return'},
|
||||
// CHECK:STDOUT: {kind: 'IntLiteral', text: '1'},
|
||||
// CHECK:STDOUT: {kind: 'ReturnStatement', text: ';', subtree_size: 3},
|
||||
// CHECK:STDOUT: {kind: 'MatchDefault', text: '}', subtree_size: 7},
|
||||
// CHECK:STDOUT: {kind: 'MatchHandler', text: '}', subtree_size: 7},
|
||||
// CHECK:STDOUT: {kind: 'MatchStatement', text: '}', subtree_size: 13},
|
||||
// CHECK:STDOUT: {kind: 'ReturnStatementStart', text: 'return'},
|
||||
// CHECK:STDOUT: {kind: 'IntLiteral', text: '0'},
|
||||
|
||||
Reference in New Issue
Block a user