visitSubterminalSymbol<E> method

  1. @override
Parser visitSubterminalSymbol<E>(
  1. SubterminalSymbol<E> node
)
override

Implementation

@override
Parser visitSubterminalSymbol<E>(SubterminalSymbol<E> node) {
  final expression = node.expression;
  final rule = expression.rule!;
  final name = rule.name;
  SubterminalParser<E> getParser() {
    final parser = DummyParser<E>();
    if (options.debug) {
      return SubterminalDebugParser<E>(parser, name, source: '$node');
    } else {
      return SubterminalParser<E>(parser, name, source: '$node');
    }
  }

  if (rules.containsKey(node)) {
    return rules[node]!;
  }

  final parser = getParser();
  rules[node] = parser;
  final child = visitOrderedChoice(expression) as Parser<E>;
  parser.parser = child;
  if (options.debug) {
    rules[node] = parser;
    return parser;
  } else {
    rules[node] = child;
    return child;
  }
}