Skip to content

Forgiving syntax #1425

@tegni

Description

@tegni

Suggestion
Provide a %catchall token_name syntax thingy that declares that everything that cannot be parsed as any defined token or terminal should be returned as the token token_name. This would allow for forgiving syntax definitions, that have a catchall that doesn't literally catch all characters but only everythin that would otherwise cause a syntax error.

Describe alternatives you've considered
I've tried using catchall definitions like a /.+/s at lower priority than all other tokens but that just returned the whole source code I gave it in single characters as that catchall token, fully ignoring all valid defined tokens. Even if it wouldn't have caused a syntax error without the catchall it just singled out every character.

Additional context
This could be useful for e.g. markup parsing. I'm creating my own markup language right now and having forgiving syntax that cannot error out, just return only-half-usable results would help a lot.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions