Skip to content

prevent empty SKIPPED nodes in the tree #700

@OmarTawfik

Description

@OmarTawfik

We insert those when there are failures, even if no text was actually skipped. Then we detect the precense of those during parsing (using a recursive cursor search) to check the validity/rank different parse results. Example:

- UsingDeconstruction (Rule): # 46..49 " {}"
- OpenBrace (Token): "{" # 47..48
- SKIPPED (Token): "" # 48..48
- CloseBrace (Token): "}" # 48..49

This has a few issues:

  • The empty SKIPPED token is confusing to see in the output, since nothing is actually skipped, and the returning tree is complete (regardless of errors).
  • Its presence will prevent us from creating AST nodes for such trees, when it is actually valid.
  • There are multiple places in parser where it creates a cursor to recursively assert some condition for all children of the current node. This incurs a big performance hit, which increases non-linearly with large trees.

Maybe we can store that info (a boolean flag?) on the parse result instead? That would eliminate the above issues, and keep the tree intact.

Possibly related to #507

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions