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

Parse non-syntactic operator tokens as K"Identifier" kind #523

Merged
merged 1 commit into from
Dec 30, 2024

Conversation

c42f
Copy link
Member

@c42f c42f commented Dec 30, 2024

Most operators are semantically just normal identifiers after parsing so should get the Kind K"Identifier". For example, after this change a + b parses with K"Identifier" kind for the + token.

As an exception, standalone syntactic ops keep their kind - they can't really be used in a sane way as identifiers or interpolated into expressions in the normal way because they have their own syntactic forms. This also helps us in Expr conversion where they also have their own rules for coalescing with dots, when dotted.

Also introduce a new keyword operators_as_identifiers to the tokenize() API to accommodate some simple uses of this API to colour token strings by operator type, even when the operator is semantically in identifier-position.

Fix #474 as a follow-on from #456

CC @fredrikekre

Most operators are semantically just normal identifiers after parsing so
get the Kind `K"Identifier"`. For example, `a + b` parses with
`K"Identifier"` kind for the `+` token.

As an exception, standalone syntactic ops keep their kind - they can't
really be used in a sane way as identifiers or interpolated into
expressions in the normal way because they have their own syntactic
forms. This also helps us in `Expr` conversion where they also have
their own rules for coalescing with dots, when dotted.

Also introduce a new keyword `operators_as_identifiers` to the
`tokenize()` API to accommodate some simple uses of this API to colour
token strings by operator type, even when the operator is semantically
in identifier-position.
@c42f c42f merged commit 35dc3bc into main Dec 30, 2024
36 checks passed
@c42f c42f deleted the caf/operator-tokens-as-identifiers branch December 30, 2024 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remap operator tokens to K"Identifier" during parsing
1 participant