Skip to content

Improve error for range without square brackets #157

@jlapeyre

Description

@jlapeyre

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions