Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

jonmeow
Copy link
Contributor

@jonmeow jonmeow commented Dec 8, 2023

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.

@jonmeow
Copy link
Contributor Author

jonmeow commented Dec 8, 2023

(note, dependencies in stack)

@jonmeow jonmeow force-pushed the op-split branch 2 times, most recently from 99ddac7 to d3d6cd4 Compare December 11, 2023 19:28
@jonmeow jonmeow force-pushed the op-split branch 2 times, most recently from 1e1665d to 159c37c Compare December 12, 2023 01:03
break;
}

context.PushState(state);
context.PushStateForExpr(operator_precedence);
} else {
context.AddNode(NodeKind::PostfixOperator, state.token, state.subtree_start,
state.has_error);
context.AddNode(NodeKind::PostfixOperatorStar, state.token,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if we only have one postfix operator for now, I think we should add a switch here and a ..._POSTFIX macro.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I'll send a separate PR for that.

@jonmeow jonmeow added this pull request to the merge queue Dec 13, 2023
Merged via the queue into carbon-language:trunk with commit 7c7afc9 Dec 13, 2023
6 checks passed
@jonmeow jonmeow deleted the op-split branch December 13, 2023 20:05
github-merge-queue bot pushed a commit that referenced this pull request Dec 14, 2023
Per request on #3481, for consistency with prefix/infix.
github-merge-queue bot pushed a commit that referenced this pull request Dec 18, 2023
Co-authored-by: Jon Ross-Perkins <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants