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

Improve error for range without square brackets #157

Open
jlapeyre opened this issue Feb 26, 2024 · 0 comments
Open

Improve error for range without square brackets #157

jlapeyre opened this issue Feb 26, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@jlapeyre
Copy link
Collaborator

Ranges look like this: [1:3], [0:2:12]. Omitting the square brackets gives syntax errors like "missing semicolon", "expecting expression", etc. This is likely to be a common error. In many languages, for example a certain ancient scripting language whose name begins with "P", ranges have the same syntax, but without brackets.

Parsing the range as a range, eg. for int i in 0:10, and also recording a specific error would be useful. It would allow parsing to continue and the error would be more useful to the user.

How? The limits and step are expressions. Perhaps make : a binary operator. This can be flattened subsequently as a range, say in oq3_syntax. This is a fair amount of work. But it might be tied in with more general facilities like this. I have only the vaguest ideas at the moment.

@jlapeyre jlapeyre added the enhancement New feature or request label Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant