Skip to content

Have ability for visitors to operate in order? #2092

Answered by robocoder
NikhilVerma asked this question in Q&A
Discussion options

You must be logged in to vote

The fix is to wrap your .OR into another rule.

this.RULE("document", () => {
    this.MANY(() => {
        this.SUBRULE(this.subdocument);
    });
});

this.RULE("subdocument", () => {
    this.OR([
        { ALT: () => this.SUBRULE(this.blockDeclaration) },
        { ALT: () => this.SUBRULE(this.attribute) },
        { ALT: () => this.SUBRULE(this.comment) }
    ]);
});

And in your code, iterate thru the children of the subdocument.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by bd82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2080 on March 15, 2025 15:37.