Skip to content

Loop analysis is overly sensitive on the root node #85

@nickelpro

Description

@nickelpro

When hand-rolling multi-byte peeks via something like this:

const invoke_lookahead_backslash = (
  preserved: source.node.Node,
  escaped: source.node.Node,
  stripped: source.node.Node,
) => {
  const pause = p.pause(LlpkgcError.Lookahead, 'Lookahead required')
  const invoke = p.invoke(lookahead_func, {
    0: preserved,
    1: escaped,
    2: stripped
  }, lookahead_error)

  pause.otherwise(invoke)
  return invoke
}

This creates a loop which is fine in most contexts, because there exists mechanisms to advance in some of those nodes.

However in the root node (or any node reachable from the root via no-advance edges), any character which is peek()'d instead of match()'d will cause the loop analysis to fail here on the pause loop. In this case the \, which is what I'm interested in, because it will either be a part of a span or not depending on the following character.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions