Split out infix and prefix operators to separate node kinds. (#3481)

This leaves a single state for each in the expr loop. I was trying to
think through ways to have per-token states, but they felt sort of
bulky.

Note this is more verbose: but I think the long-term is going to be that
when we start wanting to add handlers, we're going to need to switch to
different names based on the token found. As a consequence, the parse
state logic will end up diverging a little, and we'll just want to align
towards boilerplate handlers.

Short-term, this opens up a path for saying that each parse node
corresponds to precisely one token in success states, and separates out
what were becoming big handler functions in check.
This commit is contained in:
Jon Ross-Perkins authored and GitHub committed 2023-12-13 19:52:20 +00:00
1 parent 6419568142
commit 7c7afc9e32
55 files changed
+569 -365

No files matched your search

+6 -6
View File
@@ -16,8 +16,8 @@ fn C() -> const (i32*) { return C(); }
// CHECK:STDOUT: {kind: 'TuplePatternStart', text: '('},
// CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2},
// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'PrefixOperator', text: 'const', subtree_size: 2},
// CHECK:STDOUT: {kind: 'PostfixOperator', text: '*', subtree_size: 3},
// CHECK:STDOUT: {kind: 'PrefixOperatorConst', text: 'const', subtree_size: 2},
// CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 3},
// CHECK:STDOUT: {kind: 'ReturnType', text: '->', subtree_size: 4},
// CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 9},
// CHECK:STDOUT: {kind: 'ReturnStatementStart', text: 'return'},
@@ -32,9 +32,9 @@ fn C() -> const (i32*) { return C(); }
// CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2},
// CHECK:STDOUT: {kind: 'ExprOpenParen', text: '('},
// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'PrefixOperator', text: 'const', subtree_size: 2},
// CHECK:STDOUT: {kind: 'PrefixOperatorConst', text: 'const', subtree_size: 2},
// CHECK:STDOUT: {kind: 'ParenExpr', text: ')', subtree_size: 4},
// CHECK:STDOUT: {kind: 'PostfixOperator', text: '*', subtree_size: 5},
// CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 5},
// CHECK:STDOUT: {kind: 'ReturnType', text: '->', subtree_size: 6},
// CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 11},
// CHECK:STDOUT: {kind: 'ReturnStatementStart', text: 'return'},
@@ -49,9 +49,9 @@ fn C() -> const (i32*) { return C(); }
// CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2},
// CHECK:STDOUT: {kind: 'ExprOpenParen', text: '('},
// CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'PostfixOperator', text: '*', subtree_size: 2},
// CHECK:STDOUT: {kind: 'PostfixOperatorStar', text: '*', subtree_size: 2},
// CHECK:STDOUT: {kind: 'ParenExpr', text: ')', subtree_size: 4},
// CHECK:STDOUT: {kind: 'PrefixOperator', text: 'const', subtree_size: 5},
// CHECK:STDOUT: {kind: 'PrefixOperatorConst', text: 'const', subtree_size: 5},
// CHECK:STDOUT: {kind: 'ReturnType', text: '->', subtree_size: 6},
// CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 11},
// CHECK:STDOUT: {kind: 'ReturnStatementStart', text: 'return'},