Skip to content

Add number-syntax edge case tests#5560

Merged
laurmaedje merged 1 commit intotypst:mainfrom
wrzian:number-syntax-tests
Dec 11, 2024
Merged

Add number-syntax edge case tests#5560
laurmaedje merged 1 commit intotypst:mainfrom
wrzian:number-syntax-tests

Conversation

@wrzian
Copy link
Contributor

@wrzian wrzian commented Dec 11, 2024

I was following the number prefix changes (#5519) and found that we didn't have very many tests for basic number-syntax edge cases, so I thought of a few that I didn't see elsewhere.

I added these tests just as a single named test with implicit allowed values and explicit errors, which is fine because all syntax errors are reported at once. But I can change that if you'd prefer them split out into separate tests.

I also am not sure that we really want to allow the double-percent sign. I think that it may be more consistent to just lex all trailing alpha-numeric characters or percent signs following numbers just for simplicity. It would improve the second error, but disallow the first case. But I don't really think the first case is actually helpful for markup mode.

@wrzian wrzian changed the title improve number lexing add number-syntax edge cases tests Dec 11, 2024
@wrzian wrzian force-pushed the number-syntax-tests branch from 1fa9f30 to 87d932b Compare December 11, 2024 02:56
@laurmaedje laurmaedje changed the title add number-syntax edge cases tests Add number-syntax edge case tests Dec 11, 2024
@laurmaedje laurmaedje added this pull request to the merge queue Dec 11, 2024
@laurmaedje
Copy link
Member

Thanks!

I also am not sure that we really want to allow the double-percent sign. I think that it may be more consistent to just lex all trailing alpha-numeric characters or percent signs following numbers just for simplicity. It would improve the second error, but disallow the first case. But I don't really think the first case is actually helpful for markup mode.

I don't have a strong opinion either way. I don't really see a strong reason to forbid it (nobody will ever write that), but I'm also not necessarily opposed.

Merged via the queue into typst:main with commit 5e0e58d Dec 11, 2024
@wrzian wrzian deleted the number-syntax-tests branch December 11, 2024 20:37
@wrzian
Copy link
Contributor Author

wrzian commented Dec 11, 2024

I feel like it would be good for consistency of implementations, i.e. other parsers/highlighters, to say that number suffixes include any series of alphanumeric/percent characters (so turning #1.2%% to an error). Feels like it better follows the principle of "maxmimum munch".

Would you be ok with me implementing that?

@laurmaedje
Copy link
Member

I'd be okay with that.

@wrzian wrzian mentioned this pull request Feb 27, 2025
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.

2 participants