Skip to content

[Question] Extending skipping whitespaces mechanism? #83

@kerrytazi

Description

@kerrytazi

I'm trying to make a parser for something like this:

// single line comment
let a = 3;

Since ctpg automatically skips whitespaces I use rule like this:

stmt("let", token, "=", expr, ";")

But since "single line comment" can appear anywhere I need to implement all the variations:

stmt("let", comment, token, "=", expr, ";"),
stmt("let", token, comment, "=", expr, ";"),
stmt("let", token, "=", comment, expr, ";"),
...

I ain't doing that...

I tried to make comment optional but parser doesn't recognize empty (zero length) term.

Any ideas or is it simply not supported?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions