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

Allow subscript numbers in identifiers #516

Merged
merged 2 commits into from
Jun 27, 2024

Conversation

Omnikar
Copy link
Contributor

@Omnikar Omnikar commented Jun 27, 2024

Subscripts will format from __ followed by consecutive digits.
Identifiers are canonicalized during parsing so that A__1 and A₁ resolve to the same identifier (A₁) even when code is not formatted.

Subscripts will format from `__` followed by consecutive digits.
@kaikalii
Copy link
Member

Could cananicalization be done in the lexer? I think it makes more sense there.

@Omnikar
Copy link
Contributor Author

Omnikar commented Jun 27, 2024

That's what I initially thought, but at least from what I've gleaned from the code, the lexer returns identifier tokens as just the span they occupy in the code, so it's not possible for me to change the content of the actual identifier returned by the lexer. Since my other PR adding double exclamation points was also a form of identifier canonicalization, I just decided to put this in the same place.

@Omnikar
Copy link
Contributor Author

Omnikar commented Jun 27, 2024

Also, since there are multiple canonicalization steps now, should they be separated into a complete canonicalization function like canonicalize_ident that just calls canonicalize_exclams and canonicalize_subscripts?

@kaikalii
Copy link
Member

kaikalii commented Jun 27, 2024

Also, since there are multiple canonicalization steps now, should they be separated into a complete canonicalization function like canonicalize_ident that just calls canonicalize_exclams and canonicalize_subscripts?

Yes probably.
Ya I forgot that about the ident tokens.

@Omnikar
Copy link
Contributor Author

Omnikar commented Jun 27, 2024

Okay I added canonicalize_ident.

@kaikalii kaikalii merged commit cf41285 into uiua-lang:main Jun 27, 2024
1 check passed
@Omnikar Omnikar deleted the ident-subscripts branch June 27, 2024 23:21
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.

None yet

2 participants