Closed Omnikar closed 2 months ago
Could cananicalization be done in the lexer? I think it makes more sense there.
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.
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
?
Also, since there are multiple canonicalization steps now, should they be separated into a complete canonicalization function like
canonicalize_ident
that just callscanonicalize_exclams
andcanonicalize_subscripts
?
Yes probably. Ya I forgot that about the ident tokens.
Okay I added canonicalize_ident
.
Subscripts will format from
__
followed by consecutive digits. Identifiers are canonicalized during parsing so thatA__1
andA₁
resolve to the same identifier (A₁
) even when code is not formatted.