Skip to content

Conversation

@mohammadfawaz
Copy link
Contributor

@mohammadfawaz mohammadfawaz commented Jul 12, 2023

Closes #100

The idea is to handle the exact pattern <int>.<int> separately. The lexer will treat this as a real, so we just break it apart in the parser. I had to mess around with the spans when reporting errors for large integers because the token span is for the whole token <int>.<int> and I needed the spans of the individual <int>s.

@mohammadfawaz mohammadfawaz self-assigned this Jul 12, 2023
@mohammadfawaz mohammadfawaz marked this pull request as draft July 12, 2023 20:48
@mohammadfawaz mohammadfawaz force-pushed the mohammadfawaz/100 branch 3 times, most recently from 259a384 to 77d81ff Compare July 12, 2023 21:15
@mohammadfawaz mohammadfawaz marked this pull request as ready for review July 12, 2023 21:19
@otrho
Copy link
Contributor

otrho commented Jul 13, 2023

I'm not sure this is the best approach. Tying the dot to the int as an indexing token is fixing this problem except it does introduce that ugly regex full of whitespace which in turn needs to be specially ignored and it'll become a problem if we add structs and want to index them with Dot then Identifier.

If we kept the original way and only added a special case for the .0.0 indexing which looks like a real it means we don't need the bad regex and we can easily add symbolic indexing later.

Thinking out loud:

blah.0          -> ident, dot, int
blah.0.0        -> ident, special-case-token
blah . 0 . 0    -> ident, dot, int, dot, int  # This is because we disallow whitespace in reals.
blah . 0.0      -> ident, special-case-token  # This implies we'll still need the whitespace after the first dot in the special case regex.
blah.field_name -> ident, dot, ident          # For structs or whetever other indexing we do eventually.

Hrmm, so we can't avoid some whitespace in the special token. But still, indexing to identifiers should just work if we keep Dot as its own token, assuming that hasn't been ruled out entirely already.

@mohammadfawaz mohammadfawaz force-pushed the mohammadfawaz/100 branch 5 times, most recently from 61bb05a to cce93bd Compare July 14, 2023 14:48
@mohammadfawaz
Copy link
Contributor Author

@otrho
Alright, it seems that handling the special case for reals of the form 0.0 is enough to get everything working fine without any wonky regexes in the lexer.

@mohammadfawaz mohammadfawaz marked this pull request as draft July 14, 2023 15:39
@mohammadfawaz mohammadfawaz marked this pull request as ready for review July 14, 2023 15:51
@mohammadfawaz mohammadfawaz merged commit 295e01e into master Jul 17, 2023
@mohammadfawaz mohammadfawaz deleted the mohammadfawaz/100 branch July 17, 2023 01:57
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.

Support nested tuple indexing without parentheses t.0.0

3 participants