GbnfRecognizer constructor

GbnfRecognizer(
  1. String grammar, {
  2. String root = 'root',
})

Implementation

GbnfRecognizer(String grammar, {this.root = 'root'}) : _rules = _Parser(grammar).parse() {
  for (final entry in _rules.entries) {
    for (final name in _references(entry.value)) {
      if (!_rules.containsKey(name)) throw FormatException('rule ${entry.key} uses the undefined rule $name');
    }
  }
  if (!_rules.containsKey(root)) throw FormatException('no rule named $root');
  _checkLeftRecursion();
}