Skip to content

Keeping a node even it has zero matches #344

@iK4tsu

Description

@iK4tsu

Given the grammar

Example:

Begin < AList
AList < A*
A <- 'a'

It would be nice to keep AList even for zero matches, given that 0 is a valid match. I expect something like

Example[0,0][]
  +-Example.Begin[0,0][]
    +-Example.AList[0,0][]

It is possible to achieve something like this by using '^AList', however, this also implies that all rules not defined in the grammar are kept, which creates unwanted noise. Moreover, since there is no way to halt the persistence, i.e. all child nodes share the same constraint, it causes even more noise when more than zero elements match.

Either all zero or more constraints would need to be kept in the final tree, which is probably undesired given the breaking change, or a new symbol that enforces the tagged rule, and only the tagged rule, to always be kept, could be added. Unless there is an intended and already implemented way of achieving this.

This affects constraints that can match with zero elements, meaning that the zero or one constraint would work similarly.

Edit: I didn't test this grammar. I think the description is simple enough to understand the desired outcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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