UNPKG

net.akehurst.language-agl-processor

Version:
21,124 lines 733 kB
import {
  initMetadataForObject1cxne3s9w65el as initMetadataForObject,
  LinkedHashMap1zhqxkxv3xnkl as LinkedHashMap,
  Triple1vhi3d0dgpnjb as Triple,
  ArrayList3it5z8td81qkl as ArrayList,
  Unit_instance1fbcbse1fwigr as Unit_instance,
  collectionSizeOrDefault36dulx8yinfqm as collectionSizeOrDefault,
  UnsupportedOperationException2tkumpmhredt3 as UnsupportedOperationException,
  toSet2orjxp16sotqu as toSet,
  initMetadataForCompanion1wyw17z38v6ac as initMetadataForCompanion,
  lazy2hsh8ze7j6ikd as lazy,
  THROW_CCE2g6jy02ryeudk as THROW_CCE,
  KProperty1ca4yb4wlo496 as KProperty1,
  getPropertyCallableRef3hckxc0xueiaj as getPropertyCallableRef,
  StringBuildermazzzhj6kkai as StringBuilder,
  addAll1k27qatfgp3k5 as addAll,
  toString1pkumu07cwy4m as toString,
  compareBy2697bq0ffft96 as compareBy,
  sortedWith2csnbbb21k0lg as sortedWith,
  VOID3gxj6tk5isa35 as VOID,
  joinToString1cxrrlmo0chqs as joinToString,
  initMetadataForClassbxx6q50dy2s7 as initMetadataForClass,
  emptySetcxexqki71qfa as emptySet,
  plus18eogev54fmsa as plus,
  contentHashCode2i020q5tbeh2s as contentHashCode,
  plus2m1vv33moko5t as plus_0,
  flatten2dh4kibw1u0qq as flatten,
  checkIndexOverflow3frtmheghr0th as checkIndexOverflow,
  listOfvhqybd2zx248 as listOf,
  emptyList1g2z5xcrvp2zy as emptyList,
  println29lx63wmxk0st as println,
  println2shhhgwwt4c61 as println_0,
  toString30pk9tzaqopn as toString_0,
  LinkedHashSet2tkztfx86kyx2 as LinkedHashSet,
  ensureNotNull1e947j3ixpazm as ensureNotNull,
  Paire9pteg33gng7 as Pair,
  IllegalStateExceptionkoljg5n0nrlr as IllegalStateException,
  equals2au1ep9vhcato as equals,
  FunctionAdapter3lcrrz3moet5b as FunctionAdapter,
  isInterface3d6p8outrmvmk as isInterface,
  Comparator2b3maoeh98xtg as Comparator,
  hashCodeq5arwsb9dgti as hashCode,
  toList3jhuyej2anx2q as toList,
  defineProp3ur6h3slcvq4x as defineProp,
  THROW_IAE23kobfj9wdoxr as THROW_IAE,
  Enum3alwj03lh1n41 as Enum,
  initMetadataForInterface1egvbzx539z91 as initMetadataForInterface,
  toList383f556t1dixk as toList_0,
  throwUninitializedPropertyAccessExceptionyynx7gkm73wd as throwUninitializedPropertyAccessException,
  toList2z3tifmtru5ra as toList_1,
  NoSuchElementException679xzhnp5bpj as NoSuchElementException,
  IllegalArgumentException2asla15b5jaob as IllegalArgumentException,
  setOf1u3mizs95ngxo as setOf,
  noWhenBranchMatchedException2a6r7ubxgky5j as noWhenBranchMatchedException,
  getBooleanHashCode1bbj3u6b3v0a7 as getBooleanHashCode,
  plus20p0vtfmu0596 as plus_1,
  listOf1jh22dvmctj1r as listOf_0,
  plus310ted5e4i90h as plus_2,
  plus1ogy4liedzq5j as plus_3,
  first28gmhyvs4kf06 as first,
  union28sojvmrkgw6y as union,
  minus27abgkurcn6u0 as minus,
  HashMap1a0ld5kgwhmhv as HashMap,
  NotImplementedErrorfzlkpv14xxr8 as NotImplementedError,
  compareValues1n2ayl87ihzfk as compareValues,
  Regexxgw0gjiagf4z as Regex,
  Collection1k04j3hzsbod0 as Collection,
  first58ocm7j58k3q as first_0,
  KtMap140uvy3s5zad8 as KtMap,
  firstOrNull1982767dljvdy as firstOrNull,
  protoOf180f3jzyo7rfj as protoOf,
  arrayListOf1fz8nib0ncbow as arrayListOf,
  mutableListOf6oorvk2mtdmp as mutableListOf,
  setOf45ia9pnfhe90 as setOf_0,
  intersect7qttw6wlmz1n as intersect,
  KtMutableSetwuwn7k5m570a as KtMutableSet,
  getKClassFromExpression348iqjl4fnx2f as getKClassFromExpression,
  toMutableSetjdpdbr9jsqq8 as toMutableSet,
  getStringHashCode26igk1bx568vk as getStringHashCode,
  last1vo29oleiqj36 as last,
  max2o8z1isrnjymo as max,
  sorted354mfsiv4s7x5 as sorted,
  substringiqarkczpya5m as substring,
  isCharSequence1ju9jr1w86plq as isCharSequence,
  reversed3umwqsxpi431x as reversed,
  sortWith4fnm6b3vw03s as sortWith,
  minus2znw4oicpx34e as minus_0,
  reversed22y3au42jl32b as reversed_0,
  maxOrNull2e5ok5wkly1cp as maxOrNull,
  emptyMapr06gerzljqtm as emptyMap,
  minus165a8u1e0x1lu as minus_1,
  compareTo3ankvs086tmwq as compareTo,
  Comparable198qfk8pnblz0 as Comparable,
  RuntimeException1r3t0zl97011n as RuntimeException,
  captureStack1fzi4aczwc4hg as captureStack,
  numberToInt1ygmcfwhs2fkq as numberToInt,
  createThis2j2avj17cvnv2 as createThis,
  until1jbpn0z3f8lbg as until,
  last3s1sh0kl8j0vf as last_0,
  copyToArray2j022khrow2yi as copyToArray,
  mapCapacity1h45rc3eh9p2l as mapCapacity,
  coerceAtLeast2bkz8m9ik7hep as coerceAtLeast,
  booleanArray2jdug9b51huk7 as booleanArray,
  trimIndent1qytc1wvt8suh as trimIndent,
  toMap1vec9topfei08 as toMap,
  regionMatches30ph926sbb53j as regionMatches,
  maxWithOrNullsohvqg0i6v8s as maxWithOrNull,
  charCodeAt1yspne1d8erbm as charCodeAt,
  toString3o7ifthqydp6e as toString_1,
  split2bvyvnrlcifjv as split,
  copyOf3rutauicler23 as copyOf,
  RegexOption_MULTILINE_getInstance3m3iukvv670g5 as RegexOption_MULTILINE_getInstance,
  mapsbvh18eqox7a as map,
  toListx6x8nvfmvvht as toList_2,
  lastIndexOfAnyfsuozy9hsp41 as lastIndexOfAny,
  substring3saq8ornu0luv as substring_0,
  trim11nh7r46at6sx as trim,
  removeSurroundingtenczfhnh0cp as removeSurrounding,
  toInt2q8uldh7sc951 as toInt,
  lastOrNull1aq5oz189qoe1 as lastOrNull,
  substringBeforeLast14532pi2uwutw as substringBeforeLast,
  contains3ue2qo8xhmpf1 as contains,
  charSequenceLength3278n89t01tmv as charSequenceLength,
  charSequenceSubSequence1iwpdba8s3jc7 as charSequenceSubSequence,
  drop3na99dw9feawf as drop,
  replace3le3ie7l9k8aq as replace,
  to2cs3ny02qtbcb as to,
  mutableMapOfk2y3zt1azl40 as mutableMapOf,
  toMutableList20rdgwi7d3cwi as toMutableList,
  reversenv3adafjrtzo as reverse,
  get_lastIndex1yw0x4k50k51w as get_lastIndex,
  mapOf2zpbbmyqk8xpf as mapOf,
} from './kotlin-kotlin-stdlib.mjs';
import {
  mutableQueueOf1rumet9be0696 as mutableQueueOf,
  binaryHeaph0xdqa11rx2r as binaryHeap,
  clone3r99vnzybx8ak as clone,
  deepClone18s2gowzs8h7 as deepClone,
} from './net.akehurst.language-collections.mjs';
import {
  lazyMutableMapNotNullytuj7lulozz7 as lazyMutableMapNotNull,
  lazyMapNotNull301q5a32qegqb as lazyMapNotNull,
  mutableStackOf1lnre6z49o79y as mutableStackOf,
} from './net.akehurst.kotlinx-kotlinx-collections.mjs';
import {
  RegexEnginePlatform_getInstance1hlxdjjdt9nw2 as RegexEnginePlatform_getInstance,
  UnescapedLiteral1oksfmzc43do as UnescapedLiteral,
  CommonRegexPatterns_getInstanceyhbpadc5bomg as CommonRegexPatterns_getInstance,
  regexMatcher7lcajteh1ep3 as regexMatcher,
} from './net.akehurst.language-agl-regex.mjs';
//region block: imports
var imul = Math.imul;
//endregion
//region block: pre-declaration
class BuildConfig_0 {
  constructor() {
    this.version = '4.2.2.21';
    this.buildStamp = '2026-06-18T14:21:42.850496Z[UTC]';
    this.buildDate = '2026-Jun-18';
    this.buildTime = '14:21:42 UTC';
  }
  g17() {
    return this.version;
  }
  h17() {
    return this.buildStamp;
  }
  i17() {
    return this.buildDate;
  }
  j17() {
    return this.buildTime;
  }
}
class Companion {
  constructor() {
    this.nextNumber = 0;
  }
  d1b(_set____db54di) {
    this.nextNumber = _set____db54di;
  }
  e1b() {
    return this.nextNumber;
  }
  merge(trans) {
    // Inline function 'kotlin.collections.groupBy' call
    // Inline function 'kotlin.collections.groupByTo' call
    var destination = LinkedHashMap.j4();
    var _iterator__ex2g4s = trans.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      var key = new Triple(element.source, element.target, element.action);
      // Inline function 'kotlin.collections.getOrPut' call
      var value = destination.c3(key);
      var tmp;
      if (value == null) {
        var answer = ArrayList.o1();
        destination.f3(key, answer);
        tmp = answer;
      } else {
        tmp = value;
      }
      var list = tmp;
      list.v(element);
    }
    var g = destination;
    // Inline function 'kotlin.collections.map' call
    // Inline function 'kotlin.collections.mapTo' call
    var destination_0 = ArrayList.a1(g.h1());
    // Inline function 'kotlin.collections.iterator' call
    var _iterator__ex2g4s_0 = g.z1().g1();
    while (_iterator__ex2g4s_0.f()) {
      var item = _iterator__ex2g4s_0.e();
      var from = item.a2().jm_1;
      var action = item.a2().lm_1;
      var to = item.a2().km_1;
      // Inline function 'kotlin.collections.map' call
      var this_0 = item.b2();
      // Inline function 'kotlin.collections.mapTo' call
      var destination_1 = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
      var _iterator__ex2g4s_1 = this_0.g1();
      while (_iterator__ex2g4s_1.f()) {
        var item_0 = _iterator__ex2g4s_1.e();
        var tmp$ret$6 = item_0.lh;
        destination_1.v(tmp$ret$6);
      }
      // Inline function 'kotlin.collections.reduce' call
      var iterator = destination_1.g1();
      if (!iterator.f())
        throw UnsupportedOperationException.g9("Empty collection can't be reduced.");
      var accumulator = iterator.e();
      while (iterator.f()) {
        var tmp0 = accumulator;
        var it = iterator.e();
        accumulator = tmp0.union(it);
      }
      var lh = accumulator;
      // Inline function 'kotlin.collections.map' call
      var this_1 = item.b2();
      // Inline function 'kotlin.collections.mapTo' call
      var destination_2 = ArrayList.a1(collectionSizeOrDefault(this_1, 10));
      var _iterator__ex2g4s_2 = this_1.g1();
      while (_iterator__ex2g4s_2.f()) {
        var item_1 = _iterator__ex2g4s_2.e();
        var tmp$ret$11 = item_1.up;
        destination_2.v(tmp$ret$11);
      }
      // Inline function 'kotlin.collections.reduce' call
      var iterator_0 = destination_2.g1();
      if (!iterator_0.f())
        throw UnsupportedOperationException.g9("Empty collection can't be reduced.");
      var accumulator_0 = iterator_0.e();
      while (iterator_0.f()) {
        var tmp0_0 = accumulator_0;
        var it_0 = iterator_0.e();
        accumulator_0 = tmp0_0.union(it_0);
      }
      var up = accumulator_0;
      var tmp$ret$16 = new TransitionForMinimal(from, to, action, lh, up);
      destination_0.v(tmp$ret$16);
    }
    var m = toSet(destination_0);
    return m;
  }
}
class AutomatonForMinimal {
  constructor(runtimeRuleSet, userGoalRule) {
    this.runtimeRuleSet = runtimeRuleSet;
    this.userGoalRule = userGoalRule;
    var tmp = this;
    var _unary__edvuaz = Companion_instance.nextNumber;
    Companion_instance.nextNumber = _unary__edvuaz + 1 | 0;
    tmp.number = _unary__edvuaz;
    var tmp_0 = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp_0.g1b_1 = LinkedHashMap.j4();
    var tmp_1 = this;
    tmp_1.h1b_1 = lazy(AutomatonForMinimal$goalRule$delegate$lambda(this));
    var tmp_2 = this;
    var tmp_3 = this.goalRule;
    tmp_2.startState = this.createState(new RulePositionRuntime(tmp_3 instanceof RuntimeRule ? tmp_3 : THROW_CCE(), Companion_getInstance_11().OPTION_NONE, 0));
    var tmp_4 = this;
    tmp_4.i1b_1 = lazy(AutomatonForMinimal$usedRules$delegate$lambda(this));
    var tmp_5 = this;
    tmp_5.j1b_1 = lazy(AutomatonForMinimal$usedTerminals$delegate$lambda(this));
  }
  p1b() {
    return this.runtimeRuleSet;
  }
  q1b() {
    return this.userGoalRule;
  }
  r1b() {
    return this.number;
  }
  s1b() {
    return this.g1b_1.e3();
  }
  t1b() {
    var tmp0 = this.h1b_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('goalRule', 1, tmp, AutomatonForMinimal$_get_goalRule_$ref_bc6um1(), null);
    return tmp0.b2();
  }
  u1b() {
    return this.startState;
  }
  v1b() {
    var tmp0 = this.i1b_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('usedRules', 1, tmp, AutomatonForMinimal$_get_usedRules_$ref_34nyhi(), null);
    return tmp0.b2();
  }
  w1b() {
    var tmp0 = this.j1b_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('usedTerminals', 1, tmp, AutomatonForMinimal$_get_usedTerminals_$ref_xd3hli(), null);
    return tmp0.b2();
  }
  createState(rp) {
    var s = this.g1b_1.c3(rp);
    var tmp;
    if (null == s) {
      s = new StateForMinimal(this, this.g1b_1.h1(), rp);
      var tmp0 = this.g1b_1;
      // Inline function 'kotlin.collections.set' call
      var value = s;
      tmp0.f3(rp, value);
      tmp = s;
    } else {
      tmp = s;
    }
    return tmp;
  }
  x1b(withStates) {
    var b = StringBuilder.s();
    var states = this.states;
    // Inline function 'kotlin.collections.flatMap' call
    // Inline function 'kotlin.collections.flatMapTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = states.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      var list = element.allOutTransition;
      addAll(destination, list);
    }
    var transitions = toSet(destination);
    b.ya(' States: ' + states.h1() + '  Transitions: ' + transitions.h1() + ' ');
    b.ya('\n');
    if (withStates) {
      // Inline function 'kotlin.collections.forEach' call
      var _iterator__ex2g4s_0 = states.g1();
      while (_iterator__ex2g4s_0.f()) {
        var element_0 = _iterator__ex2g4s_0.e();
        var tmp = element_0.toString();
        // Inline function 'kotlin.collections.flatMap' call
        var tmp0 = element_0.allOutTransition;
        // Inline function 'kotlin.collections.flatMapTo' call
        var destination_0 = ArrayList.o1();
        var _iterator__ex2g4s_1 = tmp0.g1();
        while (_iterator__ex2g4s_1.f()) {
          var element_1 = _iterator__ex2g4s_1.e();
          var list_0 = element_1.context;
          addAll(destination_0, list_0);
        }
        // Inline function 'kotlin.collections.map' call
        // Inline function 'kotlin.collections.mapTo' call
        var destination_1 = ArrayList.a1(collectionSizeOrDefault(destination_0, 10));
        var _iterator__ex2g4s_2 = destination_0.g1();
        while (_iterator__ex2g4s_2.f()) {
          var item = _iterator__ex2g4s_2.e();
          var tmp$ret$6 = item.number;
          destination_1.v(tmp$ret$6);
        }
        var str = tmp + ' {' + toString(destination_1) + '}';
        b.ya(str).ya('\n');
      }
    }
    var tmp_0 = AutomatonForMinimal$usedAutomatonToString$lambda;
    // Inline function 'kotlin.collections.forEach' call
    var _iterator__ex2g4s_3 = sortedWith(transitions, compareBy([tmp_0, AutomatonForMinimal$usedAutomatonToString$lambda_0])).g1();
    while (_iterator__ex2g4s_3.f()) {
      var element_2 = _iterator__ex2g4s_3.e();
      var tmp_1 = element_2.context;
      var prevStr = joinToString(tmp_1, VOID, '', '', VOID, VOID, AutomatonForMinimal$usedAutomatonToString$lambda_1);
      var frStr = '' + element_2.source.number + ':' + element_2.source.rp.toString();
      var toStr = '' + element_2.target.number + ':' + element_2.target.rp.toString();
      var trStr = frStr + ' --> ' + toStr;
      var tmp_2 = element_2.lh.fullContent;
      var lh = '[' + joinToString(tmp_2, VOID, VOID, VOID, VOID, VOID, AutomatonForMinimal$usedAutomatonToString$lambda_2) + ']';
      var tmp_3 = element_2.up.fullContent;
      var up = '(' + joinToString(tmp_3, VOID, VOID, VOID, VOID, VOID, AutomatonForMinimal$usedAutomatonToString$lambda_3) + ')';
      b.ya(trStr);
      b.ya(' ' + element_2.action.toString() + ' ');
      b.ya(lh);
      b.ya(up);
      b.ya(' {' + prevStr + '} ');
      b.ya('\n');
    }
    return b.toString();
  }
  usedAutomatonToString(withStates, $super) {
    withStates = withStates === VOID ? false : withStates;
    return $super === VOID ? this.x1b(withStates) : $super.x1b.call(this, withStates);
  }
  hashCode() {
    return this.number;
  }
  equals(other) {
    var tmp;
    if (!(other instanceof AutomatonForMinimal)) {
      tmp = false;
    } else {
      if (!(this.number === other.number)) {
        tmp = false;
      } else {
        tmp = true;
      }
    }
    return tmp;
  }
  toString() {
    return '' + this.number;
  }
  get states() {
    return this.s1b();
  }
  get goalRule() {
    return this.t1b();
  }
  get usedRules() {
    return this.v1b();
  }
  get usedTerminals() {
    return this.w1b();
  }
}
class StateForMinimal {
  constructor(automaton, number, rp) {
    this.automaton = automaton;
    this.number = number;
    this.rp = rp;
    var tmp = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp.outCompleteTransitionsByCtx = LinkedHashMap.j4();
    var tmp_0 = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp_0.outIncompleteTransitionsByCtx = LinkedHashMap.j4();
    var tmp_1 = this;
    // Inline function 'kotlin.arrayOf' call
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    var tmp$ret$4 = [this.automaton.number, this.number];
    tmp_1.o1b_1 = contentHashCode(tmp$ret$4);
  }
  y1b() {
    return this.automaton;
  }
  r1b() {
    return this.number;
  }
  z1b() {
    return this.rp;
  }
  a1c() {
    return this.outCompleteTransitionsByCtx;
  }
  b1c() {
    return this.outIncompleteTransitionsByCtx;
  }
  c1c() {
    return toSet(flatten(plus_0(this.outCompleteTransitionsByCtx, this.outIncompleteTransitionsByCtx).e3()));
  }
  outCompleteTransForCtx(key) {
    return this.outCompleteTransitionsByCtx.c3(key);
  }
  outIncompleteTransForCtx(ctx) {
    return this.outIncompleteTransitionsByCtx.c3(ctx);
  }
  addOutCompleteTrans(key, trans) {
    // Inline function 'kotlin.collections.forEach' call
    var _iterator__ex2g4s = trans.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      mergeCompleteTransFor(this, key, element);
    }
    return Unit_instance;
  }
  addOutIncompleteTrans(key, trans) {
    // Inline function 'kotlin.collections.forEach' call
    var _iterator__ex2g4s = trans.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      mergeIncompleteTransFor(this, key, element);
    }
    return Unit_instance;
  }
  hashCode() {
    return this.o1b_1;
  }
  equals(other) {
    var tmp;
    if (!(other instanceof StateForMinimal)) {
      tmp = false;
    } else {
      if (!(this.automaton.number === other.automaton.number)) {
        tmp = false;
      } else {
        if (!(this.number === other.number)) {
          tmp = false;
        } else {
          tmp = true;
        }
      }
    }
    return tmp;
  }
  toString() {
    return '' + this.number + '/' + this.automaton.number + ' ' + this.rp.toString();
  }
  get allOutTransition() {
    return this.c1c();
  }
}
class TransitionForMinimal {
  constructor(source, target, action, lh, up) {
    this.source = source;
    this.target = target;
    this.action = action;
    this.lh = lh;
    this.up = up;
    var tmp = this;
    // Inline function 'kotlin.arrayOf' call
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    var tmp$ret$2 = [this.source, this.target, this.action, this.lh, this.up];
    tmp.f1b_1 = contentHashCode(tmp$ret$2);
  }
  tq() {
    return this.source;
  }
  m12() {
    return this.target;
  }
  d1c() {
    return this.action;
  }
  e1c() {
    return this.lh;
  }
  f1c() {
    return this.up;
  }
  sb() {
    var tmp;
    if (this.source.rp.isAtEnd) {
      // Inline function 'kotlin.collections.filter' call
      var tmp0 = this.source.outCompleteTransitionsByCtx.z1();
      // Inline function 'kotlin.collections.filterTo' call
      var destination = ArrayList.o1();
      var _iterator__ex2g4s = tmp0.g1();
      while (_iterator__ex2g4s.f()) {
        var element = _iterator__ex2g4s.e();
        if (element.b2().p1(this)) {
          destination.v(element);
        }
      }
      // Inline function 'kotlin.collections.map' call
      // Inline function 'kotlin.collections.mapTo' call
      var destination_0 = ArrayList.a1(collectionSizeOrDefault(destination, 10));
      var _iterator__ex2g4s_0 = destination.g1();
      while (_iterator__ex2g4s_0.f()) {
        var item = _iterator__ex2g4s_0.e();
        var tmp$ret$3 = item.a2().hi_1;
        destination_0.v(tmp$ret$3);
      }
      tmp = toSet(destination_0);
    } else {
      // Inline function 'kotlin.collections.filter' call
      var tmp0_0 = this.source.outIncompleteTransitionsByCtx.z1();
      // Inline function 'kotlin.collections.filterTo' call
      var destination_1 = ArrayList.o1();
      var _iterator__ex2g4s_1 = tmp0_0.g1();
      while (_iterator__ex2g4s_1.f()) {
        var element_0 = _iterator__ex2g4s_1.e();
        if (element_0.b2().p1(this)) {
          destination_1.v(element_0);
        }
      }
      // Inline function 'kotlin.collections.map' call
      // Inline function 'kotlin.collections.mapTo' call
      var destination_2 = ArrayList.a1(collectionSizeOrDefault(destination_1, 10));
      var _iterator__ex2g4s_2 = destination_1.g1();
      while (_iterator__ex2g4s_2.f()) {
        var item_0 = _iterator__ex2g4s_2.e();
        var tmp$ret$9 = item_0.a2();
        destination_2.v(tmp$ret$9);
      }
      tmp = toSet(destination_2);
    }
    return tmp;
  }
  hashCode() {
    return this.f1b_1;
  }
  equals(other) {
    var tmp;
    if (!(other instanceof TransitionForMinimal)) {
      tmp = false;
    } else {
      if (!(this.source.number === other.source.number)) {
        tmp = false;
      } else {
        if (!this.target.equals(other.target)) {
          tmp = false;
        } else {
          if (!this.action.equals(other.action)) {
            tmp = false;
          } else {
            if (!this.lh.equals(other.lh)) {
              tmp = false;
            } else {
              if (!this.up.equals(other.up)) {
                tmp = false;
              } else {
                tmp = true;
              }
            }
          }
        }
      }
    }
    return tmp;
  }
  toString() {
    var tmp = this.source.rp.toString();
    var tmp_0 = this.target.rp.toString();
    var tmp_1 = this.action.toString();
    var tmp_2 = this.lh.toString();
    var tmp_3 = this.up.toString();
    var tmp_4 = this.context;
    return tmp + ' --> ' + tmp_0 + ' ' + tmp_1 + '[' + tmp_2 + '](' + tmp_3 + ') {' + joinToString(tmp_4, VOID, VOID, VOID, VOID, VOID, TransitionForMinimal$toString$lambda) + '}';
  }
  ni() {
    return this.source;
  }
  oi() {
    return this.target;
  }
  mm() {
    return this.action;
  }
  d16() {
    return this.lh;
  }
  g1c() {
    return this.up;
  }
  h1c(source, target, action, lh, up) {
    return new TransitionForMinimal(source, target, action, lh, up);
  }
  copy(source, target, action, lh, up, $super) {
    source = source === VOID ? this.source : source;
    target = target === VOID ? this.target : target;
    action = action === VOID ? this.action : action;
    lh = lh === VOID ? this.lh : lh;
    up = up === VOID ? this.up : up;
    return $super === VOID ? this.h1c(source, target, action, lh, up) : $super.h1c.call(this, source, target, action, lh, up);
  }
  get context() {
    return this.sb();
  }
}
class GSSNodeForMinimal {
  constructor(state, rlh, sp, nip) {
    this.state = state;
    this.rlh = rlh;
    this.sp = sp;
    this.nip = nip;
    this.nibs = this.nip;
  }
  i1c() {
    return this.state;
  }
  j1c() {
    return this.rlh;
  }
  k1c() {
    return this.sp;
  }
  l1c() {
    return this.nip;
  }
  m1c(_set____db54di) {
    this.nibs = _set____db54di;
  }
  n1c() {
    return this.nibs;
  }
  h19() {
    return this.state.rp.isGoal;
  }
  o1c() {
    return this.state.rp.isAtEnd;
  }
  p1c() {
    return this.sp === this.nip;
  }
  ni() {
    return this.state;
  }
  oi() {
    return this.rlh;
  }
  mm() {
    return this.sp;
  }
  d16() {
    return this.nip;
  }
  q1c(state, rlh, sp, nip) {
    return new GSSNodeForMinimal(state, rlh, sp, nip);
  }
  copy(state, rlh, sp, nip, $super) {
    state = state === VOID ? this.state : state;
    rlh = rlh === VOID ? this.rlh : rlh;
    sp = sp === VOID ? this.sp : sp;
    nip = nip === VOID ? this.nip : nip;
    return $super === VOID ? this.q1c(state, rlh, sp, nip) : $super.q1c.call(this, state, rlh, sp, nip);
  }
  toString() {
    return 'GSSNodeForMinimal(state=' + this.state.toString() + ', rlh=' + this.rlh.toString() + ', sp=' + this.sp + ', nip=' + this.nip + ')';
  }
  hashCode() {
    var result = this.state.hashCode();
    result = imul(result, 31) + this.rlh.hashCode() | 0;
    result = imul(result, 31) + this.sp | 0;
    result = imul(result, 31) + this.nip | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof GSSNodeForMinimal))
      return false;
    if (!this.state.equals(other.state))
      return false;
    if (!this.rlh.equals(other.rlh))
      return false;
    if (!(this.sp === other.sp))
      return false;
    if (!(this.nip === other.nip))
      return false;
    return true;
  }
  get isGoal() {
    return this.h19();
  }
  get isComplete() {
    return this.o1c();
  }
  get isEmptyMatch() {
    return this.p1c();
  }
}
class SpptDataNode {}
class CompleteNodeForMinimal {
  constructor(rule, startPosition, nextInputPosition, nextInputNoSkip, option, dynamicPriority) {
    this.r1c_1 = rule;
    this.s1c_1 = startPosition;
    this.t1c_1 = nextInputPosition;
    this.u1c_1 = nextInputNoSkip;
    this.v1c_1 = option;
    this.w1c_1 = dynamicPriority;
    var tmp = this;
    // Inline function 'kotlin.arrayOf' call
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    var tmp$ret$2 = [this.r1c_1, this.s1c_1, this.t1c_1];
    tmp.x1c_1 = contentHashCode(tmp$ret$2);
  }
  y1c() {
    return this.r1c_1;
  }
  z1c() {
    return this.s1c_1;
  }
  a1d() {
    return this.t1c_1;
  }
  b1d() {
    return this.u1c_1;
  }
  c1d() {
    return this.v1c_1;
  }
  d1d() {
    return this.w1c_1;
  }
  hashCode() {
    return this.x1c_1;
  }
  equals(other) {
    var tmp;
    if (!(other instanceof CompleteNodeForMinimal)) {
      tmp = false;
    } else {
      if (!(this.s1c_1 === other.s1c_1)) {
        tmp = false;
      } else {
        if (!(this.t1c_1 === other.t1c_1)) {
          tmp = false;
        } else {
          if (!this.r1c_1.equals(other.r1c_1)) {
            tmp = false;
          } else {
            tmp = true;
          }
        }
      }
    }
    return tmp;
  }
  toString() {
    return 'CN(' + this.r1c_1.tag + '|' + this.v1c_1.toString() + ',' + this.s1c_1 + '-' + this.t1c_1 + ')';
  }
  get rule() {
    return this.y1c();
  }
  get startPosition() {
    return this.z1c();
  }
  get nextInputPosition() {
    return this.a1d();
  }
  get nextInputNoSkip() {
    return this.b1d();
  }
  get option() {
    return this.c1d();
  }
  get dynamicPriority() {
    return this.d1d();
  }
}
class Companion_0 {
  constructor() {
    this.TRACE = false;
  }
  a1e() {
    return this.TRACE;
  }
  parser(goalRuleName, runtimeRuleSet) {
    var userGoalRule = runtimeRuleSet.findRuntimeRule(goalRuleName);
    var automaton = new AutomatonForMinimal(runtimeRuleSet, userGoalRule);
    var skipAutomaton_0 = skipAutomaton(this, runtimeRuleSet);
    var goalRule = runtimeRuleSet.findRuntimeRule(goalRuleName);
    return new MinimalParser(automaton, false, skipAutomaton_0);
  }
  b1e(_this__u8e3s4) {
    return _this__u8e3s4.t1c_1 - _this__u8e3s4.s1c_1 | 0;
  }
  setFirstChildForParent(_this__u8e3s4, parent, child) {
    if (parent.isComplete) {
      _this__u8e3s4.setFirstChildForComplete(_get_complete__1az5pu(this, parent), child, parent.state.rp.k1b_1.isChoiceAmbiguous);
    } else {
      _this__u8e3s4.setFirstChildForGrowing(parent, child);
    }
  }
}
class sam$kotlin_Comparator$0 {
  constructor(function_0) {
    this.t1f_1 = function_0;
  }
  lg(a, b) {
    return this.t1f_1(a, b);
  }
  compare(a, b) {
    return this.lg(a, b);
  }
  u3() {
    return this.t1f_1;
  }
  equals(other) {
    var tmp;
    if (!(other == null) ? isInterface(other, Comparator) : false) {
      var tmp_0;
      if (!(other == null) ? isInterface(other, FunctionAdapter) : false) {
        tmp_0 = equals(this.u3(), other.u3());
      } else {
        tmp_0 = false;
      }
      tmp = tmp_0;
    } else {
      tmp = false;
    }
    return tmp;
  }
  hashCode() {
    return hashCode(this.u3());
  }
}
class MinimalParser {
  constructor(automaton, isSkip, skipAutomaton) {
    this.automaton = automaton;
    this.isSkip = isSkip;
    this.skipAutomaton = skipAutomaton;
    this.ss = this.automaton.startState;
    this.sppf = new TreeDataGrowing(this.automaton.number);
    var tmp = this;
    var tmp_0 = MinimalParser$gss$lambda;
    tmp.gss = GraphStructuredStack.new_net_akehurst_language_agl_runtime_graph_GraphStructuredStack(binaryHeap(new sam$kotlin_Comparator$0(tmp_0)));
    var tmp_1 = this;
    tmp_1.c1e_1 = lazy(MinimalParser$skipTerms$delegate$lambda(this));
    var tmp_2 = this;
    tmp_2.d1e_1 = lazy(MinimalParser$skipParser$delegate$lambda(this));
    var tmp_3 = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp_3.embedded = LinkedHashMap.j4();
    this.sentence = null;
    this.scanner = new ScannerOnDemand(RegexEnginePlatform_getInstance(), toList(this.automaton.usedTerminals));
    var tmp_4 = this;
    tmp_4.e1e_1 = lazyMutableMapNotNull(MinimalParser$_firstTerminal$lambda);
    var tmp_5 = this;
    tmp_5.f1e_1 = lazyMutableMapNotNull(MinimalParser$_parentInContext$lambda);
    var tmp_6 = this;
    tmp_6.g1e_1 = lazyMutableMapNotNull(MinimalParser$_possibleContexts$delegate$lambda);
  }
  y1b() {
    return this.automaton;
  }
  u1f() {
    return this.isSkip;
  }
  v1f() {
    return this.skipAutomaton;
  }
  w1f() {
    return this.ss;
  }
  x1f(_set____db54di) {
    this.sppf = _set____db54di;
  }
  y1f() {
    return this.sppf;
  }
  z1f() {
    return this.gss;
  }
  a1g() {
    var tmp0 = this.c1e_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('skipTerms', 1, tmp, MinimalParser$_get_skipTerms_$ref_hmetp0(), null);
    return tmp0.b2();
  }
  b1g() {
    var tmp0 = this.d1e_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('skipParser', 1, tmp, MinimalParser$_get_skipParser_$ref_vbmvz4(), null);
    return tmp0.b2();
  }
  c1g() {
    return this.embedded;
  }
  d1g(_set____db54di) {
    this.sentence = _set____db54di;
  }
  e1g() {
    return this.sentence;
  }
  f1g() {
    return this.scanner;
  }
  parse(sentenceText) {
    this.sentence = new SentenceDefault(sentenceText, null);
    var tmp0_safe_receiver = this.skipParser;
    if (tmp0_safe_receiver == null)
      null;
    else {
      tmp0_safe_receiver.sentence = this.sentence;
    }
    var td = parseAt(this, 0, Companion_getInstance_7().EOT);
    var tmp;
    if (td == null) {
      var message = 'Parse Failed';
      throw IllegalStateException.t4(toString(message));
    } else {
      tmp = td;
    }
    var sppt = tmp;
    return sppt;
  }
  reset() {
    this.scanner.reset();
    var tmp0_safe_receiver = this.skipParser;
    var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.scanner;
    if (tmp1_safe_receiver == null)
      null;
    else {
      tmp1_safe_receiver.reset();
    }
    this.gss.clear();
    this.sppf = new TreeDataGrowing(this.automaton.number);
  }
  clearCache() {
    this.e1e_1.i3();
    this.f1e_1.i3();
    _get__possibleContexts__e1uu9v(this).i3();
  }
  cachePossibleContext(rp, ctx) {
    _get__possibleContexts__e1uu9v(this).c3(rp).v(ctx);
  }
  cacheFirstTerminalInContext(ctx, rp, fti) {
    this.e1e_1.c3(ctx).c3(rp).v(fti);
  }
  cacheParentInContext(ctx, cr, pn) {
    this.f1e_1.c3(ctx).c3(cr).k1(pn);
  }
  get skipTerms() {
    return this.a1g();
  }
  get skipParser() {
    return this.b1g();
  }
}
class AutomatonKind extends Enum {
  get name() {
    return this.r3();
  }
  get ordinal() {
    return this.s3();
  }
}
class StateNumber {
  constructor(value) {
    this.value = value;
  }
  b2() {
    return this.value;
  }
  ni() {
    return this.value;
  }
  i1g(value) {
    return new StateNumber(value);
  }
  copy(value, $super) {
    value = value === VOID ? this.value : value;
    return $super === VOID ? this.i1g(value) : $super.i1g.call(this, value);
  }
  toString() {
    return 'StateNumber(value=' + this.value + ')';
  }
  hashCode() {
    return this.value;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof StateNumber))
      return false;
    if (!(this.value === other.value))
      return false;
    return true;
  }
}
class Automaton {}
function asString(withStates, $super) {
  withStates = withStates === VOID ? false : withStates;
  return $super === VOID ? this.l1g(withStates) : $super.l1g.call(this, withStates);
}
class AutomatonState {}
class AutomatonTransition {}
class TransitionContext {}
class LookaheadGuard {}
class ParseAction extends Enum {
  get name() {
    return this.r3();
  }
  get ordinal() {
    return this.s3();
  }
}
class AutomatonBuilder {}
class TransitionBuilder {}
class AutomatonBuilderDefault {
  constructor(rrs, automatonKind, userGoalRuleName, isSkip) {
    this.s1g_1 = rrs;
    var tmp = this;
    var _receiver__tnumb7 = this.s1g_1;
    var _unary__edvuaz = _receiver__tnumb7.s1d_1;
    _receiver__tnumb7.s1d_1 = _unary__edvuaz + 1 | 0;
    tmp.t1g_1 = new ParserStateSet(_unary__edvuaz, this.s1g_1, this.s1g_1.findRuntimeRule(userGoalRuleName), isSkip, automatonKind, true);
    this.u1g_1 = 0;
    this.v1g_1 = ParseAction_GOAL_getInstance();
    this.w1g_1 = ParseAction_WIDTH_getInstance();
    this.x1g_1 = ParseAction_HEIGHT_getInstance();
    this.y1g_1 = ParseAction_GRAFT_getInstance();
    this.z1g_1 = ParseAction_EMBED_getInstance();
    this.a1h_1 = ParseAction_GOAL_getInstance();
    this.b1h_1 = ParseAction_WIDTH_getInstance();
    this.c1h_1 = ParseAction_HEIGHT_getInstance();
    this.d1h_1 = ParseAction_GRAFT_getInstance();
  }
  f1h(rulePositions) {
    return this.t1g_1.y1h(toList_0(rulePositions));
  }
  state(ruleNumber, option, position) {
    if (-1 === ruleNumber) {
      var tmp = this.t1g_1.goalRule;
      this.f1h([new RulePositionRuntime(tmp instanceof RuntimeRule ? tmp : THROW_CCE(), option, position)]);
    } else
      this.f1h([new RulePositionRuntime(this.s1g_1.runtimeRules.i1(ruleNumber), option, position)]);
  }
  transition(action, init) {
    this.z1h(action, typeof init === 'function' ? init : THROW_CCE());
  }
  z1h(action, init) {
    var b = new TransitionBuilderDefault(this.t1g_1, action);
    init(b);
    b.e1h();
  }
  e1h() {
    return this.t1g_1;
  }
}
class TransitionBuilderDefault {
  constructor(stateSet, action) {
    this.a1i_1 = stateSet;
    this.b1i_1 = action;
    this.c1i_1 = emptySet();
    this.d1i_1 = null;
    var tmp = this;
    // Inline function 'kotlin.collections.mutableSetOf' call
    tmp.e1i_1 = LinkedHashSet.j1();
    var tmp_0 = this;
    // Inline function 'kotlin.collections.mutableSetOf' call
    tmp_0.h1i_1 = LinkedHashSet.j1();
  }
  pctx(stateNumbers) {
    var tmp = this;
    // Inline function 'kotlin.collections.map' call
    var this_0 = toList_1(stateNumbers);
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var tmp0 = this.a1i_1.allBuiltStates;
      var tmp$ret$1;
      $l$block: {
        // Inline function 'kotlin.collections.first' call
        var _iterator__ex2g4s_0 = tmp0.g1();
        while (_iterator__ex2g4s_0.f()) {
          var element = _iterator__ex2g4s_0.e();
          if (item === element.i1i_1.value) {
            tmp$ret$1 = element;
            break $l$block;
          }
        }
        throw NoSuchElementException.q('Collection contains no element matching the predicate.');
      }
      var tmp$ret$2 = tmp$ret$1;
      destination.v(tmp$ret$2);
    }
    tmp.d1i_1 = toSet(destination);
  }
  ctx(stateNumbers) {
    var tmp = this;
    // Inline function 'kotlin.collections.map' call
    var this_0 = toList_1(stateNumbers);
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var tmp0 = this.a1i_1.allBuiltStates;
      var tmp$ret$1;
      $l$block: {
        // Inline function 'kotlin.collections.first' call
        var _iterator__ex2g4s_0 = tmp0.g1();
        while (_iterator__ex2g4s_0.f()) {
          var element = _iterator__ex2g4s_0.e();
          if (item === element.i1i_1.value) {
            tmp$ret$1 = element;
            break $l$block;
          }
        }
        throw NoSuchElementException.q('Collection contains no element matching the predicate.');
      }
      var tmp$ret$2 = tmp$ret$1;
      destination.v(tmp$ret$2);
    }
    tmp.c1i_1 = toSet(destination);
  }
  src(stateNumber) {
    return this.q1i(this.a1i_1.allBuiltStates.i1(stateNumber));
  }
  tgt(stateNumber) {
    return this.r1i(this.a1i_1.allBuiltStates.i1(stateNumber));
  }
  q1i(state) {
    this.f1i_1 = state;
  }
  r1i(state) {
    this.g1i_1 = state;
  }
  e1h() {
    var tmp = _get__src__d2utae(this);
    var tmp_0 = tmp instanceof ParserState ? tmp : THROW_CCE();
    var tmp_1 = _get__tgt__d2v8ix(this);
    var trans = new Transition(tmp_0, tmp_1 instanceof ParserState ? tmp_1 : THROW_CCE(), this.b1i_1, this.h1i_1);
    switch (this.b1i_1.q3_1) {
      case 2:
      case 4:
        // Inline function 'kotlin.collections.isNotEmpty' call

        // Inline function 'kotlin.require' call

        if (!!this.c1i_1.l1()) {
          var message = 'ctx(...) must be set before build()';
          throw IllegalArgumentException.f1(toString(message));
        }

        // Inline function 'kotlin.check' call

        if (!!_get__src__d2utae(this).isAtEnd) {
          var message_0 = this.b1i_1.toString() + ' requires non-at-end source state';
          throw IllegalStateException.t4(toString(message_0));
        }

        // Inline function 'kotlin.check' call

        if (!(this.d1i_1 == null)) {
          var message_1 = 'pctx(...) is not meaningful for ' + this.b1i_1.toString() + ' transitions';
          throw IllegalStateException.t4(toString(message_1));
        }

        // Inline function 'kotlin.check' call

        if (!this.e1i_1.l1()) {
          var message_2 = 'prevPair(...) is not meaningful for ' + this.b1i_1.toString() + ' transitions';
          throw IllegalStateException.t4(toString(message_2));
        }

        var _iterator__ex2g4s = this.c1i_1.g1();
        while (_iterator__ex2g4s.f()) {
          var prev = _iterator__ex2g4s.e();
          _get__src__d2utae(this).outTransitions.addTransitionForIncomplete(prev, trans);
        }

        break;
      case 0:
      case 1:
      case 3:
        // Inline function 'kotlin.check' call

        if (!_get__src__d2utae(this).isAtEnd) {
          var message_3 = this.b1i_1.toString() + ' requires at-end source state';
          throw IllegalStateException.t4(toString(message_3));
        }

        // Inline function 'kotlin.collections.isNotEmpty' call

        if (!this.e1i_1.l1()) {
          // Inline function 'kotlin.check' call
          if (!(this.d1i_1 == null)) {
            var message_4 = 'Cannot mix prevPair(...) with pctx(...)';
            throw IllegalStateException.t4(toString(message_4));
          }
          var tmp_2;
          if (this.c1i_1.l1()) {
            tmp_2 = true;
          } else {
            var tmp_3 = this.c1i_1;
            // Inline function 'kotlin.collections.map' call
            var this_0 = this.e1i_1;
            // Inline function 'kotlin.collections.mapTo' call
            var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
            var _iterator__ex2g4s_0 = this_0.g1();
            while (_iterator__ex2g4s_0.f()) {
              var item = _iterator__ex2g4s_0.e();
              var tmp$ret$14 = item.ii_1;
              destination.v(tmp$ret$14);
            }
            tmp_2 = equals(tmp_3, toSet(destination));
          }
          // Inline function 'kotlin.require' call
          if (!tmp_2) {
            var message_5 = 'When using prevPair(...), ctx(...) is optional but if supplied must equal the set of `prev` states across the supplied pairs';
            throw IllegalArgumentException.f1(toString(message_5));
          }
          var _iterator__ex2g4s_1 = this.e1i_1.g1();
          while (_iterator__ex2g4s_1.f()) {
            var _destruct__k2r9zo = _iterator__ex2g4s_1.e();
            var prevPrev = _destruct__k2r9zo.ni();
            var prev_0 = _destruct__k2r9zo.oi();
            _get__src__d2utae(this).outTransitions.addTransitionForComplete(prev_0, prevPrev, trans);
          }
        } else {
          // Inline function 'kotlin.collections.isNotEmpty' call
          // Inline function 'kotlin.require' call
          if (!!this.c1i_1.l1()) {
            var message_6 = 'ctx(...) must be set before build()';
            throw IllegalArgumentException.f1(toString(message_6));
          }
          var tmp1_elvis_lhs = this.d1i_1;
          var prevPrevs = tmp1_elvis_lhs == null ? setOf(this.a1i_1.startState) : tmp1_elvis_lhs;
          var _iterator__ex2g4s_2 = this.c1i_1.g1();
          while (_iterator__ex2g4s_2.f()) {
            var prev_1 = _iterator__ex2g4s_2.e();
            var _iterator__ex2g4s_3 = prevPrevs.g1();
            while (_iterator__ex2g4s_3.f()) {
              var prevPrev_0 = _iterator__ex2g4s_3.e();
              _get__src__d2utae(this).outTransitions.addTransitionForComplete(prev_1, prevPrev_0, trans);
            }
          }
        }

        break;
      default:
        noWhenBranchMatchedException();
        break;
    }
    return trans;
  }
}
class BuildCacheAbstract {
  constructor(stateSet) {
    this.s1i_1 = stateSet;
    this.t1i_1 = true;
    this.u1i_1 = new FirstFollowCache3();
    var tmp = this;
    var tmp_0 = 0;
    var tmp_1 = this.s1i_1.runtimeRuleSet.runtimeRules.h1();
    // Inline function 'kotlin.arrayOfNulls' call
    var tmp_2 = Array(tmp_1);
    while (tmp_0 < tmp_1) {
      tmp_2[tmp_0] = null;
      tmp_0 = tmp_0 + 1 | 0;
    }
    tmp.v1i_1 = tmp_2;
  }
  w1i() {
    this.t1i_1 = false;
  }
}
class FirstOfResult {
  constructor(needsFirstOfParentNext, result) {
    this.c1j_1 = needsFirstOfParentNext;
    this.d1j_1 = result;
  }
  toString() {
    return 'FirstOfResult(needsFirstOfParentNext=' + this.c1j_1 + ', result=' + this.d1j_1.toString() + ')';
  }
  hashCode() {
    var result = getBooleanHashCode(this.c1j_1);
    result = imul(result, 31) + this.d1j_1.hashCode() | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof FirstOfResult))
      return false;
    if (!(this.c1j_1 === other.c1j_1))
      return false;
    if (!this.d1j_1.equals(other.d1j_1))
      return false;
    return true;
  }
}
class ClosureItemLC1 {
  constructor(parentItem, rulePosition, next, lookaheadSet) {
    this.parentItem = parentItem;
    this.rulePosition = rulePosition;
    this.next = next;
    this.lookaheadSet = lookaheadSet;
    var tmp = this;
    tmp.e1j_1 = lazy(BuildCacheLC1$Companion$ClosureItemLC1$allPrev$delegate$lambda(this));
    var tmp_0 = this;
    tmp_0.f1j_1 = lazy(BuildCacheLC1$Companion$ClosureItemLC1$allRulePositionsButTop$delegate$lambda(this));
    var tmp_1 = this;
    var tmp0_safe_receiver = this.parentItem;
    tmp_1.g1j_1 = hashCode(listOf_0([tmp0_safe_receiver == null ? null : tmp0_safe_receiver.lookaheadSet, this.rulePosition, this.next, this.lookaheadSet]));
  }
  h1j() {
    return this.parentItem;
  }
  c1f() {
    return this.rulePosition;
  }
  uw() {
    return this.next;
  }
  i1j() {
    return this.lookaheadSet;
  }
  j1j() {
    var tmp0 = this.e1j_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('allPrev', 1, tmp, BuildCacheLC1$Companion$ClosureItemLC1$_get_allPrev_$ref_ip84s6(), null);
    return tmp0.b2();
  }
  k1j() {
    var tmp0 = this.f1j_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('allRulePositionsButTop', 1, tmp, BuildCacheLC1$Companion$ClosureItemLC1$_get_allRulePositionsButTop_$ref_l7n5l1(), null);
    return tmp0.b2();
  }
  equivalentOf(other) {
    var tmp;
    if (this.rulePosition.equals(other.rulePosition) && this.lookaheadSet.equals(other.lookaheadSet)) {
      var tmp0_safe_receiver = this.parentItem;
      var tmp_0 = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.lookaheadSet;
      var tmp1_safe_receiver = other.parentItem;
      tmp = equals(tmp_0, tmp1_safe_receiver == null ? null : tmp1_safe_receiver.lookaheadSet);
    } else {
      tmp = false;
    }
    return tmp;
  }
  hashCode() {
    return this.g1j_1;
  }
  equals(other) {
    var tmp;
    if (other instanceof ClosureItemLC1) {
      var tmp_0;
      var tmp_1;
      if (other.rulePosition.equals(this.rulePosition) && equals(other.next, this.next) && other.lookaheadSet.equals(this.lookaheadSet)) {
        var tmp1_safe_receiver = other.parentItem;
        var tmp_2 = tmp1_safe_receiver == null ? null : tmp1_safe_receiver.lookaheadSet;
        var tmp2_safe_receiver = this.parentItem;
        tmp_1 = equals(tmp_2, tmp2_safe_receiver == null ? null : tmp2_safe_receiver.lookaheadSet);
      } else {
        tmp_1 = false;
      }
      if (tmp_1) {
        tmp_0 = equals(other.allPrev, this.allPrev);
      } else {
        tmp_0 = false;
      }
      tmp = tmp_0;
    } else {
      tmp = false;
    }
    return tmp;
  }
  toString() {
    var tmp = chain(this);
    var tmp_0 = this.lookaheadSet.fullContent;
    return tmp + '[' + joinToString(tmp_0, VOID, VOID, VOID, VOID, VOID, BuildCacheLC1$Companion$ClosureItemLC1$toString$lambda) + ']';
  }
  get allPrev() {
    return this.j1j();
  }
  get allRulePositionsButTop() {
    return this.k1j();
  }
}
class PossibleTransInfo {
  constructor(prev, parent, parentFirstOfNext, action, firstOf, firstOfNext) {
    this.prev = prev;
    this.parent = parent;
    this.parentFirstOfNext = parentFirstOfNext;
    this.action = action;
    this.firstOf = firstOf;
    this.firstOfNext = firstOfNext;
  }
  ww() {
    return this.prev;
  }
  s10() {
    return this.parent;
  }
  l1j() {
    return this.parentFirstOfNext;
  }
  d1c() {
    return this.action;
  }
  m1j() {
    return this.firstOf;
  }
  n1j() {
    return this.firstOfNext;
  }
  o1j() {
    var tmp;
    switch (this.action.q3_1) {
      case 2:
      case 4:
        // Inline function 'kotlin.collections.map' call

        var this_0 = this.firstOf.fullContent;
        // Inline function 'kotlin.collections.mapTo' call

        var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
        var _iterator__ex2g4s = this_0.g1();
        while (_iterator__ex2g4s.f()) {
          var item = _iterator__ex2g4s.e();
          var tmp$ret$0 = new RulePositionRuntime(item, Companion_getInstance_11().OPTION_NONE, -1);
          destination.v(tmp$ret$0);
        }

        tmp = destination;
        break;
      case 0:
      case 1:
        var tmp1_safe_receiver = this.parent;
        var tmp2_safe_receiver = tmp1_safe_receiver == null ? null : tmp1_safe_receiver.rulePosition;
        var tmp3_safe_receiver = tmp2_safe_receiver == null ? null : tmp2_safe_receiver.next();
        var tmp4_elvis_lhs = tmp3_safe_receiver == null ? null : toList(tmp3_safe_receiver);
        tmp = tmp4_elvis_lhs == null ? emptyList() : tmp4_elvis_lhs;
        break;
      case 3:
        tmp = listOf(this.prev.atEnd());
        break;
      default:
        noWhenBranchMatchedException();
        break;
    }
    return tmp;
  }
  ni() {
    return this.prev;
  }
  oi() {
    return this.parent;
  }
  mm() {
    return this.parentFirstOfNext;
  }
  d16() {
    return this.action;
  }
  g1c() {
    return this.firstOf;
  }
  p1j() {
    return this.firstOfNext;
  }
  q1j(prev, parent, parentFirstOfNext, action, firstOf, firstOfNext) {
    return new PossibleTransInfo(prev, parent, parentFirstOfNext, action, firstOf, firstOfNext);
  }
  copy(prev, parent, parentFirstOfNext, action, firstOf, firstOfNext, $super) {
    prev = prev === VOID ? this.prev : prev;
    parent = parent === VOID ? this.parent : parent;
    parentFirstOfNext = parentFirstOfNext === VOID ? this.parentFirstOfNext : parentFirstOfNext;
    action = action === VOID ? this.action : action;
    firstOf = firstOf === VOID ? this.firstOf : firstOf;
    firstOfNext = firstOfNext === VOID ? this.firstOfNext : firstOfNext;
    return $super === VOID ? this.q1j(prev, parent, parentFirstOfNext, action, firstOf, firstOfNext) : $super.q1j.call(this, prev, parent, parentFirstOfNext, action, firstOf, firstOfNext);
  }
  toString() {
    return 'PossibleTransInfo(prev=' + this.prev.toString() + ', parent=' + toString_0(this.parent) + ', parentFirstOfNext=' + this.parentFirstOfNext.toString() + ', action=' + this.action.toString() + ', firstOf=' + this.firstOf.toString() + ', firstOfNext=' + this.firstOfNext.toString() + ')';
  }
  hashCode() {
    var result = this.prev.hashCode();
    result = imul(result, 31) + (this.parent == null ? 0 : this.parent.hashCode()) | 0;
    result = imul(result, 31) + this.parentFirstOfNext.hashCode() | 0;
    result = imul(result, 31) + this.action.hashCode() | 0;
    result = imul(result, 31) + this.firstOf.hashCode() | 0;
    result = imul(result, 31) + this.firstOfNext.hashCode() | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof PossibleTransInfo))
      return false;
    if (!this.prev.equals(other.prev))
      return false;
    if (!equals(this.parent, other.parent))
      return false;
    if (!this.parentFirstOfNext.equals(other.parentFirstOfNext))
      return false;
    if (!this.action.equals(other.action))
      return false;
    if (!this.firstOf.equals(other.firstOf))
      return false;
    if (!this.firstOfNext.equals(other.firstOfNext))
      return false;
    return true;
  }
  get to() {
    return this.o1j();
  }
}
class PossibleState {
  constructor(firstOfCache, rulePosition) {
    this.firstOfCache = firstOfCache;
    this.rulePosition = rulePosition;
    var tmp = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp.outTransInfo = LinkedHashMap.j4();
  }
  r1j() {
    return this.firstOfCache;
  }
  c1f() {
    return this.rulePosition;
  }
  s1j() {
    return this.rulePosition.isAtStart;
  }
  t1j() {
    return this.rulePosition.isAtEnd;
  }
  u1j() {
    return this.rulePosition.isGoal && this.isAtStart;
  }
  v1j() {
    return this.rulePosition.isGoal && this.isAtEnd;
  }
  w1j() {
    return this.outTransInfo;
  }
  j1j() {
    // Inline function 'kotlin.collections.flatMap' call
    var tmp0 = this.outTransInfo.e3();
    // Inline function 'kotlin.collections.flatMapTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      // Inline function 'kotlin.collections.map' call
      // Inline function 'kotlin.collections.mapTo' call
      var destination_0 = ArrayList.a1(collectionSizeOrDefault(element, 10));
      var _iterator__ex2g4s_0 = element.g1();
      while (_iterator__ex2g4s_0.f()) {
        var item = _iterator__ex2g4s_0.e();
        var tmp$ret$0 = item.prev;
        destination_0.v(tmp$ret$0);
      }
      var list = destination_0;
      addAll(destination, list);
    }
    return toList(toSet(destination));
  }
  setTransInfo(prev, parent, parentFirstOfNext, firstOf, firstOfNext) {
    var tmp;
    if (this.rulePosition.isGoal) {
      var tmp_0;
      if (this.rulePosition.isAtEnd) {
        tmp_0 = ParseAction_GOAL_getInstance();
      } else if (this.rulePosition.isAtStart) {
        tmp_0 = ParseAction_WIDTH_getInstance();
      } else {
        var message = 'should not happen';
        throw IllegalStateException.t4(toString(message));
      }
      tmp = tmp_0;
    } else if (this.rulePosition.isAtEnd) {
      var tmp_1;
      if (null == parent) {
        var message_0 = 'should not happen';
        throw IllegalStateException.t4(toString(message_0));
      } else if (parent.isGoalStart) {
        tmp_1 = ParseAction_GRAFT_getInstance();
      } else if (parent.isAtStart) {
        tmp_1 = ParseAction_HEIGHT_getInstance();
      } else if (parent.isAtEnd) {
        var message_1 = 'should not happen';
        throw IllegalStateException.t4(toString(message_1));
      } else {
        tmp_1 = ParseAction_GRAFT_getInstance();
      }
      tmp = tmp_1;
    } else {
      tmp = ParseAction_WIDTH_getInstance();
    }
    var action = tmp;
    var set = this.outTransInfo.c3(prev);
    if (null == set) {
      // Inline function 'kotlin.collections.mutableSetOf' call
      set = LinkedHashSet.j1();
      var tmp0 = this.outTransInfo;
      // Inline function 'kotlin.collections.set' call
      var value = set;
      tmp0.f3(prev, value);
    }
    set.v(new PossibleTransInfo(prev, parent, parentFirstOfNext, action, firstOf, firstOfNext));
  }
  firstOfNext(prev) {
    return ensureNotNull(ensureNotNull(this.firstOfCache.c3(this.rulePosition)).c3(prev));
  }
  hashCode() {
    return this.rulePosition.hashCode();
  }
  equals(other) {
    var tmp;
    if (!(other instanceof PossibleState)) {
      tmp = false;
    } else {
      tmp = this.rulePosition.equals(other.rulePosition);
    }
    return tmp;
  }
  toString() {
    var tmp = this.rulePosition.toString();
    var tmp_0 = this.outTransInfo.z1();
    return tmp + '{' + joinToString(tmp_0, VOID, VOID, VOID, VOID, VOID, BuildCacheLC1$Companion$PossibleState$toString$lambda) + '}';
  }
  get isAtStart() {
    return this.s1j();
  }
  get isAtEnd() {
    return this.t1j();
  }
  get isGoalStart() {
    return this.u1j();
  }
  get isGoalEnd() {
    return this.v1j();
  }
  get allPrev() {
    return this.j1j();
  }
}
class Companion_1 {}
class BuildCacheLC1 extends BuildCacheAbstract {
  constructor(stateSet) {
    super(stateSet);
    var tmp = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp.j1k_1 = LinkedHashMap.j4();
    var tmp_0 = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp_0.k1k_1 = LinkedHashMap.j4();
    var tmp_1 = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp_1.l1k_1 = LinkedHashMap.j4();
    var tmp_2 = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp_2.m1k_1 = LinkedHashMap.j4();
    var tmp0 = this.l1k_1;
    var tmp2 = stateSet.startRulePosition;
    // Inline function 'kotlin.collections.set' call
    var value = new StateInfo(setOf(stateSet.startRulePosition));
    tmp0.f3(tmp2, value);
  }
  x1i() {
    this.j1k_1.i3();
    this.k1k_1.i3();
    this.t1i_1 = true;
  }
  z1i(rulePositions) {
    // Inline function 'kotlin.collections.mapNotNull' call
    // Inline function 'kotlin.collections.mapNotNullTo' call
    var destination = ArrayList.o1();
    // Inline function 'kotlin.collections.forEach' call
    var _iterator__ex2g4s = rulePositions.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      var tmp0_safe_receiver = this.l1k_1.c3(element);
      if (tmp0_safe_receiver == null)
        null;
      else {
        // Inline function 'kotlin.let' call
        destination.v(tmp0_safe_receiver);
      }
    }
    var sis = toSet(destination);
    if (false) {
      // Inline function 'kotlin.check' call
      if (!(1 === sis.h1())) {
        throw IllegalStateException.t4('Check failed.');
      }
    }
    return first(sis);
  }
  y1i() {
    return stateInfo4(this);
  }
  a1j(prevState, fromState) {
    if (false) {
      var tmp = Debug_instance;
      var tmp_0 = IndentDelta_INC_AFTER_getInstance();
      tmp.debug(tmp_0, BuildCacheLC1$widthInto$lambda(prevState, fromState));
    }
    this.u1i_1.i3();
    // Inline function 'kotlin.collections.flatMap' call
    var tmp0 = prevState.j1i_1;
    // Inline function 'kotlin.collections.flatMapTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      // Inline function 'kotlin.collections.flatMap' call
      var tmp0_0 = fromState.j1i_1;
      // Inline function 'kotlin.collections.flatMapTo' call
      var destination_0 = ArrayList.o1();
      var _iterator__ex2g4s_0 = tmp0_0.g1();
      while (_iterator__ex2g4s_0.f()) {
        var element_0 = _iterator__ex2g4s_0.e();
        var parentFollow = fromState.isGoal ? Companion_getInstance_7().EOT : Companion_getInstance_7().RT;
        var list = this.u1i_1.p1k(element, element_0, parentFollow);
        addAll(destination_0, list);
      }
      var list_0 = destination_0;
      addAll(destination, list_0);
    }
    var firstTerminals = toSet(destination);
    // Inline function 'kotlin.collections.map' call
    // Inline function 'kotlin.collections.mapTo' call
    var destination_1 = ArrayList.a1(collectionSizeOrDefault(firstTerminals, 10));
    var _iterator__ex2g4s_1 = firstTerminals.g1();
    while (_iterator__ex2g4s_1.f()) {
      var item = _iterator__ex2g4s_1.e();
      var action = item.terminalRule.isEmbedded ? ParseAction_EMBED_getInstance() : ParseAction_WIDTH_getInstance();
      var rp = item.terminalRule.y1e();
      var lhs = item.parentExpectedAt;
      var tmp$ret$6 = new WidthInfo(action, rp, lhs);
      destination_1.v(tmp$ret$6);
    }
    var wis = destination_1;
    // Inline function 'kotlin.collections.groupBy' call
    // Inline function 'kotlin.collections.groupByTo' call
    var destination_2 = LinkedHashMap.j4();
    var _iterator__ex2g4s_2 = wis.g1();
    while (_iterator__ex2g4s_2.f()) {
      var element_1 = _iterator__ex2g4s_2.e();
      var key = new Pair(element_1.x1k_1, element_1.w1k_1);
      // Inline function 'kotlin.collections.getOrPut' call
      var value = destination_2.c3(key);
      var tmp_1;
      if (value == null) {
        var answer = ArrayList.o1();
        destination_2.f3(key, answer);
        tmp_1 = answer;
      } else {
        tmp_1 = value;
      }
      var list_1 = tmp_1;
      list_1.v(element_1);
    }
    // Inline function 'kotlin.collections.map' call
    // Inline function 'kotlin.collections.mapTo' call
    var destination_3 = ArrayList.a1(destination_2.h1());
    // Inline function 'kotlin.collections.iterator' call
    var _iterator__ex2g4s_3 = destination_2.z1().g1();
    while (_iterator__ex2g4s_3.f()) {
      var item_0 = _iterator__ex2g4s_3.e();
      var rp_0 = item_0.a2().hi_1;
      var action_0 = item_0.a2().ii_1;
      // Inline function 'kotlin.collections.map' call
      var this_0 = item_0.b2();
      // Inline function 'kotlin.collections.mapTo' call
      var destination_4 = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
      var _iterator__ex2g4s_4 = this_0.g1();
      while (_iterator__ex2g4s_4.f()) {
        var item_1 = _iterator__ex2g4s_4.e();
        var tmp$ret$15 = item_1.y1k_1;
        destination_4.v(tmp$ret$15);
      }
      // Inline function 'kotlin.collections.reduce' call
      var iterator = destination_4.g1();
      if (!iterator.f())
        throw UnsupportedOperationException.g9("Empty collection can't be reduced.");
      var accumulator = iterator.e();
      while (iterator.f()) {
        var tmp0_1 = accumulator;
        var e = iterator.e();
        accumulator = tmp0_1.union(e);
      }
      var lhs_0 = accumulator;
      var tmp$ret$20 = new WidthInfo(action_0, rp_0, lhs_0);
      destination_3.v(tmp$ret$20);
    }
    var wisMerged = destination_3;
    if (false) {
      var tmp_2 = Debug_instance;
      var tmp_3 = IndentDelta_DEC_BEFORE_getInstance();
      tmp_2.debug(tmp_3, BuildCacheLC1$widthInto$lambda_0(prevState, fromState));
    }
    // Inline function 'kotlin.collections.forEach' call
    var _iterator__ex2g4s_5 = wisMerged.g1();
    while (_iterator__ex2g4s_5.f()) {
      var element_2 = _iterator__ex2g4s_5.e();
      var tmp0_2 = this.l1k_1;
      var tmp2 = element_2.x1k_1;
      // Inline function 'kotlin.collections.set' call
      var value_0 = new StateInfo(setOf(element_2.x1k_1));
      tmp0_2.f3(tmp2, value_0);
    }
    return toSet(wisMerged);
  }
  b1j(prevPrev, prevState, fromState) {
    var calc = calcAndCacheHeightOrGraftInto(this, prevPrev, prevState, fromState);
    return calc;
  }
}
class FirstFollowCache3 {
  constructor() {
    var tmp = this;
    tmp.y1j_1 = lazyMutableMapNotNull(FirstFollowCache3$_doneFollow$delegate$lambda);
    var tmp_0 = this;
    tmp_0.z1j_1 = lazyMutableMapNotNull(FirstFollowCache3$_firstTerminal$delegate$lambda);
    var tmp_1 = this;
    tmp_1.a1k_1 = lazyMutableMapNotNull(FirstFollowCache3$_parentInContext$delegate$lambda);
    var tmp_2 = this;
    tmp_2.b1k_1 = lazyMutableMapNotNull(FirstFollowCache3$_possibleContexts$delegate$lambda);
  }
  i3() {
    _get__doneFollow__hbu15r(this).i3();
    _get__firstTerminal__6wo3he(this).i3();
    _get__parentInContext__7bhu5m(this).i3();
    _get__possibleContexts__e1uu9v_0(this).i3();
  }
  n1k(rp) {
    return _get__possibleContexts__e1uu9v_0(this).c3(rp);
  }
  p1k(context, rulePosition, parentFollow) {
    if (false) {
      // Inline function 'kotlin.check' call
      if (!!context.isAtEnd) {
        var message = 'firstTerminal(' + context.toString() + ',' + rulePosition.toString() + ')';
        throw IllegalStateException.t4(toString(message));
      }
    }
    var tmp;
    if (_get__firstTerminal__6wo3he(this).a3(context) && _get__firstTerminal__6wo3he(this).c3(context).a3(rulePosition)) {
      tmp = _get__firstTerminal__6wo3he(this).c3(context).c3(rulePosition);
    } else {
      processClosureFor(this, context, rulePosition, parentFollow);
      tmp = _get__firstTerminal__6wo3he(this).c3(context).c3(rulePosition);
    }
    return tmp;
  }
  o1k(contextContext, context, completedRule) {
    var ctx = context.isAtStart ? contextContext : context;
    var tmp;
    if (_get__parentInContext__7bhu5m(this).a3(ctx) && _get__parentInContext__7bhu5m(this).c3(ctx).a3(completedRule)) {
      tmp = _get__parentInContext__7bhu5m(this).c3(ctx).c3(completedRule);
    } else {
      processClosureFor(this, contextContext, context, Companion_getInstance_7().RT);
      tmp = _get__parentInContext__7bhu5m(this).c3(ctx).c3(completedRule);
    }
    return tmp;
  }
  c1k(context, rulePosition, parentExpectedAt) {
    this.i3();
    var graph = new ClosureGraph(context, rulePosition, parentExpectedAt);
    this.a1l(graph);
  }
  z1k(graph) {
    if (false) {
      var tmp = IndentDelta_INC_AFTER_getInstance();
      debug(tmp, FirstFollowCache3$calcFirstTermClosure$lambda(graph));
    }
    if (graph.b1f_1.h1f_1.isGoal && graph.b1f_1.h1f_1.isAtEnd) {
      return Unit_instance;
    }
    var todoList = mutableQueueOf([]);
    todoList.r16(graph.b1f_1);
    while (todoList.q11()) {
      var cls = todoList.s16();
      var _iterator__ex2g4s = cls.c1f().items.g1();
      while (_iterator__ex2g4s.f()) {
        var item = _iterator__ex2g4s.e();
        if (item.isTerminal)
          graph.e1f(cls, item.y1e());
        else if (item.isNonTerminal) {
          var childRps = item.d1f();
          var _iterator__ex2g4s_0 = childRps.g1();
          while (_iterator__ex2g4s_0.f()) {
            var childRp = _iterator__ex2g4s_0.e();
            var child = graph.e1f(cls, childRp);
            if (null != child) {
              todoList.r16(child);
            }
          }
        } else {
          // Inline function 'kotlin.error' call
          var message = 'Internal Error: should never happen';
          throw IllegalStateException.t4(toString(message));
        }
      }
    }
    graph.f1f();
    cacheStuff(this, graph);
    if (false) {
      var tmp_0 = IndentDelta_DEC_BEFORE_getInstance();
      debug(tmp_0, FirstFollowCache3$calcFirstTermClosure$lambda_0(graph));
    }
  }
  a1l(graph) {
    if (false) {
      var tmp = IndentDelta_INC_AFTER_getInstance();
      debug(tmp, FirstFollowCache3$calcAllClosure$lambda(graph));
    }
    if (graph.b1f_1.h1f_1.isGoal && graph.b1f_1.h1f_1.isAtEnd) {
      return Unit_instance;
    } else {
      var todoList = mutableQueueOf([]);
      todoList.r16(graph.b1f_1);
      while (todoList.q11()) {
        var cls = todoList.s16();
        var _iterator__ex2g4s = cls.c1f().items.g1();
        while (_iterator__ex2g4s.f()) {
          var item = _iterator__ex2g4s.e();
          if (item.isTerminal)
            graph.e1f(cls, item.y1e());
          else if (item.isNonTerminal) {
            var childRps = item.b1l();
            var _iterator__ex2g4s_0 = childRps.g1();
            while (_iterator__ex2g4s_0.f()) {
              var childRp = _iterator__ex2g4s_0.e();
              var child = graph.e1f(cls, childRp);
              if (null != child) {
                todoList.r16(child);
              }
            }
          } else {
            // Inline function 'kotlin.error' call
            var message = 'Internal Error: should never happen';
            throw IllegalStateException.t4(toString(message));
          }
        }
      }
      graph.f1f();
      cacheStuff(this, graph);
    }
    if (false) {
      var tmp_0 = IndentDelta_DEC_BEFORE_getInstance();
      debug(tmp_0, FirstFollowCache3$calcAllClosure$lambda_0(graph));
    }
  }
}
class FirstOf {
  constructor() {
    var tmp = this;
    // Inline function 'kotlin.collections.hashMapOf' call
    tmp.d1l_1 = HashMap.o7();
  }
  e1l(rulePosition, ifReachedEnd) {
    this.d1l_1.i3();
    var tmp;
    if (rulePosition.isAtEnd) {
      tmp = ifReachedEnd;
    } else {
      // Inline function 'kotlin.collections.mutableMapOf' call
      var tmp_0 = LinkedHashMap.j4();
      // Inline function 'kotlin.collections.hashMapOf' call
      var tmp$ret$1 = HashMap.o7();
      var res = firstOfRpNotEmpty(this, rulePosition, tmp_0, tmp$ret$1);
      var tmp_1;
      if (res.c1j_1) {
        var tmp_2;
        if (rulePosition.isAtEnd) {
          tmp_2 = res.d1j_1.union(ifReachedEnd);
        } else {
          var next = rulePosition.next();
          var notSelf = minus(next, rulePosition);
          // Inline function 'kotlin.collections.map' call
          // Inline function 'kotlin.collections.mapTo' call
          var destination = ArrayList.a1(collectionSizeOrDefault(notSelf, 10));
          var _iterator__ex2g4s = notSelf.g1();
          while (_iterator__ex2g4s.f()) {
            var item = _iterator__ex2g4s.e();
            var tmp$ret$2 = this.e1l(item, ifReachedEnd);
            destination.v(tmp$ret$2);
          }
          // Inline function 'kotlin.collections.fold' call
          var accumulator = Companion_getInstance_7().EMPTY;
          var _iterator__ex2g4s_0 = destination.g1();
          while (_iterator__ex2g4s_0.f()) {
            var element = _iterator__ex2g4s_0.e();
            accumulator = accumulator.union(element);
          }
          var ne = accumulator;
          tmp_2 = res.d1j_1.union(ne);
        }
        tmp_1 = tmp_2;
      } else {
        tmp_1 = res.d1j_1;
      }
      tmp = tmp_1;
    }
    return tmp;
  }
}
class sam$kotlin_Comparator$0_0 {
  constructor(function_0) {
    this.f1l_1 = function_0;
  }
  lg(a, b) {
    return this.f1l_1(a, b);
  }
  compare(a, b) {
    return this.lg(a, b);
  }
  u3() {
    return this.f1l_1;
  }
  equals(other) {
    var tmp;
    if (!(other == null) ? isInterface(other, Comparator) : false) {
      var tmp_0;
      if (!(other == null) ? isInterface(other, FunctionAdapter) : false) {
        tmp_0 = equals(this.u3(), other.u3());
      } else {
        tmp_0 = false;
      }
      tmp = tmp_0;
    } else {
      tmp = false;
    }
    return tmp;
  }
  hashCode() {
    return hashCode(this.u3());
  }
}
class Companion_2 {
  constructor() {
    Companion_instance_2 = this;
    this.EMPTY = new Lookahead(Companion_getInstance_3().EMPTY, Companion_getInstance_3().EMPTY);
  }
  n1l() {
    return this.EMPTY;
  }
  merge(automaton, initial) {
    var tmp;
    if (initial.h1() === 1) {
      tmp = initial;
    } else {
      // Inline function 'kotlin.collections.groupBy' call
      // Inline function 'kotlin.collections.groupByTo' call
      var destination = LinkedHashMap.j4();
      var _iterator__ex2g4s = initial.g1();
      while (_iterator__ex2g4s.f()) {
        var element = _iterator__ex2g4s.e();
        var key = element.upLookaheadSet;
        // Inline function 'kotlin.collections.getOrPut' call
        var value = destination.c3(key);
        var tmp_0;
        if (value == null) {
          var answer = ArrayList.o1();
          destination.f3(key, answer);
          tmp_0 = answer;
        } else {
          tmp_0 = value;
        }
        var list = tmp_0;
        list.v(element);
      }
      // Inline function 'kotlin.collections.map' call
      // Inline function 'kotlin.collections.mapTo' call
      var destination_0 = ArrayList.a1(destination.h1());
      // Inline function 'kotlin.collections.iterator' call
      var _iterator__ex2g4s_0 = destination.z1().g1();
      while (_iterator__ex2g4s_0.f()) {
        var item = _iterator__ex2g4s_0.e();
        var up = item.a2();
        // Inline function 'kotlin.collections.map' call
        var this_0 = item.b2();
        // Inline function 'kotlin.collections.mapTo' call
        var destination_1 = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
        var _iterator__ex2g4s_1 = this_0.g1();
        while (_iterator__ex2g4s_1.f()) {
          var item_0 = _iterator__ex2g4s_1.e();
          var tmp$ret$6 = item_0.guardLookaheadSet;
          destination_1.v(tmp$ret$6);
        }
        // Inline function 'kotlin.collections.reduce' call
        var iterator = destination_1.g1();
        if (!iterator.f())
          throw UnsupportedOperationException.g9("Empty collection can't be reduced.");
        var accumulator = iterator.e();
        while (iterator.f()) {
          var tmp0 = accumulator;
          var l = iterator.e();
          accumulator = tmp0.o1l(automaton, l);
        }
        var guard = accumulator;
        var tmp$ret$11 = new Lookahead(guard, up);
        destination_0.v(tmp$ret$11);
      }
      // Inline function 'kotlin.collections.groupBy' call
      var tmp0_0 = toSet(destination_0);
      // Inline function 'kotlin.collections.groupByTo' call
      var destination_2 = LinkedHashMap.j4();
      var _iterator__ex2g4s_2 = tmp0_0.g1();
      while (_iterator__ex2g4s_2.f()) {
        var element_0 = _iterator__ex2g4s_2.e();
        var key_0 = element_0.guardLookaheadSet;
        // Inline function 'kotlin.collections.getOrPut' call
        var value_0 = destination_2.c3(key_0);
        var tmp_1;
        if (value_0 == null) {
          var answer_0 = ArrayList.o1();
          destination_2.f3(key_0, answer_0);
          tmp_1 = answer_0;
        } else {
          tmp_1 = value_0;
        }
        var list_0 = tmp_1;
        list_0.v(element_0);
      }
      // Inline function 'kotlin.collections.map' call
      // Inline function 'kotlin.collections.mapTo' call
      var destination_3 = ArrayList.a1(destination_2.h1());
      // Inline function 'kotlin.collections.iterator' call
      var _iterator__ex2g4s_3 = destination_2.z1().g1();
      while (_iterator__ex2g4s_3.f()) {
        var item_1 = _iterator__ex2g4s_3.e();
        var guard_0 = item_1.a2();
        // Inline function 'kotlin.collections.map' call
        var this_1 = item_1.b2();
        // Inline function 'kotlin.collections.mapTo' call
        var destination_4 = ArrayList.a1(collectionSizeOrDefault(this_1, 10));
        var _iterator__ex2g4s_4 = this_1.g1();
        while (_iterator__ex2g4s_4.f()) {
          var item_2 = _iterator__ex2g4s_4.e();
          var tmp$ret$20 = item_2.upLookaheadSet;
          destination_4.v(tmp$ret$20);
        }
        // Inline function 'kotlin.collections.reduce' call
        var iterator_0 = destination_4.g1();
        if (!iterator_0.f())
          throw UnsupportedOperationException.g9("Empty collection can't be reduced.");
        var accumulator_0 = iterator_0.e();
        while (iterator_0.f()) {
          var tmp0_1 = accumulator_0;
          var l_0 = iterator_0.e();
          accumulator_0 = tmp0_1.o1l(automaton, l_0);
        }
        var up_0 = accumulator_0;
        var tmp$ret$25 = new Lookahead(guard_0, up_0);
        destination_3.v(tmp$ret$25);
      }
      var merged = toSet(destination_3);
      var tmp_2;
      if (merged.h1() === 1) {
        tmp_2 = merged;
      } else {
        // Inline function 'kotlin.collections.sortedByDescending' call
        // Inline function 'kotlin.comparisons.compareByDescending' call
        var tmp_3 = Lookahead$Companion$merge$lambda;
        var tmp$ret$28 = new sam$kotlin_Comparator$0_0(tmp_3);
        var sortedMerged = sortedWith(merged, tmp$ret$28);
        // Inline function 'kotlin.collections.mutableSetOf' call
        var result = LinkedHashSet.j1();
        // Inline function 'kotlin.collections.mutableSetOf' call
        var mergedIntoOther = LinkedHashSet.j1();
        var inductionVariable = 0;
        var last = sortedMerged.h1() - 1 | 0;
        if (inductionVariable <= last)
          do {
            var i = inductionVariable;
            inductionVariable = inductionVariable + 1 | 0;
            var lh1 = sortedMerged.i1(i);
            if (!mergedIntoOther.p1(lh1)) {
              var inductionVariable_0 = i + 1 | 0;
              var last_0 = sortedMerged.h1();
              if (inductionVariable_0 < last_0)
                do {
                  var j = inductionVariable_0;
                  inductionVariable_0 = inductionVariable_0 + 1 | 0;
                  var lh2 = sortedMerged.i1(j);
                  if (lh1.guardLookaheadSet.p1l(lh2.guardLookaheadSet)) {
                    lh1 = new Lookahead(lh1.guardLookaheadSet, lh1.upLookaheadSet.o1l(automaton, lh2.upLookaheadSet));
                    mergedIntoOther.v(lh2);
                  }
                }
                 while (inductionVariable_0 < last_0);
              result.v(lh1);
            }
          }
           while (inductionVariable <= last);
        tmp_2 = result;
      }
      tmp = tmp_2;
    }
    return tmp;
  }
}
class Lookahead {
  constructor(guardLookaheadSet, upLookaheadSet) {
    Companion_getInstance_2();
    this.guardLookaheadSet = guardLookaheadSet;
    this.upLookaheadSet = upLookaheadSet;
  }
  q1l() {
    return this.guardLookaheadSet;
  }
  r1l() {
    return this.upLookaheadSet;
  }
  p1g() {
    return this.guardLookaheadSet.m1l();
  }
  f1c() {
    return this.upLookaheadSet.m1l();
  }
  hashCode() {
    // Inline function 'kotlin.arrayOf' call
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    var tmp$ret$2 = [this.guardLookaheadSet, this.upLookaheadSet];
    return contentHashCode(tmp$ret$2);
  }
  equals(other) {
    var tmp;
    if (!(other instanceof Lookahead)) {
      tmp = false;
    } else {
      if (!this.upLookaheadSet.equals(other.upLookaheadSet)) {
        tmp = false;
      } else {
        if (!this.guardLookaheadSet.equals(other.guardLookaheadSet)) {
          tmp = false;
        } else {
          tmp = true;
        }
      }
    }
    return tmp;
  }
  toString() {
    return 'LH(' + this.guardLookaheadSet.toString() + ', ' + this.upLookaheadSet.toString() + ')';
  }
  get guard() {
    return this.p1g();
  }
  get up() {
    return this.f1c();
  }
}
class Companion_3 {
  constructor() {
    Companion_instance_3 = this;
    this.EMPTY = new LookaheadSet(-1, false, false, false, emptySet());
    this.ANY = new LookaheadSet(-2, false, false, true, emptySet());
    this.EOT = new LookaheadSet(-3, false, true, false, emptySet());
    this.RT = new LookaheadSet(-4, true, false, false, emptySet());
    this.RT_EOT = new LookaheadSet(-5, true, true, false, emptySet());
    this.UNCACHED_NUMBER = -6;
  }
  n1l() {
    return this.EMPTY;
  }
  s1l() {
    return this.ANY;
  }
  t1l() {
    return this.EOT;
  }
  u1l() {
    return this.RT;
  }
  v1l() {
    return this.RT_EOT;
  }
  w1l() {
    return this.UNCACHED_NUMBER;
  }
  createFromRuntimeRules(automaton, fullContent) {
    var tmp;
    if (fullContent.l1()) {
      tmp = Companion_getInstance_3().EMPTY;
    } else {
      var includeUP = fullContent.p1(Companion_getInstance_17().USE_RUNTIME_LOOKAHEAD);
      var includeEOT = fullContent.p1(Companion_getInstance_17().END_OF_TEXT);
      var matchAny = fullContent.p1(Companion_getInstance_17().ANY_LOOKAHEAD);
      var content = minus(minus(minus(fullContent, Companion_getInstance_17().USE_RUNTIME_LOOKAHEAD), Companion_getInstance_17().END_OF_TEXT), Companion_getInstance_17().ANY_LOOKAHEAD);
      tmp = automaton.y1l(includeUP, includeEOT, matchAny, content);
    }
    return tmp;
  }
}
class LookaheadSet {
  constructor(number, includesRT, includesEOT, matchANY, content) {
    Companion_getInstance_3();
    this.g1l_1 = number;
    this.h1l_1 = includesRT;
    this.i1l_1 = includesEOT;
    this.j1l_1 = matchANY;
    this.k1l_1 = content;
    var tmp = this;
    tmp.l1l_1 = lazy(LookaheadSet$regex$delegate$lambda(this));
  }
  m1l() {
    // Inline function 'kotlin.collections.mutableSetOf' call
    var c = LinkedHashSet.j1();
    if (this.h1l_1) {
      c.v(Companion_getInstance_17().USE_RUNTIME_LOOKAHEAD);
    }
    if (this.i1l_1) {
      c.v(Companion_getInstance_17().END_OF_TEXT);
    }
    if (this.j1l_1) {
      c.v(Companion_getInstance_17().ANY_LOOKAHEAD);
    }
    c.k1(this.k1l_1);
    return c;
  }
  b1m() {
    return new LookaheadSetPart(this.h1l_1, this.i1l_1, this.j1l_1, this.k1l_1);
  }
  c1m(eotLookahead, runtimeLookahead) {
    var tmp;
    if (eotLookahead.h1l_1) {
      var message = 'EOT lookahead must be real lookahead values';
      throw IllegalStateException.t4(toString(message));
    } else if (runtimeLookahead.h1l_1) {
      var message_0 = 'EOT lookahead must be real lookahead values';
      throw IllegalStateException.t4(toString(message_0));
    } else if (this.j1l_1 || (this.i1l_1 && eotLookahead.j1l_1) || (this.h1l_1 && runtimeLookahead.j1l_1)) {
      tmp = new LookaheadSetPart(false, false, true, emptySet());
    } else {
      var tmp_0;
      if (this.i1l_1 && this.h1l_1) {
        var resolvedContent = union(union(this.k1l_1, runtimeLookahead.k1l_1), eotLookahead.k1l_1);
        var eot = eotLookahead.i1l_1 || runtimeLookahead.i1l_1;
        tmp_0 = new LookaheadSetPart(false, eot, false, resolvedContent);
      } else if (this.i1l_1) {
        var resolvedContent_0 = union(this.k1l_1, eotLookahead.k1l_1);
        var eot_0 = eotLookahead.i1l_1;
        tmp_0 = new LookaheadSetPart(false, eot_0, false, resolvedContent_0);
      } else if (this.h1l_1) {
        var resolvedContent_1 = union(this.k1l_1, runtimeLookahead.k1l_1);
        var eot_1 = runtimeLookahead.i1l_1;
        tmp_0 = new LookaheadSetPart(false, eot_1, false, resolvedContent_1);
      } else {
        tmp_0 = new LookaheadSetPart(false, false, false, this.k1l_1);
      }
      tmp = tmp_0;
    }
    return tmp;
  }
  d1m(eotLookahead, runtimeLookahead) {
    var tmp;
    if (eotLookahead.h1l_1) {
      var message = 'EOT lookahead must be real lookahead values';
      throw IllegalStateException.t4(toString(message));
    } else if (runtimeLookahead.includesRT) {
      var message_0 = 'EOT lookahead must be real lookahead values';
      throw IllegalStateException.t4(toString(message_0));
    } else if (this.j1l_1 || (this.i1l_1 && eotLookahead.j1l_1) || (this.h1l_1 && runtimeLookahead.matchANY)) {
      tmp = new LookaheadSetPart(false, false, true, emptySet());
    } else {
      var tmp_0;
      if (this.i1l_1 && this.h1l_1) {
        var resolvedContent = union(union(this.k1l_1, runtimeLookahead.content), eotLookahead.k1l_1);
        var eot = eotLookahead.i1l_1 || runtimeLookahead.includesEOT;
        tmp_0 = new LookaheadSetPart(false, eot, false, resolvedContent);
      } else if (this.i1l_1) {
        var resolvedContent_0 = union(this.k1l_1, eotLookahead.k1l_1);
        var eot_0 = eotLookahead.i1l_1;
        tmp_0 = new LookaheadSetPart(false, eot_0, false, resolvedContent_0);
      } else if (this.h1l_1) {
        var resolvedContent_1 = union(this.k1l_1, runtimeLookahead.content);
        var eot_1 = runtimeLookahead.includesEOT;
        tmp_0 = new LookaheadSetPart(false, eot_1, false, resolvedContent_1);
      } else {
        tmp_0 = new LookaheadSetPart(false, false, false, this.k1l_1);
      }
      tmp = tmp_0;
    }
    return tmp;
  }
  o1l(automaton, lookahead) {
    var rt = this.h1l_1 || lookahead.h1l_1;
    var eot = this.i1l_1 || lookahead.i1l_1;
    var ma = this.j1l_1 || lookahead.j1l_1;
    return automaton.y1l(rt, eot, ma, union(this.k1l_1, lookahead.k1l_1));
  }
  f1m(automaton, additionalContent) {
    var rt = this.h1l_1;
    var eot = this.i1l_1;
    var ma = this.j1l_1;
    return automaton.y1l(rt, eot, ma, union(this.k1l_1, additionalContent));
  }
  p1l(other) {
    return this.j1l_1 ? true : !this.i1l_1 && other.i1l_1 ? false : !this.h1l_1 && other.h1l_1 ? false : this.m1l().w2(other.m1l());
  }
  hashCode() {
    return this.g1l_1;
  }
  equals(other) {
    var tmp;
    if (other instanceof LookaheadSet) {
      tmp = this.g1l_1 === other.g1l_1;
    } else {
      tmp = false;
    }
    return tmp;
  }
  toString() {
    var tmp;
    if (this.equals(Companion_getInstance_3().EMPTY)) {
      tmp = 'LookaheadSet{' + this.g1l_1 + ',[EMPTY]}';
    } else if (this.equals(Companion_getInstance_3().ANY)) {
      tmp = 'LookaheadSet{' + this.g1l_1 + ',[ANY]}';
    } else if (this.equals(Companion_getInstance_3().RT)) {
      tmp = 'LookaheadSet{' + this.g1l_1 + ',[RT]}';
    } else if (this.equals(Companion_getInstance_3().EOT)) {
      tmp = 'LookaheadSet{' + this.g1l_1 + ',[EOT]}';
    } else {
      var tmp_0 = this.m1l();
      tmp = 'LookaheadSet{' + this.g1l_1 + ',' + joinToString(tmp_0, ',', '[', ']', VOID, VOID, LookaheadSet$toString$lambda) + '}';
    }
    return tmp;
  }
}
class Companion_4 {
  lhs(_this__u8e3s4, stateSet) {
    return stateSet.y1l(_this__u8e3s4.includesRT, _this__u8e3s4.includesEOT, _this__u8e3s4.matchANY, _this__u8e3s4.content);
  }
}
class ParserState {
  constructor(number, rulePosition, stateSet) {
    this.i1i_1 = number;
    this.j1i_1 = rulePosition;
    this.stateSet = stateSet;
    var tmp = this;
    var tmp_0;
    switch (this.stateSet.automatonKind.q3_1) {
      case 0:
        throw NotImplementedError.im();
      case 1:
        throw NotImplementedError.im();
      case 2:
        tmp_0 = new TransitionCacheLC1();
        break;
      default:
        noWhenBranchMatchedException();
        break;
    }
    tmp.outTransitions = tmp_0;
    var tmp_1 = this;
    tmp_1.k1i_1 = lazy(ParserState$runtimeRules$delegate$lambda(this));
    var tmp_2 = this;
    tmp_2.l1i_1 = lazy(ParserState$runtimeRulesAsSet$delegate$lambda(this));
    var tmp_3 = this;
    tmp_3.m1i_1 = lazy(ParserState$optionList$delegate$lambda(this));
    var tmp_4 = this;
    tmp_4.n1i_1 = lazy(ParserState$isChoice$delegate$lambda(this));
    var tmp_5 = this;
    tmp_5.o1i_1 = lazy(ParserState$isOptional$delegate$lambda(this));
    var tmp_6 = this;
    tmp_6.p1i_1 = lazy(ParserState$isList$delegate$lambda(this));
    var tmp_7 = this;
    var tmp0 = this.j1i_1;
    var tmp$ret$0;
    $l$block_0: {
      // Inline function 'kotlin.collections.any' call
      var tmp_8;
      if (isInterface(tmp0, Collection)) {
        tmp_8 = tmp0.l1();
      } else {
        tmp_8 = false;
      }
      if (tmp_8) {
        tmp$ret$0 = false;
        break $l$block_0;
      }
      var _iterator__ex2g4s = tmp0.g1();
      while (_iterator__ex2g4s.f()) {
        var element = _iterator__ex2g4s.e();
        if (element.isAtEnd) {
          tmp$ret$0 = true;
          break $l$block_0;
        }
      }
      tmp$ret$0 = false;
    }
    tmp_7.isAtEnd = tmp$ret$0;
    this.isGoal = this.firstRule.isGoal;
  }
  r1b() {
    return this.i1i_1;
  }
  c1f() {
    return this.j1i_1;
  }
  g1m() {
    return this.stateSet;
  }
  h1m() {
    return this.outTransitions;
  }
  i1m() {
    var tmp0 = this.k1i_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('runtimeRules', 1, tmp, ParserState$_get_runtimeRules_$ref_1hrpf1(), null);
    return tmp0.b2();
  }
  j1m() {
    var tmp0 = this.l1i_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('runtimeRulesAsSet', 1, tmp, ParserState$_get_runtimeRulesAsSet_$ref_erejer(), null);
    return tmp0.b2();
  }
  k1m() {
    var tmp0 = this.m1i_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('optionList', 1, tmp, ParserState$_get_optionList_$ref_cldr7r(), null);
    return tmp0.b2();
  }
  l1m() {
    // Inline function 'kotlin.collections.map' call
    var this_0 = this.optionList;
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var tmp$ret$0 = item.value;
      destination.v(tmp$ret$0);
    }
    return destination;
  }
  m1m() {
    var tmp0 = this.n1i_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('isChoice', 1, tmp, ParserState$_get_isChoice_$ref_g739j5(), null);
    return tmp0.b2();
  }
  n1m() {
    var tmp0 = this.o1i_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('isOptional', 1, tmp, ParserState$_get_isOptional_$ref_gnza8u(), null);
    return tmp0.b2();
  }
  o1m() {
    var tmp0 = this.p1i_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('isList', 1, tmp, ParserState$_get_isList_$ref_pqc12c(), null);
    return tmp0.b2();
  }
  p1m() {
    return first_0(this.runtimeRules);
  }
  q1m() {
    return this.firstRule.isTerminal;
  }
  t1j() {
    return this.isAtEnd;
  }
  r1m() {
    var tmp0 = this.j1i_1;
    var tmp$ret$0;
    $l$block_0: {
      // Inline function 'kotlin.collections.any' call
      var tmp;
      if (isInterface(tmp0, Collection)) {
        tmp = tmp0.l1();
      } else {
        tmp = false;
      }
      if (tmp) {
        tmp$ret$0 = false;
        break $l$block_0;
      }
      var _iterator__ex2g4s = tmp0.g1();
      while (_iterator__ex2g4s.f()) {
        var element = _iterator__ex2g4s.e();
        if (!element.isAtEnd) {
          tmp$ret$0 = true;
          break $l$block_0;
        }
      }
      tmp$ret$0 = false;
    }
    return tmp$ret$0;
  }
  h19() {
    return this.isGoal;
  }
  y1l(includesUP, includeEOT, matchAny, content) {
    return this.stateSet.y1l(includesUP, includeEOT, matchAny, content);
  }
  transitionsGoal(previous) {
    var cache = this.outTransitions.findTransitionForIncompleteByPrevious(previous);
    var tmp;
    if (null == cache) {
      if (false) {
        // Inline function 'kotlin.check' call
        if (!!this.stateSet.preBuilt) {
          var message = 'Transitions not built for ' + this.toString() + ' -previous-> ' + previous.toString();
          throw IllegalStateException.t4(toString(message));
        }
      }
      var filteredTransitions = toList(this.stateSet.j1h_1.u1m(this, previous));
      // Inline function 'kotlin.collections.map' call
      // Inline function 'kotlin.collections.mapTo' call
      var destination = ArrayList.a1(collectionSizeOrDefault(filteredTransitions, 10));
      var _iterator__ex2g4s = filteredTransitions.g1();
      while (_iterator__ex2g4s.f()) {
        var item = _iterator__ex2g4s.e();
        var tmp$ret$2 = this.outTransitions.addTransitionForIncomplete(previous, item);
        destination.v(tmp$ret$2);
      }
      var storedTrans = destination;
      tmp = storedTrans;
    } else {
      tmp = cache;
    }
    var trans = tmp;
    return trans;
  }
  transitionsInComplete(previous) {
    var cache = this.outTransitions.findTransitionForIncompleteByPrevious(previous);
    var tmp;
    if (null == cache) {
      if (false) {
        // Inline function 'kotlin.check' call
        if (!!this.stateSet.preBuilt) {
          var message = 'Transitions not built for ' + this.toString() + ' -previous-> ' + previous.toString();
          throw IllegalStateException.t4(toString(message));
        }
      }
      var filteredTransitions = toList(this.stateSet.j1h_1.v1m(this, previous));
      // Inline function 'kotlin.collections.map' call
      // Inline function 'kotlin.collections.mapTo' call
      var destination = ArrayList.a1(collectionSizeOrDefault(filteredTransitions, 10));
      var _iterator__ex2g4s = filteredTransitions.g1();
      while (_iterator__ex2g4s.f()) {
        var item = _iterator__ex2g4s.e();
        var tmp$ret$2 = this.outTransitions.addTransitionForIncomplete(previous, item);
        destination.v(tmp$ret$2);
      }
      var storedTrans = destination;
      tmp = storedTrans;
    } else {
      tmp = cache;
    }
    var trans = tmp;
    return trans;
  }
  transitionsComplete(previous, prevPrev) {
    var cache = this.outTransitions.findTransitionForCompleteByPrevious(previous, prevPrev);
    var tmp;
    if (null == cache) {
      if (false) {
        // Inline function 'kotlin.check' call
        if (!!this.stateSet.preBuilt) {
          var message = 'Transitions not built for ' + this.toString() + ' -previous-> ' + previous.toString();
          throw IllegalStateException.t4(toString(message));
        }
      }
      var filteredTransitions = toList(this.stateSet.j1h_1.w1m(this, previous, prevPrev));
      // Inline function 'kotlin.collections.map' call
      // Inline function 'kotlin.collections.mapTo' call
      var destination = ArrayList.a1(collectionSizeOrDefault(filteredTransitions, 10));
      var _iterator__ex2g4s = filteredTransitions.g1();
      while (_iterator__ex2g4s.f()) {
        var item = _iterator__ex2g4s.e();
        var tmp$ret$2 = this.outTransitions.addTransitionForComplete(previous, prevPrev, item);
        destination.v(tmp$ret$2);
      }
      var storedTrans = destination;
      tmp = storedTrans;
    } else {
      tmp = cache;
    }
    var trans = tmp;
    return trans;
  }
  hashCode() {
    return this.i1i_1.value + imul(this.stateSet.number, 31) | 0;
  }
  equals(other) {
    var tmp;
    if (!(other instanceof ParserState)) {
      tmp = false;
    } else {
      if (!(this.i1i_1.value === other.i1i_1.value)) {
        tmp = false;
      } else {
        if (!(this.stateSet.number === other.stateSet.number)) {
          tmp = false;
        } else {
          tmp = true;
        }
      }
    }
    return tmp;
  }
  toString() {
    return 'State(' + this.i1i_1.value + '/' + this.stateSet.number + '-' + toString(this.j1i_1) + ')';
  }
  get number() {
    return this.r1b();
  }
  get rulePosition() {
    return this.c1f();
  }
  get runtimeRules() {
    return this.i1m();
  }
  get runtimeRulesAsSet() {
    return this.j1m();
  }
  get optionList() {
    return this.k1m();
  }
  get priorityList() {
    return this.l1m();
  }
  get isChoice() {
    return this.m1m();
  }
  get isOptional() {
    return this.n1m();
  }
  get isList() {
    return this.o1m();
  }
  get firstRule() {
    return this.p1m();
  }
  get isLeaf() {
    return this.q1m();
  }
  get isNotAtEnd() {
    return this.r1m();
  }
}
class sam$kotlin_Comparator$0_1 {
  constructor(function_0) {
    this.d1n_1 = function_0;
  }
  lg(a, b) {
    return this.d1n_1(a, b);
  }
  compare(a, b) {
    return this.lg(a, b);
  }
  u3() {
    return this.d1n_1;
  }
  equals(other) {
    var tmp;
    if (!(other == null) ? isInterface(other, Comparator) : false) {
      var tmp_0;
      if (!(other == null) ? isInterface(other, FunctionAdapter) : false) {
        tmp_0 = equals(this.u3(), other.u3());
      } else {
        tmp_0 = false;
      }
      tmp = tmp_0;
    } else {
      tmp = false;
    }
    return tmp;
  }
  hashCode() {
    return hashCode(this.u3());
  }
}
class ParserStateSet {
  constructor(number, runtimeRuleSet, userGoalRule, isSkip, automatonKind, preBuilt) {
    this.number = number;
    this.runtimeRuleSet = runtimeRuleSet;
    this.userGoalRule = userGoalRule;
    this.isSkip = isSkip;
    this.automatonKind = automatonKind;
    this.g1h_1 = 0;
    var tmp = this;
    // Inline function 'kotlin.collections.mutableListOf' call
    tmp.h1h_1 = ArrayList.o1();
    this.i1h_1 = 0;
    this.j1h_1 = new RuntimeTransitionCalculator(this);
    this.preBuilt = preBuilt;
    var tmp_0 = this;
    tmp_0.k1h_1 = lazy(ParserStateSet$buildCache$delegate$lambda(this));
    var tmp_1 = this;
    tmp_1.l1h_1 = lazy(ParserStateSet$usedRules$delegate$lambda(this));
    var tmp_2 = this;
    tmp_2.m1h_1 = lazy(ParserStateSet$usedTerminalRules$delegate$lambda(this));
    var tmp_3 = this;
    tmp_3.n1h_1 = lazy(ParserStateSet$usedNonTerminalRules$delegate$lambda(this));
    var tmp_4 = this;
    tmp_4.o1h_1 = lazy(ParserStateSet$firstTerminals$delegate$lambda(this));
    var tmp_5 = this;
    tmp_5.p1h_1 = lazy(ParserStateSet$embeddedRuntimeRuleSet$delegate$lambda(this));
    var tmp_6 = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp_6.q1h_1 = LinkedHashMap.j4();
    var tmp_7 = this;
    // Inline function 'kotlin.collections.mutableListOf' call
    tmp_7.r1h_1 = ArrayList.o1();
    var tmp_8 = this;
    tmp_8.s1h_1 = lazy(ParserStateSet$goalRule$delegate$lambda(this));
    var tmp_9 = this;
    tmp_9.t1h_1 = lazy(ParserStateSet$startRulePosition$delegate$lambda(this));
    var tmp_10 = this;
    tmp_10.u1h_1 = lazy(ParserStateSet$finishRulePosition$delegate$lambda(this));
    var tmp_11 = this;
    tmp_11.v1h_1 = lazy(ParserStateSet$startState$delegate$lambda(this));
    var tmp_12 = this;
    tmp_12.w1h_1 = lazy(ParserStateSet$finishState$delegate$lambda(this));
    this.x1h_1 = new FirstOf();
  }
  r1b() {
    return this.number;
  }
  p1b() {
    return this.runtimeRuleSet;
  }
  q1b() {
    return this.userGoalRule;
  }
  u1f() {
    return this.isSkip;
  }
  j1n() {
    return this.automatonKind;
  }
  k1n() {
    return this.j1h_1;
  }
  l1n() {
    return this.preBuilt;
  }
  x1m() {
    var tmp0 = this.k1h_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('buildCache', 1, tmp, ParserStateSet$_get_buildCache_$ref_7quire(), null);
    return tmp0.b2();
  }
  v1b() {
    var tmp0 = this.l1h_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('usedRules', 1, tmp, ParserStateSet$_get_usedRules_$ref_a9jloy(), null);
    return tmp0.b2();
  }
  m1n() {
    var tmp0 = this.m1h_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('usedTerminalRules', 1, tmp, ParserStateSet$_get_usedTerminalRules_$ref_xaekha(), null);
    return tmp0.b2();
  }
  n1n() {
    var tmp0 = this.n1h_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('usedNonTerminalRules', 1, tmp, ParserStateSet$_get_usedNonTerminalRules_$ref_z5pug3(), null);
    return tmp0.b2();
  }
  o1n() {
    var tmp0 = this.o1h_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('firstTerminals', 1, tmp, ParserStateSet$_get_firstTerminals_$ref_2rxbfd(), null);
    return tmp0.b2();
  }
  p1n() {
    var tmp0 = this.p1h_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('embeddedRuntimeRuleSet', 1, tmp, ParserStateSet$_get_embeddedRuntimeRuleSet_$ref_4teomu(), null);
    return tmp0.b2();
  }
  q1n() {
    return toList(this.r1h_1);
  }
  r1n() {
    // Inline function 'kotlin.collections.flatMap' call
    var tmp0 = this.allBuiltStates;
    // Inline function 'kotlin.collections.flatMapTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      var list = element.outTransitions.allBuiltTransitions;
      addAll(destination, list);
    }
    return toSet(destination);
  }
  t1b() {
    var tmp0 = this.s1h_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('goalRule', 1, tmp, ParserStateSet$_get_goalRule_$ref_eaq6qn(), null);
    return tmp0.b2();
  }
  s1n() {
    var tmp0 = this.t1h_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('startRulePosition', 1, tmp, ParserStateSet$_get_startRulePosition_$ref_byigx1(), null);
    return tmp0.b2();
  }
  t1n() {
    var tmp0 = this.u1h_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('finishRulePosition', 1, tmp, ParserStateSet$_get_finishRulePosition_$ref_5204i2(), null);
    return tmp0.b2();
  }
  u1b() {
    var tmp0 = this.v1h_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('startState', 1, tmp, ParserStateSet$_get_startState_$ref_budccf(), null);
    return tmp0.b2();
  }
  u1n() {
    var tmp0 = this.w1h_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('finishState', 1, tmp, ParserStateSet$_get_finishState_$ref_kmsh5a(), null);
    return tmp0.b2();
  }
  v1n() {
    return this.x1h_1;
  }
  y1h(rulePositions) {
    if (false) {
      // Inline function 'kotlin.collections.contains' call
      // Inline function 'kotlin.collections.containsKey' call
      var this_0 = this.q1h_1;
      // Inline function 'kotlin.check' call
      if (!!(isInterface(this_0, KtMap) ? this_0 : THROW_CCE()).a3(rulePositions)) {
        var message = 'State already created for ' + toString(rulePositions);
        throw IllegalStateException.t4(toString(message));
      }
    }
    var existing = this.q1h_1.c3(rulePositions);
    var tmp;
    if (!(null == existing)) {
      tmp = existing;
    } else {
      var _unary__edvuaz = this.i1h_1;
      this.i1h_1 = _unary__edvuaz + 1 | 0;
      var state = new ParserState(new StateNumber(_unary__edvuaz), toList(rulePositions), this);
      // Inline function 'kotlin.collections.set' call
      this.q1h_1.f3(rulePositions, state);
      this.r1h_1.n3(state.i1i_1.value, state);
      tmp = state;
    }
    return tmp;
  }
  w1n(rulePositions) {
    if (false) {
      // Inline function 'kotlin.collections.contains' call
      // Inline function 'kotlin.collections.containsKey' call
      var this_0 = this.q1h_1;
      // Inline function 'kotlin.check' call
      if (!!(isInterface(this_0, KtMap) ? this_0 : THROW_CCE()).a3(rulePositions)) {
        var message = 'State already created for ' + toString(rulePositions);
        throw IllegalStateException.t4(toString(message));
      }
    }
    var existing = this.q1h_1.c3(rulePositions);
    var tmp;
    if (!(null == existing)) {
      tmp = existing;
    } else {
      var si = this.x1m().z1i(rulePositions);
      var state = this.y1h(toList(si.d1k_1));
      tmp = state;
    }
    return tmp;
  }
  z1m(rulePositions) {
    var tmp0 = this.allBuiltStates;
    var tmp$ret$1;
    $l$block: {
      // Inline function 'kotlin.collections.firstOrNull' call
      var _iterator__ex2g4s = tmp0.g1();
      while (_iterator__ex2g4s.f()) {
        var element = _iterator__ex2g4s.e();
        if (equals(toSet(element.j1i_1), toSet(rulePositions))) {
          tmp$ret$1 = element;
          break $l$block;
        }
      }
      tmp$ret$1 = null;
    }
    return tmp$ret$1;
  }
  x1n(rulePositions) {
    var tmp0_elvis_lhs = this.z1m(rulePositions);
    return tmp0_elvis_lhs == null ? this.w1n(rulePositions) : tmp0_elvis_lhs;
  }
  a1n(rulePositions) {
    var tmp0 = this.allBuiltStates;
    var tmp$ret$1;
    $l$block: {
      // Inline function 'kotlin.collections.firstOrNull' call
      var _iterator__ex2g4s = tmp0.g1();
      while (_iterator__ex2g4s.f()) {
        var element = _iterator__ex2g4s.e();
        if (element.j1i_1.w2(rulePositions)) {
          tmp$ret$1 = element;
          break $l$block;
        }
      }
      tmp$ret$1 = null;
    }
    var existing = tmp$ret$1;
    return existing;
  }
  y1m(rulePositions) {
    var tmp0_elvis_lhs = this.a1n(rulePositions);
    return tmp0_elvis_lhs == null ? this.w1n(rulePositions) : tmp0_elvis_lhs;
  }
  y1l(includeRT, includeEOT, matchAny, content) {
    var tmp;
    if (content.l1()) {
      var tmp_0;
      if (matchAny) {
        tmp_0 = Companion_getInstance_3().ANY;
      } else if (includeRT && !includeEOT && !matchAny) {
        tmp_0 = Companion_getInstance_3().RT;
      } else if (!includeRT && includeEOT && !matchAny) {
        tmp_0 = Companion_getInstance_3().EOT;
      } else if (!includeRT && !includeEOT && !matchAny) {
        tmp_0 = Companion_getInstance_3().EMPTY;
      } else if (includeRT && !includeEOT && !matchAny) {
        tmp_0 = Companion_getInstance_3().RT;
      } else if (includeRT && includeEOT && !matchAny) {
        tmp_0 = Companion_getInstance_3().RT_EOT;
      } else {
        var message = 'Internal Error: situation not handled';
        throw IllegalStateException.t4(toString(message));
      }
      tmp = tmp_0;
    } else {
      var tmp0 = this.h1h_1;
      var tmp$ret$1;
      $l$block: {
        // Inline function 'kotlin.collections.firstOrNull' call
        var _iterator__ex2g4s = tmp0.g1();
        while (_iterator__ex2g4s.f()) {
          var element = _iterator__ex2g4s.e();
          if (element.h1l_1 === includeRT && element.i1l_1 === includeEOT && element.j1l_1 === matchAny && equals(element.k1l_1, content)) {
            tmp$ret$1 = element;
            break $l$block;
          }
        }
        tmp$ret$1 = null;
      }
      var existing = tmp$ret$1;
      var tmp_1;
      if (null == existing) {
        var _unary__edvuaz = this.g1h_1;
        this.g1h_1 = _unary__edvuaz + 1 | 0;
        var num = _unary__edvuaz;
        var lhs = new LookaheadSet(num, includeRT, includeEOT, matchAny, content);
        this.h1h_1.v(lhs);
        tmp_1 = lhs;
      } else {
        tmp_1 = existing;
      }
      tmp = tmp_1;
    }
    return tmp;
  }
  y1n(part) {
    return this.y1l(part.includesRT, part.includesEOT, part.matchANY, part.content);
  }
  precedenceRulesFor(sourceState) {
    // Inline function 'kotlin.collections.map' call
    var this_0 = sourceState.runtimeRules;
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var tmp$ret$0 = this.runtimeRuleSet.z1n(item);
      destination.v(tmp$ret$0);
    }
    return firstOrNull(destination);
  }
  build() {
    if (!this.preBuilt) {
      this.x1m().w1i();
      buildAndTraverse(this);
      this.preBuilt = true;
      this.x1m().x1i();
    }
    return this;
  }
  hashCode() {
    return this.number;
  }
  equals(other) {
    var tmp;
    if (other instanceof ParserStateSet) {
      tmp = this.number === other.number;
    } else {
      tmp = false;
    }
    return tmp;
  }
  x1b(withStates) {
    var b = StringBuilder.s();
    var states = this.allBuiltStates;
    // Inline function 'kotlin.collections.flatMap' call
    // Inline function 'kotlin.collections.flatMapTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = states.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      var list = element.outTransitions.allBuiltTransitions;
      addAll(destination, list);
    }
    var transitions = destination;
    b.ya('UsedRules: ' + this.usedRules.h1() + '  States: ' + states.h1() + '  Transitions: ' + transitions.h1() + ' ');
    b.ya('\n');
    if (withStates) {
      // Inline function 'kotlin.collections.forEach' call
      var _iterator__ex2g4s_0 = states.g1();
      while (_iterator__ex2g4s_0.f()) {
        var element_0 = _iterator__ex2g4s_0.e();
        var tmp = element_0.toString();
        var tmp_0 = element_0.outTransitions.allPrevious;
        var str = tmp + ' {' + joinToString(tmp_0, VOID, VOID, VOID, VOID, VOID, ParserStateSet$usedAutomatonToString$lambda) + '}';
        b.ya(str).ya('\n');
      }
    }
    // Inline function 'kotlin.collections.sortedBy' call
    // Inline function 'kotlin.comparisons.compareBy' call
    var tmp_1 = ParserStateSet$usedAutomatonToString$lambda_0;
    var tmp$ret$5 = new sam$kotlin_Comparator$0_1(tmp_1);
    // Inline function 'kotlin.collections.sortedBy' call
    var this_0 = sortedWith(transitions, tmp$ret$5);
    // Inline function 'kotlin.comparisons.compareBy' call
    var tmp_2 = ParserStateSet$usedAutomatonToString$lambda_1;
    var tmp$ret$7 = new sam$kotlin_Comparator$0_1(tmp_2);
    // Inline function 'kotlin.collections.forEach' call
    var _iterator__ex2g4s_1 = sortedWith(this_0, tmp$ret$7).g1();
    while (_iterator__ex2g4s_1.f()) {
      var element_1 = _iterator__ex2g4s_1.e();
      var tmp_3 = element_1.e1n_1.outTransitions.previousFor(element_1);
      var prev = joinToString(tmp_3, VOID, VOID, VOID, VOID, VOID, ParserStateSet$usedAutomatonToString$lambda_2);
      var frStr = '' + element_1.e1n_1.i1i_1.value + ':(' + joinToString(element_1.e1n_1.j1i_1, VOID, VOID, VOID, VOID, VOID, ParserStateSet$usedAutomatonToString$lambda_3) + ')';
      var toStr = '' + element_1.f1n_1.i1i_1.value + ':' + toString(element_1.f1n_1.j1i_1);
      var trStr = frStr + ' --> ' + toStr;
      var lh = joinToString(element_1.lookaheadGuard, '|', VOID, VOID, VOID, VOID, ParserStateSet$usedAutomatonToString$lambda_4);
      b.ya(' ' + element_1.g1n_1.toString() + ' ');
      b.ya(trStr);
      b.ya(lh);
      b.ya(' {' + prev + '} ');
      b.ya('\n');
    }
    return b.toString();
  }
  usedAutomatonToString(withStates, $super) {
    withStates = withStates === VOID ? false : withStates;
    return $super === VOID ? this.x1b(withStates) : $super.x1b.call(this, withStates);
  }
  toString() {
    return 'ParserStateSet{' + this.number + ' (' + this.userGoalRule.tag + ') }';
  }
  j1g() {
    return this.runtimeRuleSet;
  }
  i1c() {
    return toSet(this.r1h_1);
  }
  k1g() {
    return this.allBuiltTransitions;
  }
  l1g(withStates) {
    return this.usedAutomatonToString(withStates);
  }
  get usedRules() {
    return this.v1b();
  }
  get usedTerminalRules() {
    return this.m1n();
  }
  get usedNonTerminalRules() {
    return this.n1n();
  }
  get firstTerminals() {
    return this.o1n();
  }
  get embeddedRuntimeRuleSet() {
    return this.p1n();
  }
  get allBuiltStates() {
    return this.q1n();
  }
  get allBuiltTransitions() {
    return this.r1n();
  }
  get goalRule() {
    return this.t1b();
  }
  get startRulePosition() {
    return this.s1n();
  }
  get finishRulePosition() {
    return this.t1n();
  }
  get startState() {
    return this.u1b();
  }
  get finishState() {
    return this.u1n();
  }
  get ruleSet() {
    return this.j1g();
  }
  get state() {
    return this.i1c();
  }
  get transition() {
    return this.k1g();
  }
}
class RuntimeTransitionCalculator {
  constructor(stateSet) {
    this.s1m_1 = stateSet;
    var tmp = this;
    // Inline function 'kotlin.collections.mutableSetOf' call
    tmp.t1m_1 = LinkedHashSet.j1();
  }
  u1m(sourceState, previousState) {
    this.t1m_1.i3();
    var widthInto = this.s1m_1.x1m().a1j(previousState, sourceState);
    var _iterator__ex2g4s = widthInto.g1();
    while (_iterator__ex2g4s.f()) {
      var wi = _iterator__ex2g4s.e();
      var tmp = wi.x1k_1.k1b_1;
      var rr = tmp instanceof RuntimeRule ? tmp : THROW_CCE();
      if (rr.isTerminal)
        this.t1m_1.v(createWidthOrEmbeddedTransition(this, sourceState, wi));
      else {
        // Inline function 'kotlin.error' call
        var message = 'Should never happen';
        throw IllegalStateException.t4(toString(message));
      }
    }
    return this.t1m_1;
  }
  w1m(sourceState, previousState, prevPrev) {
    this.t1m_1.i3();
    var heightOrGraftInto = this.s1m_1.x1m().b1j(prevPrev, previousState, sourceState);
    var _iterator__ex2g4s = heightOrGraftInto.g1();
    while (_iterator__ex2g4s.f()) {
      var hg = _iterator__ex2g4s.e();
      switch (hg.r1k_1.q3_1) {
        case 3:
          if (sourceState.isGoal && this.s1m_1.isSkip) {
            var to = sourceState;
            this.t1m_1.v(new Transition(sourceState, to, ParseAction_GOAL_getInstance(), setOf(Companion_getInstance_2().EMPTY)));
          } else {
            var ts = createGoalTransition3(this, sourceState, hg);
            this.t1m_1.v(ts);
          }

          break;
        case 0:
          var ts_0 = createHeightTransition3(this, sourceState, hg);
          this.t1m_1.v(ts_0);
          break;
        case 1:
          var ts_1 = createGraftTransition3(this, sourceState, hg);
          this.t1m_1.v(ts_1);
          break;
        default:
          // Inline function 'kotlin.error' call

          throw IllegalStateException.t4(toString(''));
      }
    }
    return this.t1m_1;
  }
  v1m(source, previous) {
    this.t1m_1.i3();
    var widthInto = this.s1m_1.x1m().a1j(previous, source);
    var _iterator__ex2g4s = widthInto.g1();
    while (_iterator__ex2g4s.f()) {
      var wi = _iterator__ex2g4s.e();
      var ts = createWidthOrEmbeddedTransition(this, source, wi);
      this.t1m_1.v(ts);
    }
    return this.t1m_1;
  }
}
class RuntimeGuard {}
class ToEndMultiGraftRuntimeGuard {
  constructor(trans) {
    this.trans = trans;
    var tmp = this;
    var tmp_0 = this.trans.f1n_1.firstRule.rhs;
    tmp.rhs = tmp_0 instanceof RuntimeRuleRhsListSimple ? tmp_0 : THROW_CCE();
    this.min = this.rhs.a1o_1;
    this.max = this.rhs.b1o_1;
  }
  c1o() {
    return this.trans;
  }
  d1o() {
    return this.rhs;
  }
  e1o() {
    return this.min;
  }
  f1o() {
    return this.max;
  }
  execute(numNonSkipChildren) {
    return this.min <= (numNonSkipChildren + 1 | 0) && (-1 === this.max || (numNonSkipChildren + 1 | 0) <= this.max);
  }
  expectedWhenFailed(numNonSkipChildren) {
    var tmp;
    if (this.min > numNonSkipChildren) {
      tmp = setOf(this.rhs.repeatedRhsItem);
    } else if (!(-1 === this.max) && this.max < (numNonSkipChildren + 1 | 0)) {
      // Inline function 'kotlin.collections.map' call
      var this_0 = this.trans.lookaheadGuard;
      // Inline function 'kotlin.collections.mapTo' call
      var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
      var _iterator__ex2g4s = this_0.g1();
      while (_iterator__ex2g4s.f()) {
        var item = _iterator__ex2g4s.e();
        var tmp$ret$0 = item.guardLookaheadSet;
        destination.v(tmp$ret$0);
      }
      // Inline function 'kotlin.collections.fold' call
      var accumulator = Companion_getInstance_7().EMPTY;
      var _iterator__ex2g4s_0 = destination.g1();
      while (_iterator__ex2g4s_0.f()) {
        var element = _iterator__ex2g4s_0.e();
        accumulator = accumulator.union(element.b1m());
      }
      tmp = accumulator.fullContent;
    } else {
      tmp = emptySet();
    }
    return tmp;
  }
  toString() {
    return 'ToEndMulti{' + this.min + ' <= n}';
  }
}
class ToItemMultiGraftRuntimeGuard {
  constructor(trans) {
    this.trans = trans;
    var tmp = this;
    var tmp_0 = this.trans.f1n_1.firstRule.rhs;
    tmp.rhs = tmp_0 instanceof RuntimeRuleRhsListSimple ? tmp_0 : THROW_CCE();
    this.min = this.rhs.a1o_1;
    this.max = this.rhs.b1o_1;
  }
  c1o() {
    return this.trans;
  }
  d1o() {
    return this.rhs;
  }
  e1o() {
    return this.min;
  }
  f1o() {
    return this.max;
  }
  execute(numNonSkipChildren) {
    return -1 === this.max || (numNonSkipChildren + 1 | 0) < this.max;
  }
  expectedWhenFailed(numNonSkipChildren) {
    return -1 === this.max || (numNonSkipChildren + 1 | 0) < this.max ? emptySet() : emptySet();
  }
  toString() {
    return 'ToItemMulti{n <= ' + this.max + '}';
  }
}
class ToEndSListGraftRuntimeGuard {
  constructor(trans) {
    this.trans = trans;
    var tmp = this;
    var tmp_0 = this.trans.f1n_1.firstRule.rhs;
    tmp.rhs = tmp_0 instanceof RuntimeRuleRhsList ? tmp_0 : THROW_CCE();
    this.min = this.rhs.min;
    this.max = this.rhs.max;
  }
  c1o() {
    return this.trans;
  }
  d1o() {
    return this.rhs;
  }
  e1o() {
    return this.min;
  }
  f1o() {
    return this.max;
  }
  execute(numNonSkipChildren) {
    return this.min <= ((numNonSkipChildren / 2 | 0) + 1 | 0) && (-1 === this.max || ((numNonSkipChildren / 2 | 0) + 1 | 0) <= this.max);
  }
  expectedWhenFailed(numNonSkipChildren) {
    return this.min <= ((numNonSkipChildren / 2 | 0) + 1 | 0) ? emptySet() : -1 === this.max || ((numNonSkipChildren / 2 | 0) + 1 | 0) <= this.max ? emptySet() : emptySet();
  }
  toString() {
    return 'ToEndSList{' + this.min + ' <= n}';
  }
}
class ToItemSListGraftRuntimeGuard {
  constructor(trans) {
    this.trans = trans;
    var tmp = this;
    var tmp_0 = this.trans.f1n_1.firstRule.rhs;
    tmp.rhs = tmp_0 instanceof RuntimeRuleRhsList ? tmp_0 : THROW_CCE();
    this.min = this.rhs.min;
    this.max = this.rhs.max;
  }
  c1o() {
    return this.trans;
  }
  d1o() {
    return this.rhs;
  }
  e1o() {
    return this.min;
  }
  f1o() {
    return this.max;
  }
  execute(numNonSkipChildren) {
    return -1 === this.max || ((numNonSkipChildren / 2 | 0) + 1 | 0) < this.max;
  }
  expectedWhenFailed(numNonSkipChildren) {
    return -1 === this.max || ((numNonSkipChildren / 2 | 0) + 1 | 0) < this.max ? emptySet() : emptySet();
  }
  toString() {
    return 'ToItemSList{n <= ' + this.max + '}';
  }
}
class ToSeparatorSListGraftRuntimeGuard {
  constructor(trans) {
    this.trans = trans;
    var tmp = this;
    var tmp_0 = this.trans.f1n_1.firstRule.rhs;
    tmp.rhs = tmp_0 instanceof RuntimeRuleRhsList ? tmp_0 : THROW_CCE();
    this.min = this.rhs.min;
    this.max = this.rhs.max;
  }
  c1o() {
    return this.trans;
  }
  d1o() {
    return this.rhs;
  }
  e1o() {
    return this.min;
  }
  f1o() {
    return this.max;
  }
  execute(numNonSkipChildren) {
    return -1 === this.max || ((numNonSkipChildren / 2 | 0) + 1 | 0) < this.max;
  }
  expectedWhenFailed(numNonSkipChildren) {
    return -1 === this.max || ((numNonSkipChildren / 2 | 0) + 1 | 0) < this.max ? emptySet() : emptySet();
  }
  toString() {
    return 'ToSeparatorSList{n <= ' + this.max + '}';
  }
}
class DefaultRuntimeGuard {
  execute(numNonSkipChildren) {
    return true;
  }
  expectedWhenFailed(numNonSkipChildren) {
    var message = 'Internal Error: should never happen';
    throw IllegalStateException.t4(toString(message));
  }
  toString() {
    return 'DefaultRuntimeGuard{true}';
  }
}
class Companion_5 {
  runtimeGuardFor(trans) {
    var target = trans.f1n_1.firstRule;
    var targetRp = trans.f1n_1.j1i_1.i1(0);
    var tgtRhs = target.rhs;
    var tmp;
    if (trans.g1n_1.q3_1 === 1) {
      var tmp_0;
      if (tgtRhs instanceof RuntimeRuleRhsListSimple) {
        var tmp_1;
        if (targetRp.isAtEnd) {
          tmp_1 = new ToEndMultiGraftRuntimeGuard(trans);
        } else if (targetRp.m1b_1 === 1) {
          tmp_1 = new ToItemMultiGraftRuntimeGuard(trans);
        } else {
          throw NotImplementedError.im();
        }
        tmp_0 = tmp_1;
      } else {
        if (tgtRhs instanceof RuntimeRuleRhsListSeparated) {
          var tmp_2;
          if (targetRp.isAtEnd) {
            tmp_2 = new ToEndSListGraftRuntimeGuard(trans);
          } else if (targetRp.m1b_1 === 2) {
            tmp_2 = new ToItemSListGraftRuntimeGuard(trans);
          } else if (targetRp.m1b_1 === 1) {
            tmp_2 = new ToSeparatorSListGraftRuntimeGuard(trans);
          } else {
            throw NotImplementedError.im();
          }
          tmp_0 = tmp_2;
        } else {
          tmp_0 = DefaultRuntimeGuard_instance;
        }
      }
      tmp = tmp_0;
    } else {
      tmp = DefaultRuntimeGuard_instance;
    }
    return tmp;
  }
}
class Transition {
  constructor(source, target, action, lookaheadGuard) {
    this.e1n_1 = source;
    this.f1n_1 = target;
    this.g1n_1 = action;
    this.lookaheadGuard = lookaheadGuard;
    var tmp = this;
    tmp.h1n_1 = lazy(Transition$context$delegate$lambda(this));
    this.runtimeGuard = Companion_instance_5.runtimeGuardFor(this);
    var tmp_0 = this;
    tmp_0.i1n_1 = lazy(Transition$hashCode_cache$delegate$lambda(this));
  }
  tq() {
    return this.e1n_1;
  }
  m12() {
    return this.f1n_1;
  }
  d1c() {
    return this.g1n_1;
  }
  g1o() {
    return this.lookaheadGuard;
  }
  sb() {
    var tmp0 = this.h1n_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('context', 1, tmp, Transition$_get_context_$ref_7yxvsu(), null);
    return tmp0.b2();
  }
  h1o() {
    return this.runtimeGuard;
  }
  m1g() {
    return this.lookaheadGuard;
  }
  ww() {
    // Inline function 'kotlin.collections.map' call
    var this_0 = this.context;
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var tmp$ret$0 = item.previous;
      destination.v(tmp$ret$0);
    }
    return toSet(destination);
  }
  n1g() {
    // Inline function 'kotlin.collections.filterIsInstance' call
    var tmp0 = this.context;
    // Inline function 'kotlin.collections.filterIsInstanceTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      if (element instanceof CompleteKey) {
        destination.v(element);
      }
    }
    // Inline function 'kotlin.collections.map' call
    // Inline function 'kotlin.collections.mapTo' call
    var destination_0 = ArrayList.a1(collectionSizeOrDefault(destination, 10));
    var _iterator__ex2g4s_0 = destination.g1();
    while (_iterator__ex2g4s_0.f()) {
      var item = _iterator__ex2g4s_0.e();
      var tmp$ret$2 = item.j1o_1;
      destination_0.v(tmp$ret$2);
    }
    return toSet(destination_0);
  }
  o1g() {
    // Inline function 'kotlin.collections.filterIsInstance' call
    var tmp0 = this.context;
    // Inline function 'kotlin.collections.filterIsInstanceTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      if (element instanceof CompleteKey) {
        destination.v(element);
      }
    }
    return toSet(destination);
  }
  hashCode() {
    return _get_hashCode_cache__hrfw4t(this);
  }
  equals(other) {
    if (other instanceof Transition) {
      if (!this.e1n_1.equals(other.e1n_1))
        return false;
      if (!this.f1n_1.equals(other.f1n_1))
        return false;
      if (!this.g1n_1.equals(other.g1n_1))
        return false;
      if (!equals(this.lookaheadGuard, other.lookaheadGuard))
        return false;
      return true;
    } else {
      return false;
    }
  }
  toString() {
    var tmp = this.context;
    var ctx = joinToString(tmp, VOID, VOID, VOID, VOID, VOID, Transition$toString$lambda);
    var lhsStr = joinToString(this.lookaheadGuard, '|', VOID, VOID, VOID, VOID, Transition$toString$lambda_0);
    return 'Transition: ' + this.e1n_1.toString() + ' -- ' + this.g1n_1.toString() + lhsStr + ' --> ' + this.f1n_1.toString() + ' {' + ctx + '}';
  }
  get source() {
    return this.tq();
  }
  get target() {
    return this.m12();
  }
  get action() {
    return this.d1c();
  }
  get context() {
    return this.sb();
  }
  get lookahead() {
    return this.m1g();
  }
  get prev() {
    return this.ww();
  }
  get prevPrev() {
    return this.n1g();
  }
  get transContext() {
    return this.o1g();
  }
}
class TransitionCache {}
class TransitionPrevInfoKey {}
class CompleteKey {
  constructor(previous, prevPrev) {
    this.i1o_1 = previous;
    this.j1o_1 = prevPrev;
  }
  l1o() {
    return this.i1o_1;
  }
  n1g() {
    return this.j1o_1;
  }
  ww() {
    return this.i1o_1;
  }
  toString() {
    return '' + this.j1o_1.i1i_1.value + '-' + this.i1o_1.i1i_1.value;
  }
  ni() {
    return this.i1o_1;
  }
  oi() {
    return this.j1o_1;
  }
  m1o(previous, prevPrev) {
    return new CompleteKey(previous, prevPrev);
  }
  copy(previous, prevPrev, $super) {
    previous = previous === VOID ? this.i1o_1 : previous;
    prevPrev = prevPrev === VOID ? this.j1o_1 : prevPrev;
    return $super === VOID ? this.m1o(previous, prevPrev) : $super.m1o.call(this, previous, prevPrev);
  }
  hashCode() {
    var result = this.i1o_1.hashCode();
    result = imul(result, 31) + this.j1o_1.hashCode() | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof CompleteKey))
      return false;
    if (!this.i1o_1.equals(other.i1o_1))
      return false;
    if (!this.j1o_1.equals(other.j1o_1))
      return false;
    return true;
  }
  get previous() {
    return this.l1o();
  }
  get prevPrev() {
    return this.n1g();
  }
  get prev() {
    return this.ww();
  }
}
class IncompleteKey {
  constructor(previous) {
    this.n1o_1 = previous;
  }
  l1o() {
    return this.n1o_1;
  }
  toString() {
    return '' + this.n1o_1.i1i_1.value;
  }
  ni() {
    return this.n1o_1;
  }
  o1o(previous) {
    return new IncompleteKey(previous);
  }
  copy(previous, $super) {
    previous = previous === VOID ? this.n1o_1 : previous;
    return $super === VOID ? this.o1o(previous) : $super.o1o.call(this, previous);
  }
  hashCode() {
    return this.n1o_1.hashCode();
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof IncompleteKey))
      return false;
    if (!this.n1o_1.equals(other.n1o_1))
      return false;
    return true;
  }
  get previous() {
    return this.l1o();
  }
}
class Companion_6 {}
class TransitionCacheLC1 {
  constructor() {
    var tmp = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp.p1o_1 = LinkedHashMap.j4();
    var tmp_0 = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp_0.q1o_1 = LinkedHashMap.j4();
    var tmp_1 = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp_1.r1o_1 = LinkedHashMap.j4();
    var tmp_2 = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp_2.s1o_1 = LinkedHashMap.j4();
  }
  r1n() {
    return toSet(plus_2(_get__allBuiltIncomplete__j98m7d(this), _get__allBuiltComplete__fb3q3g(this)));
  }
  k1o() {
    return toSet(plus_2(_get__allPreviousIncomplete__5lazpo(this), _get__allPreviousComplete__hn51vr(this)));
  }
  addTransitionForComplete(previous, prevPrev, tr) {
    var automaton = tr.e1n_1.stateSet;
    var key = new Pair(tr.g1n_1, tr.f1n_1);
    var existing = this.p1o_1.c3(key);
    var ck = new CompleteKey(previous, prevPrev);
    var tmp;
    if (null == existing) {
      var tmp0 = this.p1o_1;
      // Inline function 'kotlin.collections.set' call
      var value = new Pair(setOf(ck), tr);
      tmp0.f3(key, value);
      updateCompleteByPrevious(this, setOf(ck), null, tr);
      tmp = tr;
    } else {
      var toMerge = setOf_0([tr, existing.ii_1]);
      var mergedTr = merge(Companion_instance_6, automaton, toMerge);
      var mergedPrev = plus(existing.hi_1, ck);
      var tmp0_0 = this.p1o_1;
      // Inline function 'kotlin.collections.set' call
      var value_0 = new Pair(mergedPrev, mergedTr);
      tmp0_0.f3(key, value_0);
      updateCompleteByPrevious(this, mergedPrev, existing.ii_1, mergedTr);
      if (false) {
        var tmp_0 = Debug_instance;
        var tmp_1 = IndentDelta_NONE_getInstance();
        tmp_0.debug(tmp_1, TransitionCacheLC1$addTransitionForComplete$lambda(toMerge));
      }
      if (false) {
        var tmp_2 = Debug_instance;
        var tmp_3 = IndentDelta_NONE_getInstance();
        tmp_2.debug(tmp_3, TransitionCacheLC1$addTransitionForComplete$lambda_0(mergedTr));
      }
      tmp = mergedTr;
    }
    return tmp;
  }
  addTransitionForIncomplete(previous, tr) {
    var automaton = tr.e1n_1.stateSet;
    var key = new Pair(tr.g1n_1, tr.f1n_1);
    var existing = this.q1o_1.c3(key);
    var tmp;
    if (null == existing) {
      var tmp0 = this.q1o_1;
      // Inline function 'kotlin.collections.set' call
      var value = new Pair(setOf(previous), tr);
      tmp0.f3(key, value);
      updateIncompleteByPrevious(this, setOf(previous), null, tr);
      tmp = tr;
    } else {
      var toMerge = setOf_0([tr, existing.ii_1]);
      var mergedTr = merge(Companion_instance_6, automaton, toMerge);
      var mergedPrev = plus(existing.hi_1, previous);
      var tmp0_0 = this.q1o_1;
      // Inline function 'kotlin.collections.set' call
      var value_0 = new Pair(mergedPrev, mergedTr);
      tmp0_0.f3(key, value_0);
      updateIncompleteByPrevious(this, mergedPrev, existing.ii_1, mergedTr);
      if (false) {
        var tmp_0 = Debug_instance;
        var tmp_1 = IndentDelta_NONE_getInstance();
        tmp_0.debug(tmp_1, TransitionCacheLC1$addTransitionForIncomplete$lambda(toMerge));
      }
      if (false) {
        var tmp_2 = Debug_instance;
        var tmp_3 = IndentDelta_NONE_getInstance();
        tmp_2.debug(tmp_3, TransitionCacheLC1$addTransitionForIncomplete$lambda_0(mergedTr));
      }
      tmp = mergedTr;
    }
    return tmp;
  }
  findTransitionForCompleteByPrevious(previous, prevPrev) {
    return this.r1o_1.c3(new CompleteKey(previous, prevPrev));
  }
  findTransitionForIncompleteByPrevious(previous) {
    return this.s1o_1.c3(previous);
  }
  findTransitionByKey(key) {
    // Inline function 'kotlin.TODO' call
    var reason = 'not implemented';
    throw NotImplementedError.im('An operation is not implemented: ' + reason);
  }
  previousFor(transition) {
    var tmp;
    if (transition.e1n_1.isAtEnd) {
      // Inline function 'kotlin.collections.filter' call
      var tmp0 = this.r1o_1.z1();
      // Inline function 'kotlin.collections.filterTo' call
      var destination = ArrayList.o1();
      var _iterator__ex2g4s = tmp0.g1();
      while (_iterator__ex2g4s.f()) {
        var element = _iterator__ex2g4s.e();
        if (element.b2().p1(transition)) {
          destination.v(element);
        }
      }
      // Inline function 'kotlin.collections.map' call
      // Inline function 'kotlin.collections.mapTo' call
      var destination_0 = ArrayList.a1(collectionSizeOrDefault(destination, 10));
      var _iterator__ex2g4s_0 = destination.g1();
      while (_iterator__ex2g4s_0.f()) {
        var item = _iterator__ex2g4s_0.e();
        var tmp$ret$3 = item.a2();
        destination_0.v(tmp$ret$3);
      }
      tmp = destination_0;
    } else {
      // Inline function 'kotlin.collections.filter' call
      var tmp0_0 = this.s1o_1.z1();
      // Inline function 'kotlin.collections.filterTo' call
      var destination_1 = ArrayList.o1();
      var _iterator__ex2g4s_1 = tmp0_0.g1();
      while (_iterator__ex2g4s_1.f()) {
        var element_0 = _iterator__ex2g4s_1.e();
        if (element_0.b2().p1(transition)) {
          destination_1.v(element_0);
        }
      }
      // Inline function 'kotlin.collections.map' call
      // Inline function 'kotlin.collections.mapTo' call
      var destination_2 = ArrayList.a1(collectionSizeOrDefault(destination_1, 10));
      var _iterator__ex2g4s_2 = destination_1.g1();
      while (_iterator__ex2g4s_2.f()) {
        var item_0 = _iterator__ex2g4s_2.e();
        var tmp$ret$9 = new IncompleteKey(item_0.a2());
        destination_2.v(tmp$ret$9);
      }
      tmp = destination_2;
    }
    return tmp;
  }
  createTransitionForComplete(previous, prevPrev, from, action, to, lookahead) {
    var trans = new Transition(from, to, action, lookahead);
    this.addTransitionForComplete(previous, prevPrev, trans);
  }
  createTransitionForIncomplete(previous, from, action, to, lookahead) {
    var trans = new Transition(from, to, action, lookahead);
    this.addTransitionForIncomplete(previous, trans);
  }
  get allBuiltTransitions() {
    return this.r1n();
  }
  get allPrevious() {
    return this.k1o();
  }
}
class Companion_7 {
  constructor() {
    Companion_instance_7 = this;
    this.EMPTY = new LookaheadSetPart(false, false, false, emptySet());
    this.RT = new LookaheadSetPart(true, false, false, emptySet());
    this.ANY = new LookaheadSetPart(false, false, true, emptySet());
    this.EOT = new LookaheadSetPart(false, true, false, emptySet());
  }
  n1l() {
    return this.EMPTY;
  }
  u1l() {
    return this.RT;
  }
  s1l() {
    return this.ANY;
  }
  t1l() {
    return this.EOT;
  }
  createFromRuntimeRules(fullContent) {
    var includeRT = fullContent.p1(Companion_getInstance_17().USE_RUNTIME_LOOKAHEAD);
    var includeEOT = fullContent.p1(Companion_getInstance_17().END_OF_TEXT);
    var matchAny = fullContent.p1(Companion_getInstance_17().ANY_LOOKAHEAD);
    var content = minus(minus(minus(fullContent, Companion_getInstance_17().USE_RUNTIME_LOOKAHEAD), Companion_getInstance_17().END_OF_TEXT), Companion_getInstance_17().ANY_LOOKAHEAD);
    return new LookaheadSetPart(includeRT, includeEOT, matchAny, content);
  }
  unionAll(_this__u8e3s4) {
    // Inline function 'kotlin.collections.fold' call
    var accumulator = Companion_getInstance_7().EMPTY;
    var _iterator__ex2g4s = _this__u8e3s4.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      accumulator = accumulator.union(element);
    }
    return accumulator;
  }
}
class sam$kotlin_Comparator$0_2 {
  constructor(function_0) {
    this.t1o_1 = function_0;
  }
  lg(a, b) {
    return this.t1o_1(a, b);
  }
  compare(a, b) {
    return this.lg(a, b);
  }
  u3() {
    return this.t1o_1;
  }
  equals(other) {
    var tmp;
    if (!(other == null) ? isInterface(other, Comparator) : false) {
      var tmp_0;
      if (!(other == null) ? isInterface(other, FunctionAdapter) : false) {
        tmp_0 = equals(this.u3(), other.u3());
      } else {
        tmp_0 = false;
      }
      tmp = tmp_0;
    } else {
      tmp = false;
    }
    return tmp;
  }
  hashCode() {
    return hashCode(this.u3());
  }
}
class LookaheadSetPart {
  constructor(includesRT, includesEOT, matchANY, content) {
    Companion_getInstance_7();
    this.includesRT = includesRT;
    this.includesEOT = includesEOT;
    this.matchANY = matchANY;
    this.content = content;
    var tmp = this;
    tmp.e1m_1 = lazy(LookaheadSetPart$regex$delegate$lambda(this));
  }
  u1o() {
    return this.includesRT;
  }
  v1o() {
    return this.includesEOT;
  }
  w1o() {
    return this.matchANY;
  }
  kp() {
    return this.content;
  }
  x1o() {
    var tmp0 = this.e1m_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('regex', 1, tmp, LookaheadSetPart$_get_regex_$ref_i6110o(), null);
    return tmp0.b2();
  }
  m1l() {
    // Inline function 'kotlin.collections.mutableSetOf' call
    var cont = LinkedHashSet.j1();
    if (this.includesRT) {
      cont.v(Companion_getInstance_17().USE_RUNTIME_LOOKAHEAD);
    }
    if (this.includesEOT) {
      cont.v(Companion_getInstance_17().END_OF_TEXT);
    }
    if (this.matchANY) {
      cont.v(Companion_getInstance_17().ANY_LOOKAHEAD);
    }
    cont.k1(this.content);
    return cont;
  }
  p11() {
    return !this.includesRT && !this.includesEOT && !this.matchANY && this.content.l1();
  }
  q11() {
    return !this.isEmpty;
  }
  resolve(eotLookahead, runtimeLookahead) {
    var tmp;
    if (eotLookahead.includesRT) {
      var message = 'EOT lookahead must be real lookahead values';
      throw IllegalStateException.t4(toString(message));
    } else if (runtimeLookahead.includesRT) {
      var message_0 = 'EOT lookahead must be real lookahead values';
      throw IllegalStateException.t4(toString(message_0));
    } else if (this.matchANY || (this.includesEOT && eotLookahead.matchANY) || (this.includesRT && runtimeLookahead.matchANY)) {
      tmp = new LookaheadSetPart(false, false, true, emptySet());
    } else {
      var tmp_0;
      if (this.includesEOT && this.includesRT) {
        var resolvedContent = union(union(this.content, runtimeLookahead.content), eotLookahead.content);
        var eot = eotLookahead.includesEOT || runtimeLookahead.includesEOT;
        tmp_0 = new LookaheadSetPart(false, eot, false, resolvedContent);
      } else if (this.includesEOT) {
        var resolvedContent_0 = union(this.content, eotLookahead.content);
        var eot_0 = eotLookahead.includesEOT;
        tmp_0 = new LookaheadSetPart(false, eot_0, false, resolvedContent_0);
      } else if (this.includesRT) {
        var resolvedContent_1 = union(this.content, runtimeLookahead.content);
        var eot_1 = runtimeLookahead.includesEOT;
        tmp_0 = new LookaheadSetPart(false, eot_1, false, resolvedContent_1);
      } else {
        tmp_0 = new LookaheadSetPart(false, false, false, this.content);
      }
      tmp = tmp_0;
    }
    return tmp;
  }
  intersect(lookahead) {
    var rt = this.includesRT && lookahead.includesRT;
    var eot = this.includesEOT && lookahead.includesEOT;
    var ma = this.matchANY && lookahead.matchANY;
    return new LookaheadSetPart(rt, eot, ma, intersect(this.content, lookahead.content));
  }
  union(lhs) {
    return this.matchANY ? Companion_getInstance_7().ANY : lhs.matchANY ? Companion_getInstance_7().ANY : new LookaheadSetPart(this.includesRT || lhs.includesRT, this.includesEOT || lhs.includesEOT, false, union(this.content, lhs.content));
  }
  unionContent(additionalContent) {
    var rt = this.includesRT;
    var eot = this.includesEOT;
    var ma = this.matchANY;
    return new LookaheadSetPart(rt, eot, ma, union(this.content, additionalContent));
  }
  containsAll(other) {
    return this.matchANY ? true : !this.includesEOT && other.includesEOT ? false : !this.includesRT && other.includesRT ? false : this.fullContent.w2(other.fullContent);
  }
  toString() {
    // Inline function 'kotlin.collections.sortedBy' call
    var this_0 = this.fullContent;
    // Inline function 'kotlin.comparisons.compareBy' call
    var tmp = LookaheadSetPart$toString$lambda;
    var tmp$ret$0 = new sam$kotlin_Comparator$0_2(tmp);
    var tmp_0 = sortedWith(this_0, tmp$ret$0);
    return 'LHS(' + joinToString(tmp_0, VOID, VOID, VOID, VOID, VOID, LookaheadSetPart$toString$lambda_0) + ')';
  }
  ni() {
    return this.includesRT;
  }
  oi() {
    return this.includesEOT;
  }
  mm() {
    return this.matchANY;
  }
  d16() {
    return this.content;
  }
  y1o(includesRT, includesEOT, matchANY, content) {
    return new LookaheadSetPart(includesRT, includesEOT, matchANY, content);
  }
  copy(includesRT, includesEOT, matchANY, content, $super) {
    includesRT = includesRT === VOID ? this.includesRT : includesRT;
    includesEOT = includesEOT === VOID ? this.includesEOT : includesEOT;
    matchANY = matchANY === VOID ? this.matchANY : matchANY;
    content = content === VOID ? this.content : content;
    return $super === VOID ? this.y1o(includesRT, includesEOT, matchANY, content) : $super.y1o.call(this, includesRT, includesEOT, matchANY, content);
  }
  hashCode() {
    var result = getBooleanHashCode(this.includesRT);
    result = imul(result, 31) + getBooleanHashCode(this.includesEOT) | 0;
    result = imul(result, 31) + getBooleanHashCode(this.matchANY) | 0;
    result = imul(result, 31) + hashCode(this.content) | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof LookaheadSetPart))
      return false;
    if (!(this.includesRT === other.includesRT))
      return false;
    if (!(this.includesEOT === other.includesEOT))
      return false;
    if (!(this.matchANY === other.matchANY))
      return false;
    if (!equals(this.content, other.content))
      return false;
    return true;
  }
  get regex() {
    return this.x1o();
  }
  get fullContent() {
    return this.m1l();
  }
  get isEmpty() {
    return this.p11();
  }
  get isNotEmpty() {
    return this.q11();
  }
}
class sam$kotlin_Comparator$0_3 {
  constructor(function_0) {
    this.z1o_1 = function_0;
  }
  lg(a, b) {
    return this.z1o_1(a, b);
  }
  compare(a, b) {
    return this.lg(a, b);
  }
  u3() {
    return this.z1o_1;
  }
  equals(other) {
    var tmp;
    if (!(other == null) ? isInterface(other, Comparator) : false) {
      var tmp_0;
      if (!(other == null) ? isInterface(other, FunctionAdapter) : false) {
        tmp_0 = equals(this.u3(), other.u3());
      } else {
        tmp_0 = false;
      }
      tmp = tmp_0;
    } else {
      tmp = false;
    }
    return tmp;
  }
  hashCode() {
    return hashCode(this.u3());
  }
}
class Companion_8 {
  constructor() {
    Companion_instance_8 = this;
    this.EMPTY = new LookaheadInfoPart(Companion_getInstance_7().EMPTY, Companion_getInstance_7().EMPTY);
  }
  n1l() {
    return this.EMPTY;
  }
  merge(initial) {
    return this.merge2(initial);
  }
  merge1(initial) {
    var tmp;
    if (initial.h1() === 1) {
      tmp = initial;
    } else {
      // Inline function 'kotlin.collections.groupBy' call
      // Inline function 'kotlin.collections.groupByTo' call
      var destination = LinkedHashMap.j4();
      var _iterator__ex2g4s = initial.g1();
      while (_iterator__ex2g4s.f()) {
        var element = _iterator__ex2g4s.e();
        var key = element.v1k_1;
        // Inline function 'kotlin.collections.getOrPut' call
        var value = destination.c3(key);
        var tmp_0;
        if (value == null) {
          var answer = ArrayList.o1();
          destination.f3(key, answer);
          tmp_0 = answer;
        } else {
          tmp_0 = value;
        }
        var list = tmp_0;
        list.v(element);
      }
      // Inline function 'kotlin.collections.map' call
      // Inline function 'kotlin.collections.mapTo' call
      var destination_0 = ArrayList.a1(destination.h1());
      // Inline function 'kotlin.collections.iterator' call
      var _iterator__ex2g4s_0 = destination.z1().g1();
      while (_iterator__ex2g4s_0.f()) {
        var item = _iterator__ex2g4s_0.e();
        var up = item.a2();
        // Inline function 'kotlin.collections.map' call
        var this_0 = item.b2();
        // Inline function 'kotlin.collections.mapTo' call
        var destination_1 = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
        var _iterator__ex2g4s_1 = this_0.g1();
        while (_iterator__ex2g4s_1.f()) {
          var item_0 = _iterator__ex2g4s_1.e();
          var tmp$ret$6 = item_0.u1k_1;
          destination_1.v(tmp$ret$6);
        }
        // Inline function 'kotlin.collections.reduce' call
        var iterator = destination_1.g1();
        if (!iterator.f())
          throw UnsupportedOperationException.g9("Empty collection can't be reduced.");
        var accumulator = iterator.e();
        while (iterator.f()) {
          var tmp0 = accumulator;
          var l = iterator.e();
          accumulator = tmp0.union(l);
        }
        var guard = accumulator;
        var tmp$ret$11 = new LookaheadInfoPart(guard, up);
        destination_0.v(tmp$ret$11);
      }
      // Inline function 'kotlin.collections.groupBy' call
      var tmp0_0 = toSet(destination_0);
      // Inline function 'kotlin.collections.groupByTo' call
      var destination_2 = LinkedHashMap.j4();
      var _iterator__ex2g4s_2 = tmp0_0.g1();
      while (_iterator__ex2g4s_2.f()) {
        var element_0 = _iterator__ex2g4s_2.e();
        var key_0 = element_0.u1k_1;
        // Inline function 'kotlin.collections.getOrPut' call
        var value_0 = destination_2.c3(key_0);
        var tmp_1;
        if (value_0 == null) {
          var answer_0 = ArrayList.o1();
          destination_2.f3(key_0, answer_0);
          tmp_1 = answer_0;
        } else {
          tmp_1 = value_0;
        }
        var list_0 = tmp_1;
        list_0.v(element_0);
      }
      // Inline function 'kotlin.collections.map' call
      // Inline function 'kotlin.collections.mapTo' call
      var destination_3 = ArrayList.a1(destination_2.h1());
      // Inline function 'kotlin.collections.iterator' call
      var _iterator__ex2g4s_3 = destination_2.z1().g1();
      while (_iterator__ex2g4s_3.f()) {
        var item_1 = _iterator__ex2g4s_3.e();
        var guard_0 = item_1.a2();
        // Inline function 'kotlin.collections.map' call
        var this_1 = item_1.b2();
        // Inline function 'kotlin.collections.mapTo' call
        var destination_4 = ArrayList.a1(collectionSizeOrDefault(this_1, 10));
        var _iterator__ex2g4s_4 = this_1.g1();
        while (_iterator__ex2g4s_4.f()) {
          var item_2 = _iterator__ex2g4s_4.e();
          var tmp$ret$20 = item_2.v1k_1;
          destination_4.v(tmp$ret$20);
        }
        // Inline function 'kotlin.collections.reduce' call
        var iterator_0 = destination_4.g1();
        if (!iterator_0.f())
          throw UnsupportedOperationException.g9("Empty collection can't be reduced.");
        var accumulator_0 = iterator_0.e();
        while (iterator_0.f()) {
          var tmp0_1 = accumulator_0;
          var l_0 = iterator_0.e();
          accumulator_0 = tmp0_1.union(l_0);
        }
        var up_0 = accumulator_0;
        var tmp$ret$25 = new LookaheadInfoPart(guard_0, up_0);
        destination_3.v(tmp$ret$25);
      }
      var merged = toSet(destination_3);
      var tmp_2;
      if (merged.h1() === 1) {
        tmp_2 = merged;
      } else {
        // Inline function 'kotlin.collections.sortedByDescending' call
        // Inline function 'kotlin.comparisons.compareByDescending' call
        var tmp_3 = LookaheadInfoPart$Companion$merge1$lambda;
        var tmp$ret$28 = new sam$kotlin_Comparator$0_3(tmp_3);
        var sortedMerged = sortedWith(merged, tmp$ret$28);
        // Inline function 'kotlin.collections.mutableSetOf' call
        var result = LinkedHashSet.j1();
        // Inline function 'kotlin.collections.mutableSetOf' call
        var mergedIntoOther = LinkedHashSet.j1();
        var inductionVariable = 0;
        var last = sortedMerged.h1() - 1 | 0;
        if (inductionVariable <= last)
          do {
            var i = inductionVariable;
            inductionVariable = inductionVariable + 1 | 0;
            var lh1 = sortedMerged.i1(i);
            if (!mergedIntoOther.p1(lh1)) {
              var inductionVariable_0 = i + 1 | 0;
              var last_0 = sortedMerged.h1();
              if (inductionVariable_0 < last_0)
                do {
                  var j = inductionVariable_0;
                  inductionVariable_0 = inductionVariable_0 + 1 | 0;
                  var lh2 = sortedMerged.i1(j);
                  if (lh1.u1k_1.containsAll(lh2.u1k_1)) {
                    lh1 = new LookaheadInfoPart(lh1.u1k_1, lh1.v1k_1.union(lh2.v1k_1));
                    mergedIntoOther.v(lh2);
                  }
                }
                 while (inductionVariable_0 < last_0);
              result.v(lh1);
            }
          }
           while (inductionVariable <= last);
        tmp_2 = result;
      }
      tmp = tmp_2;
    }
    return tmp;
  }
  merge2(initial) {
    var r = new LookaheadInfoPart(Companion_getInstance_7().EMPTY, Companion_getInstance_7().EMPTY);
    // Inline function 'kotlin.collections.forEach' call
    var _iterator__ex2g4s = initial.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      var g = r.u1k_1.union(element.u1k_1);
      var u = r.v1k_1.union(element.v1k_1);
      r = new LookaheadInfoPart(g, u);
    }
    return setOf(r);
  }
}
class LookaheadInfoPart {
  constructor(guard, up) {
    Companion_getInstance_8();
    this.u1k_1 = guard;
    this.v1k_1 = up;
  }
  toString() {
    return 'LookaheadInfoPart(guard=' + this.u1k_1.toString() + ', up=' + this.v1k_1.toString() + ')';
  }
  hashCode() {
    var result = this.u1k_1.hashCode();
    result = imul(result, 31) + this.v1k_1.hashCode() | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof LookaheadInfoPart))
      return false;
    if (!this.u1k_1.equals(other.u1k_1))
      return false;
    if (!this.v1k_1.equals(other.v1k_1))
      return false;
    return true;
  }
}
class StateInfo {
  constructor(rulePositions) {
    this.d1k_1 = rulePositions;
    this.e1k_1 = emptySet();
  }
  toString() {
    return 'StateInfo(rulePositions=' + toString(this.d1k_1) + ')';
  }
  hashCode() {
    return hashCode(this.d1k_1);
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof StateInfo))
      return false;
    if (!equals(this.d1k_1, other.d1k_1))
      return false;
    return true;
  }
}
class TransInfo {
  constructor(prevPairs, action, to, lookahead) {
    this.q1k_1 = prevPairs;
    this.r1k_1 = action;
    this.s1k_1 = to;
    this.t1k_1 = lookahead;
  }
  toString() {
    return 'TransInfo(prevPairs=' + toString(this.q1k_1) + ', action=' + this.r1k_1.toString() + ', to=' + toString(this.s1k_1) + ', lookahead=' + toString(this.t1k_1) + ')';
  }
  hashCode() {
    var result = hashCode(this.q1k_1);
    result = imul(result, 31) + this.r1k_1.hashCode() | 0;
    result = imul(result, 31) + hashCode(this.s1k_1) | 0;
    result = imul(result, 31) + hashCode(this.t1k_1) | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof TransInfo))
      return false;
    if (!equals(this.q1k_1, other.q1k_1))
      return false;
    if (!this.r1k_1.equals(other.r1k_1))
      return false;
    if (!equals(this.s1k_1, other.s1k_1))
      return false;
    if (!equals(this.t1k_1, other.t1k_1))
      return false;
    return true;
  }
}
class TransPrev {
  constructor(prevPrev, prev) {
    this.b1n_1 = prevPrev;
    this.c1n_1 = prev;
  }
  toString() {
    return 'TransPrev(prevPrev=' + toString(this.b1n_1) + ', prev=' + toString(this.c1n_1) + ')';
  }
  hashCode() {
    var result = hashCode(this.b1n_1);
    result = imul(result, 31) + hashCode(this.c1n_1) | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof TransPrev))
      return false;
    if (!equals(this.b1n_1, other.b1n_1))
      return false;
    if (!equals(this.c1n_1, other.c1n_1))
      return false;
    return true;
  }
}
class WidthInfo {
  constructor(action, to, lookaheadSet) {
    this.w1k_1 = action;
    this.x1k_1 = to;
    this.y1k_1 = lookaheadSet;
  }
  toString() {
    return 'WidthInfo(action=' + this.w1k_1.toString() + ', to=' + this.x1k_1.toString() + ', lookaheadSet=' + this.y1k_1.toString() + ')';
  }
  hashCode() {
    var result = this.w1k_1.hashCode();
    result = imul(result, 31) + this.x1k_1.hashCode() | 0;
    result = imul(result, 31) + this.y1k_1.hashCode() | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof WidthInfo))
      return false;
    if (!this.w1k_1.equals(other.w1k_1))
      return false;
    if (!this.x1k_1.equals(other.x1k_1))
      return false;
    if (!this.y1k_1.equals(other.y1k_1))
      return false;
    return true;
  }
}
class FirstTerminalInfo {
  constructor(terminalRule, parentExpectedAt) {
    this.terminalRule = terminalRule;
    this.parentExpectedAt = parentExpectedAt;
    var tmp = this;
    // Inline function 'kotlin.arrayOf' call
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    var tmp$ret$2 = [this.terminalRule, this.parentExpectedAt];
    tmp.h1e_1 = contentHashCode(tmp$ret$2);
  }
  a1p() {
    return this.terminalRule;
  }
  b1p() {
    return this.parentExpectedAt;
  }
  hashCode() {
    return this.h1e_1;
  }
  equals(other) {
    var tmp;
    if (!(other instanceof FirstTerminalInfo)) {
      tmp = false;
    } else {
      if (!other.terminalRule.equals(this.terminalRule)) {
        tmp = false;
      } else {
        if (!other.parentExpectedAt.equals(this.parentExpectedAt)) {
          tmp = false;
        } else {
          tmp = true;
        }
      }
    }
    return tmp;
  }
  toString() {
    return this.terminalRule.tag + ' ' + this.parentExpectedAt.toString();
  }
  ni() {
    return this.terminalRule;
  }
  oi() {
    return this.parentExpectedAt;
  }
  c1p(terminalRule, parentExpectedAt) {
    return new FirstTerminalInfo(terminalRule, parentExpectedAt);
  }
  copy(terminalRule, parentExpectedAt, $super) {
    terminalRule = terminalRule === VOID ? this.terminalRule : terminalRule;
    parentExpectedAt = parentExpectedAt === VOID ? this.parentExpectedAt : parentExpectedAt;
    return $super === VOID ? this.c1p(terminalRule, parentExpectedAt) : $super.c1p.call(this, terminalRule, parentExpectedAt);
  }
}
class ParentNext {
  constructor(firstPosition, rulePosition, expectedAt, parentExpectedAt) {
    this.firstPosition = firstPosition;
    this.rulePosition = rulePosition;
    this.expectedAt = expectedAt;
    this.parentExpectedAt = parentExpectedAt;
  }
  d1p() {
    return this.firstPosition;
  }
  c1f() {
    return this.rulePosition;
  }
  e1p() {
    return this.expectedAt;
  }
  b1p() {
    return this.parentExpectedAt;
  }
  ni() {
    return this.firstPosition;
  }
  oi() {
    return this.rulePosition;
  }
  mm() {
    return this.expectedAt;
  }
  d16() {
    return this.parentExpectedAt;
  }
  f1p(firstPosition, rulePosition, expectedAt, parentExpectedAt) {
    return new ParentNext(firstPosition, rulePosition, expectedAt, parentExpectedAt);
  }
  copy(firstPosition, rulePosition, expectedAt, parentExpectedAt, $super) {
    firstPosition = firstPosition === VOID ? this.firstPosition : firstPosition;
    rulePosition = rulePosition === VOID ? this.rulePosition : rulePosition;
    expectedAt = expectedAt === VOID ? this.expectedAt : expectedAt;
    parentExpectedAt = parentExpectedAt === VOID ? this.parentExpectedAt : parentExpectedAt;
    return $super === VOID ? this.f1p(firstPosition, rulePosition, expectedAt, parentExpectedAt) : $super.f1p.call(this, firstPosition, rulePosition, expectedAt, parentExpectedAt);
  }
  toString() {
    return 'ParentNext(firstPosition=' + this.firstPosition + ', rulePosition=' + this.rulePosition.toString() + ', expectedAt=' + this.expectedAt.toString() + ', parentExpectedAt=' + this.parentExpectedAt.toString() + ')';
  }
  hashCode() {
    var result = getBooleanHashCode(this.firstPosition);
    result = imul(result, 31) + this.rulePosition.hashCode() | 0;
    result = imul(result, 31) + this.expectedAt.hashCode() | 0;
    result = imul(result, 31) + this.parentExpectedAt.hashCode() | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof ParentNext))
      return false;
    if (!(this.firstPosition === other.firstPosition))
      return false;
    if (!this.rulePosition.equals(other.rulePosition))
      return false;
    if (!this.expectedAt.equals(other.expectedAt))
      return false;
    if (!this.parentExpectedAt.equals(other.parentExpectedAt))
      return false;
    return true;
  }
}
class ClosureItem {}
class ClosureItemAbstractGraph {
  constructor(graph, rulePosition, context, parentExpectedAt) {
    this.g1f_1 = graph;
    this.h1f_1 = rulePosition;
    this.i1f_1 = context;
    this.j1f_1 = parentExpectedAt;
    this.k1f_1 = false;
    var tmp = this;
    tmp.l1f_1 = lazy(ClosureGraph$Companion$ClosureItemAbstractGraph$expectedAt$delegate$lambda(this));
    var tmp_0 = this;
    tmp_0.m1f_1 = lazy(ClosureGraph$Companion$ClosureItemAbstractGraph$children$delegate$lambda(this));
    var tmp_1 = this;
    tmp_1.n1f_1 = lazy(ClosureGraph$Companion$ClosureItemAbstractGraph$parents$delegate$lambda(this));
    var tmp_2 = this;
    tmp_2.p1f_1 = lazy(ClosureGraph$Companion$ClosureItemAbstractGraph$parentNext$delegate$lambda(this));
    var tmp_3 = this;
    // Inline function 'kotlin.arrayOf' call
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    tmp_3._id = [this.h1f_1, this.i1f_1, this.j1f_1];
  }
  k1p() {
    return this.g1f_1;
  }
  c1f() {
    return this.h1f_1;
  }
  sb() {
    return this.i1f_1;
  }
  b1p() {
    return this.j1f_1;
  }
  e1p() {
    var tmp0 = this.l1f_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('expectedAt', 1, tmp, ClosureGraph$Companion$ClosureItemAbstractGraph$_get_expectedAt_$ref_p3bkd0(), null);
    return tmp0.b2();
  }
  o15() {
    var tmp0 = this.m1f_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('children', 1, tmp, ClosureGraph$Companion$ClosureItemAbstractGraph$_get_children_$ref_yo8ks8(), null);
    return tmp0.b2();
  }
  i1p() {
    var tmp0 = this.n1f_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('parents', 1, tmp, ClosureGraph$Companion$ClosureItemAbstractGraph$_get_parents_$ref_9fhpsq(), null);
    return tmp0.b2();
  }
  l1p() {
    // Inline function 'kotlin.collections.mutableSetOf' call
    var tmp$ret$0 = LinkedHashSet.j1();
    return this.m1p(tmp$ret$0);
  }
  n1p(_set____db54di) {
    this.o1f_1 = _set____db54di;
  }
  q1f() {
    var tmp = this.o1f_1;
    if (!(tmp == null))
      return tmp;
    else {
      throwUninitializedPropertyAccessException('downInfo');
    }
  }
  s1f() {
    var tmp0 = this.p1f_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('parentNext', 1, tmp, ClosureGraph$Companion$ClosureItemAbstractGraph$_get_parentNext_$ref_58nkue(), null);
    return tmp0.b2();
  }
  o1p() {
    if (!this.k1f_1) {
      // Inline function 'kotlin.collections.linkedSetOf' call
      var tmp$ret$0 = LinkedHashSet.j1();
      this.n1p(tmp$ret$0);
      this.k1f_1 = true;
      var children = this.o15();
      if (children.l1()) {
        if (this.h1f_1.isTerminal) {
          var firstTerminalInfo = new FirstTerminalInfo(this.h1f_1.k1b_1, this.j1f_1);
          var tmp = this.q1f();
          (isInterface(tmp, KtMutableSet) ? tmp : THROW_CCE()).v(firstTerminalInfo);
        }
      } else {
        var _iterator__ex2g4s = children.g1();
        while (_iterator__ex2g4s.f()) {
          var child = _iterator__ex2g4s.e();
          child.o1p();
          if (child.c1f().isAtStart || child.c1f().isTerminal) {
            var tmp_0 = this.q1f();
            (isInterface(tmp_0, KtMutableSet) ? tmp_0 : THROW_CCE()).k1(child.q1f());
          }
        }
      }
    }
  }
  m1p(done) {
    var rp = this.h1f_1;
    var tmp = rp.k1b_1;
    var rr = tmp instanceof RuntimeRule ? tmp : THROW_CCE();
    var tmp_0;
    if (rr.isGoal) {
      tmp_0 = 'G';
    } else if (rr.isEmptyTerminal) {
      tmp_0 = '<E>';
    } else if (rr.isEmptyListTerminal) {
      tmp_0 = '<EL>';
    } else if (rr.isNonTerminal) {
      var tmp0_subject = rr.rhs;
      var tmp_1;
      if (tmp0_subject instanceof RuntimeRuleRhsGoal) {
        tmp_1 = rr.tag;
      } else {
        if (tmp0_subject instanceof RuntimeRuleRhsConcatenation) {
          tmp_1 = rp.isAtEnd ? rr.tag + '[ER]' : rr.tag + '[' + rp.m1b_1 + ']';
        } else {
          if (tmp0_subject instanceof RuntimeRuleRhsChoice) {
            tmp_1 = rr.tag + '.' + rp.l1b_1.toString();
          } else {
            if (tmp0_subject instanceof RuntimeRuleRhsListSimple) {
              var tmp_2;
              if (rp.isAtStart) {
                tmp_2 = rr.tag + '.b';
              } else if (rp.m1b_1 === 1) {
                tmp_2 = rr.tag + '.i';
              } else if (rp.isAtEnd) {
                tmp_2 = rr.tag + '.e';
              } else {
                throw NotImplementedError.im();
              }
              tmp_1 = tmp_2;
            } else {
              if (tmp0_subject instanceof RuntimeRuleRhsListSeparated) {
                var tmp_3;
                if (rp.isAtStart) {
                  tmp_3 = rr.tag + '.b';
                } else if (rp.m1b_1 === 1) {
                  tmp_3 = rr.tag + '.s';
                } else if (rp.m1b_1 === 2) {
                  tmp_3 = rr.tag + '.i';
                } else if (rp.isAtEnd) {
                  tmp_3 = rr.tag + '.e';
                } else {
                  throw NotImplementedError.im();
                }
                tmp_1 = tmp_3;
              } else {
                throw NotImplementedError.im();
              }
            }
          }
        }
      }
      tmp_0 = tmp_1;
    } else {
      tmp_0 = rr.tag;
    }
    var str = tmp_0;
    var tmp_4;
    if (done.p1(this)) {
      // Inline function 'kotlin.collections.filter' call
      var tmp0 = this.i1p();
      // Inline function 'kotlin.collections.filterTo' call
      var destination = ArrayList.o1();
      var _iterator__ex2g4s = tmp0.g1();
      while (_iterator__ex2g4s.f()) {
        var element = _iterator__ex2g4s.e();
        if (!done.p1(element)) {
          destination.v(element);
        }
      }
      var fp = destination;
      var tmp_5;
      if (this instanceof ClosureItemRootGraph) {
        tmp_5 = listOf(str);
      } else {
        if (this instanceof ClosureItemChildGraph) {
          // Inline function 'kotlin.collections.flatMap' call
          // Inline function 'kotlin.collections.flatMapTo' call
          var destination_0 = ArrayList.o1();
          var _iterator__ex2g4s_0 = fp.g1();
          while (_iterator__ex2g4s_0.f()) {
            var element_0 = _iterator__ex2g4s_0.e();
            // Inline function 'kotlin.collections.map' call
            var this_0 = element_0.m1p(done);
            // Inline function 'kotlin.collections.mapTo' call
            var destination_1 = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
            var _iterator__ex2g4s_1 = this_0.g1();
            while (_iterator__ex2g4s_1.f()) {
              var item = _iterator__ex2g4s_1.e();
              var tmp$ret$3 = item + '-' + str;
              destination_1.v(tmp$ret$3);
            }
            var list = destination_1;
            addAll(destination_0, list);
          }
          tmp_5 = destination_0;
        } else {
          var message = 'Internal Error: subtype of ClosureItemAbstractGraph not handled - ' + getKClassFromExpression(this).md();
          throw IllegalStateException.t4(toString(message));
        }
      }
      tmp_4 = tmp_5;
    } else {
      var newDone = plus(done, this);
      var tmp_6;
      if (this instanceof ClosureItemRootGraph) {
        tmp_6 = listOf(str);
      } else {
        if (this instanceof ClosureItemChildGraph) {
          // Inline function 'kotlin.collections.flatMap' call
          var tmp0_0 = this.i1p();
          // Inline function 'kotlin.collections.flatMapTo' call
          var destination_2 = ArrayList.o1();
          var _iterator__ex2g4s_2 = tmp0_0.g1();
          while (_iterator__ex2g4s_2.f()) {
            var element_1 = _iterator__ex2g4s_2.e();
            // Inline function 'kotlin.collections.map' call
            var this_1 = element_1.m1p(newDone);
            // Inline function 'kotlin.collections.mapTo' call
            var destination_3 = ArrayList.a1(collectionSizeOrDefault(this_1, 10));
            var _iterator__ex2g4s_3 = this_1.g1();
            while (_iterator__ex2g4s_3.f()) {
              var item_0 = _iterator__ex2g4s_3.e();
              var tmp$ret$9 = item_0 + '-' + str;
              destination_3.v(tmp$ret$9);
            }
            var list_0 = destination_3;
            addAll(destination_2, list_0);
          }
          tmp_6 = destination_2;
        } else {
          var message_0 = 'Internal Error: subtype of ClosureItemAbstractGraph not handled - ' + getKClassFromExpression(this).md();
          throw IllegalStateException.t4(toString(message_0));
        }
      }
      tmp_4 = tmp_6;
    }
    return tmp_4;
  }
  p1p() {
    return this._id;
  }
  hashCode() {
    return contentHashCode(this._id);
  }
  equals(other) {
    var tmp;
    if (!(!(other == null) ? isInterface(other, ClosureItem) : false)) {
      tmp = false;
    } else {
      if (!this.h1f_1.equals(other.c1f())) {
        tmp = false;
      } else {
        if (!this.i1f_1.equals(other.sb())) {
          tmp = false;
        } else {
          if (!this.j1f_1.equals(other.b1p())) {
            tmp = false;
          } else {
            tmp = true;
          }
        }
      }
    }
    return tmp;
  }
  toString() {
    return '{' + this.i1f_1.toString() + '} ' + this.h1f_1.toString() + ' [' + this.j1f_1.toString() + ']';
  }
}
class ClosureItemRootGraph extends ClosureItemAbstractGraph {
  constructor(graph, context, rulePosition, parentExpectedAt) {
    super(graph, rulePosition, context, parentExpectedAt);
    this.b1q_1 = true;
  }
  q1p() {
    return this.b1q_1;
  }
  j1p(done) {
    return this.h1f_1.toString();
  }
}
class ClosureItemChildGraph extends ClosureItemAbstractGraph {
  constructor(graph, rulePosition, context, parentExpectedAt) {
    super(graph, rulePosition, context, parentExpectedAt);
    this.m1q_1 = false;
  }
  q1p() {
    return this.m1q_1;
  }
  j1p(done) {
    var tmp;
    if (done.p1(this)) {
      tmp = this.h1f_1.toString() + '...';
    } else {
      done.v(this);
      var tmp_0 = this.i1p();
      tmp = joinToString(tmp_0, '\n', VOID, VOID, VOID, VOID, ClosureGraph$Companion$ClosureItemChildGraph$toStringRec$lambda(done, this));
    }
    return tmp;
  }
}
class Companion_9 {
  constructor() {
    Companion_instance_9 = this;
    this.n1q_1 = new FirstOf();
  }
  expectedAt(rp, parentExpectedAt) {
    var tmp;
    if (rp.isAtEnd) {
      tmp = parentExpectedAt;
    } else {
      var nexts = rp.next();
      if (false) {
        // Inline function 'kotlin.collections.isNotEmpty' call
        // Inline function 'kotlin.check' call
        if (!!nexts.l1()) {
          var message = 'Internal Error: if not a terminal and not atEnd rulePosition.next() should never be empty';
          throw IllegalStateException.t4(toString(message));
        }
      }
      // Inline function 'kotlin.collections.map' call
      // Inline function 'kotlin.collections.mapTo' call
      var destination = ArrayList.a1(collectionSizeOrDefault(nexts, 10));
      var _iterator__ex2g4s = nexts.g1();
      while (_iterator__ex2g4s.f()) {
        var item = _iterator__ex2g4s.e();
        var tmp$ret$3 = Companion_getInstance_9().n1q_1.e1l(item, parentExpectedAt);
        destination.v(tmp$ret$3);
      }
      var allNextExpectedAt = destination;
      // Inline function 'kotlin.collections.fold' call
      var accumulator = Companion_getInstance_7().EMPTY;
      var _iterator__ex2g4s_0 = allNextExpectedAt.g1();
      while (_iterator__ex2g4s_0.f()) {
        var element = _iterator__ex2g4s_0.e();
        accumulator = accumulator.union(element);
      }
      tmp = accumulator;
    }
    return tmp;
  }
  parentNext(parents) {
    // Inline function 'kotlin.collections.mutableSetOf' call
    var result = LinkedHashSet.j1();
    var _iterator__ex2g4s = parents.g1();
    while (_iterator__ex2g4s.f()) {
      var parent = _iterator__ex2g4s.e();
      var atStart = parent.c1f().isAtStart;
      var tmp;
      switch (atStart) {
        case true:
          tmp = parent.b1p();
          break;
        case false:
          tmp = Companion_getInstance_7().EMPTY;
          break;
        default:
          noWhenBranchMatchedException();
          break;
      }
      var prntNextContextExpectedAt = tmp;
      var _iterator__ex2g4s_0 = parent.c1f().next().g1();
      while (_iterator__ex2g4s_0.f()) {
        var prntNext = _iterator__ex2g4s_0.e();
        var prntNextExpectedAt = this.n1q_1.e1l(prntNext, parent.b1p());
        var pn = new ParentNext(atStart, prntNext, prntNextExpectedAt, prntNextContextExpectedAt);
        result.v(pn);
      }
    }
    return result;
  }
}
class ClosureGraph {
  constructor(rootContext, rootRulePosition, rootParentFollow) {
    Companion_getInstance_9();
    var tmp = this;
    tmp.z1e_1 = lazyMutableMapNotNull(ClosureGraph$_childrenOf$delegate$lambda);
    var tmp_0 = this;
    tmp_0.a1f_1 = lazyMutableMapNotNull(ClosureGraph$_parentsOf$delegate$lambda);
    this.b1f_1 = new ClosureItemRootGraph(this, rootContext, rootRulePosition, rootParentFollow);
  }
  r1f() {
    return toMutableSet(_get__parentsOf__h88uxi(this).d3());
  }
  f1f() {
    this.b1f_1.o1p();
    var _iterator__ex2g4s = this.r1f().g1();
    while (_iterator__ex2g4s.f()) {
      var cls = _iterator__ex2g4s.e();
      cls.o1p();
    }
  }
  g1p(parent) {
    return _get__childrenOf__aagwgs(this).c3(parent).c3(parent.c1f().m1b_1);
  }
  h1p(child) {
    return _get__parentsOf__h88uxi(this).c3(child);
  }
  o1q(child, parent) {
    _get__childrenOf__aagwgs(this).c3(parent).c3(parent.c1f().m1b_1).v(child);
    return _get__parentsOf__h88uxi(this).c3(child).v(parent);
  }
  e1f(parent, childRulePosition) {
    var childContext = parent.c1f().isAtStart ? parent.sb() : parent.c1f();
    var childParentExpectedAt = parent.e1p();
    var child = new ClosureItemChildGraph(this, childRulePosition, childContext, childParentExpectedAt);
    var added = this.o1q(child, parent);
    return added ? child : null;
  }
}
class LanguageIssueKind extends Enum {
  get name() {
    return this.r3();
  }
  get ordinal() {
    return this.s3();
  }
}
class LanguageProcessorPhase extends Enum {
  get name() {
    return this.r3();
  }
  get ordinal() {
    return this.s3();
  }
}
class LanguageIssue {
  constructor(kind, phase, location, message, data) {
    data = data === VOID ? null : data;
    this.kind = kind;
    this.phase = phase;
    this.location = location;
    this.message = message;
    this.data = data;
  }
  um() {
    return this.kind;
  }
  t1q() {
    return this.phase;
  }
  t15() {
    return this.location;
  }
  l() {
    return this.message;
  }
  u15() {
    return this.data;
  }
  ni() {
    return this.kind;
  }
  oi() {
    return this.phase;
  }
  mm() {
    return this.location;
  }
  d16() {
    return this.message;
  }
  g1c() {
    return this.data;
  }
  u1q(kind, phase, location, message, data) {
    return new LanguageIssue(kind, phase, location, message, data);
  }
  copy(kind, phase, location, message, data, $super) {
    kind = kind === VOID ? this.kind : kind;
    phase = phase === VOID ? this.phase : phase;
    location = location === VOID ? this.location : location;
    message = message === VOID ? this.message : message;
    data = data === VOID ? this.data : data;
    return $super === VOID ? this.u1q(kind, phase, location, message, data) : $super.u1q.call(this, kind, phase, location, message, data);
  }
  toString() {
    return 'LanguageIssue(kind=' + this.kind.toString() + ', phase=' + this.phase.toString() + ', location=' + toString_0(this.location) + ', message=' + this.message + ', data=' + toString_0(this.data) + ')';
  }
  hashCode() {
    var result = this.kind.hashCode();
    result = imul(result, 31) + this.phase.hashCode() | 0;
    result = imul(result, 31) + (this.location == null ? 0 : this.location.hashCode()) | 0;
    result = imul(result, 31) + getStringHashCode(this.message) | 0;
    result = imul(result, 31) + (this.data == null ? 0 : hashCode(this.data)) | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof LanguageIssue))
      return false;
    if (!this.kind.equals(other.kind))
      return false;
    if (!this.phase.equals(other.phase))
      return false;
    if (!equals(this.location, other.location))
      return false;
    if (!(this.message === other.message))
      return false;
    if (!equals(this.data, other.data))
      return false;
    return true;
  }
}
class IssueCollection {}
class IssueHolder {
  constructor(defaultPhase, issues) {
    defaultPhase = defaultPhase === VOID ? LanguageProcessorPhase_ALL_getInstance() : defaultPhase;
    issues = issues === VOID ? emptyList() : issues;
    this.v1q_1 = defaultPhase;
    this.w1q_1 = toMutableSet(issues);
  }
  v15() {
    return this.w1q_1;
  }
  w15() {
    // Inline function 'kotlin.collections.filter' call
    var tmp0 = this.w1q_1;
    // Inline function 'kotlin.collections.filterTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      if (element.kind.equals(LanguageIssueKind_ERROR_getInstance())) {
        destination.v(element);
      }
    }
    return destination;
  }
  x15() {
    // Inline function 'kotlin.collections.filter' call
    var tmp0 = this.w1q_1;
    // Inline function 'kotlin.collections.filterTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      if (element.kind.equals(LanguageIssueKind_WARNING_getInstance())) {
        destination.v(element);
      }
    }
    return destination;
  }
  y15() {
    // Inline function 'kotlin.collections.filter' call
    var tmp0 = this.w1q_1;
    // Inline function 'kotlin.collections.filterTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      if (element.kind.equals(LanguageIssueKind_INFORMATION_getInstance())) {
        destination.v(element);
      }
    }
    return destination;
  }
  clear() {
    this.w1q_1.i3();
  }
  x1q(kind, phase, location, message, data) {
    this.w1q_1.v(new LanguageIssue(kind, phase, location, message, data));
  }
  raise(kind, phase, location, message, data, $super) {
    data = data === VOID ? null : data;
    var tmp;
    if ($super === VOID) {
      this.x1q(kind, phase, location, message, data);
      tmp = Unit_instance;
    } else {
      tmp = $super.x1q.call(this, kind, phase, location, message, data);
    }
    return tmp;
  }
  y1q(location, message, data) {
    return this.raise(LanguageIssueKind_INFORMATION_getInstance(), this.v1q_1, location, message, data);
  }
  info(location, message, data, $super) {
    data = data === VOID ? null : data;
    var tmp;
    if ($super === VOID) {
      this.y1q(location, message, data);
      tmp = Unit_instance;
    } else {
      tmp = $super.y1q.call(this, location, message, data);
    }
    return tmp;
  }
  z1q(location, message, data) {
    return this.raise(LanguageIssueKind_WARNING_getInstance(), this.v1q_1, location, message, data);
  }
  warn(location, message, data, $super) {
    data = data === VOID ? null : data;
    var tmp;
    if ($super === VOID) {
      this.z1q(location, message, data);
      tmp = Unit_instance;
    } else {
      tmp = $super.z1q.call(this, location, message, data);
    }
    return tmp;
  }
  a1r(location, message, data) {
    return this.raise(LanguageIssueKind_ERROR_getInstance(), this.v1q_1, location, message, data);
  }
  error(location, message, data, $super) {
    data = data === VOID ? null : data;
    var tmp;
    if ($super === VOID) {
      this.a1r(location, message, data);
      tmp = Unit_instance;
    } else {
      tmp = $super.a1r.call(this, location, message, data);
    }
    return tmp;
  }
  addAll(issues) {
    addAll(this.w1q_1, issues);
  }
  addAllFrom(other) {
    this.addAll(other.all);
  }
  h1() {
    return this.w1q_1.h1();
  }
  g1() {
    return this.w1q_1.g1();
  }
  l1() {
    return this.w1q_1.l1();
  }
  b1r(element) {
    return this.w1q_1.p1(element);
  }
  p1(element) {
    if (!(element instanceof LanguageIssue))
      return false;
    return this.b1r(element instanceof LanguageIssue ? element : THROW_CCE());
  }
  c1r(elements) {
    return this.w1q_1.w2(elements);
  }
  w2(elements) {
    return this.c1r(elements);
  }
  toString() {
    return joinToString(this.w1q_1, '\n', VOID, VOID, VOID, VOID, IssueHolder$toString$lambda);
  }
  get all() {
    return this.v15();
  }
  get errors() {
    return this.w15();
  }
  get warnings() {
    return this.x15();
  }
  get informations() {
    return this.y15();
  }
}
class SentenceIdentityFunction {}
class SentenceIdentityFunctionNull_0 {
  invoke() {
    return null;
  }
}
class ParseOptions {}
class ParseOptionsDefault {
  constructor(enabled, goalRuleName, sentenceIdentity, reportErrors, reportGrammarAmbiguities, cacheSkip, reverseFindWordStartRegex, reverseFindWordStartBySkipRules) {
    enabled = enabled === VOID ? true : enabled;
    goalRuleName = goalRuleName === VOID ? null : goalRuleName;
    sentenceIdentity = sentenceIdentity === VOID ? SentenceIdentityFunctionNull_instance : sentenceIdentity;
    reportErrors = reportErrors === VOID ? true : reportErrors;
    reportGrammarAmbiguities = reportGrammarAmbiguities === VOID ? false : reportGrammarAmbiguities;
    cacheSkip = cacheSkip === VOID ? true : cacheSkip;
    reverseFindWordStartRegex = reverseFindWordStartRegex === VOID ? null : reverseFindWordStartRegex;
    reverseFindWordStartBySkipRules = reverseFindWordStartBySkipRules === VOID ? true : reverseFindWordStartBySkipRules;
    this.d1r_1 = enabled;
    this.e1r_1 = goalRuleName;
    this.f1r_1 = sentenceIdentity;
    this.g1r_1 = reportErrors;
    this.h1r_1 = reportGrammarAmbiguities;
    this.i1r_1 = cacheSkip;
    this.j1r_1 = reverseFindWordStartRegex;
    this.k1r_1 = reverseFindWordStartBySkipRules;
  }
  l1r(_set____db54di) {
    this.d1r_1 = _set____db54di;
  }
  m1r() {
    return this.d1r_1;
  }
  n1r(_set____db54di) {
    this.e1r_1 = _set____db54di;
  }
  o1r() {
    return this.e1r_1;
  }
  p1r(_set____db54di) {
    this.f1r_1 = _set____db54di;
  }
  q1r() {
    return this.f1r_1;
  }
  r1r(_set____db54di) {
    this.g1r_1 = _set____db54di;
  }
  s1r() {
    return this.g1r_1;
  }
  t1r(_set____db54di) {
    this.h1r_1 = _set____db54di;
  }
  u1r() {
    return this.h1r_1;
  }
  v1r(_set____db54di) {
    this.i1r_1 = _set____db54di;
  }
  w1r() {
    return this.i1r_1;
  }
  x1r(_set____db54di) {
    this.j1r_1 = _set____db54di;
  }
  y1r() {
    return this.j1r_1;
  }
  z1r(_set____db54di) {
    this.k1r_1 = _set____db54di;
  }
  a1s() {
    return this.k1r_1;
  }
  clone() {
    return new ParseOptionsDefault(this.d1r_1, this.e1r_1, this.f1r_1, this.g1r_1, this.h1r_1, this.i1r_1);
  }
  get enabled() {
    return this.m1r();
  }
  set enabled(value) {
    this.l1r(value);
  }
  get goalRuleName() {
    return this.o1r();
  }
  set goalRuleName(value) {
    this.n1r(value);
  }
  get sentenceIdentity() {
    return this.q1r();
  }
  set sentenceIdentity(value) {
    this.p1r(value);
  }
  get reportErrors() {
    return this.s1r();
  }
  set reportErrors(value) {
    this.r1r(value);
  }
  get reportGrammarAmbiguities() {
    return this.u1r();
  }
  set reportGrammarAmbiguities(value) {
    this.t1r(value);
  }
  get cacheSkip() {
    return this.w1r();
  }
  set cacheSkip(value) {
    this.v1r(value);
  }
  get reverseFindWordStartRegex() {
    return this.y1r();
  }
  set reverseFindWordStartRegex(value) {
    this.x1r(value);
  }
  get reverseFindWordStartBySkipRules() {
    return this.a1s();
  }
  set reverseFindWordStartBySkipRules(value) {
    this.z1r(value);
  }
}
class ParseResult {}
class ParseResultDefault {
  constructor(sppt, issues) {
    this.b1s_1 = sppt;
    this.c1s_1 = issues;
  }
  d1s() {
    return this.b1s_1;
  }
  e1s() {
    return this.c1s_1;
  }
  ni() {
    return this.b1s_1;
  }
  oi() {
    return this.c1s_1;
  }
  f1s(sppt, issues) {
    return new ParseResultDefault(sppt, issues);
  }
  copy(sppt, issues, $super) {
    sppt = sppt === VOID ? this.b1s_1 : sppt;
    issues = issues === VOID ? this.c1s_1 : issues;
    return $super === VOID ? this.f1s(sppt, issues) : $super.f1s.call(this, sppt, issues);
  }
  toString() {
    return 'ParseResultDefault(sppt=' + toString_0(this.b1s_1) + ', issues=' + toString(this.c1s_1) + ')';
  }
  hashCode() {
    var result = this.b1s_1 == null ? 0 : hashCode(this.b1s_1);
    result = imul(result, 31) + hashCode(this.c1s_1) | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof ParseResultDefault))
      return false;
    if (!equals(this.b1s_1, other.b1s_1))
      return false;
    if (!equals(this.c1s_1, other.c1s_1))
      return false;
    return true;
  }
  get sppt() {
    return this.d1s();
  }
  get issues() {
    return this.e1s();
  }
}
class ParseFailure {}
class ParseFailureRuntime {
  constructor(failedSpines) {
    this.g1s_1 = failedSpines;
  }
  h1s() {
    return this.g1s_1;
  }
  i1s() {
    // Inline function 'kotlin.collections.flatMap' call
    var tmp0 = this.g1s_1;
    // Inline function 'kotlin.collections.flatMapTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      var list = element.expectedNextTerminals;
      addAll(destination, list);
    }
    return toSet(destination);
  }
  j1s() {
    // Inline function 'kotlin.collections.map' call
    var this_0 = this.expectedTerminals;
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var tmp$ret$0 = item.tag;
      destination.v(tmp$ret$0);
    }
    return toSet(destination);
  }
  message(sentence, location) {
    // Inline function 'kotlin.collections.map' call
    var this_0 = this.g1s_1;
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var tmp$ret$0 = last(item.elements).rule.tag;
      destination.v(tmp$ret$0);
    }
    var p = joinToString(destination, ' | ');
    var contextInText = sentence.contextInText(location.position);
    var message = 'Failed to match {' + p + '} at: ' + contextInText;
    return message;
  }
  ni() {
    return this.g1s_1;
  }
  k1s(failedSpines) {
    return new ParseFailureRuntime(failedSpines);
  }
  copy(failedSpines, $super) {
    failedSpines = failedSpines === VOID ? this.g1s_1 : failedSpines;
    return $super === VOID ? this.k1s(failedSpines) : $super.k1s.call(this, failedSpines);
  }
  toString() {
    return 'ParseFailureRuntime(failedSpines=' + toString(this.g1s_1) + ')';
  }
  hashCode() {
    return hashCode(this.g1s_1);
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof ParseFailureRuntime))
      return false;
    if (!equals(this.g1s_1, other.g1s_1))
      return false;
    return true;
  }
  get failedSpines() {
    return this.h1s();
  }
  get expectedTerminals() {
    return this.i1s();
  }
  get expected() {
    return this.j1s();
  }
}
class ExpectedAtResult {}
class ExpectedAtResultDefault {
  constructor(usedPosition, spines) {
    this.l1s_1 = usedPosition;
    this.m1s_1 = spines;
  }
  n1s() {
    return this.l1s_1;
  }
  o1s() {
    return this.m1s_1;
  }
  ni() {
    return this.l1s_1;
  }
  oi() {
    return this.m1s_1;
  }
  p1s(usedPosition, spines) {
    return new ExpectedAtResultDefault(usedPosition, spines);
  }
  copy(usedPosition, spines, $super) {
    usedPosition = usedPosition === VOID ? this.l1s_1 : usedPosition;
    spines = spines === VOID ? this.m1s_1 : spines;
    return $super === VOID ? this.p1s(usedPosition, spines) : $super.p1s.call(this, usedPosition, spines);
  }
  toString() {
    return 'ExpectedAtResultDefault(usedPosition=' + this.l1s_1 + ', spines=' + toString(this.m1s_1) + ')';
  }
  hashCode() {
    var result = this.l1s_1;
    result = imul(result, 31) + hashCode(this.m1s_1) | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof ExpectedAtResultDefault))
      return false;
    if (!(this.l1s_1 === other.l1s_1))
      return false;
    if (!equals(this.m1s_1, other.m1s_1))
      return false;
    return true;
  }
  get usedPosition() {
    return this.n1s();
  }
  get spines() {
    return this.o1s();
  }
}
class Parser {}
class LeftCornerParser {
  constructor(scanner, ruleSet) {
    this.scanner = scanner;
    this.automatonKind = AutomatonKind_LOOKAHEAD_1_getInstance();
    var tmp = this;
    tmp.s1t_1 = ruleSet instanceof RuntimeRuleSet ? ruleSet : THROW_CCE();
    this.t1t_1 = null;
    this.u1t_1 = new IssueHolder(LanguageProcessorPhase_PARSE_getInstance());
  }
  f1g() {
    return this.scanner;
  }
  j1n() {
    return this.automatonKind;
  }
  j1g() {
    return this.s1t_1;
  }
  w1t() {
    return this.s1t_1;
  }
  x1t() {
    var tmp0_safe_receiver = this.t1t_1;
    var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.y1s_1;
    var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : tmp1_safe_receiver.p11();
    return tmp2_elvis_lhs == null ? true : tmp2_elvis_lhs;
  }
  reset() {
    var tmp0_safe_receiver = this.t1t_1;
    if (tmp0_safe_receiver == null)
      null;
    else {
      tmp0_safe_receiver.f1u();
    }
    this.t1t_1 = null;
  }
  interrupt(message) {
    var tmp0_safe_receiver = this.t1t_1;
    if (tmp0_safe_receiver == null)
      null;
    else {
      tmp0_safe_receiver.g1u(message);
    }
  }
  buildFor(goalRuleName) {
    this.s1t_1.buildFor(goalRuleName, this.automatonKind);
  }
  parseForGoal(goalRuleName, sentenceText) {
    return this.parse(sentenceText, new ParseOptionsDefault(VOID, goalRuleName));
  }
  parse(sentenceText, options) {
    // Inline function 'kotlin.check' call
    if (!(sentenceText.length < 2147483647)) {
      var message = 'The parser can only handle a max sentence size < 2147483647 characters, requested size was ' + sentenceText.length;
      throw IllegalStateException.t4(toString(message));
    }
    var tmp0_safe_receiver = options.sentenceIdentity;
    var sentence = new SentenceDefault(sentenceText, tmp0_safe_receiver == null ? null : tmp0_safe_receiver.invoke());
    var tmp1_elvis_lhs = options.goalRuleName;
    var tmp;
    if (tmp1_elvis_lhs == null) {
      var message_0 = 'Must define a goal rule in options';
      throw IllegalStateException.t4(toString(message_0));
    } else {
      tmp = tmp1_elvis_lhs;
    }
    var goalRuleName = tmp;
    var reportErrors = options.reportErrors;
    var reportGrammarAmbiguities = options.reportGrammarAmbiguities;
    var cacheSkip = options.cacheSkip;
    this.u1t_1.clear();
    this.scanner.reset();
    var rp = createRuntimeParser(this, sentence, goalRuleName, this.scanner, this.automatonKind, cacheSkip);
    this.t1t_1 = rp;
    var possibleEndOfText = setOf(Companion_getInstance_3().EOT);
    var parseArgs = new GrowArgs(true, false, false, false, reportErrors, reportGrammarAmbiguities, false, false);
    var startSkipFailures = rp.h1u(0, possibleEndOfText, parseArgs);
    var seasons = 1;
    var maxNumHeads = rp.y1s_1.i1u();
    var totalWork = maxNumHeads;
    while (rp.y1s_1.j1u() && (rp.y1s_1.k1u().l1() || !rp.y1s_1.e1u_1)) {
      if (false) {
        println_0('season ' + seasons + ' ===================================');
      }
      var steps = rp.l1u(possibleEndOfText, parseArgs);
      seasons = seasons + steps | 0;
      var tmp0 = maxNumHeads;
      // Inline function 'kotlin.math.max' call
      var b = rp.y1s_1.i1u();
      maxNumHeads = Math.max(tmp0, b);
      totalWork = totalWork + rp.y1s_1.i1u() | 0;
    }
    var match = rp.y1s_1.d1u_1.complete;
    var tmp_0;
    if (!(match.root == null)) {
      var sppt = new SPPTFromTreeData(match, sentence, seasons, maxNumHeads);
      tmp_0 = new ParseResultDefault(sppt, this.u1t_1);
    } else {
      createParseIssuesFromFailures(this, sentence, options, rp);
      var sppt_0 = null;
      tmp_0 = new ParseResultDefault(sppt_0, this.u1t_1);
    }
    return tmp_0;
  }
  expectedAt(sentenceText, position, options) {
    var tmp0_elvis_lhs = options.goalRuleName;
    var tmp;
    if (tmp0_elvis_lhs == null) {
      var message = 'Must define a goal rule in options';
      throw IllegalStateException.t4(toString(message));
    } else {
      tmp = tmp0_elvis_lhs;
    }
    var goalRuleName = tmp;
    var cacheSkip = options.cacheSkip;
    var revWordStartPosition = findReverseStartPosition(this, sentenceText, position, options);
    var wordStartPosition = position - revWordStartPosition | 0;
    var usedText = substring(sentenceText, 0, wordStartPosition);
    this.scanner.reset();
    var rp = createRuntimeParser(this, new SentenceDefault(usedText, options.sentenceIdentity.invoke()), goalRuleName, this.scanner, this.automatonKind, cacheSkip);
    this.t1t_1 = rp;
    var possibleEndOfText = setOf(Companion_getInstance_3().EOT);
    var parseArgs = Companion_getInstance_10().forExpectedAt;
    var startSkipFailures = rp.h1u(0, possibleEndOfText, parseArgs);
    var seasons = 1;
    while (rp.y1s_1.m1u() && (rp.y1s_1.k1u().l1() || !rp.y1s_1.e1u_1)) {
      rp.l1u(possibleEndOfText, parseArgs);
      seasons = seasons + 1 | 0;
    }
    var tmp_0;
    if (rp.z1s_1.l1()) {
      tmp_0 = new ExpectedAtResultDefault(wordStartPosition, emptySet());
    } else {
      var map = rp.z1s_1;
      // Inline function 'kotlin.collections.forEach' call
      // Inline function 'kotlin.collections.iterator' call
      var _iterator__ex2g4s = startSkipFailures.z1().g1();
      while (_iterator__ex2g4s.f()) {
        var element = _iterator__ex2g4s.e();
        var tmp0_elvis_lhs_0 = map.c3(element.a2());
        var tmp_1;
        if (tmp0_elvis_lhs_0 == null) {
          // Inline function 'kotlin.collections.mutableListOf' call
          tmp_1 = ArrayList.o1();
        } else {
          tmp_1 = tmp0_elvis_lhs_0;
        }
        var l = tmp_1;
        l.k1(element.b2());
        // Inline function 'kotlin.collections.set' call
        var key = element.a2();
        map.f3(key, l);
      }
      var tmp1_safe_receiver = map.c3(max(map.d3()));
      var tmp_2;
      if (tmp1_safe_receiver == null) {
        tmp_2 = null;
      } else {
        // Inline function 'kotlin.collections.flatMap' call
        // Inline function 'kotlin.collections.flatMapTo' call
        var destination = ArrayList.o1();
        var _iterator__ex2g4s_0 = tmp1_safe_receiver.g1();
        while (_iterator__ex2g4s_0.f()) {
          var element_0 = _iterator__ex2g4s_0.e();
          var tmp_3;
          if (element_0 instanceof FailedParseReasonEmbedded) {
            // Inline function 'kotlin.collections.filter' call
            var tmp0 = element_0.j1t_1;
            // Inline function 'kotlin.collections.filterTo' call
            var destination_0 = ArrayList.o1();
            var _iterator__ex2g4s_1 = tmp0.g1();
            while (_iterator__ex2g4s_1.f()) {
              var element_1 = _iterator__ex2g4s_1.e();
              if (!element_1.q1t() && element_1.m1t_1 === wordStartPosition) {
                destination_0.v(element_1);
              }
            }
            tmp_3 = destination_0;
          } else {
            tmp_3 = !element_0.q1t() && element_0.m1t_1 === wordStartPosition ? listOf(element_0) : emptyList();
          }
          var list = tmp_3;
          addAll(destination, list);
        }
        tmp_2 = destination;
      }
      var tmp2_elvis_lhs = tmp_2;
      var validFailReasons = tmp2_elvis_lhs == null ? emptyList() : tmp2_elvis_lhs;
      // Inline function 'kotlin.collections.map' call
      // Inline function 'kotlin.collections.mapTo' call
      var destination_1 = ArrayList.a1(collectionSizeOrDefault(validFailReasons, 10));
      var _iterator__ex2g4s_2 = validFailReasons.g1();
      while (_iterator__ex2g4s_2.f()) {
        var item = _iterator__ex2g4s_2.e();
        var tmp$ret$11 = item.r1t();
        destination_1.v(tmp$ret$11);
      }
      var rspines = destination_1;
      return new ExpectedAtResultDefault(wordStartPosition, toSet(rspines));
    }
    return tmp_0;
  }
  expectedTerminalsAt(sentenceText, position, options) {
    var res = this.expectedAt(sentenceText, position, options);
    // Inline function 'kotlin.collections.flatMap' call
    var tmp0 = res.spines;
    // Inline function 'kotlin.collections.flatMapTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      var list = element.expectedNextTerminals;
      addAll(destination, list);
    }
    // Inline function 'kotlin.collections.flatMap' call
    // Inline function 'kotlin.collections.flatMapTo' call
    var destination_0 = ArrayList.o1();
    var _iterator__ex2g4s_0 = destination.g1();
    while (_iterator__ex2g4s_0.f()) {
      var element_0 = _iterator__ex2g4s_0.e();
      var list_0 = element_0.isTerminal ? listOf(element_0) : emptyList();
      addAll(destination_0, list_0);
    }
    return toSet(destination_0);
  }
  get ruleSet() {
    return this.j1g();
  }
  get runtimeDataIsEmpty() {
    return this.x1t();
  }
}
class GrowArgs {
  constructor(buildTree, noLookahead, heightGraftOnly, nonEmptyWidthOnly, reportErrors, reportGrammarAmbiguities, allowEOTAfterSkip, snapshoGss) {
    this.buildTree = buildTree;
    this.noLookahead = noLookahead;
    this.heightGraftOnly = heightGraftOnly;
    this.nonEmptyWidthOnly = nonEmptyWidthOnly;
    this.reportErrors = reportErrors;
    this.reportGrammarAmbiguities = reportGrammarAmbiguities;
    this.allowEOTAfterSkip = allowEOTAfterSkip;
    this.snapshoGss = snapshoGss;
  }
  n1u() {
    return this.buildTree;
  }
  o1u() {
    return this.noLookahead;
  }
  p1u() {
    return this.heightGraftOnly;
  }
  q1u() {
    return this.nonEmptyWidthOnly;
  }
  s1r() {
    return this.reportErrors;
  }
  u1r() {
    return this.reportGrammarAmbiguities;
  }
  r1u() {
    return this.allowEOTAfterSkip;
  }
  s1u() {
    return this.snapshoGss;
  }
  ni() {
    return this.buildTree;
  }
  oi() {
    return this.noLookahead;
  }
  mm() {
    return this.heightGraftOnly;
  }
  d16() {
    return this.nonEmptyWidthOnly;
  }
  g1c() {
    return this.reportErrors;
  }
  p1j() {
    return this.reportGrammarAmbiguities;
  }
  t1u() {
    return this.allowEOTAfterSkip;
  }
  u1u() {
    return this.snapshoGss;
  }
  v1u(buildTree, noLookahead, heightGraftOnly, nonEmptyWidthOnly, reportErrors, reportGrammarAmbiguities, allowEOTAfterSkip, snapshoGss) {
    return new GrowArgs(buildTree, noLookahead, heightGraftOnly, nonEmptyWidthOnly, reportErrors, reportGrammarAmbiguities, allowEOTAfterSkip, snapshoGss);
  }
  copy(buildTree, noLookahead, heightGraftOnly, nonEmptyWidthOnly, reportErrors, reportGrammarAmbiguities, allowEOTAfterSkip, snapshoGss, $super) {
    buildTree = buildTree === VOID ? this.buildTree : buildTree;
    noLookahead = noLookahead === VOID ? this.noLookahead : noLookahead;
    heightGraftOnly = heightGraftOnly === VOID ? this.heightGraftOnly : heightGraftOnly;
    nonEmptyWidthOnly = nonEmptyWidthOnly === VOID ? this.nonEmptyWidthOnly : nonEmptyWidthOnly;
    reportErrors = reportErrors === VOID ? this.reportErrors : reportErrors;
    reportGrammarAmbiguities = reportGrammarAmbiguities === VOID ? this.reportGrammarAmbiguities : reportGrammarAmbiguities;
    allowEOTAfterSkip = allowEOTAfterSkip === VOID ? this.allowEOTAfterSkip : allowEOTAfterSkip;
    snapshoGss = snapshoGss === VOID ? this.snapshoGss : snapshoGss;
    return $super === VOID ? this.v1u(buildTree, noLookahead, heightGraftOnly, nonEmptyWidthOnly, reportErrors, reportGrammarAmbiguities, allowEOTAfterSkip, snapshoGss) : $super.v1u.call(this, buildTree, noLookahead, heightGraftOnly, nonEmptyWidthOnly, reportErrors, reportGrammarAmbiguities, allowEOTAfterSkip, snapshoGss);
  }
  toString() {
    return 'GrowArgs(buildTree=' + this.buildTree + ', noLookahead=' + this.noLookahead + ', heightGraftOnly=' + this.heightGraftOnly + ', nonEmptyWidthOnly=' + this.nonEmptyWidthOnly + ', reportErrors=' + this.reportErrors + ', reportGrammarAmbiguities=' + this.reportGrammarAmbiguities + ', allowEOTAfterSkip=' + this.allowEOTAfterSkip + ', snapshoGss=' + this.snapshoGss + ')';
  }
  hashCode() {
    var result = getBooleanHashCode(this.buildTree);
    result = imul(result, 31) + getBooleanHashCode(this.noLookahead) | 0;
    result = imul(result, 31) + getBooleanHashCode(this.heightGraftOnly) | 0;
    result = imul(result, 31) + getBooleanHashCode(this.nonEmptyWidthOnly) | 0;
    result = imul(result, 31) + getBooleanHashCode(this.reportErrors) | 0;
    result = imul(result, 31) + getBooleanHashCode(this.reportGrammarAmbiguities) | 0;
    result = imul(result, 31) + getBooleanHashCode(this.allowEOTAfterSkip) | 0;
    result = imul(result, 31) + getBooleanHashCode(this.snapshoGss) | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof GrowArgs))
      return false;
    if (!(this.buildTree === other.buildTree))
      return false;
    if (!(this.noLookahead === other.noLookahead))
      return false;
    if (!(this.heightGraftOnly === other.heightGraftOnly))
      return false;
    if (!(this.nonEmptyWidthOnly === other.nonEmptyWidthOnly))
      return false;
    if (!(this.reportErrors === other.reportErrors))
      return false;
    if (!(this.reportGrammarAmbiguities === other.reportGrammarAmbiguities))
      return false;
    if (!(this.allowEOTAfterSkip === other.allowEOTAfterSkip))
      return false;
    if (!(this.snapshoGss === other.snapshoGss))
      return false;
    return true;
  }
}
class Companion_10 {
  constructor() {
    Companion_instance_10 = this;
    this.forExpectedAt = new GrowArgs(false, false, false, false, true, false, true, true);
  }
  w1u() {
    return this.forExpectedAt;
  }
}
class sam$kotlin_Comparator$0_4 {
  constructor(function_0) {
    this.g1w_1 = function_0;
  }
  lg(a, b) {
    return this.g1w_1(a, b);
  }
  compare(a, b) {
    return this.lg(a, b);
  }
  u3() {
    return this.g1w_1;
  }
  equals(other) {
    var tmp;
    if (!(other == null) ? isInterface(other, Comparator) : false) {
      var tmp_0;
      if (!(other == null) ? isInterface(other, FunctionAdapter) : false) {
        tmp_0 = equals(this.u3(), other.u3());
      } else {
        tmp_0 = false;
      }
      tmp = tmp_0;
    } else {
      tmp = false;
    }
    return tmp;
  }
  hashCode() {
    return hashCode(this.u3());
  }
}
class sam$kotlin_Comparator$0_5 {
  constructor(function_0) {
    this.h1w_1 = function_0;
  }
  lg(a, b) {
    return this.h1w_1(a, b);
  }
  compare(a, b) {
    return this.lg(a, b);
  }
  u3() {
    return this.h1w_1;
  }
  equals(other) {
    var tmp;
    if (!(other == null) ? isInterface(other, Comparator) : false) {
      var tmp_0;
      if (!(other == null) ? isInterface(other, FunctionAdapter) : false) {
        tmp_0 = equals(this.u3(), other.u3());
      } else {
        tmp_0 = false;
      }
      tmp = tmp_0;
    } else {
      tmp = false;
    }
    return tmp;
  }
  hashCode() {
    return hashCode(this.u3());
  }
}
class RuntimeParser {}
class RuntimeParserAgl {
  constructor(sentence, isSkipParser, stateSet, skipStateSet, cacheSkip, userGoalRule, scanner, _issues) {
    Companion_getInstance_10();
    this.q1s_1 = sentence;
    this.r1s_1 = isSkipParser;
    this.s1s_1 = stateSet;
    this.t1s_1 = skipStateSet;
    this.u1s_1 = cacheSkip;
    this.v1s_1 = userGoalRule;
    this.w1s_1 = scanner;
    this.x1s_1 = _issues;
    this.y1s_1 = new ParseGraph(this.q1s_1, this.w1s_1, this.s1s_1.number);
    var tmp = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp.z1s_1 = LinkedHashMap.j4();
    this.a1t_1 = null;
    var tmp_0 = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp_0.b1t_1 = LinkedHashMap.j4();
    var tmp_1 = this;
    var tmp0_safe_receiver = this.t1s_1;
    var tmp_2;
    if (tmp0_safe_receiver == null) {
      tmp_2 = null;
    } else {
      // Inline function 'kotlin.let' call
      if (this.s1s_1.preBuilt) {
        this.t1s_1.build();
      }
      var tmp0_subject = this.w1s_1;
      var tmp_3;
      if (tmp0_subject instanceof ScannerOnDemand) {
        tmp_3 = new ScannerOnDemand(this.w1s_1.regexEngine, toList(this.t1s_1.usedTerminalRules));
      } else {
        if (tmp0_subject instanceof ScannerClassic) {
          tmp_3 = this.w1s_1;
        } else {
          var message = 'subtype of Scanner unsupported - ' + getKClassFromExpression(this.w1s_1).md();
          throw IllegalStateException.t4(toString(message));
        }
      }
      var skipScanner = tmp_3;
      tmp_2 = new RuntimeParserAgl(this.q1s_1, true, tmp0_safe_receiver, null, false, this.t1s_1.userGoalRule, skipScanner, this.x1s_1);
    }
    tmp_1.c1t_1 = tmp_2;
    this.d1t_1 = 0;
  }
  f1u() {
    this.b1t_1.i3();
    this.y1s_1.f1u();
    this.z1s_1.i3();
  }
  h1u(startPosition, possibleEndOfText, parseArgs) {
    var gState = this.s1s_1.startState;
    var tmp;
    if (this.s1s_1.isSkip) {
      tmp = null;
    } else {
      // Inline function 'kotlin.collections.flatMap' call
      var tmp0 = gState.j1i_1;
      // Inline function 'kotlin.collections.flatMapTo' call
      var destination = ArrayList.o1();
      var _iterator__ex2g4s = tmp0.g1();
      while (_iterator__ex2g4s.f()) {
        var element = _iterator__ex2g4s.e();
        // Inline function 'kotlin.collections.map' call
        // Inline function 'kotlin.collections.mapTo' call
        var destination_0 = ArrayList.a1(collectionSizeOrDefault(possibleEndOfText, 10));
        var _iterator__ex2g4s_0 = possibleEndOfText.g1();
        while (_iterator__ex2g4s_0.f()) {
          var item = _iterator__ex2g4s_0.e();
          var tmp$ret$0 = this.s1s_1.x1h_1.e1l(element, item.b1m());
          destination_0.v(tmp$ret$0);
        }
        var list = destination_0;
        addAll(destination, list);
      }
      // Inline function 'kotlin.collections.fold' call
      var accumulator = Companion_getInstance_7().EMPTY;
      var _iterator__ex2g4s_1 = destination.g1();
      while (_iterator__ex2g4s_1.f()) {
        var element_0 = _iterator__ex2g4s_1.e();
        accumulator = accumulator.union(element_0);
      }
      var skipLhsp = accumulator;
      var endOfSkipLookaheadSet = this.s1s_1.y1n(skipLhsp);
      tmp = tryParseSkipUntilNone(this, setOf(endOfSkipLookaheadSet), startPosition, parseArgs);
    }
    var initialSkipData = tmp;
    var runtimeLookahead = possibleEndOfText;
    this.y1s_1.i1w(gState, startPosition, runtimeLookahead, initialSkipData);
    var tmp0_safe_receiver = this.c1t_1;
    var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.z1s_1;
    var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : clone(tmp1_safe_receiver);
    return tmp2_elvis_lhs == null ? emptyMap() : tmp2_elvis_lhs;
  }
  g1u(message) {
    this.a1t_1 = message;
  }
  j1w() {
    var m = this.a1t_1;
    if (null != m) {
      // Inline function 'kotlin.error' call
      var message = 'ParserTerminated: ' + m;
      throw IllegalStateException.t4(toString(message));
    }
  }
  l1u(possibleEndOfText, growArgs) {
    var currentNextInputPosition = this.y1s_1.k1w();
    failedReasonsClear(this, currentNextInputPosition);
    var steps = 0;
    var progressSteps = lazyMutableMapNotNull(RuntimeParserAgl$grow3$lambda);
    // Inline function 'kotlin.collections.mutableSetOf' call
    var doneEmpties = LinkedHashSet.j1();
    while (this.y1s_1.j1u() && this.y1s_1.k1w() <= currentNextInputPosition) {
      this.j1w();
      var graph = this.y1s_1;
      if (false) {
        println_0('step ' + steps + ' --------------------------------------');
        println_0(graph);
      }
      var head = this.y1s_1.l1w();
      var tmp;
      if (head.p1c()) {
        var tmp_0 = head.i1c();
        // Inline function 'kotlin.collections.map' call
        var this_0 = graph.n1v(head);
        // Inline function 'kotlin.collections.mapTo' call
        var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
        var _iterator__ex2g4s = this_0.g1();
        while (_iterator__ex2g4s.f()) {
          var item = _iterator__ex2g4s.e();
          var tmp$ret$1 = new Pair(item, graph.n1v(item));
          destination.v(tmp$ret$1);
        }
        tmp = doneEmpties.p1(new Pair(tmp_0, destination));
      } else {
        tmp = false;
      }
      if (tmp) {
        this.y1s_1.m1v(head);
      } else {
        if (head.p1c()) {
          var tmp_1 = head.i1c();
          // Inline function 'kotlin.collections.map' call
          var this_1 = graph.n1v(head);
          // Inline function 'kotlin.collections.mapTo' call
          var destination_0 = ArrayList.a1(collectionSizeOrDefault(this_1, 10));
          var _iterator__ex2g4s_0 = this_1.g1();
          while (_iterator__ex2g4s_0.f()) {
            var item_0 = _iterator__ex2g4s_0.e();
            var tmp$ret$4 = new Pair(item_0, graph.n1v(item_0));
            destination_0.v(tmp$ret$4);
          }
          doneEmpties.v(new Pair(tmp_1, destination_0));
        }
        growHead(this, head, possibleEndOfText, growArgs);
        steps = steps + 1 | 0;
      }
      var progStep = progressSteps.c3(head);
      if (progStep > 1000) {
        this.g1u('The Parser has exceeded the configured number of non-progressing steps, self-terminated as it is likely it will never stop.');
      } else {
        // Inline function 'kotlin.collections.set' call
        var value = progStep + 1 | 0;
        progressSteps.f3(head, value);
      }
    }
    return steps;
  }
  d1w(lastTokenStart, atPosition, runtimeLhs, lhs, possibleEndOfText, parseArgs) {
    var tmp;
    if (null == this.c1t_1) {
      tmp = new Pair(null, false);
    } else {
      var tmp_0;
      if (lhs.i1l_1 || lhs.h1l_1) {
        // Inline function 'kotlin.collections.flatMap' call
        // Inline function 'kotlin.collections.flatMapTo' call
        var destination = ArrayList.o1();
        var _iterator__ex2g4s = runtimeLhs.g1();
        while (_iterator__ex2g4s.f()) {
          var element = _iterator__ex2g4s.e();
          // Inline function 'kotlin.collections.map' call
          // Inline function 'kotlin.collections.mapTo' call
          var destination_0 = ArrayList.a1(collectionSizeOrDefault(possibleEndOfText, 10));
          var _iterator__ex2g4s_0 = possibleEndOfText.g1();
          while (_iterator__ex2g4s_0.f()) {
            var item = _iterator__ex2g4s_0.e();
            var tmp$ret$0 = this.s1s_1.y1n(lhs.c1m(item, element));
            destination_0.v(tmp$ret$0);
          }
          var list = destination_0;
          addAll(destination, list);
        }
        tmp_0 = toSet(destination);
      } else {
        tmp_0 = setOf(lhs);
      }
      var skipLh = tmp_0;
      var needSkip = false;
      var _iterator__ex2g4s_1 = skipLh.g1();
      while (_iterator__ex2g4s_1.f()) {
        var lh = _iterator__ex2g4s_1.e();
        var _iterator__ex2g4s_2 = lh.k1l_1.g1();
        while (_iterator__ex2g4s_2.f()) {
          var lhr = _iterator__ex2g4s_2.e();
          var ml = this.y1s_1.z1t_1.matchedLength(this.q1s_1, lastTokenStart, lhr);
          if ((lastTokenStart + ml | 0) > atPosition)
            needSkip = true;
        }
      }
      var skipData = tryParseSkipUntilNone(this, skipLh, atPosition, parseArgs);
      var tmp_1;
      if (needSkip && null == skipData) {
        tmp_1 = new Pair(skipData, true);
      } else {
        tmp_1 = new Pair(skipData, false);
      }
      tmp = tmp_1;
    }
    return tmp;
  }
  m1w(possibleEndOfText, runtimeLookaheadSet, transition) {
    var tmp = first_0(transition.f1n_1.runtimeRules).rhs;
    var embeddedRhs = tmp instanceof RuntimeRuleRhsEmbedded ? tmp : THROW_CCE();
    var embeddedRuntimeRuleSet = embeddedRhs.embeddedRuntimeRuleSet;
    var embeddedStartRule = embeddedRhs.embeddedStartRule;
    var embeddedS0 = embeddedRuntimeRuleSet.c1l(embeddedStartRule.tag, this.s1s_1.automatonKind).startState;
    var embeddedSkipStateSet = embeddedRuntimeRuleSet.skipParserStateSet;
    var embeddedParser = new RuntimeParserAgl(this.q1s_1, false, embeddedS0.stateSet, embeddedSkipStateSet, this.u1s_1, embeddedStartRule, this.w1s_1, this.x1s_1);
    var tmp0_safe_receiver = this.t1s_1;
    var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.firstTerminals;
    var skipTerms = tmp1_elvis_lhs == null ? emptySet() : tmp1_elvis_lhs;
    var endingLookahead = first(transition.lookaheadGuard).guardLookaheadSet;
    var embeddedPossibleEOT = endingLookahead.f1m(embeddedS0.stateSet, skipTerms);
    // Inline function 'kotlin.collections.flatMap' call
    // Inline function 'kotlin.collections.flatMapTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = runtimeLookaheadSet.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      // Inline function 'kotlin.collections.map' call
      // Inline function 'kotlin.collections.mapTo' call
      var destination_0 = ArrayList.a1(collectionSizeOrDefault(possibleEndOfText, 10));
      var _iterator__ex2g4s_0 = possibleEndOfText.g1();
      while (_iterator__ex2g4s_0.f()) {
        var item = _iterator__ex2g4s_0.e();
        var tmp$ret$0 = Companion_instance_4.lhs(embeddedPossibleEOT.c1m(item, element), embeddedS0.stateSet);
        destination_0.v(tmp$ret$0);
      }
      var list = destination_0;
      addAll(destination, list);
    }
    var embeddedEOT = toSet(destination);
    return new Pair(embeddedParser, embeddedEOT);
  }
  k1v(head, transition, possibleEndOfText, parseArgs) {
    var tmp;
    if (parseArgs.heightGraftOnly) {
      tmp = false;
    } else {
      var _destruct__k2r9zo = this.m1w(possibleEndOfText, head.x1u_1.g1v_1, transition);
      var embeddedParser = _destruct__k2r9zo.ni();
      var embeddedEOT = _destruct__k2r9zo.oi();
      var tmp_0;
      if (embeddedParser instanceof RuntimeParserAgl) {
        var endingLookahead = first(transition.lookaheadGuard).guardLookaheadSet;
        var startPosition = head.a1v_1;
        embeddedParser.h1u(startPosition, embeddedEOT, parseArgs);
        var seasons = 1;
        var maxNumHeads = embeddedParser.y1s_1.i1u();
        do {
          embeddedParser.l1u(embeddedEOT, parseArgs);
          seasons = seasons + 1 | 0;
          var tmp0 = maxNumHeads;
          // Inline function 'kotlin.math.max' call
          var b = embeddedParser.y1s_1.i1u();
          maxNumHeads = Math.max(tmp0, b);
        }
         while (embeddedParser.y1s_1.m1u() && (embeddedParser.y1s_1.k1u().l1() || !embeddedParser.y1s_1.e1u_1));
        var match = embeddedParser.y1s_1.d1u_1.complete;
        var tmp_1;
        if (!(match.root == null)) {
          var embeddedS0 = embeddedParser.s1s_1.startState;
          var tmp1_safe_receiver = match.root;
          var ni = ensureNotNull(tmp1_safe_receiver == null ? null : tmp1_safe_receiver.nextInputPosition);
          // Inline function 'kotlin.collections.flatMap' call
          var tmp0_0 = head.x1u_1.g1v_1;
          // Inline function 'kotlin.collections.flatMapTo' call
          var destination = ArrayList.o1();
          var _iterator__ex2g4s = tmp0_0.g1();
          while (_iterator__ex2g4s.f()) {
            var element = _iterator__ex2g4s.e();
            // Inline function 'kotlin.collections.map' call
            // Inline function 'kotlin.collections.mapTo' call
            var destination_0 = ArrayList.a1(collectionSizeOrDefault(possibleEndOfText, 10));
            var _iterator__ex2g4s_0 = possibleEndOfText.g1();
            while (_iterator__ex2g4s_0.f()) {
              var item = _iterator__ex2g4s_0.e();
              var tmp$ret$1 = Companion_instance_4.lhs(endingLookahead.c1m(item, element), embeddedS0.stateSet);
              destination_0.v(tmp$ret$1);
            }
            var list = destination_0;
            addAll(destination, list);
          }
          var skipLh = toSet(destination);
          var skipData = tryParseSkipUntilNone(this, skipLh, ni, parseArgs);
          if (false) {
            var tmp_2 = Debug_instance;
            var tmp_3 = IndentDelta_NONE_getInstance();
            tmp_2.debug(tmp_3, RuntimeParserAgl$doEmbedded$lambda(head, transition));
          }
          tmp_1 = this.y1s_1.n1w(head, transition.f1n_1, head.x1u_1.g1v_1, startPosition, ni, match, skipData);
        } else {
          recordFailedEmbedded(this, parseArgs, head, transition, embeddedParser.z1s_1);
          tmp_1 = false;
        }
        tmp_0 = tmp_1;
      } else {
        if (embeddedParser instanceof RuntimeParserExternal) {
          // Inline function 'kotlin.TODO' call
          throw NotImplementedError.im();
        } else {
          var message = "Subtype of RuntimeParser not supported: '" + getKClassFromExpression(embeddedParser).md() + "'";
          throw IllegalStateException.t4(toString(message));
        }
      }
      tmp = tmp_0;
    }
    return tmp;
  }
}
class RuntimeContext {
  constructor(head, prev, prevPrev) {
    this.r1v_1 = head;
    this.s1v_1 = prev;
    this.t1v_1 = prevPrev;
  }
  toString() {
    return 'RuntimeContext(head=' + this.r1v_1.toString() + ', prev=' + toString_0(this.s1v_1) + ', prevPrev=' + toString_0(this.t1v_1) + ')';
  }
  hashCode() {
    var result = this.r1v_1.hashCode();
    result = imul(result, 31) + (this.s1v_1 == null ? 0 : this.s1v_1.hashCode()) | 0;
    result = imul(result, 31) + (this.t1v_1 == null ? 0 : this.t1v_1.hashCode()) | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof RuntimeContext))
      return false;
    if (!this.r1v_1.equals(other.r1v_1))
      return false;
    if (!equals(this.s1v_1, other.s1v_1))
      return false;
    if (!equals(this.t1v_1, other.t1v_1))
      return false;
    return true;
  }
}
class RuntimeParserExternal {}
class FailedParseReason {
  constructor(fromSkipParser, failedAtPosition, head, transition, gssSnapshot) {
    this.l1t_1 = fromSkipParser;
    this.m1t_1 = failedAtPosition;
    this.n1t_1 = head;
    this.o1t_1 = transition;
    this.p1t_1 = gssSnapshot;
  }
  q1t() {
    return this.l1t_1;
  }
}
class FailedParseReasonEmbedded extends FailedParseReason {
  constructor(fromSkipParser, failedAtPosition, head, transition, gssSnapshot, embededFailedParseReasons) {
    super(fromSkipParser, failedAtPosition, head, transition, gssSnapshot);
    this.j1t_1 = embededFailedParseReasons;
    var tmp = this;
    tmp.k1t_1 = lazy(FailedParseReasonEmbedded$spine$delegate$lambda(transition, head, this, gssSnapshot));
  }
  r1t() {
    var tmp0 = this.k1t_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('spine', 1, tmp, FailedParseReasonEmbedded$_get_spine_$ref_696nsz(), null);
    return tmp0.b2();
  }
}
class FailedParseReasonLookahead extends FailedParseReason {
  constructor(fromSkipParser, failedAtPosition, head, transition, gssSnapshot, runtimeLhs, possibleEndOfText) {
    super(fromSkipParser, failedAtPosition, head, transition, gssSnapshot);
    this.y1w_1 = runtimeLhs;
    this.z1w_1 = possibleEndOfText;
    var tmp = this;
    tmp.a1x_1 = lazy(FailedParseReasonLookahead$spine$delegate$lambda(this, transition, head, gssSnapshot));
  }
  r1t() {
    var tmp0 = this.a1x_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('spine', 1, tmp, FailedParseReasonLookahead$_get_spine_$ref_6f8gap(), null);
    return tmp0.b2();
  }
  q1t() {
    return this.l1t_1;
  }
}
class FailedParseReasonWidthTo extends FailedParseReason {
  constructor(fromSkipParser, failedAtPosition, head, transition, gssSnapshot) {
    super(fromSkipParser, failedAtPosition, head, transition, gssSnapshot);
    this.g1x_1 = new RuntimeSpineDefault(head, gssSnapshot, setOf(transition.f1n_1.firstRule), head.b1v_1);
  }
  r1t() {
    return this.g1x_1;
  }
}
class FailedParseExpectedSkipAfter extends FailedParseReason {
  constructor(fromSkipParser, failedAtPosition, head, transition, gssSnapshot, firstTerminals) {
    super(fromSkipParser, failedAtPosition, head, transition, gssSnapshot);
    this.m1x_1 = new RuntimeSpineDefault(head, gssSnapshot, firstTerminals, head.b1v_1);
  }
  r1t() {
    return this.m1x_1;
  }
}
class FailedParseReasonGraftRTG extends FailedParseReason {
  constructor(fromSkipParser, failedAtPosition, head, transition, gssSnapshot, prevNumNonSkipChildren) {
    super(fromSkipParser, failedAtPosition, head, transition, gssSnapshot);
    this.s1x_1 = prevNumNonSkipChildren;
    var tmp = this;
    tmp.t1x_1 = lazy(FailedParseReasonGraftRTG$spine$delegate$lambda(transition, this, head, gssSnapshot));
  }
  r1t() {
    var tmp0 = this.t1x_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('spine', 1, tmp, FailedParseReasonGraftRTG$_get_spine_$ref_mtwlws(), null);
    return tmp0.b2();
  }
}
class RuleSet {}
class Rule {}
class PrefRule {}
class Assoc extends Enum {
  get name() {
    return this.r3();
  }
  get ordinal() {
    return this.s3();
  }
}
class PrefOption {}
class OptionNum {
  constructor(value) {
    this.value = value;
  }
  b2() {
    return this.value;
  }
  v1y() {
    if (this.value < 0) {
      // Inline function 'kotlin.error' call
      var message = 'Should not happen';
      throw IllegalStateException.t4(toString(message));
    }
    return this.value;
  }
  p11() {
    return this.equals(Companion_getInstance_11().OPTION_OPTIONAL_EMPTY) || this.equals(Companion_getInstance_11().OPTION_MULTI_EMPTY) || this.equals(Companion_getInstance_11().OPTION_SLIST_EMPTY);
  }
  w1y() {
    return this.value >= 0;
  }
  x1y() {
    return this.equals(Companion_getInstance_11().OPTION_NONE);
  }
  y1y() {
    return this.equals(Companion_getInstance_11().OPTION_OPTIONAL_EMPTY) || this.equals(Companion_getInstance_11().OPTION_OPTIONAL_ITEM);
  }
  z1y() {
    return this.equals(Companion_getInstance_11().OPTION_MULTI_EMPTY) || this.equals(Companion_getInstance_11().OPTION_MULTI_ITEM);
  }
  a1z() {
    return this.equals(Companion_getInstance_11().OPTION_SLIST_EMPTY) || this.equals(Companion_getInstance_11().OPTION_SLIST_ITEM_OR_SEPERATOR);
  }
  b1z(other) {
    return compareTo(this.value, other.value);
  }
  d(other) {
    return this.b1z(other instanceof OptionNum ? other : THROW_CCE());
  }
  toString() {
    return this.equals(Companion_getInstance_11().OPTION_NONE) ? 'oN' : this.equals(Companion_getInstance_11().OPTION_OPTIONAL_EMPTY) ? 'OE' : this.equals(Companion_getInstance_11().OPTION_OPTIONAL_ITEM) ? 'OI' : this.equals(Companion_getInstance_11().OPTION_MULTI_EMPTY) ? 'LE' : this.equals(Companion_getInstance_11().OPTION_MULTI_ITEM) ? 'LI' : this.equals(Companion_getInstance_11().OPTION_SLIST_EMPTY) ? 'SE' : this.equals(Companion_getInstance_11().OPTION_SLIST_ITEM_OR_SEPERATOR) ? 'SI' : 'o' + this.value;
  }
  ni() {
    return this.value;
  }
  i1g(value) {
    return new OptionNum(value);
  }
  copy(value, $super) {
    value = value === VOID ? this.value : value;
    return $super === VOID ? this.i1g(value) : $super.i1g.call(this, value);
  }
  hashCode() {
    return this.value;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof OptionNum))
      return false;
    if (!(this.value === other.value))
      return false;
    return true;
  }
  get asIndex() {
    return this.v1y();
  }
  get isEmpty() {
    return this.p11();
  }
  get isChoiceOption() {
    return this.w1y();
  }
  get isNoneOption() {
    return this.x1y();
  }
  get isOptionalOption() {
    return this.y1y();
  }
  get isListSimpleOption() {
    return this.z1y();
  }
  get isListSeparatedOption() {
    return this.a1z();
  }
}
class Companion_11 {
  constructor() {
    Companion_instance_11 = this;
    this.START_OF_RULE = 0;
    this.END_OF_RULE = -1;
    this.OPTION_NONE = new OptionNum(-1);
    this.OPTION_OPTIONAL_ITEM = new OptionNum(-2);
    this.OPTION_OPTIONAL_EMPTY = new OptionNum(-3);
    this.OPTION_MULTI_ITEM = new OptionNum(-4);
    this.OPTION_MULTI_EMPTY = new OptionNum(-5);
    this.OPTION_SLIST_ITEM_OR_SEPERATOR = new OptionNum(-6);
    this.OPTION_SLIST_EMPTY = new OptionNum(-7);
    this.POSITION_MULIT_ITEM = 1;
    this.POSITION_SLIST_SEPARATOR = 1;
    this.POSITION_SLIST_ITEM = 2;
  }
  c1z() {
    return this.START_OF_RULE;
  }
  d1z() {
    return this.END_OF_RULE;
  }
  e1z() {
    return this.OPTION_NONE;
  }
  f1z() {
    return this.OPTION_OPTIONAL_ITEM;
  }
  g1z() {
    return this.OPTION_OPTIONAL_EMPTY;
  }
  h1z() {
    return this.OPTION_MULTI_ITEM;
  }
  i1z() {
    return this.OPTION_MULTI_EMPTY;
  }
  j1z() {
    return this.OPTION_SLIST_ITEM_OR_SEPERATOR;
  }
  k1z() {
    return this.OPTION_SLIST_EMPTY;
  }
  l1z() {
    return this.POSITION_MULIT_ITEM;
  }
  m1z() {
    return this.POSITION_SLIST_SEPARATOR;
  }
  n1z() {
    return this.POSITION_SLIST_ITEM;
  }
}
class RulePosition_0 {}
class RuntimeSpine {}
class ParserTerminatedException extends RuntimeException {
  constructor() {
    return new.target.v1z();
  }
  static v1z() {
    var $this = this.uc();
    captureStack($this, $this.u1z_1);
    return $this;
  }
}
class ConcatenationBuilder {}
class ChoiceBuilder {}
class PrecedenceBuilder {}
class IssueMessage_0 {
  constructor() {
    this.PARSER_WONT_STOP = 'The Parser has exceeded the configured number of non-progressing steps, self-terminated as it is likely it will never stop.';
  }
  w1z() {
    return this.PARSER_WONT_STOP;
  }
}
class Companion_12 {
  constructor() {
    Companion_instance_12 = this;
    this.powersOf2 = this.nPowersOf2(31);
  }
  nPowersOf2(n) {
    var tmp;
    if (n === 1) {
      tmp = listOf(2);
    } else {
      var tmp_0 = this.nPowersOf2(n - 1 | 0);
      // Inline function 'kotlin.math.pow' call
      var tmp$ret$0 = Math.pow(2.0, n);
      tmp = plus_1(tmp_0, numberToInt(tmp$ret$0));
    }
    return tmp;
  }
  x1z() {
    return this.powersOf2;
  }
  closestGreaterPowerOf2(n) {
    var tmp0 = this.powersOf2;
    var tmp$ret$1;
    $l$block: {
      // Inline function 'kotlin.collections.indexOfFirst' call
      var index = 0;
      var _iterator__ex2g4s = tmp0.g1();
      while (_iterator__ex2g4s.f()) {
        var item = _iterator__ex2g4s.e();
        if (item > n) {
          tmp$ret$1 = index;
          break $l$block;
        }
        index = index + 1 | 0;
      }
      tmp$ret$1 = -1;
    }
    var i = tmp$ret$1;
    if (i < 0) {
      // Inline function 'kotlin.error' call
      var message = 'Too many rules';
      throw IllegalStateException.t4(toString(message));
    } else {
      return i + 1 | 0;
    }
  }
}
class CompletedNodesStore {
  constructor(num) {
    this.y1z_1 = num;
    this.z1z_1 = HashMap.o7();
    this.a20_1 = null;
    this.b20_1 = HashMap.o7();
    this.c20_1 = null;
  }
  i3() {
    this.z1z_1.i3();
    this.a20_1 = null;
    this.b20_1.i3();
    this.c20_1 = null;
  }
  d20(runtimeRule, inputPosition, value) {
    if (runtimeRule.u1d_1 === -1) {
      this.a20_1 = value;
    } else if (runtimeRule.u1d_1 === -2) {
      // Inline function 'kotlin.collections.set' call
      this.b20_1.f3(inputPosition, value);
    } else if (runtimeRule.u1d_1 === -3) {
      this.c20_1 = value;
    } else {
      var tmp0 = this.z1z_1;
      // Inline function 'kotlin.collections.set' call
      var key = new Pair(runtimeRule, inputPosition);
      tmp0.f3(key, value);
    }
  }
  e20(runtimeRule, inputPosition) {
    var tmp;
    if (runtimeRule.u1d_1 === -1) {
      tmp = this.a20_1;
    } else if (runtimeRule.u1d_1 === -2) {
      tmp = this.b20_1.c3(inputPosition);
    } else if (runtimeRule.u1d_1 === -3) {
      tmp = this.c20_1;
    } else {
      tmp = this.z1z_1.c3(new Pair(runtimeRule, inputPosition));
    }
    return tmp;
  }
}
class GraphStructuredStack {
  constructor(_growingHeadHeap, previous, count) {
    return new.target.h20(_growingHeadHeap, previous, count);
  }
  static h20(_growingHeadHeap, previous, count) {
    var $this = createThis(this);
    $this._growingHeadHeap = _growingHeadHeap;
    $this.f20_1 = previous;
    $this.g20_1 = count;
    return $this;
  }
  i20() {
    return this._growingHeadHeap;
  }
  static new_net_akehurst_language_agl_runtime_graph_GraphStructuredStack(headHeap) {
    // Inline function 'kotlin.collections.hashMapOf' call
    var tmp = HashMap.o7();
    // Inline function 'kotlin.collections.hashMapOf' call
    var tmp$ret$1 = HashMap.o7();
    return this.h20(headHeap, tmp, tmp$ret$1);
  }
  j20() {
    // Inline function 'kotlin.collections.filter' call
    var tmp0 = this.g20_1.z1();
    // Inline function 'kotlin.collections.filterTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      if (element.b2() === 0) {
        destination.v(element);
      }
    }
    // Inline function 'kotlin.collections.map' call
    // Inline function 'kotlin.collections.mapTo' call
    var destination_0 = ArrayList.a1(collectionSizeOrDefault(destination, 10));
    var _iterator__ex2g4s_0 = destination.g1();
    while (_iterator__ex2g4s_0.f()) {
      var item = _iterator__ex2g4s_0.e();
      var tmp$ret$3 = item.a2();
      destination_0.v(tmp$ret$3);
    }
    return destination_0;
  }
  p11() {
    return this.f20_1.l1() && this.g20_1.l1() && this._growingHeadHeap.l1();
  }
  i1u() {
    return this._growingHeadHeap.h1();
  }
  j1u() {
    return this._growingHeadHeap.e17();
  }
  k20() {
    return this._growingHeadHeap.b17();
  }
  l20() {
    return toList(this._growingHeadHeap);
  }
  extractRoot() {
    return ensureNotNull(this._growingHeadHeap.f17());
  }
  clear() {
    this.g20_1.i3();
    this.f20_1.i3();
    this._growingHeadHeap.i3();
  }
  root(head) {
    this._growingHeadHeap.c17(head, head);
    var set = this.f20_1.c3(head);
    var tmp;
    if (null == set) {
      var tmp0 = this.f20_1;
      // Inline function 'kotlin.collections.linkedSetOf' call
      // Inline function 'kotlin.collections.set' call
      var value = LinkedHashSet.j1();
      tmp0.f3(head, value);
      // Inline function 'kotlin.collections.set' call
      this.g20_1.f3(head, 0);
      tmp = true;
    } else {
      tmp = false;
    }
    var createdNewHead = tmp;
    if (false) {
      check(this);
    }
    return createdNewHead;
  }
  pushTriple(cur, prev, rhd) {
    if (null == prev) {
      this.root(cur);
    } else if (null == rhd) {
      this._growingHeadHeap.c17(cur, cur);
      this.push(prev, cur);
    } else {
      this._growingHeadHeap.c17(cur, cur);
      this.push(rhd, prev);
      this.push(prev, cur);
    }
  }
  push(currentHead, nextHead) {
    this._growingHeadHeap.g3(currentHead);
    var set = this.f20_1.c3(nextHead);
    if (null == set) {
      // Inline function 'kotlin.collections.linkedSetOf' call
      set = LinkedHashSet.j1();
      var tmp0 = this.f20_1;
      // Inline function 'kotlin.collections.set' call
      var value = set;
      tmp0.f3(nextHead, value);
      // Inline function 'kotlin.collections.set' call
      this.g20_1.f3(nextHead, 0);
      this._growingHeadHeap.c17(nextHead, nextHead);
    }
    var added = set.v(currentHead);
    if (added) {
      var hc = this.g20_1.c3(currentHead);
      if (null == hc) {
        var tmp0_0 = this.f20_1;
        // Inline function 'kotlin.collections.linkedSetOf' call
        // Inline function 'kotlin.collections.set' call
        var value_0 = LinkedHashSet.j1();
        tmp0_0.f3(currentHead, value_0);
        // Inline function 'kotlin.collections.set' call
        this.g20_1.f3(currentHead, 1);
      } else {
        var tmp0_1 = this.g20_1;
        // Inline function 'kotlin.collections.set' call
        var value_1 = hc + 1 | 0;
        tmp0_1.f3(currentHead, value_1);
      }
    }
    if (false) {
      check(this);
    }
  }
  contains(head) {
    return this.f20_1.a3(head);
  }
  peekPrevious(head) {
    var tmp0_safe_receiver = this.f20_1.c3(head);
    var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : toMutableSet(tmp0_safe_receiver);
    return tmp1_elvis_lhs == null ? emptySet() : tmp1_elvis_lhs;
  }
  pop(head) {
    this._growingHeadHeap.g3(head);
    var count = this.g20_1.c3(head);
    var tmp;
    if (null == count) {
      tmp = emptySet();
    } else {
      var tmp_0;
      if (count === 0) {
        this.g20_1.g3(head);
        var prev = toMutableSet(ensureNotNull(this.f20_1.g3(head)));
        // Inline function 'kotlin.collections.forEach' call
        var _iterator__ex2g4s = prev.g1();
        while (_iterator__ex2g4s.f()) {
          var element = _iterator__ex2g4s.e();
          var c = ensureNotNull(this.g20_1.c3(element));
          var tmp0 = this.g20_1;
          // Inline function 'kotlin.collections.set' call
          var value = c - 1 | 0;
          tmp0.f3(element, value);
        }
        if (false) {
          check(this);
        }
        tmp_0 = prev;
      } else {
        var prev_0 = toMutableSet(ensureNotNull(this.f20_1.c3(head)));
        if (false) {
          check(this);
        }
        tmp_0 = prev_0;
      }
      tmp = tmp_0;
    }
    return tmp;
  }
  snapshotFor(head) {
    var prev = this.f20_1.c3(head);
    return null == prev ? null : deepClone(this.f20_1);
  }
  dropStack(head, ifDropped) {
    var d = this._growingHeadHeap.g3(head);
    return removeStack(this, head, ifDropped);
  }
  toString() {
    // Inline function 'kotlin.collections.filter' call
    var tmp0 = this.g20_1.z1();
    // Inline function 'kotlin.collections.filterTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      if (element.b2() === 0) {
        destination.v(element);
      }
    }
    var heads = destination;
    var tmp;
    if (heads.l1()) {
      var tmp_0;
      if (this.f20_1.l1() && this.g20_1.l1()) {
        tmp_0 = '<empty>';
      } else {
        tmp_0 = '<error>';
      }
      tmp = tmp_0;
    } else {
      tmp = joinToString(heads, '\n', VOID, VOID, VOID, VOID, GraphStructuredStack$toString$lambda(this));
    }
    return tmp;
  }
  get roots() {
    return this.j20();
  }
  get isEmpty() {
    return this.p11();
  }
  get numberOfHeads() {
    return this.i1u();
  }
  get hasNextHead() {
    return this.j1u();
  }
  get peekFirstHead() {
    return this.k20();
  }
  get heads() {
    return this.l20();
  }
}
class Companion_13 {}
class ToProcessPrevious {
  constructor(previous, remainingHeads) {
    this.previous = previous;
    this.remainingHeads = remainingHeads;
  }
  l1o() {
    return this.previous;
  }
  m20() {
    return this.remainingHeads;
  }
  ni() {
    return this.previous;
  }
  oi() {
    return this.remainingHeads;
  }
  n20(previous, remainingHeads) {
    return new ToProcessPrevious(previous, remainingHeads);
  }
  copy(previous, remainingHeads, $super) {
    previous = previous === VOID ? this.previous : previous;
    remainingHeads = remainingHeads === VOID ? this.remainingHeads : remainingHeads;
    return $super === VOID ? this.n20(previous, remainingHeads) : $super.n20.call(this, previous, remainingHeads);
  }
  toString() {
    return 'ToProcessPrevious(previous=' + toString_0(this.previous) + ', remainingHeads=' + toString(this.remainingHeads) + ')';
  }
  hashCode() {
    var result = this.previous == null ? 0 : this.previous.hashCode();
    result = imul(result, 31) + hashCode(this.remainingHeads) | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof ToProcessPrevious))
      return false;
    if (!equals(this.previous, other.previous))
      return false;
    if (!equals(this.remainingHeads, other.remainingHeads))
      return false;
    return true;
  }
}
class NextToProcess {
  constructor(growingNode, previous) {
    this.growingNode = growingNode;
    this.previous = previous;
  }
  o20() {
    return this.growingNode;
  }
  l1o() {
    return this.previous;
  }
  p20() {
    var tmp;
    if (this.previous.l1()) {
      tmp = listOf(new ToProcessTriple(this.growingNode, null, null));
    } else {
      // Inline function 'kotlin.collections.flatMap' call
      var tmp0 = this.previous;
      // Inline function 'kotlin.collections.flatMapTo' call
      var destination = ArrayList.o1();
      var _iterator__ex2g4s = tmp0.g1();
      while (_iterator__ex2g4s.f()) {
        var element = _iterator__ex2g4s.e();
        var tmp_0;
        if (element.remainingHeads.l1()) {
          tmp_0 = listOf(new ToProcessTriple(this.growingNode, element.previous, null));
        } else {
          // Inline function 'kotlin.collections.map' call
          var this_0 = element.remainingHeads;
          // Inline function 'kotlin.collections.mapTo' call
          var destination_0 = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
          var _iterator__ex2g4s_0 = this_0.g1();
          while (_iterator__ex2g4s_0.f()) {
            var item = _iterator__ex2g4s_0.e();
            var tmp$ret$0 = new ToProcessTriple(this.growingNode, element.previous, item);
            destination_0.v(tmp$ret$0);
          }
          tmp_0 = destination_0;
        }
        var list = tmp_0;
        addAll(destination, list);
      }
      tmp = destination;
    }
    return tmp;
  }
  ni() {
    return this.growingNode;
  }
  oi() {
    return this.previous;
  }
  q20(growingNode, previous) {
    return new NextToProcess(growingNode, previous);
  }
  copy(growingNode, previous, $super) {
    growingNode = growingNode === VOID ? this.growingNode : growingNode;
    previous = previous === VOID ? this.previous : previous;
    return $super === VOID ? this.q20(growingNode, previous) : $super.q20.call(this, growingNode, previous);
  }
  toString() {
    return 'NextToProcess(growingNode=' + this.growingNode.toString() + ', previous=' + toString(this.previous) + ')';
  }
  hashCode() {
    var result = this.growingNode.hashCode();
    result = imul(result, 31) + hashCode(this.previous) | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof NextToProcess))
      return false;
    if (!this.growingNode.equals(other.growingNode))
      return false;
    if (!equals(this.previous, other.previous))
      return false;
    return true;
  }
  get triples() {
    return this.p20();
  }
}
class ToProcessTriple {
  constructor(growingNode, previous, remainingHead) {
    this.growingNode = growingNode;
    this.previous = previous;
    this.remainingHead = remainingHead;
  }
  o20() {
    return this.growingNode;
  }
  l1o() {
    return this.previous;
  }
  r20() {
    return this.remainingHead;
  }
  toString() {
    return this.growingNode.toString() + ' ==> ' + toString_0(this.previous) + ' ==> ' + toString_0(this.remainingHead);
  }
  ni() {
    return this.growingNode;
  }
  oi() {
    return this.previous;
  }
  mm() {
    return this.remainingHead;
  }
  s20(growingNode, previous, remainingHead) {
    return new ToProcessTriple(growingNode, previous, remainingHead);
  }
  copy(growingNode, previous, remainingHead, $super) {
    growingNode = growingNode === VOID ? this.growingNode : growingNode;
    previous = previous === VOID ? this.previous : previous;
    remainingHead = remainingHead === VOID ? this.remainingHead : remainingHead;
    return $super === VOID ? this.s20(growingNode, previous, remainingHead) : $super.s20.call(this, growingNode, previous, remainingHead);
  }
  hashCode() {
    var result = this.growingNode.hashCode();
    result = imul(result, 31) + (this.previous == null ? 0 : this.previous.hashCode()) | 0;
    result = imul(result, 31) + (this.remainingHead == null ? 0 : this.remainingHead.hashCode()) | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof ToProcessTriple))
      return false;
    if (!this.growingNode.equals(other.growingNode))
      return false;
    if (!equals(this.previous, other.previous))
      return false;
    if (!equals(this.remainingHead, other.remainingHead))
      return false;
    return true;
  }
}
class Companion_14 {}
class MergeDecision {
  constructor(reason, choice, text) {
    this.reason = reason;
    this.choice = choice;
    this.text = text;
  }
  t20() {
    return this.reason;
  }
  u20() {
    return this.choice;
  }
  v20() {
    return this.text;
  }
  ni() {
    return this.reason;
  }
  oi() {
    return this.choice;
  }
  mm() {
    return this.text;
  }
  w20(reason, choice, text) {
    return new MergeDecision(reason, choice, text);
  }
  copy(reason, choice, text, $super) {
    reason = reason === VOID ? this.reason : reason;
    choice = choice === VOID ? this.choice : choice;
    text = text === VOID ? this.text : text;
    return $super === VOID ? this.w20(reason, choice, text) : $super.w20.call(this, reason, choice, text);
  }
  toString() {
    return 'MergeDecision(reason=' + toString(this.reason) + ', choice=' + this.choice.toString() + ', text=' + this.text + ')';
  }
  hashCode() {
    var result = hashCode(this.reason);
    result = imul(result, 31) + this.choice.hashCode() | 0;
    result = imul(result, 31) + getStringHashCode(this.text) | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof MergeDecision))
      return false;
    if (!equals(this.reason, other.reason))
      return false;
    if (!this.choice.equals(other.choice))
      return false;
    if (!(this.text === other.text))
      return false;
    return true;
  }
}
class MergeReason extends Enum {
  get name() {
    return this.r3();
  }
  get ordinal() {
    return this.s3();
  }
}
class MergeChoice extends Enum {
  get name() {
    return this.r3();
  }
  get ordinal() {
    return this.s3();
  }
}
class sam$kotlin_Comparator$0_6 {
  constructor(function_0) {
    this.d21_1 = function_0;
  }
  lg(a, b) {
    return this.d21_1(a, b);
  }
  compare(a, b) {
    return this.lg(a, b);
  }
  u3() {
    return this.d21_1;
  }
  equals(other) {
    var tmp;
    if (!(other == null) ? isInterface(other, Comparator) : false) {
      var tmp_0;
      if (!(other == null) ? isInterface(other, FunctionAdapter) : false) {
        tmp_0 = equals(this.u3(), other.u3());
      } else {
        tmp_0 = false;
      }
      tmp = tmp_0;
    } else {
      tmp = false;
    }
    return tmp;
  }
  hashCode() {
    return hashCode(this.u3());
  }
}
class ParseGraph {
  constructor(sentence, scanner, stateSetNumber) {
    this.y1t_1 = sentence;
    this.z1t_1 = scanner;
    this.a1u_1 = stateSetNumber;
    var tmp = this;
    // Inline function 'kotlin.collections.mutableSetOf' call
    tmp.b1u_1 = LinkedHashSet.j1();
    var tmp_0 = this;
    var tmp_1 = ParseGraph$_gss$lambda;
    tmp_0.c1u_1 = GraphStructuredStack.new_net_akehurst_language_agl_runtime_graph_GraphStructuredStack(binaryHeap(new sam$kotlin_Comparator$0_6(tmp_1)));
    this.d1u_1 = new TreeDataGrowing(this.a1u_1);
    this.e1u_1 = true;
  }
  k1u() {
    return this.b1u_1;
  }
  m1u() {
    return !this.c1u_1.isEmpty;
  }
  i1u() {
    return this.c1u_1.numberOfHeads;
  }
  j1u() {
    return this.c1u_1.hasNextHead;
  }
  k1w() {
    var root = this.c1u_1.peekFirstHead;
    return null == root ? 2147483647 : root.a1v_1;
  }
  l1w() {
    return ensureNotNull(this.c1u_1.peekFirstHead);
  }
  p11() {
    return this.c1u_1.isEmpty && this.d1u_1.isClean;
  }
  f21(state, runtimeLookaheadSet, startPosition, nextInputPositionBeforeSkip, nextInputPositionAfterSkip, numNonSkipChildren, childrenPriorities) {
    var listSize = Companion_instance_15.listSize(first_0(state.runtimeRules), numNonSkipChildren);
    return new GrowingNodeIndex(new RuntimeState(state, runtimeLookaheadSet), startPosition, nextInputPositionBeforeSkip, nextInputPositionAfterSkip, listSize, childrenPriorities);
  }
  f1u() {
    this.z1t_1.reset();
    this.c1u_1.clear();
    this.b1u_1.i3();
    this.d1u_1 = new TreeDataGrowing(this.a1u_1);
  }
  c21(head) {
    return this.c1u_1.pop(head);
  }
  n1v(gn) {
    return this.c1u_1.peekPrevious(gn);
  }
  i1w(goalState, startPosition, runtimeLookahead, initialSkipData) {
    var tmp1_safe_receiver = initialSkipData == null ? null : initialSkipData.root;
    var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : tmp1_safe_receiver.nextInputPosition;
    var nextInputPositionAfterSkip = tmp2_elvis_lhs == null ? startPosition : tmp2_elvis_lhs;
    var st = this.f21(goalState, runtimeLookahead, nextInputPositionAfterSkip, nextInputPositionAfterSkip, nextInputPositionAfterSkip, 0, emptyList());
    this.c1u_1.root(st);
    this.d1u_1.initialise(st, initialSkipData);
    return st;
  }
  e1w(head, newState, runtimeLookaheadSet, startPosition, nextInputPosition, skipData) {
    var tmp1_safe_receiver = skipData == null ? null : skipData.root;
    var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : tmp1_safe_receiver.nextInputPosition;
    var nextInputPositionAfterSkip = tmp2_elvis_lhs == null ? nextInputPosition : tmp2_elvis_lhs;
    var newHead = this.f21(newState, runtimeLookaheadSet, startPosition, nextInputPosition, nextInputPositionAfterSkip, 0, emptyList());
    if (!(null == skipData)) {
      this.d1u_1.setSkipDataAfter(newHead.b21(), skipData);
    }
    addGrowingHead(this, head, newHead);
    return true;
  }
  n1w(head, newState, runtimeLookaheadSet, startPosition, nextInputPosition, embeddedTreeData, skipData) {
    var tmp1_safe_receiver = skipData == null ? null : skipData.root;
    var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : tmp1_safe_receiver.nextInputPosition;
    var nextInputPositionAfterSkip = tmp2_elvis_lhs == null ? nextInputPosition : tmp2_elvis_lhs;
    var newHead = this.f21(newState, runtimeLookaheadSet, startPosition, nextInputPosition, nextInputPositionAfterSkip, 0, emptyList());
    if (!(null == skipData)) {
      this.d1u_1.setSkipDataAfter(newHead.b21(), skipData);
    }
    var children = embeddedTreeData.childrenFor(ensureNotNull(embeddedTreeData.root));
    var child = first_0(children).ii_1.i1(0);
    this.d1u_1.setEmbeddedChild(newHead.b21(), child, embeddedTreeData);
    addGrowingHead(this, head, newHead);
    return true;
  }
  f1w(head, previous, parentState, parentRuntimeLookaheadSet) {
    if (false) {
      // Inline function 'kotlin.check' call
      if (!head.o1c()) {
        throw IllegalStateException.t4('Check failed.');
      }
    }
    var child = head.b21();
    var childrenPriorities = head.i1c().isChoice ? listOf(head.i1c().priorityList) : head.i1c().isOptional ? listOf(head.i1c().priorityList) : head.i1c().isList ? listOf(head.i1c().priorityList) : emptyList();
    var parent = this.f21(parentState, parentRuntimeLookaheadSet, head.y1u_1, head.z1u_1, head.a1v_1, 1, childrenPriorities);
    var tmp;
    if (parent.o1c()) {
      var newParent = parent.b21();
      var existingComplete = this.d1u_1.preferred(newParent);
      var tmp_0;
      if (!(null == existingComplete)) {
        var md = mergeDecision(this, existingComplete, newParent);
        var tmp_1;
        switch (md.choice.q3_1) {
          case 1:
            tmp_1 = preferNewCompleteParentFirstChild(this, existingComplete, parent, child, previous);
            break;
          case 0:
            tmp_1 = preferExistingCompleteParentFirstChild(this, existingComplete, parent, child, previous);
            break;
          case 3:
            tmp_1 = keepBothCompleteParentsFirstChild(this, existingComplete, parent, child, previous);
            break;
          case 2:
            tmp_1 = useExistingCompleteParentFirstChild(this, parent, child, previous);
            break;
          default:
            noWhenBranchMatchedException();
            break;
        }
        tmp_0 = tmp_1;
      } else {
        this.d1u_1.setFirstChildForComplete(newParent, child, false);
        addGrowingHead(this, previous, parent);
        tmp_0 = true;
      }
      tmp = tmp_0;
    } else {
      this.d1u_1.setFirstChildForGrowing(parent, child);
      addGrowingHead(this, previous, parent);
      tmp = true;
    }
    return tmp;
  }
  c1w(head, previous, prevPrev, newParentState, newParentRuntimeLookaheadSet) {
    if (false) {
      // Inline function 'kotlin.check' call
      if (!head.o1c()) {
        throw IllegalStateException.t4('Check failed.');
      }
    }
    var child = head.b21();
    var newParentNumNonSkipChildren = previous.b1v_1 + 1 | 0;
    var childPrio = head.i1c().isChoice ? listOf(head.i1c().priorityList) : head.i1c().isOptional ? listOf(head.i1c().priorityList) : head.i1c().isList ? listOf(head.i1c().priorityList) : emptyList();
    var childrenPriorities = plus_2(previous.c1v_1, childPrio);
    var parent = this.f21(newParentState, newParentRuntimeLookaheadSet, previous.y1u_1, head.z1u_1, head.a1v_1, newParentNumNonSkipChildren, childrenPriorities);
    var tmp;
    if (parent.o1c()) {
      var newParent = parent.b21();
      var existingComplete = this.d1u_1.preferred(newParent);
      var tmp_0;
      if (!(null == existingComplete)) {
        var md = mergeDecision(this, existingComplete, newParent);
        var tmp_1;
        switch (md.choice.q3_1) {
          case 1:
            tmp_1 = preferNewCompleteParentLastChild(this, previous, parent, child, prevPrev);
            break;
          case 0:
            tmp_1 = preferExistingCompleteParentLastChild(this, previous, parent, child, prevPrev);
            break;
          case 3:
            tmp_1 = keepBothCompleteParentsLastChild(this, previous, parent, child, prevPrev);
            break;
          case 2:
            tmp_1 = useExistingCompleteParentLastChild(this, parent, child, prevPrev);
            break;
          default:
            noWhenBranchMatchedException();
            break;
        }
        tmp_0 = tmp_1;
      } else {
        this.d1u_1.setNextChildForCompleteParent(previous, newParent, child, false);
        addGrowingHead(this, prevPrev, parent);
        tmp_0 = true;
      }
      tmp = tmp_0;
    } else {
      this.d1u_1.setNextChildForGrowingParent(previous, parent, child);
      addGrowingHead(this, prevPrev, parent);
      tmp = true;
    }
    return tmp;
  }
  e21(head) {
    if (!head.q1m() && !head.o1c()) {
      this.d1u_1.removeTreeGrowing(head);
    }
  }
  m1v(head) {
    var tmp = this.c1u_1;
    var dropped = tmp.dropStack(head, ParseGraph$dropStackWithHead$lambda(this));
  }
  b1w(lookaheadGuard, eotLookahead, runtimeLookahead, nextInputPosition) {
    var tmp;
    if (lookaheadGuard.j1l_1) {
      tmp = true;
    } else if (runtimeLookahead.h1l_1) {
      var message = 'Runtime lookahead must be real lookahead values';
      throw IllegalStateException.t4(toString(message));
    } else if (eotLookahead.h1l_1) {
      var message_0 = 'EOT lookahead must be real lookahead values';
      throw IllegalStateException.t4(toString(message_0));
    } else {
      var rtResolved = runtimeLookahead.c1m(eotLookahead, runtimeLookahead);
      var lhs = lookaheadGuard.d1m(eotLookahead, rtResolved);
      var tmp_0;
      if (lhs.matchANY) {
        tmp_0 = true;
      } else if (lhs.includesEOT && this.z1t_1.isEnd(this.y1t_1, nextInputPosition)) {
        tmp_0 = true;
      } else if (lhs.content.l1()) {
        tmp_0 = false;
      } else {
        var tmp0 = lhs.content;
        var tmp$ret$0;
        $l$block_0: {
          // Inline function 'kotlin.collections.any' call
          var tmp_1;
          if (isInterface(tmp0, Collection)) {
            tmp_1 = tmp0.l1();
          } else {
            tmp_1 = false;
          }
          if (tmp_1) {
            tmp$ret$0 = false;
            break $l$block_0;
          }
          var _iterator__ex2g4s = tmp0.g1();
          while (_iterator__ex2g4s.f()) {
            var element = _iterator__ex2g4s.e();
            if (this.z1t_1.isLookingAt(this.y1t_1, nextInputPosition, element)) {
              tmp$ret$0 = true;
              break $l$block_0;
            }
          }
          tmp$ret$0 = false;
        }
        tmp_0 = tmp$ret$0;
      }
      tmp = tmp_0;
    }
    return tmp;
  }
  p1v(lookaheadGuard, eotLookahead, runtimeLookahead, nextInputPosition) {
    var tmp;
    if (lookaheadGuard.matchANY) {
      tmp = true;
    } else if (runtimeLookahead.includesRT) {
      var message = 'Runtime lookahead must be real lookahead values';
      throw IllegalStateException.t4(toString(message));
    } else if (eotLookahead.includesRT) {
      var message_0 = 'EOT lookahead must be real lookahead values';
      throw IllegalStateException.t4(toString(message_0));
    } else {
      var rtResolved = runtimeLookahead.resolve(eotLookahead, runtimeLookahead);
      var lhs = lookaheadGuard.resolve(eotLookahead, rtResolved);
      var tmp_0;
      if (lhs.matchANY) {
        tmp_0 = true;
      } else if (lhs.includesEOT && this.z1t_1.isEnd(this.y1t_1, nextInputPosition)) {
        tmp_0 = true;
      } else if (lhs.content.l1()) {
        tmp_0 = false;
      } else {
        var tmp0 = lhs.content;
        var tmp$ret$0;
        $l$block_0: {
          // Inline function 'kotlin.collections.any' call
          var tmp_1;
          if (isInterface(tmp0, Collection)) {
            tmp_1 = tmp0.l1();
          } else {
            tmp_1 = false;
          }
          if (tmp_1) {
            tmp$ret$0 = false;
            break $l$block_0;
          }
          var _iterator__ex2g4s = tmp0.g1();
          while (_iterator__ex2g4s.f()) {
            var element = _iterator__ex2g4s.e();
            if (this.z1t_1.isLookingAt(this.y1t_1, nextInputPosition, element)) {
              tmp$ret$0 = true;
              break $l$block_0;
            }
          }
          tmp$ret$0 = false;
        }
        tmp_0 = tmp$ret$0;
      }
      tmp = tmp_0;
    }
    return tmp;
  }
  l1v(goal) {
    doRecordGoal(this, goal.b21());
  }
  toString() {
    var heads = this.c1u_1.heads;
    var tmp = 'Heads [' + heads.h1() + '] \n';
    return tmp + joinToString(heads, '\n', VOID, VOID, VOID, VOID, ParseGraph$toString$lambda(this));
  }
}
class RuntimeState {
  constructor(state, runtimeLookaheadSet) {
    this.f1v_1 = state;
    this.g1v_1 = runtimeLookaheadSet;
    var tmp = this;
    tmp.h1v_1 = lazy(RuntimeState$uncompressed$delegate$lambda(this));
    var tmp_0 = this;
    // Inline function 'kotlin.arrayOf' call
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    var tmp$ret$2 = [this.f1v_1, this.g1v_1];
    tmp_0.i1v_1 = contentHashCode(tmp$ret$2);
  }
  t1j() {
    return this.f1v_1.isAtEnd;
  }
  k1m() {
    return this.f1v_1.optionList;
  }
  j1v(previous) {
    return this.f1v_1.transitionsGoal(previous);
  }
  o1v(previous) {
    return this.f1v_1.transitionsInComplete(previous);
  }
  q1v(previous, prevPrev) {
    return this.f1v_1.transitionsComplete(previous, prevPrev);
  }
  hashCode() {
    return this.i1v_1;
  }
  equals(other) {
    var tmp;
    if (!(other instanceof RuntimeState)) {
      tmp = false;
    } else {
      if (!this.f1v_1.equals(other.f1v_1)) {
        tmp = false;
      } else {
        if (!equals(this.g1v_1, other.g1v_1)) {
          tmp = false;
        } else {
          tmp = true;
        }
      }
    }
    return tmp;
  }
  toString() {
    var tmp = toString(this.f1v_1.j1i_1);
    return 'RS{' + tmp + '[' + joinToString(this.g1v_1, '|', VOID, VOID, VOID, VOID, RuntimeState$toString$lambda) + ']}';
  }
}
class StateInfoUncompressed {
  constructor(rulePosition, follow) {
    this.g21_1 = rulePosition;
    this.h21_1 = follow;
  }
  toString() {
    return 'StateInfoUncompressed(rulePosition=' + this.g21_1.toString() + ', follow=' + toString(this.h21_1) + ')';
  }
  hashCode() {
    var result = this.g21_1.hashCode();
    result = imul(result, 31) + hashCode(this.h21_1) | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof StateInfoUncompressed))
      return false;
    if (!this.g21_1.equals(other.g21_1))
      return false;
    if (!equals(this.h21_1, other.h21_1))
      return false;
    return true;
  }
}
class Companion_15 {
  listSize(runtimeRule, numNonSkipChildren) {
    var tmp0_subject = runtimeRule.rhs;
    var tmp;
    if (tmp0_subject instanceof RuntimeRuleRhsNonTerminal) {
      tmp = numNonSkipChildren;
    } else {
      if (tmp0_subject instanceof RuntimeRuleRhsTerminal) {
        tmp = 0;
      } else {
        noWhenBranchMatchedException();
      }
    }
    return tmp;
  }
}
class GrowingNodeIndex {
  constructor(runtimeState, startPosition, nextInputPositionBeforeSkip, nextInputPositionAfterSkip, numNonSkipChildren, childrenPriorities) {
    this.x1u_1 = runtimeState;
    this.y1u_1 = startPosition;
    this.z1u_1 = nextInputPositionBeforeSkip;
    this.a1v_1 = nextInputPositionAfterSkip;
    this.b1v_1 = numNonSkipChildren;
    this.c1v_1 = childrenPriorities;
    var tmp = this;
    tmp.d1v_1 = lazy(GrowingNodeIndex$complete$delegate$lambda(this));
    var tmp_0 = this;
    // Inline function 'kotlin.arrayOf' call
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    var tmp$ret$2 = [this.x1u_1, this.y1u_1, this.a1v_1, this.b1v_1];
    tmp_0.e1v_1 = contentHashCode(tmp$ret$2);
  }
  b21() {
    var tmp0 = this.d1v_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('complete', 1, tmp, GrowingNodeIndex$_get_complete_$ref_4k948s(), null);
    return tmp0.b2();
  }
  d1d() {
    // Inline function 'kotlin.collections.map' call
    var this_0 = this.c1v_1;
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var tmp$ret$0 = item.i1(0);
      destination.v(tmp$ret$0);
    }
    return destination;
  }
  o1c() {
    return this.x1u_1.t1j();
  }
  h19() {
    return this.x1u_1.f1v_1.isGoal;
  }
  i1c() {
    return this.x1u_1.f1v_1;
  }
  q1m() {
    return this.x1u_1.f1v_1.isLeaf;
  }
  p1c() {
    return this.y1u_1 === this.z1u_1;
  }
  hashCode() {
    return this.e1v_1;
  }
  equals(other) {
    var tmp;
    if (!(other instanceof GrowingNodeIndex)) {
      tmp = false;
    } else {
      tmp = !this.x1u_1.equals(other.x1u_1) ? false : !(this.y1u_1 === other.y1u_1) ? false : !(this.a1v_1 === other.a1v_1) ? false : !(this.b1v_1 === other.b1v_1) ? false : true;
    }
    return tmp;
  }
  toString() {
    // Inline function 'kotlin.collections.map' call
    var this_0 = this.x1u_1.g1v_1;
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var tmp = item.m1l();
      var tmp$ret$0 = joinToString(tmp, VOID, VOID, VOID, VOID, VOID, GrowingNodeIndex$toString$lambda);
      destination.v(tmp$ret$0);
    }
    var ct = destination;
    var ctStr = joinToString(ct, '|', '[', ']', VOID, VOID, GrowingNodeIndex$toString$lambda_0);
    return 'GNI{state=' + this.x1u_1.f1v_1.toString() + ',lhs=' + ctStr + ',sp=' + this.y1u_1 + ',np=' + this.a1v_1 + ',nc=' + this.b1v_1 + '}';
  }
}
class RuleOption {
  constructor(runtimeRule, option) {
    this.runtimeRule = runtimeRule;
    this.option = option;
    this.isGoal = this.runtimeRule.isGoal;
  }
  i21() {
    return this.runtimeRule;
  }
  c1d() {
    return this.option;
  }
  h19() {
    return this.isGoal;
  }
  toString() {
    return 'RuleOption{' + this.runtimeRule.tag + ',' + this.option.toString() + '}';
  }
  ni() {
    return this.runtimeRule;
  }
  oi() {
    return this.option;
  }
  j21(runtimeRule, option) {
    return new RuleOption(runtimeRule, option);
  }
  copy(runtimeRule, option, $super) {
    runtimeRule = runtimeRule === VOID ? this.runtimeRule : runtimeRule;
    option = option === VOID ? this.option : option;
    return $super === VOID ? this.j21(runtimeRule, option) : $super.j21.call(this, runtimeRule, option);
  }
  hashCode() {
    var result = this.runtimeRule.hashCode();
    result = imul(result, 31) + this.option.hashCode() | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof RuleOption))
      return false;
    if (!this.runtimeRule.equals(other.runtimeRule))
      return false;
    if (!this.option.equals(other.option))
      return false;
    return true;
  }
}
class RulePositionRuntime {
  constructor(rule, option, position) {
    this.k1b_1 = rule;
    this.l1b_1 = option;
    this.m1b_1 = position;
    this.identity = new RuleOption(this.k1b_1, this.l1b_1);
    var tmp = this;
    // Inline function 'kotlin.arrayOf' call
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    var tmp$ret$2 = [this.k1b_1, this.l1b_1, this.m1b_1];
    tmp.n1b_1 = contentHashCode(tmp$ret$2);
  }
  y1c() {
    return this.k1b_1;
  }
  c1d() {
    return this.l1b_1;
  }
  o1z() {
    return this.m1b_1;
  }
  sz() {
    return this.identity;
  }
  s1j() {
    return 0 === this.m1b_1;
  }
  t1j() {
    return -1 === this.m1b_1;
  }
  h19() {
    return this.k1b_1.isGoal;
  }
  b1y() {
    return this.k1b_1.isTerminal;
  }
  h1y() {
    return this.k1b_1.isEmbedded;
  }
  m16() {
    var tmp;
    if (this.isAtEnd) {
      tmp = emptySet();
    } else {
      tmp = this.k1b_1.rhs.rhsItemsAt(this.l1b_1, this.m1b_1);
    }
    return tmp;
  }
  p1z() {
    var ps = this.k1b_1.w1d_1 ? 'pseudo ' : '';
    var tmp;
    if (this.k1b_1.isTerminal) {
      tmp = this.k1b_1.tag === this.k1b_1.rhs.asString ? this.k1b_1.tag : this.k1b_1.tag + '(' + this.k1b_1.rhs.asString + ')';
    } else if (this.k1b_1.isChoice) {
      var tmp_0 = this.k1b_1.rhs;
      var choice = (tmp_0 instanceof RuntimeRuleRhsChoice ? tmp_0 : THROW_CCE()).options.i1(this.l1b_1.asIndex);
      var items = choice.rhsItems.i1(0);
      var pos = this.m1b_1 === -1 ? items.h1() : this.m1b_1;
      var tmp_1 = until(0, pos);
      var before = joinToString(tmp_1, ' ', VOID, VOID, VOID, VOID, RulePositionRuntime$_get_asString_$lambda_kh5w9a(items));
      var tmp_2 = until(pos, items.h1());
      var after = joinToString(tmp_2, ' ', VOID, VOID, VOID, VOID, RulePositionRuntime$_get_asString_$lambda_kh5w9a_0(items));
      tmp = ps + this.k1b_1.tag + ' = ' + before + ' . ' + after;
    } else if (this.k1b_1.isListSimple) {
      var tmp_3;
      if (this.l1b_1.isEmpty) {
        tmp_3 = '[EMPTY ' + this.k1b_1.rhsItems.i1(0).i1(0).tag + '] .';
      } else {
        switch (this.m1b_1) {
          case 0:
            tmp_3 = '. [' + this.k1b_1.rhsItems.i1(0).i1(0).tag + ']';
            break;
          case -1:
            tmp_3 = '[' + this.k1b_1.rhsItems.i1(0).i1(0).tag + '] .';
            break;
          case 1:
            tmp_3 = '[' + this.k1b_1.rhsItems.i1(0).i1(0).tag + ' . ' + this.k1b_1.rhsItems.i1(0).i1(0).tag + ']';
            break;
          default:
            tmp_3 = '???';
            break;
        }
      }
      tmp = tmp_3;
    } else if (this.k1b_1.isListSeparated) {
      var tmp_4;
      if (this.l1b_1.isEmpty) {
        tmp_4 = '[EMPTY ' + this.k1b_1.rhsItems.i1(0).i1(0).tag + ' sep ' + this.k1b_1.rhsItems.i1(1).i1(0).tag + '] .';
      } else {
        switch (this.m1b_1) {
          case 0:
            tmp_4 = '. [' + this.k1b_1.rhsItems.i1(0).i1(0).tag + ' sep ' + this.k1b_1.rhsItems.i1(1).i1(0).tag + ']';
            break;
          case -1:
            tmp_4 = '[' + this.k1b_1.rhsItems.i1(0).i1(0).tag + ' sep ' + this.k1b_1.rhsItems.i1(1).i1(0).tag + '] .';
            break;
          case 2:
            tmp_4 = '[' + this.k1b_1.rhsItems.i1(0).i1(0).tag + ' . ' + this.k1b_1.rhsItems.i1(0).i1(0).tag + ' sep ' + this.k1b_1.rhsItems.i1(1).i1(0).tag + ']';
            break;
          case 1:
            tmp_4 = '[' + this.k1b_1.rhsItems.i1(1).i1(0).tag + ' . ' + this.k1b_1.rhsItems.i1(0).i1(0).tag + ' sep ' + this.k1b_1.rhsItems.i1(1).i1(0).tag + ']';
            break;
          default:
            tmp_4 = '???';
            break;
        }
      }
      tmp = tmp_4;
    } else {
      var items_0 = this.k1b_1.rhsItems.i1(0);
      var pos_0 = this.m1b_1 === -1 ? items_0.h1() : this.m1b_1;
      var tmp_5 = until(0, pos_0);
      var before_0 = joinToString(tmp_5, ' ', VOID, VOID, VOID, VOID, RulePositionRuntime$_get_asString_$lambda_kh5w9a_1(items_0));
      var tmp_6 = until(pos_0, items_0.h1());
      var after_0 = joinToString(tmp_6, ' ', VOID, VOID, VOID, VOID, RulePositionRuntime$_get_asString_$lambda_kh5w9a_2(items_0));
      tmp = ps + this.k1b_1.tag + ' = ' + before_0 + ' . ' + after_0;
    }
    return tmp;
  }
  atEnd() {
    return new RulePositionRuntime(this.k1b_1, this.l1b_1, -1);
  }
  next() {
    return this.isAtEnd ? emptySet() : this.k1b_1.rhs.nextRulePositions(this);
  }
  hashCode() {
    return this.n1b_1;
  }
  equals(other) {
    var tmp;
    if (!(other instanceof RulePositionRuntime)) {
      tmp = false;
    } else {
      if (!(this.m1b_1 === other.m1b_1)) {
        tmp = false;
      } else {
        if (!this.l1b_1.equals(other.l1b_1)) {
          tmp = false;
        } else {
          if (!this.k1b_1.equals(other.k1b_1)) {
            tmp = false;
          } else {
            tmp = true;
          }
        }
      }
    }
    return tmp;
  }
  toString() {
    var r = this.k1b_1.equals(Companion_getInstance_17().END_OF_TEXT) ? '<EOT>' : this.k1b_1.tag;
    var rhs = this.k1b_1.rhs;
    var o = this.l1b_1.toString();
    var pos;
    switch (this.m1b_1) {
      case 0:
        pos = 'SR';
        break;
      case -1:
        pos = 'ER';
        break;
      default:
        pos = this.m1b_1.toString();
        break;
    }
    var tmp;
    if (rhs instanceof RuntimeRuleRhsTerminal) {
      tmp = pos;
    } else {
      if (rhs instanceof RuntimeRuleRhsNonTerminal) {
        var tmp_0;
        if (rhs instanceof RuntimeRuleRhsGoal) {
          tmp_0 = pos;
        } else {
          if (rhs instanceof RuntimeRuleRhsConcatenation) {
            tmp_0 = pos;
          } else {
            if (rhs instanceof RuntimeRuleRhsChoice) {
              tmp_0 = pos;
            } else {
              if (rhs instanceof RuntimeRuleRhsOptional) {
                switch (this.m1b_1) {
                  case 0:
                    tmp_0 = 'BR';
                    break;
                  case -1:
                    tmp_0 = 'ER';
                    break;
                  default:
                    tmp_0 = pos;
                    break;
                }
              } else {
                if (rhs instanceof RuntimeRuleRhsList) {
                  var tmp_1;
                  if (rhs instanceof RuntimeRuleRhsListSimple) {
                    switch (this.m1b_1) {
                      case 0:
                        tmp_1 = 'BR';
                        break;
                      case 1:
                        tmp_1 = 'MI';
                        break;
                      case -1:
                        tmp_1 = 'ER';
                        break;
                      default:
                        tmp_1 = pos;
                        break;
                    }
                  } else {
                    if (rhs instanceof RuntimeRuleRhsListSeparated) {
                      switch (this.m1b_1) {
                        case 0:
                          tmp_1 = 'BR';
                          break;
                        case 1:
                          tmp_1 = 'LS';
                          break;
                        case 2:
                          tmp_1 = 'LI';
                          break;
                        case -1:
                          tmp_1 = 'ER';
                          break;
                        default:
                          tmp_1 = pos;
                          break;
                      }
                    } else {
                      noWhenBranchMatchedException();
                    }
                  }
                  tmp_0 = tmp_1;
                } else {
                  noWhenBranchMatchedException();
                }
              }
            }
          }
        }
        tmp = tmp_0;
      } else {
        noWhenBranchMatchedException();
      }
    }
    var p = tmp;
    return 'RP(' + this.k1b_1.t1d_1 + '/' + r + ',' + o + ',' + p + ')';
  }
  get rule() {
    return this.y1c();
  }
  get option() {
    return this.c1d();
  }
  get position() {
    return this.o1z();
  }
  get isAtStart() {
    return this.s1j();
  }
  get isAtEnd() {
    return this.t1j();
  }
  get isGoal() {
    return this.h19();
  }
  get isTerminal() {
    return this.b1y();
  }
  get isEmbedded() {
    return this.h1y();
  }
  get items() {
    return this.m16();
  }
  get asString() {
    return this.p1z();
  }
}
class RuntimePreferenceOption {
  constructor(precedence, spine, option, operators, associativity) {
    this.u1v_1 = precedence;
    this.v1v_1 = spine;
    this.w1v_1 = option;
    this.x1v_1 = operators;
    this.y1v_1 = associativity;
  }
  s1y() {
    return this.u1v_1;
  }
  r1t() {
    return this.v1v_1;
  }
  c1d() {
    return this.w1v_1;
  }
  t1y() {
    return this.x1v_1;
  }
  u1y() {
    return this.y1v_1;
  }
  ni() {
    return this.u1v_1;
  }
  oi() {
    return this.v1v_1;
  }
  mm() {
    return this.w1v_1;
  }
  d16() {
    return this.x1v_1;
  }
  g1c() {
    return this.y1v_1;
  }
  k21(precedence, spine, option, operators, associativity) {
    return new RuntimePreferenceOption(precedence, spine, option, operators, associativity);
  }
  copy(precedence, spine, option, operators, associativity, $super) {
    precedence = precedence === VOID ? this.u1v_1 : precedence;
    spine = spine === VOID ? this.v1v_1 : spine;
    option = option === VOID ? this.w1v_1 : option;
    operators = operators === VOID ? this.x1v_1 : operators;
    associativity = associativity === VOID ? this.y1v_1 : associativity;
    return $super === VOID ? this.k21(precedence, spine, option, operators, associativity) : $super.k21.call(this, precedence, spine, option, operators, associativity);
  }
  toString() {
    return 'RuntimePreferenceOption(precedence=' + this.u1v_1 + ', spine=' + toString(this.v1v_1) + ', option=' + this.w1v_1.toString() + ', operators=' + toString(this.x1v_1) + ', associativity=' + this.y1v_1.toString() + ')';
  }
  hashCode() {
    var result = this.u1v_1;
    result = imul(result, 31) + hashCode(this.v1v_1) | 0;
    result = imul(result, 31) + this.w1v_1.hashCode() | 0;
    result = imul(result, 31) + hashCode(this.x1v_1) | 0;
    result = imul(result, 31) + this.y1v_1.hashCode() | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof RuntimePreferenceOption))
      return false;
    if (!(this.u1v_1 === other.u1v_1))
      return false;
    if (!equals(this.v1v_1, other.v1v_1))
      return false;
    if (!this.w1v_1.equals(other.w1v_1))
      return false;
    if (!equals(this.x1v_1, other.x1v_1))
      return false;
    if (!this.y1v_1.equals(other.y1v_1))
      return false;
    return true;
  }
  get precedence() {
    return this.s1y();
  }
  get spine() {
    return this.r1t();
  }
  get option() {
    return this.c1d();
  }
  get operators() {
    return this.t1y();
  }
  get associativity() {
    return this.u1y();
  }
}
class RuntimePreferenceRule {
  constructor(contextRule, options) {
    this.z1v_1 = contextRule;
    this.a1w_1 = options;
  }
  o1y() {
    return this.z1v_1;
  }
  p1y() {
    return this.a1w_1;
  }
  get contextRule() {
    return this.o1y();
  }
  get options() {
    return this.p1y();
  }
}
class RuntimeRule {
  constructor(ruleSetNumber, number, name, isSkip, isPseudo) {
    this.t1d_1 = ruleSetNumber;
    this.u1d_1 = number;
    this.name = name;
    this.v1d_1 = isSkip;
    this.w1d_1 = isPseudo;
    var tmp = this;
    tmp.y1d_1 = lazy(RuntimeRule$asTerminalRulePosition$delegate$lambda(this));
    var tmp_0 = this;
    // Inline function 'kotlin.arrayOf' call
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    var tmp$ret$2 = [this.t1d_1, this.u1d_1];
    tmp_0.z1d_1 = contentHashCode(tmp$ret$2);
  }
  y1x() {
    return this.t1d_1;
  }
  r1b() {
    return this.u1d_1;
  }
  r3() {
    return this.name;
  }
  u1f() {
    return this.v1d_1;
  }
  a1y() {
    return this.w1d_1;
  }
  setRhs(value) {
    this.x1d_1 = value;
  }
  d1o() {
    return _get__rhs__d2tz9p(this);
  }
  l21() {
    return !(this.name == null);
  }
  z1x() {
    var tmp0_elvis_lhs = this.name;
    var tmp;
    if (tmp0_elvis_lhs == null) {
      var tmp_0;
      if (this.isTerminal) {
        var tmp_1 = this.rhs;
        tmp_0 = toString(tmp_1 instanceof RuntimeRuleRhsTerminal ? tmp_1 : THROW_CCE());
      } else {
        // Inline function 'kotlin.error' call
        var message = 'Internal Error: no tag';
        throw IllegalStateException.t4(toString(message));
      }
      tmp = tmp_0;
    } else {
      tmp = tmp0_elvis_lhs;
    }
    return tmp;
  }
  h19() {
    var tmp = this.rhs;
    return tmp instanceof RuntimeRuleRhsGoal;
  }
  c1y() {
    return this.equals(Companion_getInstance_17().END_OF_TEXT);
  }
  d1y() {
    var tmp = this.rhs;
    return tmp instanceof RuntimeRuleRhsEmpty;
  }
  e1y() {
    var tmp = this.rhs;
    return tmp instanceof RuntimeRuleRhsEmptyList;
  }
  h1y() {
    var tmp = this.rhs;
    return tmp instanceof RuntimeRuleRhsEmbedded;
  }
  g1y() {
    var tmp = this.rhs;
    return tmp instanceof RuntimeRuleRhsPattern;
  }
  f1y() {
    var tmp = this.rhs;
    return tmp instanceof RuntimeRuleRhsLiteral;
  }
  b1y() {
    var tmp0_subject = this.rhs;
    var tmp;
    if (tmp0_subject instanceof RuntimeRuleRhsNonTerminal) {
      tmp = false;
    } else {
      if (tmp0_subject instanceof RuntimeRuleRhsEmpty) {
        tmp = true;
      } else {
        if (tmp0_subject instanceof RuntimeRuleRhsEmptyList) {
          tmp = true;
        } else {
          if (tmp0_subject instanceof RuntimeRuleRhsLiteral) {
            tmp = true;
          } else {
            if (tmp0_subject instanceof RuntimeRuleRhsPattern) {
              tmp = true;
            } else {
              if (tmp0_subject instanceof RuntimeRuleRhsEmbedded) {
                tmp = true;
              } else {
                if (tmp0_subject instanceof RuntimeRuleRhsCommonTerminal) {
                  tmp = true;
                } else {
                  noWhenBranchMatchedException();
                }
              }
            }
          }
        }
      }
    }
    return tmp;
  }
  m21() {
    var tmp0_subject = this.rhs;
    var tmp;
    if (tmp0_subject instanceof RuntimeRuleRhsTerminal) {
      tmp = false;
    } else {
      if (tmp0_subject instanceof RuntimeRuleRhsGoal) {
        tmp = true;
      } else {
        if (tmp0_subject instanceof RuntimeRuleRhsConcatenation) {
          tmp = true;
        } else {
          if (tmp0_subject instanceof RuntimeRuleRhsChoice) {
            tmp = true;
          } else {
            if (tmp0_subject instanceof RuntimeRuleRhsOptional) {
              tmp = true;
            } else {
              if (tmp0_subject instanceof RuntimeRuleRhsList) {
                tmp = true;
              } else {
                noWhenBranchMatchedException();
              }
            }
          }
        }
      }
    }
    return tmp;
  }
  m1m() {
    var tmp = this.rhs;
    return tmp instanceof RuntimeRuleRhsChoice;
  }
  i1y() {
    var tmp;
    if (this.isChoice) {
      var tmp_0 = this.rhs;
      tmp = (tmp_0 instanceof RuntimeRuleRhsChoice ? tmp_0 : THROW_CCE()).choiceKind.equals(RuntimeRuleChoiceKind_AMBIGUOUS_getInstance());
    } else {
      tmp = false;
    }
    return tmp;
  }
  n1m() {
    var tmp = this.rhs;
    return tmp instanceof RuntimeRuleRhsOptional;
  }
  l1y() {
    var tmp;
    var tmp_0 = this.rhs;
    if (tmp_0 instanceof RuntimeRuleRhsList) {
      var tmp_1 = this.rhs;
      tmp = 0 === (tmp_1 instanceof RuntimeRuleRhsList ? tmp_1 : THROW_CCE()).min;
    } else {
      tmp = false;
    }
    return tmp;
  }
  o1m() {
    var tmp = this.rhs;
    return tmp instanceof RuntimeRuleRhsList;
  }
  j1y() {
    var tmp = this.rhs;
    return tmp instanceof RuntimeRuleRhsListSimple;
  }
  k1y() {
    var tmp = this.rhs;
    return tmp instanceof RuntimeRuleRhsListSeparated;
  }
  y1e() {
    var tmp0 = this.y1d_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('asTerminalRulePosition', 1, tmp, RuntimeRule$_get_asTerminalRulePosition_$ref_m1naq1(), null);
    return tmp0.b2();
  }
  b1l() {
    return plus_3(this.d1f(), this.x1j());
  }
  x1j() {
    return this.rhs.rulePositionsNotAtStart;
  }
  d1f() {
    return this.rhs.rulePositionsAtStart;
  }
  m1y() {
    return this.rhs.rhsItems;
  }
  n1y() {
    var tmp0_subject = this.rhs;
    var tmp;
    if (tmp0_subject instanceof RuntimeRuleRhsLiteral) {
      var tmp_0 = this.rhs;
      tmp = (tmp_0 instanceof RuntimeRuleRhsLiteral ? tmp_0 : THROW_CCE()).literalUnescaped.w1a_1;
    } else {
      if (tmp0_subject instanceof RuntimeRuleRhsPattern) {
        var tmp_1 = this.rhs;
        tmp = (tmp_1 instanceof RuntimeRuleRhsPattern ? tmp_1 : THROW_CCE()).patternUnescaped.u1a_1;
      } else {
        var message = "'unescapedTerminalValue' is only valid for Literals and Patterns";
        throw IllegalStateException.t4(toString(message));
      }
    }
    return tmp;
  }
  p1z() {
    var ps = this.w1d_1 ? 'pseudo ' : '';
    var tmp;
    if (this.isTerminal) {
      tmp = this.tag === this.rhs.asString ? this.tag : this.tag + '(' + this.rhs.asString + ')';
    } else if (this.isNonTerminal) {
      tmp = ps + this.tag + ' = ' + this.rhs.asString;
    } else {
      var message = 'All rules should be either Terminal or NonTerminal';
      throw IllegalStateException.t4(toString(message));
    }
    return tmp;
  }
  hashCode() {
    return this.z1d_1;
  }
  equals(other) {
    var tmp;
    if (!(other instanceof RuntimeRule)) {
      tmp = false;
    } else {
      if (!(this.t1d_1 === other.t1d_1)) {
        tmp = false;
      } else {
        if (!(this.u1d_1 === other.u1d_1)) {
          tmp = false;
        } else {
          tmp = true;
        }
      }
    }
    return tmp;
  }
  toString() {
    var tmp;
    if (this.isTerminal) {
      tmp = this.tag === toString(this.rhs) ? this.tag : this.tag + '(' + toString(this.rhs) + ')';
    } else if (this.isNonTerminal) {
      tmp = this.tag + ' = ' + toString(this.rhs);
    } else {
      var message = 'All rules should be either Terminal or NonTerminal';
      throw IllegalStateException.t4(toString(message));
    }
    return tmp;
  }
  get ruleSetNumber() {
    return this.y1x();
  }
  get number() {
    return this.r1b();
  }
  get isSkip() {
    return this.u1f();
  }
  get isPseudo() {
    return this.a1y();
  }
  get rhs() {
    return this.d1o();
  }
  get isExplicitlyNamed() {
    return this.l21();
  }
  get tag() {
    return this.z1x();
  }
  get isGoal() {
    return this.h19();
  }
  get isEndOfText() {
    return this.c1y();
  }
  get isEmptyTerminal() {
    return this.d1y();
  }
  get isEmptyListTerminal() {
    return this.e1y();
  }
  get isEmbedded() {
    return this.h1y();
  }
  get isPattern() {
    return this.g1y();
  }
  get isLiteral() {
    return this.f1y();
  }
  get isTerminal() {
    return this.b1y();
  }
  get isNonTerminal() {
    return this.m21();
  }
  get isChoice() {
    return this.m1m();
  }
  get isChoiceAmbiguous() {
    return this.i1y();
  }
  get isOptional() {
    return this.n1m();
  }
  get isListOptional() {
    return this.l1y();
  }
  get isList() {
    return this.o1m();
  }
  get isListSimple() {
    return this.j1y();
  }
  get isListSeparated() {
    return this.k1y();
  }
  get rhsItems() {
    return this.m1y();
  }
  get unescapedTerminalValue() {
    return this.n1y();
  }
  get asString() {
    return this.p1z();
  }
}
class RuntimeRuleKind extends Enum {
  get name() {
    return this.r3();
  }
  get ordinal() {
    return this.s3();
  }
}
class RuntimeRuleRhsItemsKind extends Enum {
  get name() {
    return this.r3();
  }
  get ordinal() {
    return this.s3();
  }
}
class RuntimeRuleListKind extends Enum {
  get name() {
    return this.r3();
  }
  get ordinal() {
    return this.s3();
  }
}
class RuntimeRuleChoiceKind extends Enum {
  get name() {
    return this.r3();
  }
  get ordinal() {
    return this.s3();
  }
}
class RuntimeRuleRhs {
  constructor(rule) {
    this.rule = rule;
  }
  y1c() {
    return this.rule;
  }
  p1z() {
    return toString(this);
  }
  get rhsItems() {
    return this.m1y();
  }
  get rulePositionsNotAtStart() {
    return this.v21();
  }
  get rulePositionsAtStart() {
    return this.w21();
  }
  get asString() {
    return this.p1z();
  }
}
class RuntimeRuleRhsTerminal extends RuntimeRuleRhs {
  m1y() {
    return emptyList();
  }
  v21() {
    return emptySet();
  }
  w21() {
    return emptySet();
  }
  rhsItemsAt(option, position) {
    return emptySet();
  }
  nextRulePositions(current) {
    return emptySet();
  }
  get matchable() {
    return this.x21();
  }
}
class RuntimeRuleRhsEmpty extends RuntimeRuleRhsTerminal {
  constructor(rule) {
    super(rule);
    this.y21_1 = null;
  }
  x21() {
    return this.y21_1;
  }
  clone(clonedRules) {
    return new RuntimeRuleRhsEmpty(this.rule);
  }
  toString() {
    return Companion_getInstance_17().EMPTY.tag;
  }
}
class RuntimeRuleRhsEmptyList extends RuntimeRuleRhsTerminal {
  constructor(rule) {
    super(rule);
    this.z21_1 = null;
  }
  x21() {
    return this.z21_1;
  }
  clone(clonedRules) {
    return new RuntimeRuleRhsEmptyList(this.rule);
  }
  toString() {
    return Companion_getInstance_17().EMPTY_LIST.tag;
  }
}
class RuntimeRuleRhsCommonTerminal extends RuntimeRuleRhsTerminal {
  constructor(rule) {
    super(rule);
    var tmp = this;
    tmp.a22_1 = lazy(RuntimeRuleRhsCommonTerminal$matchable$delegate$lambda(rule));
  }
  x21() {
    var tmp0 = this.a22_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('matchable', 1, tmp, RuntimeRuleRhsCommonTerminal$_get_matchable_$ref_xni4p9(), null);
    return tmp0.b2();
  }
  clone(clonedRules) {
    return new RuntimeRuleRhsCommonTerminal(ensureNotNull(clonedRules.c3(this.rule.tag)));
  }
  toString() {
    return this.rule.tag;
  }
}
class RuntimeRuleRhsPattern extends RuntimeRuleRhsTerminal {
  constructor(rule, patternUnescaped) {
    super(rule);
    this.patternUnescaped = patternUnescaped;
    var tmp = this;
    tmp.a1m_1 = lazy(RuntimeRuleRhsPattern$matchable$delegate$lambda(rule, this));
  }
  b22() {
    return this.patternUnescaped;
  }
  x21() {
    var tmp0 = this.a1m_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('matchable', 1, tmp, RuntimeRuleRhsPattern$_get_matchable_$ref_fs06ck(), null);
    return tmp0.b2();
  }
  clone(clonedRules) {
    return new RuntimeRuleRhsPattern(ensureNotNull(clonedRules.c3(this.rule.tag)), this.patternUnescaped);
  }
  toString() {
    return '"' + this.patternUnescaped.u1a_1 + '"';
  }
}
class RuntimeRuleRhsLiteral extends RuntimeRuleRhsTerminal {
  constructor(rule, literalUnescaped) {
    super(rule);
    this.literalUnescaped = literalUnescaped;
    var tmp = this;
    tmp.z1l_1 = lazy(RuntimeRuleRhsLiteral$matchable$delegate$lambda(rule, this));
  }
  c22() {
    return this.literalUnescaped;
  }
  x21() {
    var tmp0 = this.z1l_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('matchable', 1, tmp, RuntimeRuleRhsLiteral$_get_matchable_$ref_p6e18j(), null);
    return tmp0.b2();
  }
  clone(clonedRules) {
    return new RuntimeRuleRhsLiteral(ensureNotNull(clonedRules.c3(this.rule.tag)), this.literalUnescaped);
  }
  toString() {
    return "'" + this.literalUnescaped.w1a_1 + "'";
  }
}
class RuntimeRuleRhsEmbedded extends RuntimeRuleRhsTerminal {
  constructor(rule, embeddedRuntimeRuleSet, embeddedStartRule) {
    super(rule);
    this.embeddedRuntimeRuleSet = embeddedRuntimeRuleSet;
    this.embeddedStartRule = embeddedStartRule;
    this.x1e_1 = null;
  }
  p1n() {
    return this.embeddedRuntimeRuleSet;
  }
  d22() {
    return this.embeddedStartRule;
  }
  x21() {
    return this.x1e_1;
  }
  clone(clonedRules) {
    var emClone = this.embeddedRuntimeRuleSet.clone();
    return new RuntimeRuleRhsEmbedded(ensureNotNull(clonedRules.c3(this.rule.tag)), emClone, emClone.findRuntimeRule(this.embeddedStartRule.tag));
  }
  p1z() {
    return 'EMBED ::' + this.embeddedStartRule.tag;
  }
  toString() {
    return 'EMBED ' + this.embeddedRuntimeRuleSet.number + '::' + this.embeddedStartRule.tag + '[' + this.embeddedStartRule.u1d_1 + ']';
  }
}
class RuntimeRuleRhsNonTerminal extends RuntimeRuleRhs {}
class RuntimeRuleRhsGoal extends RuntimeRuleRhsNonTerminal {
  constructor(rule, userGoalRuleItem) {
    super(rule);
    this.userGoalRuleItem = userGoalRuleItem;
    this.e22_1 = listOf(listOf(this.userGoalRuleItem));
  }
  f22() {
    return this.userGoalRuleItem;
  }
  m1y() {
    return this.e22_1;
  }
  v21() {
    return setOf_0([new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_NONE, 0), new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_NONE, -1)]);
  }
  w21() {
    return setOf(new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_NONE, 0));
  }
  rhsItemsAt(option, position) {
    return position === 0 ? setOf(this.userGoalRuleItem) : emptySet();
  }
  nextRulePositions(current) {
    return current.isAtStart ? setOf(last_0(this.rulePositionsNotAtStart)) : emptySet();
  }
  clone(clonedRules) {
    return new RuntimeRuleRhsGoal(ensureNotNull(clonedRules.c3(this.rule.tag)), ensureNotNull(clonedRules.c3(this.userGoalRuleItem.tag)));
  }
  toString() {
    return 'GOAL (' + this.userGoalRuleItem.tag + '[' + this.userGoalRuleItem.u1d_1 + ']';
  }
}
class RuntimeRuleRhsConcatenation extends RuntimeRuleRhsNonTerminal {
  constructor(rule, concatItems) {
    super(rule);
    this.concatItems = concatItems;
  }
  g22() {
    return this.concatItems;
  }
  m1y() {
    return listOf(this.concatItems);
  }
  v21() {
    return toSet(_get__rulePositions__zi96g4(this));
  }
  w21() {
    return setOf(new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_NONE, 0));
  }
  rhsItemsAt(option, position) {
    return position < this.concatItems.h1() ? setOf(this.concatItems.i1(position)) : emptySet();
  }
  nextRulePositions(current) {
    var np = current.m1b_1 + 1 | 0;
    return np === this.concatItems.h1() ? setOf(last_0(this.rulePositionsNotAtStart)) : np < this.concatItems.h1() ? setOf(_get__rulePositions__zi96g4(this).i1(np - 1 | 0)) : emptySet();
  }
  clone(clonedRules) {
    var tmp = ensureNotNull(clonedRules.c3(this.rule.tag));
    // Inline function 'kotlin.collections.map' call
    var this_0 = this.concatItems;
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var tmp$ret$0 = ensureNotNull(clonedRules.c3(item.tag));
      destination.v(tmp$ret$0);
    }
    return new RuntimeRuleRhsConcatenation(tmp, destination);
  }
  p1z() {
    return 'CONCAT(' + joinToString(this.concatItems, ' ', VOID, VOID, VOID, VOID, RuntimeRuleRhsConcatenation$_get_asString_$lambda_a0weeq) + ')';
  }
  toString() {
    return 'CONCAT(' + joinToString(this.concatItems, ' ', VOID, VOID, VOID, VOID, RuntimeRuleRhsConcatenation$toString$lambda) + ')';
  }
}
class RuntimeRuleRhsChoice extends RuntimeRuleRhsNonTerminal {
  constructor(rule, choiceKind, options) {
    super(rule);
    this.choiceKind = choiceKind;
    this.options = options;
  }
  h22() {
    return this.choiceKind;
  }
  p1y() {
    return this.options;
  }
  m1y() {
    // Inline function 'kotlin.collections.map' call
    var this_0 = this.options;
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var tmp$ret$0 = item.rhsItems.i1(0);
      destination.v(tmp$ret$0);
    }
    return destination;
  }
  v21() {
    // Inline function 'kotlin.collections.flatMapIndexed' call
    var tmp0 = this.options;
    // Inline function 'kotlin.collections.flatMapIndexedTo' call
    var destination = ArrayList.o1();
    var index = 0;
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      var _unary__edvuaz = index;
      index = _unary__edvuaz + 1 | 0;
      var op = checkIndexOverflow(_unary__edvuaz);
      // Inline function 'kotlin.collections.map' call
      var this_0 = element.rulePositionsNotAtStart;
      // Inline function 'kotlin.collections.mapTo' call
      var destination_0 = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
      var _iterator__ex2g4s_0 = this_0.g1();
      while (_iterator__ex2g4s_0.f()) {
        var item = _iterator__ex2g4s_0.e();
        var tmp$ret$0 = new RulePositionRuntime(this.rule, new OptionNum(op), item.m1b_1);
        destination_0.v(tmp$ret$0);
      }
      var list = destination_0;
      addAll(destination, list);
    }
    return toSet(destination);
  }
  rhsItemsAt(option, position) {
    return this.options.i1(option.asIndex).rhsItemsAt(Companion_getInstance_11().OPTION_NONE, position);
  }
  w21() {
    // Inline function 'kotlin.collections.mapIndexed' call
    var this_0 = this.options;
    // Inline function 'kotlin.collections.mapIndexedTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var index = 0;
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var _unary__edvuaz = index;
      index = _unary__edvuaz + 1 | 0;
      var op = checkIndexOverflow(_unary__edvuaz);
      var tmp$ret$0 = new RulePositionRuntime(this.rule, new OptionNum(op), 0);
      destination.v(tmp$ret$0);
    }
    return toSet(destination);
  }
  nextRulePositions(current) {
    // Inline function 'kotlin.collections.map' call
    var this_0 = this.options.i1(current.l1b_1.asIndex).nextRulePositions(current);
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var tmp$ret$0 = new RulePositionRuntime(this.rule, current.l1b_1, item.m1b_1);
      destination.v(tmp$ret$0);
    }
    return toSet(destination);
  }
  clone(clonedRules) {
    var tmp = ensureNotNull(clonedRules.c3(this.rule.tag));
    // Inline function 'kotlin.collections.map' call
    var this_0 = this.options;
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var tmp$ret$0 = item.clone(clonedRules);
      destination.v(tmp$ret$0);
    }
    return new RuntimeRuleRhsChoice(tmp, this.choiceKind, destination);
  }
  p1z() {
    return 'CHOICE(' + joinToString(this.options, ' | ', VOID, VOID, VOID, VOID, RuntimeRuleRhsChoice$_get_asString_$lambda_pebp4n) + ')';
  }
  toString() {
    return 'CHOICE(' + joinToString(this.options, ' | ', VOID, VOID, VOID, VOID, RuntimeRuleRhsChoice$toString$lambda) + ')';
  }
}
class RuntimeRuleRhsOptional extends RuntimeRuleRhsNonTerminal {
  constructor(rule, optionalItem) {
    super(rule);
    this.optionalItem = optionalItem;
  }
  i22() {
    return this.optionalItem;
  }
  m1y() {
    return listOf_0([listOf(this.optionalItem), listOf(Companion_getInstance_17().EMPTY)]);
  }
  w21() {
    return setOf_0([new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_OPTIONAL_ITEM, 0), new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_OPTIONAL_EMPTY, 0)]);
  }
  v21() {
    return setOf_0([new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_OPTIONAL_ITEM, -1), new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_OPTIONAL_EMPTY, -1)]);
  }
  rhsItemsAt(option, position) {
    var tmp;
    if (option.equals(Companion_getInstance_11().OPTION_OPTIONAL_EMPTY)) {
      tmp = position === 0 ? setOf(Companion_getInstance_17().EMPTY) : emptySet();
    } else if (option.equals(Companion_getInstance_11().OPTION_OPTIONAL_ITEM)) {
      switch (position) {
        case 0:
          tmp = setOf(this.optionalItem);
          break;
        case -1:
          tmp = emptySet();
          break;
        default:
          tmp = emptySet();
          break;
      }
    } else {
      var message = 'Internal Error: Invalid option value for Optional';
      throw IllegalStateException.t4(toString(message));
    }
    return tmp;
  }
  nextRulePositions(current) {
    return current.isAtStart ? setOf(current.atEnd()) : emptySet();
  }
  clone(clonedRules) {
    return new RuntimeRuleRhsOptional(ensureNotNull(clonedRules.c3(this.rule.tag)), ensureNotNull(clonedRules.c3(this.optionalItem.tag)));
  }
  toString() {
    return 'OPTIONAL ' + this.optionalItem.tag;
  }
}
class Companion_16 {
  constructor() {
    this.MULTIPLICITY_N = -1;
  }
  j22() {
    return this.MULTIPLICITY_N;
  }
}
class RuntimeRuleRhsList extends RuntimeRuleRhsNonTerminal {
  get min() {
    return this.e1o();
  }
  get max() {
    return this.f1o();
  }
}
class RuntimeRuleRhsListSimple extends RuntimeRuleRhsList {
  constructor(rule, min, max, repeatedRhsItem) {
    super(rule);
    this.a1o_1 = min;
    this.b1o_1 = max;
    this.repeatedRhsItem = repeatedRhsItem;
  }
  e1o() {
    return this.a1o_1;
  }
  f1o() {
    return this.b1o_1;
  }
  k22() {
    return this.repeatedRhsItem;
  }
  m1y() {
    return this.a1o_1 === 0 ? listOf_0([listOf(this.repeatedRhsItem), listOf(Companion_getInstance_17().EMPTY_LIST)]) : listOf(listOf(this.repeatedRhsItem));
  }
  w21() {
    var tmp;
    if (this.a1o_1 < 0) {
      var message = 'Internal Error: min must be > 0';
      throw IllegalStateException.t4(toString(message));
    } else if (!(-1 === this.b1o_1) && this.a1o_1 > this.b1o_1) {
      var message_0 = 'Internal Error: max must be > min';
      throw IllegalStateException.t4(toString(message_0));
    } else if (this.b1o_1 === 0) {
      tmp = setOf(new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_MULTI_EMPTY, 0));
    } else if (this.a1o_1 > 0) {
      tmp = setOf(new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_MULTI_ITEM, 0));
    } else {
      tmp = setOf_0([new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_MULTI_ITEM, 0), new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_MULTI_EMPTY, 0)]);
    }
    return tmp;
  }
  v21() {
    var tmp;
    if (this.a1o_1 < 0) {
      var message = 'Internal Error: min must be > 0';
      throw IllegalStateException.t4(toString(message));
    } else if (!(-1 === this.b1o_1) && this.a1o_1 > this.b1o_1) {
      var message_0 = 'Internal Error: max must be > min';
      throw IllegalStateException.t4(toString(message_0));
    } else if (this.b1o_1 === 0) {
      tmp = setOf(new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_MULTI_EMPTY, -1));
    } else if (this.a1o_1 > 0) {
      tmp = this.b1o_1 === 1 ? setOf(new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_MULTI_ITEM, -1)) : setOf_0([new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_MULTI_ITEM, 1), new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_MULTI_ITEM, -1)]);
    } else {
      tmp = this.b1o_1 === 1 ? setOf_0([new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_MULTI_ITEM, -1), new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_MULTI_EMPTY, -1)]) : setOf_0([new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_MULTI_ITEM, 1), new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_MULTI_ITEM, -1), new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_MULTI_EMPTY, -1)]);
    }
    return tmp;
  }
  rhsItemsAt(option, position) {
    var tmp;
    if (option.equals(Companion_getInstance_11().OPTION_MULTI_EMPTY)) {
      tmp = position === 0 ? setOf(Companion_getInstance_17().EMPTY_LIST) : emptySet();
    } else if (option.equals(Companion_getInstance_11().OPTION_MULTI_ITEM)) {
      switch (position) {
        case 0:
          tmp = setOf(this.repeatedRhsItem);
          break;
        case 1:
          tmp = setOf(this.repeatedRhsItem);
          break;
        default:
          tmp = emptySet();
          break;
      }
    } else {
      var message = 'Internal Error: Invalid option value for SimpleList - ' + option.toString();
      throw IllegalStateException.t4(toString(message));
    }
    return tmp;
  }
  nextRulePositions(current) {
    var tmp0_subject = current.l1b_1;
    var tmp;
    if (tmp0_subject.equals(Companion_getInstance_11().OPTION_MULTI_EMPTY)) {
      tmp = current.isAtStart && 0 === this.a1o_1 ? setOf(current.atEnd()) : emptySet();
    } else if (tmp0_subject.equals(Companion_getInstance_11().OPTION_MULTI_ITEM)) {
      switch (current.m1b_1) {
        case 0:
          tmp = 1 === this.b1o_1 ? setOf(new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_MULTI_ITEM, -1)) : 2 <= this.a1o_1 ? setOf(new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_MULTI_ITEM, 1)) : setOf_0([new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_MULTI_ITEM, 1), new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_MULTI_ITEM, -1)]);
          break;
        case 1:
          tmp = setOf_0([new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_MULTI_ITEM, 1), new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_MULTI_ITEM, -1)]);
          break;
        case -1:
          tmp = emptySet();
          break;
        default:
          tmp = emptySet();
          break;
      }
    } else {
      var message = 'Internal Error: Invalid option value for SimpleList - ' + current.l1b_1.toString();
      throw IllegalStateException.t4(toString(message));
    }
    return tmp;
  }
  clone(clonedRules) {
    return new RuntimeRuleRhsListSimple(ensureNotNull(clonedRules.c3(this.rule.tag)), this.a1o_1, this.b1o_1, ensureNotNull(clonedRules.c3(this.repeatedRhsItem.tag)));
  }
  toString() {
    return 'LIST ' + this.repeatedRhsItem.tag + ' {' + this.a1o_1 + ', ' + this.b1o_1 + '}';
  }
}
class RuntimeRuleRhsListSeparated extends RuntimeRuleRhsList {
  constructor(rule, min, max, repeatedRhsItem, separatorRhsItem) {
    super(rule);
    this.l22_1 = min;
    this.m22_1 = max;
    this.repeatedRhsItem = repeatedRhsItem;
    this.separatorRhsItem = separatorRhsItem;
  }
  e1o() {
    return this.l22_1;
  }
  f1o() {
    return this.m22_1;
  }
  k22() {
    return this.repeatedRhsItem;
  }
  n22() {
    return this.separatorRhsItem;
  }
  m1y() {
    return this.l22_1 === 0 ? listOf_0([listOf(this.repeatedRhsItem), listOf(this.separatorRhsItem), listOf(Companion_getInstance_17().EMPTY_LIST)]) : listOf_0([listOf(this.repeatedRhsItem), listOf(this.separatorRhsItem)]);
  }
  w21() {
    var tmp;
    if (this.l22_1 < 0) {
      var message = 'Internal Error: min must be > 0';
      throw IllegalStateException.t4(toString(message));
    } else if (!(-1 === this.m22_1) && this.l22_1 > this.m22_1) {
      var message_0 = 'Internal Error: max must be > min';
      throw IllegalStateException.t4(toString(message_0));
    } else if (this.m22_1 === 0) {
      tmp = setOf(new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_SLIST_EMPTY, 0));
    } else if (this.l22_1 > 0) {
      tmp = setOf(new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_SLIST_ITEM_OR_SEPERATOR, 0));
    } else {
      tmp = setOf_0([new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_SLIST_ITEM_OR_SEPERATOR, 0), new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_SLIST_EMPTY, 0)]);
    }
    return tmp;
  }
  v21() {
    var tmp;
    if (this.l22_1 < 0) {
      var message = 'Internal Error: min must be >= 0';
      throw IllegalStateException.t4(toString(message));
    } else if (!(-1 === this.m22_1) && this.l22_1 > this.m22_1) {
      var message_0 = 'Internal Error: max must be > min';
      throw IllegalStateException.t4(toString(message_0));
    } else if (this.m22_1 === 0) {
      var message_1 = 'Internal Error: max must be > 0';
      throw IllegalStateException.t4(toString(message_1));
    } else if (this.l22_1 > 0) {
      tmp = this.m22_1 === 1 ? setOf(new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_SLIST_ITEM_OR_SEPERATOR, -1)) : setOf_0([new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_SLIST_ITEM_OR_SEPERATOR, 2), new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_SLIST_ITEM_OR_SEPERATOR, 1), new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_SLIST_ITEM_OR_SEPERATOR, -1)]);
    } else {
      tmp = this.m22_1 === 1 ? setOf_0([new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_SLIST_ITEM_OR_SEPERATOR, -1), new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_SLIST_EMPTY, -1)]) : setOf_0([new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_SLIST_ITEM_OR_SEPERATOR, 2), new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_SLIST_ITEM_OR_SEPERATOR, 1), new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_SLIST_ITEM_OR_SEPERATOR, -1), new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_SLIST_EMPTY, -1)]);
    }
    return tmp;
  }
  rhsItemsAt(option, position) {
    var tmp;
    if (option.equals(Companion_getInstance_11().OPTION_SLIST_EMPTY)) {
      tmp = position === 0 ? setOf(Companion_getInstance_17().EMPTY_LIST) : emptySet();
    } else if (option.equals(Companion_getInstance_11().OPTION_SLIST_ITEM_OR_SEPERATOR)) {
      switch (position) {
        case 0:
          tmp = setOf(this.repeatedRhsItem);
          break;
        case 2:
          tmp = setOf(this.repeatedRhsItem);
          break;
        case 1:
          tmp = setOf(this.separatorRhsItem);
          break;
        default:
          tmp = emptySet();
          break;
      }
    } else {
      var message = 'Internal Error: Invalid option value for SeparatedList - ' + option.toString();
      throw IllegalStateException.t4(toString(message));
    }
    return tmp;
  }
  nextRulePositions(current) {
    var tmp0_subject = current.l1b_1;
    var tmp;
    if (tmp0_subject.equals(Companion_getInstance_11().OPTION_SLIST_EMPTY)) {
      tmp = current.isAtStart && this.l22_1 === 0 ? setOf(current.atEnd()) : emptySet();
    } else if (tmp0_subject.equals(Companion_getInstance_11().OPTION_SLIST_ITEM_OR_SEPERATOR)) {
      var tmp_0;
      switch (current.m1b_1) {
        case 0:
          tmp_0 = 1 === this.m22_1 ? setOf(new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_SLIST_ITEM_OR_SEPERATOR, -1)) : 2 <= this.l22_1 ? setOf(new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_SLIST_ITEM_OR_SEPERATOR, 1)) : setOf_0([new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_SLIST_ITEM_OR_SEPERATOR, 1), new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_SLIST_ITEM_OR_SEPERATOR, -1)]);
          break;
        case 2:
          tmp_0 = setOf_0([new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_SLIST_ITEM_OR_SEPERATOR, 1), new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_SLIST_ITEM_OR_SEPERATOR, -1)]);
          break;
        case 1:
          var tmp_1;
          if (this.m22_1 > 1 || -1 === this.m22_1) {
            tmp_1 = setOf(new RulePositionRuntime(this.rule, Companion_getInstance_11().OPTION_SLIST_ITEM_OR_SEPERATOR, 2));
          } else {
            var message = 'This should never happen!';
            throw IllegalStateException.t4(toString(message));
          }

          tmp_0 = tmp_1;
          break;
        case -1:
          tmp_0 = emptySet();
          break;
        default:
          var message_0 = 'This should never happen!';
          throw IllegalStateException.t4(toString(message_0));
      }
      tmp = tmp_0;
    } else {
      var message_1 = 'Internal Error: Invalid option value for SeparatedList - ' + current.l1b_1.toString();
      throw IllegalStateException.t4(toString(message_1));
    }
    return tmp;
  }
  clone(clonedRules) {
    return new RuntimeRuleRhsListSeparated(ensureNotNull(clonedRules.c3(this.rule.tag)), this.l22_1, this.m22_1, ensureNotNull(clonedRules.c3(this.repeatedRhsItem.tag)), ensureNotNull(clonedRules.c3(this.separatorRhsItem.tag)));
  }
  toString() {
    return 'SLIST ' + this.repeatedRhsItem.tag + ' ' + this.separatorRhsItem.tag + ' {' + this.l22_1 + ', ' + this.m22_1 + '}';
  }
}
class Companion_17 {
  constructor() {
    Companion_instance_17 = this;
    this.nextRuntimeRuleSetNumber = 0;
    var tmp = this;
    tmp.x1l_1 = lazyMapNotNull(RuntimeRuleSet$Companion$numberForGrammar$delegate$lambda);
    this.NO_RRS = -1;
    this.GOAL_RULE_NUMBER = -1;
    this.EOT_RULE_NUMBER = -2;
    this.SKIP_RULE_NUMBER = -3;
    this.SKIP_CHOICE_RULE_NUMBER = -4;
    this.RUNTIME_LOOKAHEAD_RULE_NUMBER = -6;
    this.ANY_LOOKAHEAD_RULE_NUMBER = -7;
    this.UNDEFINED_LOOKAHEAD_RULE_NUMBER = -8;
    this.EMPTY_RULE_NUMBER = -9;
    this.EMPTY_LIST_RULE_NUMBER = -10;
    this.END_OF_TEXT_TAG = '<EOT>';
    this.GOAL_TAG = '<GOAL>';
    this.SKIP_MULTI_TAG = '<SKIP-MULTI>';
    this.SKIP_CHOICE_RULE_TAG = '<SKIP-CHOICE>';
    this.RUNTIME_LOOKAHEAD_RULE_TAG = '<RT>';
    this.ANY_LOOKAHEAD_RULE_TAG = '<ANY>';
    this.UNDEFINED_LOOKAHEAD_RULE_TAG = '<UNDEFINED>';
    this.EMPTY_RULE_TAG = '<EMPTY>';
    this.EMPTY_LIST_RULE_TAG = '<EMPTY_LIST>';
    var tmp_0 = this;
    // Inline function 'kotlin.also' call
    var this_0 = new RuntimeRule(-1, -2, '<EOT>', false, false);
    this_0.setRhs(new RuntimeRuleRhsCommonTerminal(this_0));
    tmp_0.END_OF_TEXT = this_0;
    var tmp_1 = this;
    // Inline function 'kotlin.also' call
    var this_1 = new RuntimeRule(-1, -6, '<RT>', false, false);
    this_1.setRhs(new RuntimeRuleRhsCommonTerminal(this_1));
    tmp_1.USE_RUNTIME_LOOKAHEAD = this_1;
    var tmp_2 = this;
    // Inline function 'kotlin.also' call
    var this_2 = new RuntimeRule(-1, -7, '<ANY>', false, false);
    this_2.setRhs(new RuntimeRuleRhsCommonTerminal(this_2));
    tmp_2.ANY_LOOKAHEAD = this_2;
    var tmp_3 = this;
    // Inline function 'kotlin.also' call
    var this_3 = new RuntimeRule(-1, -8, '<UNDEFINED>', false, false);
    this_3.setRhs(new RuntimeRuleRhsCommonTerminal(this_3));
    tmp_3.UNDEFINED_RULE = this_3;
    var tmp_4 = this;
    // Inline function 'kotlin.also' call
    var this_4 = new RuntimeRule(-1, -9, '<EMPTY>', false, false);
    this_4.setRhs(new RuntimeRuleRhsEmpty(this_4));
    tmp_4.EMPTY = this_4;
    var tmp_5 = this;
    // Inline function 'kotlin.also' call
    var this_5 = new RuntimeRule(-1, -10, '<EMPTY_LIST>', false, false);
    this_5.setRhs(new RuntimeRuleRhsEmptyList(this_5));
    tmp_5.EMPTY_LIST = this_5;
  }
  o22(_set____db54di) {
    this.nextRuntimeRuleSetNumber = _set____db54di;
  }
  p22() {
    return this.nextRuntimeRuleSetNumber;
  }
  q22() {
    var tmp = KProperty1;
    return this.x1l_1.yj(this, getPropertyCallableRef('numberForGrammar', 1, tmp, RuntimeRuleSet$Companion$_get_numberForGrammar_$ref_uvduo1(), null));
  }
  r22() {
    return this.NO_RRS;
  }
  s22() {
    return this.GOAL_RULE_NUMBER;
  }
  t22() {
    return this.EOT_RULE_NUMBER;
  }
  u22() {
    return this.SKIP_RULE_NUMBER;
  }
  v22() {
    return this.SKIP_CHOICE_RULE_NUMBER;
  }
  w22() {
    return this.RUNTIME_LOOKAHEAD_RULE_NUMBER;
  }
  x22() {
    return this.ANY_LOOKAHEAD_RULE_NUMBER;
  }
  y22() {
    return this.UNDEFINED_LOOKAHEAD_RULE_NUMBER;
  }
  z22() {
    return this.EMPTY_RULE_NUMBER;
  }
  a23() {
    return this.EMPTY_LIST_RULE_NUMBER;
  }
  b23() {
    return this.END_OF_TEXT_TAG;
  }
  c23() {
    return this.GOAL_TAG;
  }
  d23() {
    return this.SKIP_MULTI_TAG;
  }
  e23() {
    return this.SKIP_CHOICE_RULE_TAG;
  }
  f23() {
    return this.RUNTIME_LOOKAHEAD_RULE_TAG;
  }
  g23() {
    return this.ANY_LOOKAHEAD_RULE_TAG;
  }
  h23() {
    return this.UNDEFINED_LOOKAHEAD_RULE_TAG;
  }
  i23() {
    return this.EMPTY_RULE_TAG;
  }
  j23() {
    return this.EMPTY_LIST_RULE_TAG;
  }
  k23() {
    return this.END_OF_TEXT;
  }
  l23() {
    return this.USE_RUNTIME_LOOKAHEAD;
  }
  m23() {
    return this.ANY_LOOKAHEAD;
  }
  n23() {
    return this.UNDEFINED_RULE;
  }
  n1l() {
    return this.EMPTY;
  }
  o23() {
    return this.EMPTY_LIST;
  }
  get numberForGrammar() {
    return this.q22();
  }
}
class sam$kotlin_Comparator$0_7 {
  constructor(function_0) {
    this.p23_1 = function_0;
  }
  lg(a, b) {
    return this.p23_1(a, b);
  }
  compare(a, b) {
    return this.lg(a, b);
  }
  u3() {
    return this.p23_1;
  }
  equals(other) {
    var tmp;
    if (!(other == null) ? isInterface(other, Comparator) : false) {
      var tmp_0;
      if (!(other == null) ? isInterface(other, FunctionAdapter) : false) {
        tmp_0 = equals(this.u3(), other.u3());
      } else {
        tmp_0 = false;
      }
      tmp = tmp_0;
    } else {
      tmp = false;
    }
    return tmp;
  }
  hashCode() {
    return hashCode(this.u3());
  }
}
class RuntimeRuleSet {
  constructor(number, qualifiedName, runtimeRules, precedenceRules) {
    Companion_getInstance_17();
    this.number = number;
    this.qualifiedName = qualifiedName;
    this.runtimeRules = runtimeRules;
    this.precedenceRules = precedenceRules;
    var tmp = this;
    tmp.e1d_1 = lazyMapNotNull(RuntimeRuleSet$goalRuleFor$delegate$lambda(this));
    var tmp_0 = this;
    tmp_0.f1d_1 = lazy(RuntimeRuleSet$skipRules$delegate$lambda(this));
    var tmp_1 = this;
    tmp_1.g1d_1 = lazy(RuntimeRuleSet$skipTerminals$delegate$lambda(this));
    var tmp_2 = this;
    tmp_2.h1d_1 = lazy(RuntimeRuleSet$nonSkipRules$delegate$lambda(this));
    var tmp_3 = this;
    tmp_3.i1d_1 = lazy(RuntimeRuleSet$nonSkipTerminals$delegate$lambda(this));
    var tmp_4 = this;
    tmp_4.j1d_1 = lazy(RuntimeRuleSet$terminals$delegate$lambda(this));
    var tmp_5 = this;
    tmp_5.k1d_1 = lazy(RuntimeRuleSet$embeddedTerminals$delegate$lambda(this));
    var tmp_6 = this;
    tmp_6.l1d_1 = lazy(RuntimeRuleSet$rulesByTag$delegate$lambda(this));
    var tmp_7 = this;
    tmp_7.m1d_1 = lazy(RuntimeRuleSet$nonTerminalRuleNumber$delegate$lambda(this));
    var tmp_8 = this;
    tmp_8.n1d_1 = lazy(RuntimeRuleSet$terminalByTag$delegate$lambda(this));
    var tmp_9 = this;
    tmp_9.o1d_1 = lazy(RuntimeRuleSet$embeddedRuleNumber$delegate$lambda(this));
    var tmp_10 = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp_10.p1d_1 = LinkedHashMap.j4();
    var tmp_11 = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp_11.q1d_1 = LinkedHashMap.j4();
    var tmp_12 = this;
    tmp_12.r1d_1 = lazy(RuntimeRuleSet$skipParserStateSet$delegate$lambda(this));
    this.s1d_1 = 0;
  }
  r1b() {
    return this.number;
  }
  r10() {
    return this.qualifiedName;
  }
  i1m() {
    return this.runtimeRules;
  }
  q23() {
    return this.precedenceRules;
  }
  x1x() {
    var tmp = KProperty1;
    return this.e1d_1.yj(this, getPropertyCallableRef('goalRuleFor', 1, tmp, RuntimeRuleSet$_get_goalRuleFor_$ref_fo2hrk(), null));
  }
  r23() {
    var tmp0 = this.f1d_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('skipRules', 1, tmp, RuntimeRuleSet$_get_skipRules_$ref_ccw8tq(), null);
    return tmp0.b2();
  }
  s23() {
    var tmp0 = this.g1d_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('skipTerminals', 1, tmp, RuntimeRuleSet$_get_skipTerminals_$ref_1r14nm(), null);
    return tmp0.b2();
  }
  t23() {
    var tmp0 = this.h1d_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('nonSkipRules', 1, tmp, RuntimeRuleSet$_get_nonSkipRules_$ref_p1qrhh(), null);
    return tmp0.b2();
  }
  u1x() {
    var tmp0 = this.i1d_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('nonSkipTerminals', 1, tmp, RuntimeRuleSet$_get_nonSkipTerminals_$ref_b8veed(), null);
    return tmp0.b2();
  }
  v1x() {
    var tmp0 = this.j1d_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('terminals', 1, tmp, RuntimeRuleSet$_get_terminals_$ref_y2xogd(), null);
    return tmp0.b2();
  }
  w1x() {
    var tmp0 = this.k1d_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('embeddedTerminals', 1, tmp, RuntimeRuleSet$_get_embeddedTerminals_$ref_g9kh0d(), null);
    return tmp0.b2();
  }
  u23() {
    var tmp0 = this.r1d_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('skipParserStateSet', 1, tmp, RuntimeRuleSet$_get_skipParserStateSet_$ref_cbiz4v(), null);
    return tmp0.b2();
  }
  v23(_set____db54di) {
    this.s1d_1 = _set____db54di;
  }
  w23() {
    return this.s1d_1;
  }
  automatonFor(goalRuleName, automatonKind) {
    this.buildFor(goalRuleName, automatonKind);
    return ensureNotNull(this.p1d_1.c3(goalRuleName));
  }
  usedAutomatonFor(goalRuleName) {
    return ensureNotNull(this.p1d_1.c3(goalRuleName));
  }
  buildFor(userGoalRuleName, automatonKind) {
    var ss = this.c1l(userGoalRuleName, automatonKind);
    return ss.build();
  }
  addPreBuiltFor(userGoalRuleName, automaton) {
    var tmp0 = this.p1d_1;
    // Inline function 'kotlin.collections.set' call
    var value = automaton instanceof ParserStateSet ? automaton : THROW_CCE();
    tmp0.f3(userGoalRuleName, value);
  }
  fetchStateSetFor(userGoalRule, automatonKind) {
    return this.c1l(userGoalRule.tag, automatonKind);
  }
  c1l(userGoalRuleName, automatonKind) {
    var stateSet = this.p1d_1.c3(userGoalRuleName);
    if (null == stateSet) {
      var _unary__edvuaz = this.s1d_1;
      this.s1d_1 = _unary__edvuaz + 1 | 0;
      stateSet = new ParserStateSet(_unary__edvuaz, this, this.findRuntimeRule(userGoalRuleName), false, automatonKind, false);
      var tmp0 = this.p1d_1;
      // Inline function 'kotlin.collections.set' call
      var value = stateSet;
      tmp0.f3(userGoalRuleName, value);
    }
    return stateSet;
  }
  x23(found) {
    var tmp;
    if (found.p1(this)) {
      tmp = found;
    } else {
      // Inline function 'kotlin.collections.filter' call
      var tmp0 = this.runtimeRules;
      // Inline function 'kotlin.collections.filterTo' call
      var destination = ArrayList.o1();
      var _iterator__ex2g4s = tmp0.g1();
      while (_iterator__ex2g4s.f()) {
        var element = _iterator__ex2g4s.e();
        if (element.isEmbedded) {
          destination.v(element);
        }
      }
      // Inline function 'kotlin.collections.flatMap' call
      // Inline function 'kotlin.collections.flatMapTo' call
      var destination_0 = ArrayList.o1();
      var _iterator__ex2g4s_0 = destination.g1();
      while (_iterator__ex2g4s_0.f()) {
        var element_0 = _iterator__ex2g4s_0.e();
        var tmp_0 = element_0.rhs;
        var es = (tmp_0 instanceof RuntimeRuleRhsEmbedded ? tmp_0 : THROW_CCE()).embeddedRuntimeRuleSet;
        var r = es.findEmbeddedRuleSets(plus(found, this));
        var list = plus(r, es);
        addAll(destination_0, list);
      }
      var res = toSet(destination_0);
      tmp = res;
    }
    return tmp;
  }
  findEmbeddedRuleSets(found, $super) {
    found = found === VOID ? emptySet() : found;
    return $super === VOID ? this.x23(found) : $super.x23.call(this, found);
  }
  findRuntimeRule(tag) {
    var tmp0_elvis_lhs = _get_rulesByTag__jkorgf(this).c3(tag);
    var tmp;
    if (tmp0_elvis_lhs == null) {
      var message = "Internal Error: RuntimeRule '" + tag + "' not found";
      throw IllegalStateException.t4(toString(message));
    } else {
      tmp = tmp0_elvis_lhs;
    }
    return tmp;
  }
  findTerminalRule(tag) {
    var tmp0_elvis_lhs = _get_terminalByTag__v6rb4a(this).c3(tag);
    var tmp;
    if (tmp0_elvis_lhs == null) {
      var message = 'Terminal RuntimeRule ' + tag + ' not found';
      throw IllegalStateException.t4(toString(message));
    } else {
      tmp = tmp0_elvis_lhs;
    }
    return tmp;
  }
  z1n(precedenceContext) {
    var tmp0 = this.precedenceRules;
    var tmp$ret$1;
    $l$block: {
      // Inline function 'kotlin.collections.firstOrNull' call
      var _iterator__ex2g4s = tmp0.g1();
      while (_iterator__ex2g4s.f()) {
        var element = _iterator__ex2g4s.e();
        if ((element instanceof RuntimePreferenceRule ? element : THROW_CCE()).z1v_1.equals(precedenceContext)) {
          tmp$ret$1 = element;
          break $l$block;
        }
      }
      tmp$ret$1 = null;
    }
    var tmp = tmp$ret$1;
    return (tmp == null ? true : tmp instanceof RuntimePreferenceRule) ? tmp : THROW_CCE();
  }
  y23(userGoalRuleName, withStates) {
    return ensureNotNull(this.p1d_1.c3(userGoalRuleName)).usedAutomatonToString(withStates);
  }
  usedAutomatonToString(userGoalRuleName, withStates, $super) {
    withStates = withStates === VOID ? false : withStates;
    return $super === VOID ? this.y23(userGoalRuleName, withStates) : $super.y23.call(this, userGoalRuleName, withStates);
  }
  z23(goalRuleName, automatonKind) {
    this.buildFor(goalRuleName, automatonKind);
    return this.usedAutomatonToString('S');
  }
  a24(rule, used, done) {
    var tmp;
    if (rule.isGoal) {
      used.v(rule);
      var _iterator__ex2g4s = flatten(rule.rhsItems).g1();
      while (_iterator__ex2g4s.f()) {
        var sr = _iterator__ex2g4s.e();
        this.calcUsedRules(sr instanceof RuntimeRule ? sr : THROW_CCE(), used, done);
      }
      tmp = used;
    } else if (rule.u1d_1 >= 0 && done[rule.u1d_1]) {
      tmp = used;
    } else {
      var tmp_0;
      if (rule.isNonTerminal) {
        used.v(rule);
        if (rule.u1d_1 >= 0) {
          done[rule.u1d_1] = true;
        }
        var _iterator__ex2g4s_0 = flatten(rule.rhsItems).g1();
        while (_iterator__ex2g4s_0.f()) {
          var sr_0 = _iterator__ex2g4s_0.e();
          this.calcUsedRules(sr_0 instanceof RuntimeRule ? sr_0 : THROW_CCE(), used, done);
        }
        tmp_0 = used;
      } else {
        used.v(rule);
        if (rule.u1d_1 > 0) {
          done[rule.u1d_1] = true;
        }
        tmp_0 = used;
      }
      tmp = tmp_0;
    }
    return tmp;
  }
  calcUsedRules(rule, used, done, $super) {
    var tmp;
    if (used === VOID) {
      // Inline function 'kotlin.collections.mutableSetOf' call
      tmp = LinkedHashSet.j1();
    } else {
      tmp = used;
    }
    used = tmp;
    done = done === VOID ? booleanArray(this.runtimeRules.h1()) : done;
    return $super === VOID ? this.a24(rule, used, done) : $super.a24.call(this, rule, used, done);
  }
  clone() {
    var _unary__edvuaz = Companion_getInstance_17().nextRuntimeRuleSetNumber;
    Companion_getInstance_17().nextRuntimeRuleSetNumber = _unary__edvuaz + 1 | 0;
    var cloneNumber = _unary__edvuaz;
    // Inline function 'kotlin.collections.associate' call
    var this_0 = this.runtimeRules;
    var capacity = coerceAtLeast(mapCapacity(collectionSizeOrDefault(this_0, 10)), 16);
    // Inline function 'kotlin.collections.associateTo' call
    var destination = LinkedHashMap.gb(capacity);
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      var cr = new RuntimeRule(cloneNumber, element.u1d_1, element.name, element.v1d_1, element.w1d_1);
      // Inline function 'kotlin.collections.plusAssign' call
      var pair = new Pair(element.tag, cr);
      destination.f3(pair.hi_1, pair.ii_1);
    }
    var clonedRules = destination;
    // Inline function 'kotlin.collections.forEach' call
    var _iterator__ex2g4s_0 = this.runtimeRules.g1();
    while (_iterator__ex2g4s_0.f()) {
      var element_0 = _iterator__ex2g4s_0.e();
      var tmp0_elvis_lhs = clonedRules.c3(element_0.tag);
      var tmp;
      if (tmp0_elvis_lhs == null) {
        var message = "Internal Error: cannot find cloned rule with tag '" + element_0.tag + "' ";
        throw IllegalStateException.t4(toString(message));
      } else {
        tmp = tmp0_elvis_lhs;
      }
      var cr_0 = tmp;
      cr_0.setRhs(element_0.rhs.clone(clonedRules));
    }
    var rules = toList(clonedRules.e3());
    // Inline function 'kotlin.collections.map' call
    var this_1 = this.precedenceRules;
    // Inline function 'kotlin.collections.mapTo' call
    var destination_0 = ArrayList.a1(collectionSizeOrDefault(this_1, 10));
    var _iterator__ex2g4s_1 = this_1.g1();
    while (_iterator__ex2g4s_1.f()) {
      var item = _iterator__ex2g4s_1.e();
      var clonedCtx = ensureNotNull(clonedRules.c3(item.contextRule.tag));
      // Inline function 'kotlin.collections.map' call
      var this_2 = (item instanceof RuntimePreferenceRule ? item : THROW_CCE()).a1w_1;
      // Inline function 'kotlin.collections.mapTo' call
      var destination_1 = ArrayList.a1(collectionSizeOrDefault(this_2, 10));
      var _iterator__ex2g4s_2 = this_2.g1();
      while (_iterator__ex2g4s_2.f()) {
        var item_0 = _iterator__ex2g4s_2.e();
        // Inline function 'kotlin.collections.map' call
        var this_3 = item_0.v1v_1;
        // Inline function 'kotlin.collections.mapTo' call
        var destination_2 = ArrayList.a1(collectionSizeOrDefault(this_3, 10));
        var _iterator__ex2g4s_3 = this_3.g1();
        while (_iterator__ex2g4s_3.f()) {
          var item_1 = _iterator__ex2g4s_3.e();
          var tmp$ret$6 = ensureNotNull(clonedRules.c3(item_1.tag));
          destination_2.v(tmp$ret$6);
        }
        var cTgt = destination_2;
        // Inline function 'kotlin.collections.map' call
        var this_4 = item_0.x1v_1;
        // Inline function 'kotlin.collections.mapTo' call
        var destination_3 = ArrayList.a1(collectionSizeOrDefault(this_4, 10));
        var _iterator__ex2g4s_4 = this_4.g1();
        while (_iterator__ex2g4s_4.f()) {
          var item_2 = _iterator__ex2g4s_4.e();
          var tmp$ret$9 = ensureNotNull(clonedRules.c3(item_2.tag));
          destination_3.v(tmp$ret$9);
        }
        var cOp = toSet(destination_3);
        var tmp$ret$12 = new RuntimePreferenceOption(item_0.u1v_1, cTgt, item_0.w1v_1, cOp, item_0.y1v_1);
        destination_1.v(tmp$ret$12);
      }
      var clonedPrecRules = destination_1;
      var tmp$ret$15 = new RuntimePreferenceRule(clonedCtx, clonedPrecRules);
      destination_0.v(tmp$ret$15);
    }
    var clonedPrecedenceRules = destination_0;
    var clone = new RuntimeRuleSet(cloneNumber, this.qualifiedName, rules, clonedPrecedenceRules);
    return clone;
  }
  y1c() {
    return this.runtimeRules;
  }
  toString() {
    // Inline function 'kotlin.collections.sortedBy' call
    var this_0 = this.runtimeRules;
    // Inline function 'kotlin.comparisons.compareBy' call
    var tmp = RuntimeRuleSet$toString$lambda;
    var tmp$ret$0 = new sam$kotlin_Comparator$0_7(tmp);
    // Inline function 'kotlin.collections.map' call
    var this_1 = sortedWith(this_0, tmp$ret$0);
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_1, 10));
    var _iterator__ex2g4s = this_1.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var tmp$ret$2 = '  ' + item.asString;
      destination.v(tmp$ret$2);
    }
    var rulesStr = joinToString(destination, '\n');
    // Inline function 'kotlin.collections.sortedBy' call
    var this_2 = this.precedenceRules;
    // Inline function 'kotlin.comparisons.compareBy' call
    var tmp_0 = RuntimeRuleSet$toString$lambda_0;
    var tmp$ret$5 = new sam$kotlin_Comparator$0_7(tmp_0);
    var tmp_1 = sortedWith(this_2, tmp$ret$5);
    var precRules = joinToString(tmp_1, '\n', VOID, VOID, VOID, VOID, RuntimeRuleSet$toString$lambda_1);
    var s = trimIndent("\nRuntimeRuleSet '" + this.qualifiedName + "' {\n" + rulesStr + '\n' + precRules + '\n}\n');
    return s;
  }
  hashCode() {
    return this.number;
  }
  equals(other) {
    var tmp;
    if (other instanceof RuntimeRuleSet) {
      tmp = this.number === other.number;
    } else {
      tmp = false;
    }
    return tmp;
  }
  get goalRuleFor() {
    return this.x1x();
  }
  get skipRules() {
    return this.r23();
  }
  get skipTerminals() {
    return this.s23();
  }
  get nonSkipRules() {
    return this.t23();
  }
  get nonSkipTerminals() {
    return this.u1x();
  }
  get terminals() {
    return this.v1x();
  }
  get embeddedTerminals() {
    return this.w1x();
  }
  get skipParserStateSet() {
    return this.u23();
  }
  get rule() {
    return this.y1c();
  }
}
class Quad {
  constructor(first, second, third, fourth) {
    this.first = first;
    this.second = second;
    this.third = third;
    this.fourth = fourth;
  }
  b24() {
    return this.first;
  }
  c24() {
    return this.second;
  }
  d24() {
    return this.third;
  }
  e24() {
    return this.fourth;
  }
  ni() {
    return this.first;
  }
  oi() {
    return this.second;
  }
  mm() {
    return this.third;
  }
  d16() {
    return this.fourth;
  }
  f24(first, second, third, fourth) {
    return new Quad(first, second, third, fourth);
  }
  copy(first, second, third, fourth, $super) {
    first = first === VOID ? this.first : first;
    second = second === VOID ? this.second : second;
    third = third === VOID ? this.third : third;
    fourth = fourth === VOID ? this.fourth : fourth;
    return $super === VOID ? this.f24(first, second, third, fourth) : $super.f24.call(this, first, second, third, fourth);
  }
  toString() {
    return 'Quad(first=' + toString_0(this.first) + ', second=' + toString_0(this.second) + ', third=' + toString_0(this.third) + ', fourth=' + toString_0(this.fourth) + ')';
  }
  hashCode() {
    var result = this.first == null ? 0 : hashCode(this.first);
    result = imul(result, 31) + (this.second == null ? 0 : hashCode(this.second)) | 0;
    result = imul(result, 31) + (this.third == null ? 0 : hashCode(this.third)) | 0;
    result = imul(result, 31) + (this.fourth == null ? 0 : hashCode(this.fourth)) | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof Quad))
      return false;
    if (!equals(this.first, other.first))
      return false;
    if (!equals(this.second, other.second))
      return false;
    if (!equals(this.third, other.third))
      return false;
    if (!equals(this.fourth, other.fourth))
      return false;
    return true;
  }
}
class RuntimeRuleSetBuilder2 {
  constructor(qualifiedName) {
    this.g24_1 = qualifiedName;
    var tmp = this;
    var _unary__edvuaz = Companion_getInstance_17().nextRuntimeRuleSetNumber;
    Companion_getInstance_17().nextRuntimeRuleSetNumber = _unary__edvuaz + 1 | 0;
    tmp.h24_1 = _unary__edvuaz;
    var tmp_0 = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp_0.i24_1 = LinkedHashMap.j4();
    var tmp_1 = this;
    // Inline function 'kotlin.collections.mutableListOf' call
    tmp_1.j24_1 = ArrayList.o1();
  }
  e1h() {
    // Inline function 'kotlin.collections.mapIndexed' call
    var this_0 = this.i24_1.e3();
    // Inline function 'kotlin.collections.mapIndexedTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var index = 0;
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var _unary__edvuaz = index;
      index = _unary__edvuaz + 1 | 0;
      var ruleNumber = checkIndexOverflow(_unary__edvuaz);
      var rr = item.r24(ruleNumber);
      var tmp$ret$0 = new Pair(item.m24_1, rr);
      destination.v(tmp$ret$0);
    }
    var ruleMap = toMap(plus_1(plus_1(plus_1(destination, new Pair('<EMPTY>', Companion_getInstance_17().EMPTY)), new Pair('<EMPTY_LIST>', Companion_getInstance_17().EMPTY_LIST)), new Pair('<EOT>', Companion_getInstance_17().END_OF_TEXT)));
    // Inline function 'kotlin.collections.map' call
    var this_1 = this.i24_1.e3();
    // Inline function 'kotlin.collections.mapTo' call
    var destination_0 = ArrayList.a1(collectionSizeOrDefault(this_1, 10));
    var _iterator__ex2g4s_0 = this_1.g1();
    while (_iterator__ex2g4s_0.f()) {
      var item_0 = _iterator__ex2g4s_0.e();
      item_0.s24(ruleMap);
      var tmp$ret$3 = ensureNotNull(item_0.q24_1);
      destination_0.v(tmp$ret$3);
    }
    var rules = destination_0;
    // Inline function 'kotlin.collections.map' call
    var this_2 = this.j24_1;
    // Inline function 'kotlin.collections.mapTo' call
    var destination_1 = ArrayList.a1(collectionSizeOrDefault(this_2, 10));
    var _iterator__ex2g4s_1 = this_2.g1();
    while (_iterator__ex2g4s_1.f()) {
      var item_1 = _iterator__ex2g4s_1.e();
      var tmp$ret$6 = item_1.v24(ruleMap);
      destination_1.v(tmp$ret$6);
    }
    var precRules = destination_1;
    return new RuntimeRuleSet(this.h24_1, this.g24_1, rules, precRules);
  }
}
class RuntimeSpineDefault {
  constructor(head, gssSnapshot, expectedNextTerminals, nextChildNumber) {
    this.o1w_1 = head;
    this.p1w_1 = gssSnapshot;
    this.q1w_1 = expectedNextTerminals;
    this.r1w_1 = nextChildNumber;
    var tmp = this;
    tmp.s1w_1 = lazy(RuntimeSpineDefault$elements$delegate$lambda(this));
  }
  q1z() {
    return this.q1w_1;
  }
  r1z() {
    return this.r1w_1;
  }
  r11() {
    var tmp0 = this.s1w_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('elements', 1, tmp, RuntimeSpineDefault$_get_elements_$ref_2lq9f3(), null);
    return tmp0.b2();
  }
  toString() {
    var tmp = this.elements;
    return 'RTSpine ' + joinToString(tmp, '->', VOID, VOID, VOID, VOID, RuntimeSpineDefault$toString$lambda);
  }
  get expectedNextTerminals() {
    return this.q1z();
  }
  get nextChildNumber() {
    return this.r1z();
  }
  get elements() {
    return this.r11();
  }
}
class ScanResult {}
class ScannerKind extends Enum {
  get name() {
    return this.r3();
  }
  get ordinal() {
    return this.s3();
  }
}
class Scanner {}
function scan(sentence, options, $super) {
  options = options === VOID ? null : options;
  return $super === VOID ? this.c25(sentence, options) : $super.c25.call(this, sentence, options);
}
class ScanOptions {}
class MatchableKind extends Enum {
  get name() {
    return this.r3();
  }
  get ordinal() {
    return this.s3();
  }
}
class Matchable {
  constructor(ruleSetNumber, ruleNumber, tag, expression, kind) {
    this.ruleSetNumber = ruleSetNumber;
    this.ruleNumber = ruleNumber;
    this.tag = tag;
    this.expression = expression;
    this.kind = kind;
    this.v1t_1 = null;
  }
  y1x() {
    return this.ruleSetNumber;
  }
  l25() {
    return this.ruleNumber;
  }
  z1x() {
    return this.tag;
  }
  m25() {
    return this.expression;
  }
  um() {
    return this.kind;
  }
  using(regexEngine) {
    this.v1t_1 = MatchableKind_REGEX_getInstance().equals(this.kind) ? regexEngine.createFor(this.expression.escapedForRegex) : null;
    return this;
  }
  isLookingAt(sentence, atPosition) {
    var tmp;
    switch (this.kind.q3_1) {
      case 0:
        tmp = atPosition >= sentence.text.length;
        break;
      case 1:
        tmp = regionMatches(sentence.text, atPosition, this.expression.value, 0, this.expression.value.length);
        break;
      case 2:
        tmp = ensureNotNull(this.v1t_1).matchesAt(sentence.text, atPosition);
        break;
      default:
        noWhenBranchMatchedException();
        break;
    }
    return tmp;
  }
  matchedLength(sentence, atPosition) {
    var tmp;
    switch (this.kind.q3_1) {
      case 0:
        tmp = atPosition >= sentence.text.length ? 0 : -1;
        break;
      case 1:
        tmp = regionMatches(sentence.text, atPosition, this.expression.value, 0, this.expression.value.length) ? this.expression.value.length : -1;
        break;
      case 2:
        var m = ensureNotNull(this.v1t_1).matchAt(sentence.text, atPosition);
        var tmp2_safe_receiver = m == null ? null : m.matchedText;
        var tmp3_elvis_lhs = tmp2_safe_receiver == null ? null : tmp2_safe_receiver.length;
        tmp = tmp3_elvis_lhs == null ? -1 : tmp3_elvis_lhs;
        break;
      default:
        noWhenBranchMatchedException();
        break;
    }
    return tmp;
  }
  toString() {
    return 'Matchable(' + this.ruleSetNumber + ', ' + this.ruleNumber + ', ' + this.kind.toString() + ', ' + this.tag + ', ' + toString(this.expression) + ')';
  }
  hashCode() {
    return (new Pair(this.ruleSetNumber, this.ruleNumber)).hashCode();
  }
  equals(other) {
    var tmp;
    if (!(other instanceof Matchable)) {
      tmp = false;
    } else {
      tmp = (this.ruleSetNumber === other.ruleSetNumber && this.ruleNumber === other.ruleNumber);
    }
    return tmp;
  }
}
class ScanOptionsDefault {
  constructor(enabled, resultsByLine, startAtPosition, offsetPosition) {
    enabled = enabled === VOID ? true : enabled;
    resultsByLine = resultsByLine === VOID ? false : resultsByLine;
    startAtPosition = startAtPosition === VOID ? 0 : startAtPosition;
    offsetPosition = offsetPosition === VOID ? 0 : offsetPosition;
    this.n25_1 = enabled;
    this.o25_1 = resultsByLine;
    this.p25_1 = startAtPosition;
    this.q25_1 = offsetPosition;
  }
  l1r(_set____db54di) {
    this.n25_1 = _set____db54di;
  }
  m1r() {
    return this.n25_1;
  }
  d25(_set____db54di) {
    this.o25_1 = _set____db54di;
  }
  e25() {
    return this.o25_1;
  }
  f25(_set____db54di) {
    this.p25_1 = _set____db54di;
  }
  g25() {
    return this.p25_1;
  }
  h25(_set____db54di) {
    this.q25_1 = _set____db54di;
  }
  i25() {
    return this.q25_1;
  }
  clone() {
    return new ScanOptionsDefault(this.n25_1, this.o25_1, this.p25_1, this.q25_1);
  }
  get enabled() {
    return this.m1r();
  }
  set enabled(value) {
    this.l1r(value);
  }
  get resultsByLine() {
    return this.e25();
  }
  set resultsByLine(value) {
    this.d25(value);
  }
  get startAtPosition() {
    return this.g25();
  }
  set startAtPosition(value) {
    this.f25(value);
  }
  get offsetPosition() {
    return this.i25();
  }
  set offsetPosition(value) {
    this.h25(value);
  }
}
class ScanResultDefault {
  constructor(tokensByLine, issues) {
    this.r25_1 = tokensByLine;
    this.s25_1 = issues;
    var tmp = this;
    tmp.t25_1 = lazy(ScanResultDefault$allTokens$delegate$lambda(this));
  }
  w24() {
    return this.r25_1;
  }
  e1s() {
    return this.s25_1;
  }
  x24() {
    var tmp0 = this.t25_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('allTokens', 1, tmp, ScanResultDefault$_get_allTokens_$ref_k49c9k(), null);
    return tmp0.b2();
  }
  ni() {
    return this.r25_1;
  }
  oi() {
    return this.s25_1;
  }
  u25(tokensByLine, issues) {
    return new ScanResultDefault(tokensByLine, issues);
  }
  copy(tokensByLine, issues, $super) {
    tokensByLine = tokensByLine === VOID ? this.r25_1 : tokensByLine;
    issues = issues === VOID ? this.s25_1 : issues;
    return $super === VOID ? this.u25(tokensByLine, issues) : $super.u25.call(this, tokensByLine, issues);
  }
  toString() {
    return 'ScanResultDefault(tokensByLine=' + toString(this.r25_1) + ', issues=' + toString(this.s25_1) + ')';
  }
  hashCode() {
    var result = hashCode(this.r25_1);
    result = imul(result, 31) + hashCode(this.s25_1) | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof ScanResultDefault))
      return false;
    if (!equals(this.r25_1, other.r25_1))
      return false;
    if (!equals(this.s25_1, other.s25_1))
      return false;
    return true;
  }
  get tokensByLine() {
    return this.w24();
  }
  get issues() {
    return this.e1s();
  }
  get allTokens() {
    return this.x24();
  }
}
class ScanByLineEndState {
  constructor(tokens, eolPosition, leftOverText) {
    this.tokens = tokens;
    this.eolPosition = eolPosition;
    this.leftOverText = leftOverText;
  }
  v25() {
    return this.tokens;
  }
  w25() {
    return this.eolPosition;
  }
  x25() {
    return this.leftOverText;
  }
  ni() {
    return this.tokens;
  }
  oi() {
    return this.eolPosition;
  }
  mm() {
    return this.leftOverText;
  }
  y25(tokens, eolPosition, leftOverText) {
    return new ScanByLineEndState(tokens, eolPosition, leftOverText);
  }
  copy(tokens, eolPosition, leftOverText, $super) {
    tokens = tokens === VOID ? this.tokens : tokens;
    eolPosition = eolPosition === VOID ? this.eolPosition : eolPosition;
    leftOverText = leftOverText === VOID ? this.leftOverText : leftOverText;
    return $super === VOID ? this.y25(tokens, eolPosition, leftOverText) : $super.y25.call(this, tokens, eolPosition, leftOverText);
  }
  toString() {
    return 'ScanByLineEndState(tokens=' + toString(this.tokens) + ', eolPosition=' + this.eolPosition + ', leftOverText=' + this.leftOverText + ')';
  }
  hashCode() {
    var result = hashCode(this.tokens);
    result = imul(result, 31) + this.eolPosition | 0;
    result = imul(result, 31) + getStringHashCode(this.leftOverText) | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof ScanByLineEndState))
      return false;
    if (!equals(this.tokens, other.tokens))
      return false;
    if (!(this.eolPosition === other.eolPosition))
      return false;
    if (!(this.leftOverText === other.leftOverText))
      return false;
    return true;
  }
}
class sam$kotlin_Comparator$0_8 {
  constructor(function_0) {
    this.z25_1 = function_0;
  }
  lg(a, b) {
    return this.z25_1(a, b);
  }
  compare(a, b) {
    return this.lg(a, b);
  }
  u3() {
    return this.z25_1;
  }
  equals(other) {
    var tmp;
    if (!(other == null) ? isInterface(other, Comparator) : false) {
      var tmp_0;
      if (!(other == null) ? isInterface(other, FunctionAdapter) : false) {
        tmp_0 = equals(this.u3(), other.u3());
      } else {
        tmp_0 = false;
      }
      tmp = tmp_0;
    } else {
      tmp = false;
    }
    return tmp;
  }
  hashCode() {
    return hashCode(this.u3());
  }
}
class sam$kotlin_Comparator$0_9 {
  constructor(function_0) {
    this.a26_1 = function_0;
  }
  lg(a, b) {
    return this.a26_1(a, b);
  }
  compare(a, b) {
    return this.lg(a, b);
  }
  u3() {
    return this.a26_1;
  }
  equals(other) {
    var tmp;
    if (!(other == null) ? isInterface(other, Comparator) : false) {
      var tmp_0;
      if (!(other == null) ? isInterface(other, FunctionAdapter) : false) {
        tmp_0 = equals(this.u3(), other.u3());
      } else {
        tmp_0 = false;
      }
      tmp = tmp_0;
    } else {
      tmp = false;
    }
    return tmp;
  }
  hashCode() {
    return hashCode(this.u3());
  }
}
class ScannerAbstract {
  constructor(regexEngine) {
    this.b26_1 = regexEngine;
    var tmp = this;
    tmp.c26_1 = lazy(ScannerAbstract$matchables$delegate$lambda(this));
  }
  a25() {
    return this.b26_1;
  }
  b25() {
    var tmp0 = this.c26_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('matchables', 1, tmp, ScannerAbstract$_get_matchables_$ref_gpomd2(), null);
    return tmp0.b2();
  }
  isEnd(sentence, position) {
    return position >= sentence.text.length;
  }
  matchedLength(sentence, position, terminalRule) {
    var tmp = (terminalRule instanceof RuntimeRule ? terminalRule : THROW_CCE()).rhs;
    var rhs = tmp instanceof RuntimeRuleRhsTerminal ? tmp : THROW_CCE();
    var tmp0_safe_receiver = rhs.matchable;
    var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.matchedLength(sentence, position);
    var len = tmp1_elvis_lhs == null ? -1 : tmp1_elvis_lhs;
    return len;
  }
  c25(sentence, options) {
    var opts = options == null ? new ScanOptionsDefault() : options;
    this.reset();
    var startAtPosition = opts.startAtPosition;
    var offsetPosition = opts.offsetPosition;
    var inputText = sentence.text;
    var issues = new IssueHolder(LanguageProcessorPhase_SCAN_getInstance());
    var tmp;
    if (opts.resultsByLine) {
      // Inline function 'kotlin.collections.mutableListOf' call
      var result = ArrayList.o1();
      var lines = split(sentence.text, ['\n']);
      var state = new ScanByLineEndState(emptyList(), -1, '');
      var _iterator__ex2g4s = lines.g1();
      while (_iterator__ex2g4s.f()) {
        var ln = _iterator__ex2g4s.e();
        var res = this.scanByLine(state, sentence, offsetPosition);
        result.v(res.tokens);
        state = res;
      }
      tmp = new ScanResultDefault(result, issues);
    } else {
      // Inline function 'kotlin.collections.mutableListOf' call
      var result_0 = ArrayList.o1();
      var position = startAtPosition;
      var nextInputPosition = position;
      var currentUndefinedText = '';
      var currentUndefinedStart = -1;
      while (nextInputPosition < inputText.length) {
        // Inline function 'kotlin.collections.mapNotNull' call
        var tmp0 = this.matchables;
        // Inline function 'kotlin.collections.mapNotNullTo' call
        var destination = ArrayList.o1();
        // Inline function 'kotlin.collections.forEach' call
        var _iterator__ex2g4s_0 = tmp0.g1();
        while (_iterator__ex2g4s_0.f()) {
          var element = _iterator__ex2g4s_0.e();
          var matchLength = element.matchedLength(sentence, position);
          var tmp_0;
          switch (matchLength) {
            case -1:
              tmp_0 = null;
              break;
            case 0:
              tmp_0 = null;
              break;
            default:
              tmp_0 = new LeafData(element.tag, element.kind.equals(MatchableKind_REGEX_getInstance()), position + offsetPosition | 0, matchLength, emptyList());
              break;
          }
          var tmp0_safe_receiver = tmp_0;
          if (tmp0_safe_receiver == null)
            null;
          else {
            // Inline function 'kotlin.let' call
            destination.v(tmp0_safe_receiver);
          }
        }
        var matches = destination;
        var tmp_1 = ScannerAbstract$scan$lambda;
        var longest = maxWithOrNull(matches, new sam$kotlin_Comparator$0_8(tmp_1));
        if (null == longest || longest.length === 0) {
          var text = toString_1(charCodeAt(inputText, nextInputPosition));
          if (-1 === currentUndefinedStart) {
            currentUndefinedStart = nextInputPosition;
          }
          currentUndefinedText = currentUndefinedText + text;
          nextInputPosition = nextInputPosition + 1 | 0;
        } else {
          if (!(-1 === currentUndefinedStart)) {
            var ud = new LeafData(Companion_getInstance_17().UNDEFINED_RULE.tag, false, currentUndefinedStart + offsetPosition | 0, currentUndefinedText.length, emptyList());
            result_0.v(ud);
            currentUndefinedStart = -1;
            currentUndefinedText = '';
          }
          result_0.v(longest);
          nextInputPosition = nextInputPosition + longest.length | 0;
        }
        position = nextInputPosition;
      }
      if (!(-1 === currentUndefinedStart)) {
        var loc = sentence.locationFor(currentUndefinedStart, currentUndefinedText.length);
        var ud_0 = new LeafData(Companion_getInstance_17().UNDEFINED_RULE.tag, false, currentUndefinedStart + offsetPosition | 0, currentUndefinedText.length, emptyList());
        result_0.v(ud_0);
      }
      tmp = new ScanResultDefault(listOf(result_0), issues);
    }
    return tmp;
  }
  scanByLine(previousState, sentence, offsetPosition) {
    // Inline function 'kotlin.collections.mutableListOf' call
    var result = ArrayList.o1();
    var startPosition = (previousState.eolPosition - previousState.leftOverText.length | 0) + 1 | 0;
    var currentUndefinedText = '';
    var currentUndefinedStart = -1;
    var nextInputPosition = startPosition;
    while (nextInputPosition < sentence.text.length) {
      // Inline function 'kotlin.collections.mapNotNull' call
      var tmp0 = this.matchables;
      // Inline function 'kotlin.collections.mapNotNullTo' call
      var destination = ArrayList.o1();
      // Inline function 'kotlin.collections.forEach' call
      var _iterator__ex2g4s = tmp0.g1();
      while (_iterator__ex2g4s.f()) {
        var element = _iterator__ex2g4s.e();
        var matchLength = element.matchedLength(sentence, nextInputPosition);
        var tmp;
        switch (matchLength) {
          case -1:
            tmp = null;
            break;
          case 0:
            tmp = null;
            break;
          default:
            tmp = new LeafData(element.tag, element.kind.equals(MatchableKind_REGEX_getInstance()), nextInputPosition + offsetPosition | 0, matchLength, emptyList());
            break;
        }
        var tmp0_safe_receiver = tmp;
        if (tmp0_safe_receiver == null)
          null;
        else {
          // Inline function 'kotlin.let' call
          destination.v(tmp0_safe_receiver);
        }
      }
      var matches = destination;
      var tmp_0 = ScannerAbstract$scanByLine$lambda;
      var longest = maxWithOrNull(matches, new sam$kotlin_Comparator$0_9(tmp_0));
      if (null == longest || longest.length === 0) {
        var text = toString_1(charCodeAt(sentence.text, nextInputPosition));
        if (-1 === currentUndefinedStart) {
          currentUndefinedStart = nextInputPosition;
        }
        currentUndefinedText = currentUndefinedText + text;
        nextInputPosition = nextInputPosition + 1 | 0;
      } else {
        if (!(-1 === currentUndefinedStart)) {
          var ud = new LeafData(Companion_getInstance_17().UNDEFINED_RULE.tag, false, currentUndefinedStart + offsetPosition | 0, currentUndefinedText.length, emptyList());
          result.v(ud);
          currentUndefinedStart = -1;
          currentUndefinedText = '';
        }
        result.v(longest);
        nextInputPosition = nextInputPosition + longest.length | 0;
      }
    }
    if (!(-1 === currentUndefinedStart)) {
      var loc = sentence.locationFor(currentUndefinedStart, currentUndefinedText.length);
      var ud_0 = new LeafData(Companion_getInstance_17().UNDEFINED_RULE.tag, false, currentUndefinedStart + offsetPosition | 0, currentUndefinedText.length, emptyList());
      result.v(ud_0);
    }
    var leftOverText = '';
    return new ScanByLineEndState(result, nextInputPosition, leftOverText);
  }
  get regexEngine() {
    return this.a25();
  }
  get validTerminals() {
    return this.d26();
  }
  get matchables() {
    return this.b25();
  }
  get kind() {
    return this.um();
  }
}
class Companion_18 {
  constructor() {
    Companion_instance_18 = this;
    this.LEAF_NONE = new CompleteTreeDataNode(Companion_getInstance_17().UNDEFINED_RULE, -1, -1, -1, Companion_getInstance_11().OPTION_NONE, emptyList());
  }
  e26() {
    return this.LEAF_NONE;
  }
}
class sam$kotlin_Comparator$0_10 {
  constructor(function_0) {
    this.k26_1 = function_0;
  }
  lg(a, b) {
    return this.k26_1(a, b);
  }
  compare(a, b) {
    return this.lg(a, b);
  }
  u3() {
    return this.k26_1;
  }
  equals(other) {
    var tmp;
    if (!(other == null) ? isInterface(other, Comparator) : false) {
      var tmp_0;
      if (!(other == null) ? isInterface(other, FunctionAdapter) : false) {
        tmp_0 = equals(this.u3(), other.u3());
      } else {
        tmp_0 = false;
      }
      tmp = tmp_0;
    } else {
      tmp = false;
    }
    return tmp;
  }
  hashCode() {
    return hashCode(this.u3());
  }
}
class ScannerClassic extends ScannerAbstract {
  constructor(regexEngine, terminals) {
    Companion_getInstance_18();
    super(regexEngine);
    var tmp = this;
    // Inline function 'kotlin.collections.filterNot' call
    // Inline function 'kotlin.collections.filterNotTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = terminals.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      if (!(element.isEmptyTerminal || element.isEmptyListTerminal)) {
        destination.v(element);
      }
    }
    tmp.h26_1 = destination;
    this.matchables;
    this.i26_1 = ScannerKind_Classic_getInstance();
    var tmp_0 = this;
    // Inline function 'kotlin.collections.mutableMapOf' call
    tmp_0.j26_1 = LinkedHashMap.j4();
  }
  d26() {
    return this.h26_1;
  }
  um() {
    return this.i26_1;
  }
  reset() {
  }
  isEnd(sentence, position) {
    return position >= sentence.text.length;
  }
  isLookingAt(sentence, position, terminalRule) {
    var l = this.findOrTryCreateLeaf(sentence, position, terminalRule);
    var tmp1_safe_receiver = l == null ? null : l.q1e_1;
    var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : equals(tmp1_safe_receiver, terminalRule);
    return tmp2_elvis_lhs == null ? false : tmp2_elvis_lhs;
  }
  findOrTryCreateLeaf(sentence, position, terminalRule) {
    var l = this.j26_1.c3(position);
    var tmp;
    if (terminalRule.isEmptyTerminal) {
      tmp = new CompleteTreeDataNode(Companion_getInstance_17().EMPTY, position, position, position, Companion_getInstance_11().OPTION_NONE, emptyList());
    } else if (terminalRule.isEmptyListTerminal) {
      tmp = new CompleteTreeDataNode(Companion_getInstance_17().EMPTY_LIST, position, position, position, Companion_getInstance_11().OPTION_NONE, emptyList());
    } else if (null == l) {
      var lf = scanAt(this, sentence, position);
      // Inline function 'kotlin.collections.set' call
      this.j26_1.f3(position, lf);
      tmp = Companion_getInstance_18().LEAF_NONE.equals(lf) ? null : lf;
    } else if (Companion_getInstance_18().LEAF_NONE.equals(l)) {
      tmp = null;
    } else {
      tmp = l;
    }
    var res = tmp;
    var tmp_0;
    if (equals(res == null ? null : res.q1e_1, terminalRule)) {
      tmp_0 = res;
    } else {
      tmp_0 = null;
    }
    return tmp_0;
  }
  get kind() {
    return this.um();
  }
}
class ScannerFromMatchables extends ScannerAbstract {
  constructor(regexEngine, _matchables) {
    regexEngine = regexEngine === VOID ? RegexEnginePlatform_getInstance() : regexEngine;
    super(regexEngine);
    this.n26_1 = _matchables;
  }
  b25() {
    return this.n26_1();
  }
  um() {
    var message = 'Not used';
    throw IllegalStateException.t4(toString(message));
  }
  d26() {
    var message = 'Not used';
    throw IllegalStateException.t4(toString(message));
  }
  reset() {
  }
  isLookingAt(sentence, position, terminalRule) {
    var message = 'Not used';
    throw IllegalStateException.t4(toString(message));
  }
  findOrTryCreateLeaf(sentence, position, terminalRule) {
    var message = 'Not used';
    throw IllegalStateException.t4(toString(message));
  }
  get kind() {
    return this.um();
  }
}
class Companion_19 {
  constructor() {
    Companion_instance_19 = this;
    this.END_OF_TEXT = '\x03';
    this.LEAF_NONE = new CompleteTreeDataNode(Companion_getInstance_17().UNDEFINED_RULE, -1, -1, -1, Companion_getInstance_11().OPTION_NONE, emptyList());
  }
  k23() {
    return this.END_OF_TEXT;
  }
  e26() {
    return this.LEAF_NONE;
  }
}
class IsLookingAtMask {
  constructor() {
    this.o26_1 = new Int32Array(4);
    this.p26_1 = new Int32Array(4);
  }
  q26(chunkIdx) {
    if (chunkIdx >= this.o26_1.length) {
      var tmp0 = imul(this.o26_1.length, 2);
      // Inline function 'kotlin.comparisons.maxOf' call
      var b = chunkIdx + 1 | 0;
      var newSize = Math.max(tmp0, b);
      this.o26_1 = copyOf(this.o26_1, newSize);
      this.p26_1 = copyOf(this.p26_1, newSize);
    }
  }
}
class ScannerOnDemand extends ScannerAbstract {
  constructor(regexEngine, terminals) {
    Companion_getInstance_19();
    super(regexEngine);
    this.l1e_1 = HashMap.o7();
    this.m1e_1 = new CompletedNodesStore(terminals.h1());
    var tmp = this;
    // Inline function 'kotlin.collections.filterNot' call
    // Inline function 'kotlin.collections.filterNotTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = terminals.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      if (!(element.isEmptyTerminal || element.isEmptyListTerminal)) {
        destination.v(element);
      }
    }
    tmp.n1e_1 = destination;
    this.matchables;
    this.o1e_1 = ScannerKind_OnDemand_getInstance();
  }
  s26() {
    return this.m1e_1;
  }
  d26() {
    return this.n1e_1;
  }
  um() {
    return this.o1e_1;
  }
  reset() {
    this.m1e_1.i3();
    this.l1e_1.i3();
  }
  isLookingAt(sentence, position, terminalRule) {
    var rt = terminalRule instanceof RuntimeRule ? terminalRule : THROW_CCE();
    var chunkIdx = position >>> 5 | 0;
    var bit = 1 << (position & 31);
    var existing = this.l1e_1.c3(rt);
    if (!(existing == null) && chunkIdx < existing.o26_1.length && !((existing.o26_1[chunkIdx] & bit) === 0)) {
      return !((existing.p26_1[chunkIdx] & bit) === 0);
    }
    var tmp = rt.rhs;
    var rhs = tmp instanceof RuntimeRuleRhsTerminal ? tmp : THROW_CCE();
    var tmp0_safe_receiver = rhs.matchable;
    var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.isLookingAt(sentence, position);
    var matched = tmp1_elvis_lhs == null ? false : tmp1_elvis_lhs;
    var tmp_0;
    if (existing == null) {
      // Inline function 'kotlin.also' call
      var this_0 = new IsLookingAtMask();
      // Inline function 'kotlin.collections.set' call
      this.l1e_1.f3(rt, this_0);
      tmp_0 = this_0;
    } else {
      tmp_0 = existing;
    }
    var mask = tmp_0;
    mask.q26(chunkIdx);
    mask.o26_1[chunkIdx] = mask.o26_1[chunkIdx] | bit;
    if (matched) {
      mask.p26_1[chunkIdx] = mask.p26_1[chunkIdx] | bit;
    }
    return matched;
  }
  p1e(sentence, lh, position) {
    var tmp;
    if (lh.includesRT) {
      var message = 'lookahead must be real lookahead values, <RT> must be resolved';
      throw IllegalStateException.t4(toString(message));
    } else if (lh.includesEOT && this.isEnd(sentence, position)) {
      tmp = true;
    } else {
      var tmp0 = lh.content;
      var tmp$ret$0;
      $l$block_0: {
        // Inline function 'kotlin.collections.any' call
        var tmp_0;
        if (isInterface(tmp0, Collection)) {
          tmp_0 = tmp0.l1();
        } else {
          tmp_0 = false;
        }
        if (tmp_0) {
          tmp$ret$0 = false;
          break $l$block_0;
        }
        var _iterator__ex2g4s = tmp0.g1();
        while (_iterator__ex2g4s.f()) {
          var element = _iterator__ex2g4s.e();
          if (this.isLookingAt(sentence, position, element)) {
            tmp$ret$0 = true;
            break $l$block_0;
          }
        }
        tmp$ret$0 = false;
      }
      tmp = tmp$ret$0;
    }
    return tmp;
  }
  r26(sentence, position, terminalRule) {
    var tmp = terminalRule.rhs;
    var rhs = tmp instanceof RuntimeRuleRhsTerminal ? tmp : THROW_CCE();
    var matchable = rhs.matchable;
    var tmp1_elvis_lhs = matchable == null ? null : matchable.matchedLength(sentence, position);
    return tmp1_elvis_lhs == null ? -1 : tmp1_elvis_lhs;
  }
  findOrTryCreateLeaf(sentence, position, terminalRule) {
    var existing = this.m1e_1.e20(terminalRule instanceof RuntimeRule ? terminalRule : THROW_CCE(), position);
    if (null == existing) {
      existing = tryCreateLeaf(this, sentence, position, terminalRule);
    }
    var tmp;
    if (Companion_getInstance_19().LEAF_NONE === existing) {
      tmp = null;
    } else {
      tmp = existing;
    }
    return tmp;
  }
  get kind() {
    return this.um();
  }
}
class Companion_20 {
  constructor() {
    Companion_instance_20 = this;
    this.EOL_PATTERN = Regex.if('\n', setOf(RegexOption_MULTILINE_getInstance()));
  }
  t26() {
    return this.EOL_PATTERN;
  }
  eolPositions(text) {
    var tmp = this.EOL_PATTERN.of(text);
    return toList_2(map(tmp, SentenceDefault$Companion$eolPositions$lambda));
  }
}
class Sentence {}
class SentenceAbstract {
  constructor(identity) {
    this.identity = identity;
  }
  sz() {
    return this.identity;
  }
  textAt(position, length) {
    return substring(this.text, position, position + length | 0);
  }
  positionOfLine(line) {
    var tmp;
    if (0 > line) {
      var message = 'Line number must be >= 1';
      throw IllegalStateException.t4(toString(message));
    } else if (this.eolPositions.h1() < line) {
      var message_0 = 'Number of lines in this text is ' + this.eolPositions.h1() + ', requested line number was ' + line;
      throw IllegalStateException.t4(toString(message_0));
    } else if (0 === line) {
      tmp = 0;
    } else {
      tmp = this.eolPositions.i1(line - 1 | 0) + 1 | 0;
    }
    return tmp;
  }
  locationInLine(line, position, length) {
    var tmp;
    if (0 > line) {
      var message = 'Line number must be >= 1';
      throw IllegalStateException.t4(toString(message));
    } else if (this.eolPositions.h1() < line) {
      var message_0 = 'Number of lines in this text is ' + this.eolPositions.h1() + ', requested line number was ' + line;
      throw IllegalStateException.t4(toString(message_0));
    } else {
      var col = (position - this.positionOfLine(line) | 0) + 1 | 0;
      tmp = new InputLocation(position, col, line + 1 | 0, length, this.identity);
    }
    return tmp;
  }
  locationFor(position, length) {
    var tmp;
    if (0 === position) {
      tmp = new InputLocation(position, 1, 1, length, this.identity);
    } else if (this.eolPositions.l1()) {
      tmp = new InputLocation(position, position + 1 | 0, 1, length, this.identity);
    } else {
      var tmp0 = this.eolPositions;
      var tmp$ret$1;
      $l$block: {
        // Inline function 'kotlin.collections.indexOfLast' call
        var iterator = tmp0.q1(tmp0.h1());
        while (iterator.g6()) {
          if (iterator.i6() < position) {
            tmp$ret$1 = iterator.h6();
            break $l$block;
          }
        }
        tmp$ret$1 = -1;
      }
      var line = tmp$ret$1;
      tmp = line === -1 ? new InputLocation(position, position + 1 | 0, 1, length, this.identity) : this.locationInLine(line + 1 | 0, position, length);
    }
    return tmp;
  }
  contextInText(position) {
    // Inline function 'kotlin.comparisons.maxOf' call
    var b = position - 10 | 0;
    var startIndex = Math.max(0, b);
    var tmp0 = this.text.length;
    // Inline function 'kotlin.comparisons.minOf' call
    var b_0 = position + 10 | 0;
    var endIndex = Math.min(tmp0, b_0);
    var forText = substring(this.text, startIndex, position);
    var aftText = substring(this.text, position, endIndex);
    var startOfLine = lastIndexOfAny(forText, listOf_0(['\n', '\r']));
    var tmp;
    if (-1 === startOfLine) {
      tmp = 0;
    } else {
      tmp = startOfLine + 1 | 0;
    }
    var s = tmp;
    var forTextAfterLastEol = substring_0(forText, s);
    var prefix = startOfLine > 0 ? '' : startIndex > 0 ? '...' : '';
    var postFix = endIndex < this.text.length ? '...' : '';
    return prefix + forTextAfterLastEol + '^' + aftText + postFix;
  }
  get text() {
    return this.v20();
  }
  get eolPositions() {
    return this.w26();
  }
}
class SentenceDefault extends SentenceAbstract {
  constructor(text, identity) {
    Companion_getInstance_20();
    super(identity);
    this.u26_1 = text;
    var tmp = this;
    tmp.v26_1 = lazy(SentenceDefault$eolPositions$delegate$lambda(this));
  }
  v20() {
    return this.u26_1;
  }
  w26() {
    var tmp0 = this.v26_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('eolPositions', 1, tmp, SentenceDefault$_get_eolPositions_$ref_e1vexk(), null);
    return tmp0.b2();
  }
}
class Companion_21 {
  constructor() {
    this.contextSize = 10;
  }
  x26() {
    return this.contextSize;
  }
}
class InputLocation {
  constructor(position, column, line, length, sentenceIdentity) {
    this.position = position;
    this.column = column;
    this.line = line;
    this.length = length;
    this.sentenceIdentity = sentenceIdentity;
  }
  o1z() {
    return this.position;
  }
  y26() {
    return this.column;
  }
  z26() {
    return this.line;
  }
  a27(_set____db54di) {
    this.length = _set____db54di;
  }
  a() {
    return this.length;
  }
  q1r() {
    return this.sentenceIdentity;
  }
  b27() {
    return this.position + this.length | 0;
  }
  ni() {
    return this.position;
  }
  oi() {
    return this.column;
  }
  mm() {
    return this.line;
  }
  d16() {
    return this.length;
  }
  g1c() {
    return this.sentenceIdentity;
  }
  c27(position, column, line, length, sentenceIdentity) {
    return new InputLocation(position, column, line, length, sentenceIdentity);
  }
  copy(position, column, line, length, sentenceIdentity, $super) {
    position = position === VOID ? this.position : position;
    column = column === VOID ? this.column : column;
    line = line === VOID ? this.line : line;
    length = length === VOID ? this.length : length;
    sentenceIdentity = sentenceIdentity === VOID ? this.sentenceIdentity : sentenceIdentity;
    return $super === VOID ? this.c27(position, column, line, length, sentenceIdentity) : $super.c27.call(this, position, column, line, length, sentenceIdentity);
  }
  toString() {
    return 'InputLocation(position=' + this.position + ', column=' + this.column + ', line=' + this.line + ', length=' + this.length + ', sentenceIdentity=' + toString_0(this.sentenceIdentity) + ')';
  }
  hashCode() {
    var result = this.position;
    result = imul(result, 31) + this.column | 0;
    result = imul(result, 31) + this.line | 0;
    result = imul(result, 31) + this.length | 0;
    result = imul(result, 31) + (this.sentenceIdentity == null ? 0 : hashCode(this.sentenceIdentity)) | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof InputLocation))
      return false;
    if (!(this.position === other.position))
      return false;
    if (!(this.column === other.column))
      return false;
    if (!(this.line === other.line))
      return false;
    if (!(this.length === other.length))
      return false;
    if (!equals(this.sentenceIdentity, other.sentenceIdentity))
      return false;
    return true;
  }
  get endPosition() {
    return this.b27();
  }
}
class SPPTNode {}
class SPPTBranch {}
class SPPTLeaf {}
class SPPTParser {}
function parse(treeAsString, addTree, $super) {
  addTree = addTree === VOID ? false : addTree;
  return $super === VOID ? this.w27(treeAsString, addTree) : $super.w27.call(this, treeAsString, addTree);
}
class ChildInfo {
  constructor(propertyIndex, index, total) {
    this.propertyIndex = propertyIndex;
    this.index = index;
    this.total = total;
  }
  x27() {
    return this.propertyIndex;
  }
  y27() {
    return this.index;
  }
  z27() {
    return this.total;
  }
  ni() {
    return this.propertyIndex;
  }
  oi() {
    return this.index;
  }
  mm() {
    return this.total;
  }
  a28(propertyIndex, index, total) {
    return new ChildInfo(propertyIndex, index, total);
  }
  copy(propertyIndex, index, total, $super) {
    propertyIndex = propertyIndex === VOID ? this.propertyIndex : propertyIndex;
    index = index === VOID ? this.index : index;
    total = total === VOID ? this.total : total;
    return $super === VOID ? this.a28(propertyIndex, index, total) : $super.a28.call(this, propertyIndex, index, total);
  }
  toString() {
    return 'ChildInfo(propertyIndex=' + this.propertyIndex + ', index=' + this.index + ', total=' + this.total + ')';
  }
  hashCode() {
    var result = this.propertyIndex;
    result = imul(result, 31) + this.index | 0;
    result = imul(result, 31) + this.total | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof ChildInfo))
      return false;
    if (!(this.propertyIndex === other.propertyIndex))
      return false;
    if (!(this.index === other.index))
      return false;
    if (!(this.total === other.total))
      return false;
    return true;
  }
}
class AltInfo {
  constructor(option, index, totalMatched) {
    this.option = option;
    this.index = index;
    this.totalMatched = totalMatched;
  }
  c1d() {
    return this.option;
  }
  y27() {
    return this.index;
  }
  b28() {
    return this.totalMatched;
  }
  ni() {
    return this.option;
  }
  oi() {
    return this.index;
  }
  mm() {
    return this.totalMatched;
  }
  c28(option, index, totalMatched) {
    return new AltInfo(option, index, totalMatched);
  }
  copy(option, index, totalMatched, $super) {
    option = option === VOID ? this.option : option;
    index = index === VOID ? this.index : index;
    totalMatched = totalMatched === VOID ? this.totalMatched : totalMatched;
    return $super === VOID ? this.c28(option, index, totalMatched) : $super.c28.call(this, option, index, totalMatched);
  }
  toString() {
    return 'AltInfo(option=' + this.option.toString() + ', index=' + this.index + ', totalMatched=' + this.totalMatched + ')';
  }
  hashCode() {
    var result = this.option.hashCode();
    result = imul(result, 31) + this.index | 0;
    result = imul(result, 31) + this.totalMatched | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof AltInfo))
      return false;
    if (!this.option.equals(other.option))
      return false;
    if (!(this.index === other.index))
      return false;
    if (!(this.totalMatched === other.totalMatched))
      return false;
    return true;
  }
}
class ParsePath {
  constructor(segments) {
    segments = segments === VOID ? emptyList() : segments;
    this.segments = segments;
  }
  d28() {
    return this.segments;
  }
  plus(segment) {
    return new ParsePath(plus_1(this.segments, segment));
  }
  toString() {
    return joinToString(this.segments, '/', '/');
  }
  ni() {
    return this.segments;
  }
  e28(segments) {
    return new ParsePath(segments);
  }
  copy(segments, $super) {
    segments = segments === VOID ? this.segments : segments;
    return $super === VOID ? this.e28(segments) : $super.e28.call(this, segments);
  }
  hashCode() {
    return hashCode(this.segments);
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof ParsePath))
      return false;
    if (!equals(this.segments, other.segments))
      return false;
    return true;
  }
}
class SpptDataNodeInfo {}
class PathFunction {}
class SpptWalker {}
class LeafData {
  constructor(name, isPattern, position, length, tagList) {
    this.name = name;
    this.isPattern = isPattern;
    this.position = position;
    this.length = length;
    this.tagList = tagList;
  }
  r3() {
    return this.name;
  }
  g1y() {
    return this.isPattern;
  }
  o1z() {
    return this.position;
  }
  a() {
    return this.length;
  }
  u27() {
    return this.tagList;
  }
  ni() {
    return this.name;
  }
  oi() {
    return this.isPattern;
  }
  mm() {
    return this.position;
  }
  d16() {
    return this.length;
  }
  g1c() {
    return this.tagList;
  }
  m28(name, isPattern, position, length, tagList) {
    return new LeafData(name, isPattern, position, length, tagList);
  }
  copy(name, isPattern, position, length, tagList, $super) {
    name = name === VOID ? this.name : name;
    isPattern = isPattern === VOID ? this.isPattern : isPattern;
    position = position === VOID ? this.position : position;
    length = length === VOID ? this.length : length;
    tagList = tagList === VOID ? this.tagList : tagList;
    return $super === VOID ? this.m28(name, isPattern, position, length, tagList) : $super.m28.call(this, name, isPattern, position, length, tagList);
  }
  toString() {
    return 'LeafData(name=' + this.name + ', isPattern=' + this.isPattern + ', position=' + this.position + ', length=' + this.length + ', tagList=' + toString(this.tagList) + ')';
  }
  hashCode() {
    var result = getStringHashCode(this.name);
    result = imul(result, 31) + getBooleanHashCode(this.isPattern) | 0;
    result = imul(result, 31) + this.position | 0;
    result = imul(result, 31) + this.length | 0;
    result = imul(result, 31) + hashCode(this.tagList) | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof LeafData))
      return false;
    if (!(this.name === other.name))
      return false;
    if (!(this.isPattern === other.isPattern))
      return false;
    if (!(this.position === other.position))
      return false;
    if (!(this.length === other.length))
      return false;
    if (!equals(this.tagList, other.tagList))
      return false;
    return true;
  }
}
class TreeData {}
class SharedPackedParseTree {}
function toStringAllWithIndent(indentIncrement, skipDataAsTree, $super) {
  skipDataAsTree = skipDataAsTree === VOID ? false : skipDataAsTree;
  return $super === VOID ? this.v28(indentIncrement, skipDataAsTree) : $super.v28.call(this, indentIncrement, skipDataAsTree);
}
class SharedPackedParseTreeVisitor {}
function visitNode(target, arg) {
  var tmp;
  if (isInterface(target, SPPTLeaf)) {
    tmp = this.visitLeaf(target, arg);
  } else {
    if (isInterface(target, SPPTBranch)) {
      tmp = this.visitBranch(target, arg);
    } else {
      var message = 'Unknown subtype of SPPTNode ' + getKClassFromExpression(target).md();
      throw IllegalStateException.t4(toString(message));
    }
  }
  return tmp;
}
class sam$kotlin_Comparator$0_11 {
  constructor(function_0) {
    this.w28_1 = function_0;
  }
  lg(a, b) {
    return this.w28_1(a, b);
  }
  compare(a, b) {
    return this.lg(a, b);
  }
  u3() {
    return this.w28_1;
  }
  equals(other) {
    var tmp;
    if (!(other == null) ? isInterface(other, Comparator) : false) {
      var tmp_0;
      if (!(other == null) ? isInterface(other, FunctionAdapter) : false) {
        tmp_0 = equals(this.u3(), other.u3());
      } else {
        tmp_0 = false;
      }
      tmp = tmp_0;
    } else {
      tmp = false;
    }
    return tmp;
  }
  hashCode() {
    return hashCode(this.u3());
  }
}
class CountTreesVisitor {
  visitTree(target, arg) {
    // Inline function 'kotlin.TODO' call
    throw NotImplementedError.im();
  }
  visitLeaf(target, arg) {
    return 1;
  }
  visitBranch(target, arg) {
    var currentCount = 0;
    // Inline function 'kotlin.collections.sortedBy' call
    var this_0 = target.childrenAlternatives.z1();
    // Inline function 'kotlin.comparisons.compareBy' call
    var tmp = CountTreesVisitor$visitBranch$lambda;
    var tmp$ret$0 = new sam$kotlin_Comparator$0_11(tmp);
    var _iterator__ex2g4s = sortedWith(this_0, tmp$ret$0).g1();
    while (_iterator__ex2g4s.f()) {
      var _destruct__k2r9zo = _iterator__ex2g4s.e();
      // Inline function 'kotlin.collections.component1' call
      var alt = _destruct__k2r9zo.a2();
      // Inline function 'kotlin.collections.component2' call
      var children = _destruct__k2r9zo.b2();
      if (children.l1()) {
        currentCount = currentCount + 1 | 0;
      } else {
        var max = 0;
        var inductionVariable = 0;
        var last = children.h1();
        if (inductionVariable < last)
          do {
            var i = inductionVariable;
            inductionVariable = inductionVariable + 1 | 0;
            var tmp0 = max;
            var tmp_0 = children.i1(i);
            // Inline function 'kotlin.comparisons.maxOf' call
            var b = this.visitNode(tmp_0, Unit_instance);
            max = Math.max(tmp0, b);
          }
           while (inductionVariable < last);
        currentCount = currentCount + max | 0;
      }
    }
    return currentCount;
  }
}
class sam$kotlin_Comparator$0_12 {
  constructor(function_0) {
    this.e29_1 = function_0;
  }
  lg(a, b) {
    return this.e29_1(a, b);
  }
  compare(a, b) {
    return this.lg(a, b);
  }
  u3() {
    return this.e29_1;
  }
  equals(other) {
    var tmp;
    if (!(other == null) ? isInterface(other, Comparator) : false) {
      var tmp_0;
      if (!(other == null) ? isInterface(other, FunctionAdapter) : false) {
        tmp_0 = equals(this.u3(), other.u3());
      } else {
        tmp_0 = false;
      }
      tmp = tmp_0;
    } else {
      tmp = false;
    }
    return tmp;
  }
  hashCode() {
    return hashCode(this.u3());
  }
}
class SPPTFromTreeData {
  constructor(treeData, sentence, seasons, maxNumHeads) {
    this.x28_1 = treeData;
    this.sentence = sentence;
    this.y28_1 = seasons;
    this.z28_1 = maxNumHeads;
    var tmp = this;
    tmp.a29_1 = lazy(SPPTFromTreeData$_tokensByLine$delegate$lambda(this));
    var tmp_0 = this;
    tmp_0.b29_1 = lazy(SPPTFromTreeData$asSentence$delegate$lambda(this));
    var tmp_1 = this;
    tmp_1.c29_1 = lazy(SPPTFromTreeData$countTrees$delegate$lambda(this));
    var tmp_2 = this;
    tmp_2.d29_1 = lazy(SPPTFromTreeData$toStringAll$delegate$lambda(this));
  }
  s28() {
    return this.x28_1;
  }
  e1g() {
    return this.sentence;
  }
  t28() {
    return this.y28_1;
  }
  u28() {
    return this.z28_1;
  }
  p28() {
    var tmp0 = this.b29_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('asSentence', 1, tmp, SPPTFromTreeData$_get_asSentence_$ref_19101i(), null);
    return tmp0.b2();
  }
  q28() {
    var tmp0 = this.c29_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('countTrees', 1, tmp, SPPTFromTreeData$_get_countTrees_$ref_xsxrlx(), null);
    return tmp0.b2();
  }
  r28() {
    var tmp0 = this.d29_1;
    var tmp = KProperty1;
    // Inline function 'kotlin.getValue' call
    getPropertyCallableRef('toStringAll', 1, tmp, SPPTFromTreeData$_get_toStringAll_$ref_5gchp6(), null);
    return tmp0.b2();
  }
  traverseTreeDepthFirst(callback, skipDataAsTree) {
    this.x28_1.traverseTreeDepthFirst(callback, skipDataAsTree);
  }
  tokensByLineAll() {
    return _get__tokensByLine__ebyq43(this);
  }
  tokensByLine(line) {
    var tbl = _get__tokensByLine__ebyq43(this);
    var tmp;
    if (tbl.l1() || line >= tbl.h1()) {
      tmp = emptyList();
    } else {
      tmp = tbl.i1(line);
    }
    return tmp;
  }
  v28(indentIncrement, skipDataAsTree) {
    var walker = new SpptWalkerToString(this.sentence, indentIncrement);
    this.x28_1.traverseTreeDepthFirst(walker, skipDataAsTree);
    // Inline function 'kotlin.text.trim' call
    var this_0 = walker.output;
    return toString(trim(isCharSequence(this_0) ? this_0 : THROW_CCE()));
  }
  matches(other) {
    return this.x28_1.matches(other.x28_1);
  }
  hashCode() {
    return hashCode(this.x28_1);
  }
  equals(other) {
    var tmp;
    if (!(!(other == null) ? isInterface(other, SharedPackedParseTree) : false)) {
      tmp = false;
    } else {
      if (!this.x28_1.matches(other.treeData)) {
        tmp = false;
      } else {
        tmp = true;
      }
    }
    return tmp;
  }
  get treeData() {
    return this.s28();
  }
  get seasons() {
    return this.t28();
  }
  get maxNumHeads() {
    return this.u28();
  }
  get asSentence() {
    return this.p28();
  }
  get countTrees() {
    return this.q28();
  }
  get toStringAll() {
    return this.r28();
  }
}
class SPPTParserDefault {
  constructor(rootRuleSet, embeddedRuntimeRuleSets) {
    embeddedRuntimeRuleSets = embeddedRuntimeRuleSets === VOID ? emptyMap() : embeddedRuntimeRuleSets;
    this.rootRuleSet = rootRuleSet;
    this.embeddedRuntimeRuleSets = embeddedRuntimeRuleSets;
    this.l29_1 = null;
  }
  n29() {
    return this.rootRuleSet;
  }
  o29() {
    return this.embeddedRuntimeRuleSets;
  }
  p29(_set____db54di) {
    this.m29_1 = _set____db54di;
  }
  t27() {
    var tmp = this.m29_1;
    if (!(tmp == null))
      return tmp;
    else {
      throwUninitializedPropertyAccessException('tree');
    }
  }
  clear() {
  }
  w27(treeAsString, addTree) {
    var tp = new TreeParser(treeAsString, this.embeddedRuntimeRuleSets);
    var tmp;
    if (addTree) {
      tmp = this.l29_1;
    } else {
      tmp = null;
    }
    var oldTree = tmp;
    var td = tp.a2a(_get_rootRuntimeRuleSet__c3cqbf(this), oldTree);
    this.l29_1 = td;
    this.m29_1 = new SPPTFromTreeData(td, new SentenceDefault(tp.e1g(), null), -1, -1);
    return this.tree;
  }
  addTree(treeString) {
    this.parse(treeString, true);
    return this.tree;
  }
  get tree() {
    return this.t27();
  }
  set tree(value) {
    this.p29(value);
  }
}
class TreeParser {
  constructor(treeAsString, embeddedRuntimeRuleSets) {
    this.q29_1 = treeAsString;
    this.r29_1 = embeddedRuntimeRuleSets;
    this.s29_1 = new SimpleScanner(this.q29_1, Tokens_getInstance().e2a_1);
    this.t29_1 = 0;
    this.u29_1 = 0;
    this.v29_1 = mutableStackOf([]);
    this.w29_1 = mutableStackOf([]);
    this.x29_1 = mutableStackOf([]);
    this.y29_1 = mutableStackOf([]);
    this.z29_1 = StringBuilder.s();
  }
  e1g() {
    return this.z29_1.toString();
  }
  a2a(rootRuntimeRuleSet, oldTree) {
    beginTree(this, rootRuntimeRuleSet, oldTree);
    // Inline function 'kotlin.collections.mutableListOf' call
    var tmp$ret$0 = ArrayList.o1();
    this.x29_1.o11(tmp$ret$0);
    while (this.s29_1.y2a()) {
      if (this.s29_1.z2a([Tokens_getInstance().f2a_1])) {
        scanEmpty(this);
      } else if (this.s29_1.z2a([Tokens_getInstance().g2a_1])) {
        scanEmptyList(this);
      } else if (this.s29_1.z2a([Tokens_getInstance().i2a_1, Tokens_getInstance().n2a_1, Tokens_getInstance().l2a_1])) {
        scanLeafLiteral(this);
      } else if (this.s29_1.z2a([Tokens_getInstance().i2a_1, Tokens_getInstance().n2a_1, Tokens_getInstance().i2a_1, Tokens_getInstance().j2a_1, Tokens_getInstance().i2a_1, Tokens_getInstance().o2a_1])) {
        scanEmbedded(this);
      } else if (this.s29_1.z2a([Tokens_getInstance().i2a_1, Tokens_getInstance().k2a_1, Tokens_getInstance().o2a_1])) {
        scanBranchStartWithOption(this);
      } else if (this.s29_1.z2a([Tokens_getInstance().i2a_1, Tokens_getInstance().o2a_1])) {
        scanBranchStart(this);
      } else if (this.s29_1.z2a([Tokens_getInstance().l2a_1])) {
        scanLiteral(this);
      } else if (this.s29_1.z2a([Tokens_getInstance().m2a_1, Tokens_getInstance().n2a_1, Tokens_getInstance().l2a_1])) {
        scanPattern(this);
      } else if (this.s29_1.z2a([Tokens_getInstance().p2a_1])) {
        scanBranchEnd(this);
      } else {
        scanError(this);
      }
    }
    var urn = last(this.x29_1.v11());
    return endTree(this, urn);
  }
  toString() {
    return this.s29_1.toString();
  }
}
class SimpleScanner {
  constructor(input, skip) {
    this.b2a_1 = input;
    this.c2a_1 = skip;
    this.d2a_1 = this.a2b(0).ii_1;
  }
  y2a() {
    return this.d2a_1 < charSequenceLength(this.b2a_1);
  }
  z2a(patterns) {
    var pos = this.d2a_1;
    var inductionVariable = 0;
    var last = patterns.length;
    while (inductionVariable < last) {
      var pat = patterns[inductionVariable];
      inductionVariable = inductionVariable + 1 | 0;
      var match = pat.match(this.b2a_1, pos);
      if (match == null)
        return false;
      else {
        pos = pos + match.matchedText.length | 0;
        pos = this.a2b(pos).ii_1;
      }
    }
    return true;
  }
  q2a(pattern) {
    var match = pattern.match(this.b2a_1, this.d2a_1);
    var tmp;
    if (!(null == match)) {
      var matchStr = match.matchedText;
      this.d2a_1 = this.d2a_1 + matchStr.length | 0;
      this.d2a_1 = this.a2b(this.d2a_1).ii_1;
      tmp = matchStr;
    } else {
      var message = 'Error scanning for pattern ' + toString(pattern) + ' at Position ' + this.d2a_1;
      throw IllegalStateException.t4(toString(message));
    }
    return tmp;
  }
  a2b(at) {
    var pos = at;
    var match = this.c2a_1.match(this.b2a_1, pos);
    var tmp;
    if (!(null == match)) {
      var matchStr = match.matchedText;
      pos = pos + matchStr.length | 0;
      tmp = new Pair(matchStr, pos);
    } else {
      tmp = new Pair('', pos);
    }
    return tmp;
  }
  toString() {
    var x = 5;
    var tmp0 = this.b2a_1;
    // Inline function 'kotlin.comparisons.maxOf' call
    var b = this.d2a_1 - x | 0;
    var tmp2 = Math.max(0, b);
    // Inline function 'kotlin.text.substring' call
    var endIndex = this.d2a_1;
    var before = toString(charSequenceSubSequence(tmp0, tmp2, endIndex));
    var tmp0_0 = this.b2a_1;
    var tmp2_0 = this.d2a_1;
    var tmp0_1 = charSequenceLength(this.b2a_1);
    // Inline function 'kotlin.comparisons.minOf' call
    var b_0 = this.d2a_1 + x | 0;
    // Inline function 'kotlin.text.substring' call
    var endIndex_0 = Math.min(tmp0_1, b_0);
    var after = toString(charSequenceSubSequence(tmp0_0, tmp2_0, endIndex_0));
    return before + '^' + after;
  }
}
class Tokens {
  constructor() {
    Tokens_instance = this;
    this.e2a_1 = regexMatcher('\\s+');
    this.f2a_1 = regexMatcher('\xA7empty|<EMPTY>');
    this.g2a_1 = regexMatcher('<EMPTY_LIST>');
    this.h2a_1 = regexMatcher('[a-zA-Z_\xA7][.a-zA-Z_0-9\xA7]*');
    this.i2a_1 = regexMatcher('[a-zA-Z_\xA7][a-zA-Z_0-9\xA7]*');
    this.j2a_1 = regexMatcher('::');
    this.k2a_1 = regexMatcher('[|][0-9]+');
    this.l2a_1 = regexMatcher(CommonRegexPatterns_getInstance().LITERAL.escapedForRegex);
    this.m2a_1 = regexMatcher(CommonRegexPatterns_getInstance().PATTERN.escapedForRegex);
    this.n2a_1 = regexMatcher('[:]');
    this.o2a_1 = regexMatcher('[{]');
    this.p2a_1 = regexMatcher('[}]');
  }
}
class NodeStart {
  constructor(ref, option, sentenceStartPosition, sentenceNextInputPosition) {
    this.r2a_1 = ref;
    this.s2a_1 = option;
    this.t2a_1 = sentenceStartPosition;
    this.u2a_1 = sentenceNextInputPosition;
  }
  toString() {
    return 'NodeStart(ref=' + this.r2a_1.toString() + ', option=' + this.s2a_1.toString() + ', sentenceStartPosition=' + this.t2a_1 + ', sentenceNextInputPosition=' + this.u2a_1 + ')';
  }
  hashCode() {
    var result = this.r2a_1.hashCode();
    result = imul(result, 31) + this.s2a_1.hashCode() | 0;
    result = imul(result, 31) + this.t2a_1 | 0;
    result = imul(result, 31) + this.u2a_1 | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof NodeStart))
      return false;
    if (!this.r2a_1.equals(other.r2a_1))
      return false;
    if (!this.s2a_1.equals(other.s2a_1))
      return false;
    if (!(this.t2a_1 === other.t2a_1))
      return false;
    if (!(this.u2a_1 === other.u2a_1))
      return false;
    return true;
  }
}
class RuleReference {
  constructor(qname, name) {
    this.v2a_1 = qname;
    this.w2a_1 = name;
  }
  x2a() {
    return !(null == this.v2a_1);
  }
  toString() {
    return 'RuleReference(qname=' + toString_0(this.v2a_1) + ', name=' + this.w2a_1 + ')';
  }
  hashCode() {
    var result = this.v2a_1 == null ? 0 : this.v2a_1.hashCode();
    result = imul(result, 31) + getStringHashCode(this.w2a_1) | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof RuleReference))
      return false;
    if (!equals(this.v2a_1, other.v2a_1))
      return false;
    if (!(this.w2a_1 === other.w2a_1))
      return false;
    return true;
  }
}
class QName {
  constructor(full) {
    this.b2b_1 = full;
  }
  toString() {
    return 'QName(full=' + this.b2b_1 + ')';
  }
  hashCode() {
    return getStringHashCode(this.b2b_1);
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof QName))
      return false;
    if (!(this.b2b_1 === other.b2b_1))
      return false;
    return true;
  }
}
class Companion_22 {
  constructor() {
    this.OPTION_SKIP = null;
    this.OPTION_ERROR = null;
  }
  c2b() {
    return this.OPTION_SKIP;
  }
  d2b() {
    return this.OPTION_ERROR;
  }
}
class SpptWalkerToInputSentence {
  constructor(sentence) {
    this.i29_1 = sentence;
    this.j29_1 = mutableStackOf([]);
  }
  k29() {
    var tmp;
    if (equals(Companion_instance_22.OPTION_SKIP, this.j29_1.r11().i1(0).hi_1)) {
      var startSkip = this.j29_1.r11().i1(0).ii_1;
      // Inline function 'kotlin.collections.map' call
      var this_0 = drop(this.j29_1.r11(), 1);
      // Inline function 'kotlin.collections.mapTo' call
      var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
      var _iterator__ex2g4s = this_0.g1();
      while (_iterator__ex2g4s.f()) {
        var item = _iterator__ex2g4s.e();
        var tmp$ret$0 = startSkip + item.ii_1;
        destination.v(tmp$ret$0);
      }
      tmp = destination;
    } else {
      // Inline function 'kotlin.collections.map' call
      var this_1 = this.j29_1.r11();
      // Inline function 'kotlin.collections.mapTo' call
      var destination_0 = ArrayList.a1(collectionSizeOrDefault(this_1, 10));
      var _iterator__ex2g4s_0 = this_1.g1();
      while (_iterator__ex2g4s_0.f()) {
        var item_0 = _iterator__ex2g4s_0.e();
        var tmp$ret$3 = item_0.ii_1;
        destination_0.v(tmp$ret$3);
      }
      tmp = destination_0;
    }
    return tmp;
  }
  beginTree() {
  }
  endTree() {
  }
  skip(skipData) {
    var tmp0_safe_receiver = skipData.root;
    var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.startPosition;
    var tmp;
    if (tmp1_elvis_lhs == null) {
      var message = 'Should not happen';
      throw IllegalStateException.t4(toString(message));
    } else {
      tmp = tmp1_elvis_lhs;
    }
    var startPosition = tmp;
    var tmp2_safe_receiver = skipData.root;
    var tmp3_elvis_lhs = tmp2_safe_receiver == null ? null : tmp2_safe_receiver.nextInputPosition;
    var tmp_0;
    if (tmp3_elvis_lhs == null) {
      var message_0 = 'Should not happen';
      throw IllegalStateException.t4(toString(message_0));
    } else {
      tmp_0 = tmp3_elvis_lhs;
    }
    var nextInputPosition = tmp_0;
    var matchedText = substring(this.i29_1.text, startPosition, nextInputPosition);
    if (this.j29_1.p11()) {
      pushText(this, Companion_instance_22.OPTION_SKIP, matchedText);
    } else {
      var p = this.j29_1.v11();
      pushText(this, p.hi_1, p.ii_1 + matchedText);
    }
  }
  leaf(nodeInfo) {
    var matchedText = matchedTextNoSkip(this.i29_1, nodeInfo.node);
    pushText(this, nodeInfo, matchedText);
  }
  beginBranch(nodeInfo) {
  }
  endBranch(nodeInfo) {
    var numChildren = ensureNotNull(nodeInfo.numChildrenAlternatives.c3(nodeInfo.alt.option));
    var chText = reversed_0(this.j29_1.w11(numChildren));
    var text = joinToString(chText, '', VOID, VOID, VOID, VOID, SpptWalkerToInputSentence$endBranch$lambda);
    pushText(this, nodeInfo, text);
  }
  beginEmbedded(nodeInfo) {
    this.beginBranch(nodeInfo);
  }
  endEmbedded(nodeInfo) {
    var numChildren = ensureNotNull(nodeInfo.numChildrenAlternatives.c3(Companion_getInstance_11().OPTION_NONE));
    var chText = reversed_0(this.j29_1.w11(numChildren));
    var text = joinToString(chText, '', VOID, VOID, VOID, VOID, SpptWalkerToInputSentence$endEmbedded$lambda);
    pushText(this, nodeInfo, text);
  }
  treeError(msg, path) {
    var p = path.invoke();
    var txt = 'Error at ' + last(p).startPosition + ": '" + msg + "'";
    pushText(this, Companion_instance_22.OPTION_ERROR, txt);
    println_0(txt);
  }
}
class SpptWalkerToString {
  constructor(sentence, indentDelta) {
    this.sentence = sentence;
    this.indentDelta = indentDelta;
    this.e2b_1 = '';
    this.f2b_1 = StringBuilder.s();
  }
  e1g() {
    return this.sentence;
  }
  g2b() {
    return this.indentDelta;
  }
  k29() {
    return this.f2b_1.toString();
  }
  beginTree() {
  }
  endTree() {
    this.f2b_1.ya('\n');
  }
  skip(skipData) {
    var tmp0_safe_receiver = skipData.root;
    var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.startPosition;
    var tmp;
    if (tmp1_elvis_lhs == null) {
      var message = 'Should not happen';
      throw IllegalStateException.t4(toString(message));
    } else {
      tmp = tmp1_elvis_lhs;
    }
    var startPosition = tmp;
    var tmp2_safe_receiver = skipData.root;
    var tmp3_elvis_lhs = tmp2_safe_receiver == null ? null : tmp2_safe_receiver.nextInputPosition;
    var tmp_0;
    if (tmp3_elvis_lhs == null) {
      var message_0 = 'Should not happen';
      throw IllegalStateException.t4(toString(message_0));
    } else {
      tmp_0 = tmp3_elvis_lhs;
    }
    var nextInputPosition = tmp_0;
    var matchedText = replace(replace(substring(this.sentence.text, startPosition, nextInputPosition), '\n', '\u23CE'), '\t', '\u2B72');
    this.f2b_1.ya(this.e2b_1 + "<SKIP> : '" + matchedText + "'\n");
  }
  leaf(nodeInfo) {
    var chNum = nodeInfo.child.index;
    var siblings = nodeInfo.child.total;
    var ind = siblings === 1 ? '' : this.e2b_1;
    var eol = siblings === 1 ? ' ' : '\n';
    var matchedText = replace(replace(matchedTextNoSkip(this.sentence, nodeInfo.node), '\n', '\u23CE'), '\t', '\u2B72');
    var escapedText = CommonRegexPatterns_getInstance().escape_LITERAL(matchedText).v1a_1;
    if (nodeInfo.node.rule.isEmptyTerminal)
      this.f2b_1.ya(ind + nodeInfo.node.rule.tag + eol);
    else if (nodeInfo.node.rule.isEmptyListTerminal)
      this.f2b_1.ya(ind + nodeInfo.node.rule.tag + eol);
    else if (nodeInfo.node.rule.isPattern)
      this.f2b_1.ya(ind + nodeInfo.node.rule.tag + " : '" + escapedText + "'" + eol);
    else if ("'" + matchedText + "'" === nodeInfo.node.rule.tag)
      this.f2b_1.ya(ind + "'" + escapedText + "'" + eol);
    else
      this.f2b_1.ya(ind + nodeInfo.node.rule.tag + " : '" + escapedText + "'" + eol);
  }
  beginBranch(nodeInfo) {
    var option = nodeInfo.alt.index;
    var total = nodeInfo.alt.totalMatched;
    var chNum = nodeInfo.child.index;
    var siblings = nodeInfo.child.total + (nodeInfo.alt.totalMatched - 1 | 0) | 0;
    var totChildren = nodeInfo.totalChildrenFromAllAlternatives + nodeInfo.numSkipChildren | 0;
    var eol = totChildren <= 1 ? ' ' : '\n';
    var tmp;
    if (nodeInfo.alt.totalMatched <= 1) {
      tmp = nodeInfo.node.rule.tag;
    } else {
      tmp = nodeInfo.node.rule.tag + '|' + nodeInfo.alt.option.asIndex;
    }
    var tag = tmp;
    if (siblings === 1) {
      this.f2b_1.ya(tag + ' {' + eol);
    } else {
      this.f2b_1.ya(this.e2b_1 + tag + ' {' + eol);
    }
    if (!(totChildren === 1))
      this.e2b_1 = this.e2b_1 + this.indentDelta;
  }
  endBranch(nodeInfo) {
    var chNum = nodeInfo.child.index;
    var siblings = nodeInfo.child.total + (nodeInfo.alt.totalMatched - 1 | 0) | 0;
    var totChildren = nodeInfo.totalChildrenFromAllAlternatives + nodeInfo.numSkipChildren | 0;
    var eol = siblings === 1 ? ' ' : '\n';
    if (!(totChildren === 1))
      this.e2b_1 = substring_0(this.e2b_1, this.indentDelta.length);
    var ind = totChildren === 1 ? '' : this.e2b_1;
    this.f2b_1.ya(ind + '}' + eol);
  }
  beginEmbedded(nodeInfo) {
    var tag = nodeInfo.node.rule.tag;
    this.f2b_1.ya(this.e2b_1 + tag + ' : <EMBED>::');
  }
  endEmbedded(nodeInfo) {
  }
  treeError(msg, path) {
    var p = path.invoke();
    this.f2b_1.ya(this.e2b_1 + 'Error at ' + last(p).startPosition + ": '" + msg + "'");
    println_0(this.e2b_1 + 'Error at ' + last(p).startPosition + ": '" + msg + "'");
  }
  get output() {
    return this.k29();
  }
}
class TokensByLineVisitor$visitTree$callback$1 {
  constructor($treeData, this$0, $nodeLabelStack) {
    this.h2b_1 = $treeData;
    this.i2b_1 = this$0;
    this.j2b_1 = $nodeLabelStack;
  }
  treeError(msg, path) {
    return Unit_instance;
  }
  beginTree() {
  }
  endTree() {
  }
  skip(skipData) {
    return Unit_instance;
  }
  leaf(nodeInfo) {
    var skipNodes = this.h2b_1.skipNodesAfter(nodeInfo.node);
    this.i2b_1.k2b(nodeInfo, skipNodes, this.j2b_1.r11());
  }
  beginBranch(nodeInfo) {
    return this.j2b_1.o11(nodeInfo.node.rule.tag);
  }
  endBranch(nodeInfo) {
    this.j2b_1.v11();
  }
  beginEmbedded(nodeInfo) {
    this.beginBranch(nodeInfo);
  }
  endEmbedded(nodeInfo) {
    return this.endBranch(nodeInfo);
  }
}
class TokensByLineVisitor {
  constructor(sentence) {
    this.f29_1 = sentence;
    var tmp = this;
    // Inline function 'kotlin.collections.mutableListOf' call
    var tmp$ret$0 = ArrayList.o1();
    tmp.g29_1 = mutableListOf([tmp$ret$0]);
  }
  l2b(_this__u8e3s4, index) {
    if (index >= _this__u8e3s4.h1()) {
      var inductionVariable = _this__u8e3s4.h1() - 1 | 0;
      if (inductionVariable < index)
        do {
          var i = inductionVariable;
          inductionVariable = inductionVariable + 1 | 0;
          // Inline function 'kotlin.collections.mutableListOf' call
          var tmp$ret$0 = ArrayList.o1();
          _this__u8e3s4.v(tmp$ret$0);
        }
         while (inductionVariable < index);
    }
    return _this__u8e3s4.i1(index);
  }
  h29(target, arg) {
    var treeData = (target instanceof SPPTFromTreeData ? target : THROW_CCE()).x28_1;
    var nodeLabelStack = mutableStackOf([]);
    var callback = new TokensByLineVisitor$visitTree$callback$1(treeData, this, nodeLabelStack);
    treeData.traverseTreeDepthFirst(callback, true);
  }
  k2b(nodeInfo, skipNodes, tagList) {
    var name = nodeInfo.node.rule.tag;
    var isPattern = nodeInfo.node.rule.isPattern;
    var tags = plus_1(tagList, name);
    var location = locationForNode(this.f29_1, nodeInfo.node);
    var matchedText = matchedTextNoSkip(this.f29_1, nodeInfo.node);
    var eolPositions = Companion_getInstance_20().eolPositions(matchedText);
    if (!get_isEmptyMatch(nodeInfo.node))
      if (eolPositions.l1()) {
        this.l2b(this.g29_1, location.line - 1 | 0).v(new LeafData(name, isPattern, nodeInfo.node.startPosition, nodeInfo.node.nextInputNoSkip - nodeInfo.node.startPosition | 0, tags));
      } else {
        var line = location.line;
        var indexPos = 0;
        var startPos = nodeInfo.node.startPosition;
        var startLinePos = startPos;
        var _iterator__ex2g4s = eolPositions.g1();
        while (_iterator__ex2g4s.f()) {
          var eolPos = _iterator__ex2g4s.e();
          var textLength = eolPos - indexPos | 0;
          if (0 < textLength) {
            var segmentLeaf = new LeafData(name, isPattern, startLinePos, textLength, tags);
            this.l2b(this.g29_1, line - 1 | 0).v(segmentLeaf);
            indexPos = indexPos + textLength | 0;
            startLinePos = startLinePos + textLength | 0;
          }
          var eolTextLength = 1;
          var eolLeaf = new LeafData(name, isPattern, startLinePos, eolTextLength, tags);
          this.l2b(this.g29_1, line - 1 | 0).v(eolLeaf);
          line = line + 1 | 0;
          indexPos = indexPos + 1 | 0;
          startLinePos = startLinePos + 1 | 0;
        }
        var lineText = substring_0(matchedText, indexPos);
        // Inline function 'kotlin.text.isNotEmpty' call
        if (charSequenceLength(lineText) > 0) {
          var segmentLeaf_0 = new LeafData(name, isPattern, startLinePos, lineText.length, tags);
          this.l2b(this.g29_1, line - 1 | 0).v(segmentLeaf_0);
        }
      }
  }
}
class PreferredNode {
  constructor(rule, startPosition) {
    this.rule = rule;
    this.startPosition = startPosition;
  }
  y1c() {
    return this.rule;
  }
  z1c() {
    return this.startPosition;
  }
  toString() {
    return 'PN(' + this.rule.tag + ',' + this.startPosition + ')';
  }
  ni() {
    return this.rule;
  }
  oi() {
    return this.startPosition;
  }
  m2b(rule, startPosition) {
    return new PreferredNode(rule, startPosition);
  }
  copy(rule, startPosition, $super) {
    rule = rule === VOID ? this.rule : rule;
    startPosition = startPosition === VOID ? this.startPosition : startPosition;
    return $super === VOID ? this.m2b(rule, startPosition) : $super.m2b.call(this, rule, startPosition);
  }
  hashCode() {
    var result = hashCode(this.rule);
    result = imul(result, 31) + this.startPosition | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof PreferredNode))
      return false;
    if (!equals(this.rule, other.rule))
      return false;
    if (!(this.startPosition === other.startPosition))
      return false;
    return true;
  }
}
class CompleteTreeDataNode {
  constructor(rule, startPosition, nextInputPosition, nextInputNoSkip, option, dynamicPriority) {
    this.q1e_1 = rule;
    this.r1e_1 = startPosition;
    this.s1e_1 = nextInputPosition;
    this.t1e_1 = nextInputNoSkip;
    this.u1e_1 = option;
    this.v1e_1 = dynamicPriority;
    var tmp = this;
    // Inline function 'kotlin.arrayOf' call
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    var tmp$ret$2 = [this.q1e_1, this.r1e_1, this.s1e_1];
    tmp.w1e_1 = contentHashCode(tmp$ret$2);
  }
  y1c() {
    return this.q1e_1;
  }
  z1c() {
    return this.r1e_1;
  }
  a1d() {
    return this.s1e_1;
  }
  b1d() {
    return this.t1e_1;
  }
  c1d() {
    return this.u1e_1;
  }
  d1d() {
    return this.v1e_1;
  }
  hashCode() {
    return this.w1e_1;
  }
  equals(other) {
    var tmp;
    if (!(!(other == null) ? isInterface(other, SpptDataNode) : false)) {
      tmp = false;
    } else {
      if (!(this.r1e_1 === other.startPosition)) {
        tmp = false;
      } else {
        if (!(this.s1e_1 === other.nextInputPosition)) {
          tmp = false;
        } else {
          if (!equals(this.q1e_1, other.rule)) {
            tmp = false;
          } else {
            tmp = true;
          }
        }
      }
    }
    return tmp;
  }
  toString() {
    return 'CN(' + this.q1e_1.tag + '|' + this.u1e_1.toString() + ',' + this.r1e_1 + '-' + this.s1e_1 + ')';
  }
  get rule() {
    return this.y1c();
  }
  get startPosition() {
    return this.z1c();
  }
  get nextInputPosition() {
    return this.a1d();
  }
  get nextInputNoSkip() {
    return this.b1d();
  }
  get option() {
    return this.c1d();
  }
  get dynamicPriority() {
    return this.d1d();
  }
}
class Companion_23 {}
class TreeDataComplete {
  constructor(forStateSetNumber) {
    this.forStateSetNumber = forStateSetNumber;
    this.n2b_1 = null;
    this.o2b_1 = null;
    var tmp = this;
    // Inline function 'kotlin.collections.hashMapOf' call
    tmp.p2b_1 = HashMap.o7();
    var tmp_0 = this;
    // Inline function 'kotlin.collections.hashMapOf' call
    tmp_0.q2b_1 = HashMap.o7();
    var tmp_1 = this;
    // Inline function 'kotlin.collections.hashMapOf' call
    tmp_1.r2b_1 = HashMap.o7();
    var tmp_2 = this;
    // Inline function 'kotlin.collections.hashMapOf' call
    tmp_2.s2b_1 = HashMap.o7();
  }
  t2b() {
    return this.forStateSetNumber;
  }
  p11() {
    return null == this.n2b_1 && null == this.o2b_1 && this.p2b_1.l1() && this.r2b_1.l1() && this.s2b_1.l1();
  }
  u2b() {
    return this.p2b_1;
  }
  n15() {
    return this.n2b_1;
  }
  o28() {
    return this.o2b_1;
  }
  n28() {
    return first_0(first_0(this.childrenFor(ensureNotNull(this.n2b_1))).ii_1);
  }
  setUserGoalChildrenAfterInitialSkip(nug, userGoalChildren) {
    var tmp0 = this.p2b_1;
    // Inline function 'kotlin.collections.set' call
    var value = mutableMapOf([to(Companion_getInstance_11().OPTION_NONE, toMutableList(userGoalChildren))]);
    tmp0.f3(nug, value);
  }
  childrenFor(node) {
    // Inline function 'kotlin.collections.filter' call
    var tmp0 = this.p2b_1.d3();
    // Inline function 'kotlin.collections.filterTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      if (element.startPosition === node.startPosition && element.nextInputPosition === node.nextInputPosition && equals(element.rule, node.rule)) {
        destination.v(element);
      }
    }
    var keys = destination;
    var tmp;
    switch (keys.h1()) {
      case 0:
        tmp = emptyList();
        break;
      case 1:
        // Inline function 'kotlin.collections.map' call

        var this_0 = ensureNotNull(this.p2b_1.c3(keys.i1(0))).z1();
        // Inline function 'kotlin.collections.mapTo' call

        var destination_0 = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
        var _iterator__ex2g4s_0 = this_0.g1();
        while (_iterator__ex2g4s_0.f()) {
          var item = _iterator__ex2g4s_0.e();
          var tmp$ret$3 = new Pair(item.a2(), item.b2());
          destination_0.v(tmp$ret$3);
        }

        tmp = destination_0;
        break;
      default:
        var preferred = _get_preferred__p9krn4(Companion_instance_23, keys.i1(0));
        if (false) {
          var tmp$ret$6;
          $l$block_0: {
            // Inline function 'kotlin.collections.all' call
            var tmp_0;
            if (isInterface(keys, Collection)) {
              tmp_0 = keys.l1();
            } else {
              tmp_0 = false;
            }
            if (tmp_0) {
              tmp$ret$6 = true;
              break $l$block_0;
            }
            var _iterator__ex2g4s_1 = keys.g1();
            while (_iterator__ex2g4s_1.f()) {
              var element_0 = _iterator__ex2g4s_1.e();
              if (!_get_preferred__p9krn4(Companion_instance_23, element_0).equals(preferred)) {
                tmp$ret$6 = false;
                break $l$block_0;
              }
            }
            tmp$ret$6 = true;
          }
          // Inline function 'kotlin.check' call
          if (!tmp$ret$6) {
            throw IllegalStateException.t4('Check failed.');
          }
        }

        var tmp_1;
        if (this.q2b_1.a3(preferred)) {
          var tmp0_0 = this.p2b_1;
          // Inline function 'kotlin.collections.get' call
          var key = this.q2b_1.c3(preferred);
          var tmp$ret$9 = (isInterface(tmp0_0, KtMap) ? tmp0_0 : THROW_CCE()).c3(key);
          // Inline function 'kotlin.collections.map' call
          var this_1 = ensureNotNull(tmp$ret$9).z1();
          // Inline function 'kotlin.collections.mapTo' call
          var destination_1 = ArrayList.a1(collectionSizeOrDefault(this_1, 10));
          var _iterator__ex2g4s_2 = this_1.g1();
          while (_iterator__ex2g4s_2.f()) {
            var item_0 = _iterator__ex2g4s_2.e();
            var tmp$ret$10 = new Pair(item_0.a2(), item_0.b2());
            destination_1.v(tmp$ret$10);
          }
          tmp_1 = destination_1;
        } else {
          // Inline function 'kotlin.collections.flatMap' call
          // Inline function 'kotlin.collections.flatMapTo' call
          var destination_2 = ArrayList.o1();
          var _iterator__ex2g4s_3 = keys.g1();
          while (_iterator__ex2g4s_3.f()) {
            var element_1 = _iterator__ex2g4s_3.e();
            // Inline function 'kotlin.collections.map' call
            var this_2 = ensureNotNull(this.p2b_1.c3(element_1)).z1();
            // Inline function 'kotlin.collections.mapTo' call
            var destination_3 = ArrayList.a1(collectionSizeOrDefault(this_2, 10));
            var _iterator__ex2g4s_4 = this_2.g1();
            while (_iterator__ex2g4s_4.f()) {
              var item_1 = _iterator__ex2g4s_4.e();
              var tmp$ret$13 = new Pair(item_1.a2(), item_1.b2());
              destination_3.v(tmp$ret$13);
            }
            var list = destination_3;
            addAll(destination_2, list);
          }
          tmp_1 = destination_2;
        }

        tmp = tmp_1;
        break;
    }
    return tmp;
  }
  skipDataAfter(node) {
    return this.r2b_1.c3(node);
  }
  embeddedFor(node) {
    return this.s2b_1.c3(node);
  }
  skipNodesAfter(node) {
    var skipTreeData = this.skipDataAfter(node);
    var tmp;
    if (skipTreeData == null) {
      tmp = emptyList();
    } else {
      var sur = skipTreeData.userRoot;
      var skpCh = skipTreeData.childrenFor(sur);
      return skpCh.i1(0).ii_1;
    }
    return tmp;
  }
  reset() {
    this.n2b_1 = null;
    this.o2b_1 = null;
    this.p2b_1.i3();
    this.q2b_1.i3();
    this.r2b_1.i3();
    this.s2b_1.i3();
  }
  preferred(node) {
    return this.q2b_1.c3(_get_preferred__p9krn4(Companion_instance_23, node));
  }
  setRootTo(root) {
    this.n2b_1 = root;
  }
  start(initialSkipData) {
    this.o2b_1 = initialSkipData;
  }
  remove(node) {
    this.p2b_1.g3(node);
    this.q2b_1.g3(_get_preferred__p9krn4(Companion_instance_23, node));
    this.r2b_1.g3(node);
  }
  setChildren(parent, completeChildren, isAlternative) {
    setCompletedBy(this, parent, completeChildren, isAlternative);
  }
  setSkipDataAfter(leafNodeIndex, skipData) {
    // Inline function 'kotlin.collections.set' call
    this.r2b_1.f3(leafNodeIndex, skipData);
  }
  setEmbeddedTreeFor(n, treeData) {
    // Inline function 'kotlin.collections.set' call
    this.s2b_1.f3(n, treeData);
  }
  traverseTreeDepthFirst(callback, skipDataAsTree) {
    var walker = new TreeDataWalkerDepthFirst(this);
    walker.y2b(callback, skipDataAsTree);
  }
  matches(other) {
    var tmp;
    if (!(other instanceof TreeDataComplete)) {
      tmp = false;
    } else {
      if (!equals(this.o2b_1, other.o2b_1)) {
        tmp = false;
      } else {
        if (!this.s2b_1.equals(other.s2b_1)) {
          tmp = false;
        } else {
          if (!this.r2b_1.equals(other.r2b_1)) {
            tmp = false;
          } else {
            if (!this.q2b_1.equals(other.q2b_1)) {
              tmp = false;
            } else {
              if (!this.p2b_1.equals(other.p2b_1)) {
                tmp = false;
              } else {
                tmp = true;
              }
            }
          }
        }
      }
    }
    return tmp;
  }
  hashCode() {
    return this.forStateSetNumber;
  }
  equals(other) {
    var tmp;
    if (!(other instanceof TreeDataComplete)) {
      tmp = false;
    } else {
      tmp = other.forStateSetNumber === this.forStateSetNumber;
    }
    return tmp;
  }
  toString() {
    return 'TreeData{' + this.forStateSetNumber + '}';
  }
  get isEmpty() {
    return this.p11();
  }
  get completeChildren() {
    return this.u2b();
  }
  get root() {
    return this.n15();
  }
  get initialSkip() {
    return this.o28();
  }
  get userRoot() {
    return this.n28();
  }
}
class CompleteKey_0 {
  constructor(rule, startPosition, nextInputPosition) {
    this.rule = rule;
    this.startPosition = startPosition;
    this.nextInputPosition = nextInputPosition;
  }
  y1c() {
    return this.rule;
  }
  z1c() {
    return this.startPosition;
  }
  a1d() {
    return this.nextInputPosition;
  }
  ni() {
    return this.rule;
  }
  oi() {
    return this.startPosition;
  }
  mm() {
    return this.nextInputPosition;
  }
  z2b(rule, startPosition, nextInputPosition) {
    return new CompleteKey_0(rule, startPosition, nextInputPosition);
  }
  copy(rule, startPosition, nextInputPosition, $super) {
    rule = rule === VOID ? this.rule : rule;
    startPosition = startPosition === VOID ? this.startPosition : startPosition;
    nextInputPosition = nextInputPosition === VOID ? this.nextInputPosition : nextInputPosition;
    return $super === VOID ? this.z2b(rule, startPosition, nextInputPosition) : $super.z2b.call(this, rule, startPosition, nextInputPosition);
  }
  toString() {
    return 'CompleteKey(rule=' + toString(this.rule) + ', startPosition=' + this.startPosition + ', nextInputPosition=' + this.nextInputPosition + ')';
  }
  hashCode() {
    var result = hashCode(this.rule);
    result = imul(result, 31) + this.startPosition | 0;
    result = imul(result, 31) + this.nextInputPosition | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof CompleteKey_0))
      return false;
    if (!equals(this.rule, other.rule))
      return false;
    if (!(this.startPosition === other.startPosition))
      return false;
    if (!(this.nextInputPosition === other.nextInputPosition))
      return false;
    return true;
  }
}
class Companion_24 {}
class TreeDataComplete2 {
  constructor(forStateSetNumber) {
    this.forStateSetNumber = forStateSetNumber;
    this.a2c_1 = null;
    this.b2c_1 = null;
    var tmp = this;
    // Inline function 'kotlin.collections.hashMapOf' call
    tmp._complete = HashMap.o7();
    var tmp_0 = this;
    // Inline function 'kotlin.collections.hashMapOf' call
    tmp_0._preferred = HashMap.o7();
    var tmp_1 = this;
    // Inline function 'kotlin.collections.hashMapOf' call
    tmp_1._skipDataAfter = HashMap.o7();
    var tmp_2 = this;
    // Inline function 'kotlin.collections.hashMapOf' call
    tmp_2._embeddedFor = HashMap.o7();
  }
  t2b() {
    return this.forStateSetNumber;
  }
  p11() {
    return null == this.a2c_1 && null == this.b2c_1 && this._complete.l1() && this._skipDataAfter.l1() && this._embeddedFor.l1();
  }
  u2b() {
    return this._complete;
  }
  c2c(_set____db54di) {
    this.a2c_1 = _set____db54di;
  }
  n15() {
    return this.a2c_1;
  }
  d2c(_set____db54di) {
    this.b2c_1 = _set____db54di;
  }
  o28() {
    return this.b2c_1;
  }
  n28() {
    return first_0(first_0(this.childrenFor(ensureNotNull(this.a2c_1))).ii_1);
  }
  setUserGoalChildrenAfterInitialSkip(nug, userGoalChildren) {
    var tmp0 = this._complete;
    // Inline function 'kotlin.collections.set' call
    var value = mutableMapOf([to(Companion_getInstance_11().OPTION_NONE, toMutableList(userGoalChildren))]);
    tmp0.f3(nug, value);
  }
  childrenFor(node) {
    var alternatives = this._complete.c3(node);
    var tmp;
    if (alternatives == null) {
      tmp = emptyList();
    } else {
      // Inline function 'kotlin.collections.map' call
      // Inline function 'kotlin.collections.mapTo' call
      var destination = ArrayList.a1(alternatives.h1());
      // Inline function 'kotlin.collections.iterator' call
      var _iterator__ex2g4s = alternatives.z1().g1();
      while (_iterator__ex2g4s.f()) {
        var item = _iterator__ex2g4s.e();
        var tmp$ret$1 = new Pair(item.a2(), item.b2());
        destination.v(tmp$ret$1);
      }
      tmp = destination;
    }
    return tmp;
  }
  skipDataAfter(node) {
    return this._skipDataAfter.c3(node);
  }
  embeddedFor(node) {
    return this._embeddedFor.c3(node);
  }
  skipNodesAfter(node) {
    var skipTreeData = this.skipDataAfter(node);
    var tmp;
    if (skipTreeData == null) {
      tmp = emptyList();
    } else {
      var sur = skipTreeData.userRoot;
      var skpCh = skipTreeData.childrenFor(sur);
      return skpCh.i1(0).ii_1;
    }
    return tmp;
  }
  e2c() {
    return this._complete;
  }
  f2c() {
    return this._preferred;
  }
  g2c() {
    return this._skipDataAfter;
  }
  h2c() {
    return this._embeddedFor;
  }
  reset() {
    this.a2c_1 = null;
    this.b2c_1 = null;
    this._complete.i3();
    this._preferred.i3();
    this._skipDataAfter.i3();
    this._embeddedFor.i3();
  }
  preferred(node) {
    return this._preferred.c3(_get_preferred__p9krn4_0(Companion_instance_24, node));
  }
  setRootTo(root) {
    this.a2c_1 = root;
  }
  start(initialSkipData) {
    this.b2c_1 = initialSkipData;
  }
  remove(node) {
    var tmp0_safe_receiver = this._complete.c3(node);
    if (tmp0_safe_receiver == null)
      null;
    else
      tmp0_safe_receiver.g3(node.option);
    var tmp1_safe_receiver = this._complete.c3(node);
    if ((tmp1_safe_receiver == null ? null : tmp1_safe_receiver.l1()) === true) {
      this._complete.g3(node);
    }
    this._preferred.g3(_get_preferred__p9krn4_0(Companion_instance_24, node));
    this._skipDataAfter.g3(node);
  }
  setChildren(parent, completeChildren, isAlternative) {
    setCompletedBy_0(this, parent, completeChildren, isAlternative);
  }
  setSkipDataAfter(leafNodeIndex, skipData) {
    // Inline function 'kotlin.collections.set' call
    this._skipDataAfter.f3(leafNodeIndex, skipData);
  }
  setEmbeddedTreeFor(n, treeData) {
    // Inline function 'kotlin.collections.set' call
    this._embeddedFor.f3(n, treeData);
  }
  traverseTreeDepthFirst(callback, skipDataAsTree) {
    var walker = new TreeDataWalkerDepthFirst(this);
    walker.y2b(callback, skipDataAsTree);
  }
  matches(other) {
    var tmp;
    if (!(other instanceof TreeDataComplete2)) {
      tmp = false;
    } else {
      if (!equals(this.b2c_1, other.b2c_1)) {
        tmp = false;
      } else {
        if (!this._embeddedFor.equals(other._embeddedFor)) {
          tmp = false;
        } else {
          if (!this._skipDataAfter.equals(other._skipDataAfter)) {
            tmp = false;
          } else {
            if (!this._preferred.equals(other._preferred)) {
              tmp = false;
            } else {
              if (!this._complete.equals(other._complete)) {
                tmp = false;
              } else {
                tmp = true;
              }
            }
          }
        }
      }
    }
    return tmp;
  }
  hashCode() {
    return this.forStateSetNumber;
  }
  equals(other) {
    var tmp;
    if (!(other instanceof TreeDataComplete2)) {
      tmp = false;
    } else {
      tmp = other.forStateSetNumber === this.forStateSetNumber;
    }
    return tmp;
  }
  toString() {
    return 'TreeData{' + this.forStateSetNumber + '}';
  }
  get isEmpty() {
    return this.p11();
  }
  get completeChildren() {
    return this.u2b();
  }
  get root() {
    return this.n15();
  }
  set root(value) {
    this.c2c(value);
  }
  get initialSkip() {
    return this.o28();
  }
  set initialSkip(value) {
    this.d2c(value);
  }
  get userRoot() {
    return this.n28();
  }
}
class Companion_25 {
  of(child) {
    return new ChildChain(child, null, 1);
  }
}
class ChildChain {
  constructor(head, prev, size) {
    this.i2c_1 = head;
    this.j2c_1 = prev;
    this.k2c_1 = size;
  }
  l2c(child) {
    return new ChildChain(child, this, this.k2c_1 + 1 | 0);
  }
  m2c() {
    var out = ArrayList.a1(this.k2c_1);
    var node = this;
    while (!(node == null)) {
      out.v(node.i2c_1);
      node = node.j2c_1;
    }
    reverse(out);
    return out;
  }
  toString() {
    return toString(this.m2c());
  }
}
class TreeDataGrowing {
  constructor(forStateSetNumber) {
    this.forStateSetNumber = forStateSetNumber;
    this.complete = treeData(this.forStateSetNumber);
    var tmp = this;
    // Inline function 'kotlin.collections.hashMapOf' call
    tmp.i1e_1 = HashMap.o7();
  }
  t2b() {
    return this.forStateSetNumber;
  }
  n2c() {
    return this.i1e_1.l1();
  }
  p11() {
    return this.complete.isEmpty && this.isClean;
  }
  b21() {
    return this.complete;
  }
  o2c() {
    // Inline function 'kotlin.collections.mapValues' call
    var this_0 = this.i1e_1;
    // Inline function 'kotlin.collections.mapValuesTo' call
    var destination = LinkedHashMap.gb(mapCapacity(this_0.h1()));
    // Inline function 'kotlin.collections.associateByTo' call
    var _iterator__ex2g4s = this_0.z1().g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      var tmp = element.a2();
      // Inline function 'kotlin.collections.component2' call
      var chain = element.b2();
      var tmp1_elvis_lhs = chain == null ? null : chain.m2c();
      var tmp$ret$2 = tmp1_elvis_lhs == null ? emptyList() : tmp1_elvis_lhs;
      destination.f3(tmp, tmp$ret$2);
    }
    return destination;
  }
  preferred(node) {
    var tmp = this.complete.preferred(node);
    return (tmp == null ? true : isInterface(tmp, SpptDataNode)) ? tmp : THROW_CCE();
  }
  initialise(gni, initialSkipData) {
    setGrowingChildren(this, gni, null);
    this.complete.start(initialSkipData);
  }
  removeTreeGrowing(node) {
    var childrenOfRemoved = removeGrowingNode(this, node);
  }
  setEmbeddedChild(parent, child, embeddedTreeData) {
    var completeChildren = listOf(child);
    this.complete.setChildren(parent, completeChildren, true);
    this.complete.setEmbeddedTreeFor(parent, embeddedTreeData);
  }
  setFirstChildForComplete(parent, child, isAlternative) {
    var completeChildren = listOf(child);
    this.complete.setChildren(parent, completeChildren, isAlternative);
  }
  setFirstChildForGrowing(parent, child) {
    setGrowingChildren(this, parent, Companion_instance_25.of(child));
  }
  setNextChildForCompleteParent(oldParent, newParent, nextChild, isAlternative) {
    if (this.i1e_1.a3(oldParent)) {
      var chain = this.i1e_1.c3(oldParent);
      var tmp1_elvis_lhs = chain == null ? null : chain.l2c(nextChild);
      var extended = tmp1_elvis_lhs == null ? Companion_instance_25.of(nextChild) : tmp1_elvis_lhs;
      this.complete.setChildren(newParent, extended.m2c(), isAlternative);
    } else {
      // Inline function 'kotlin.TODO' call
      var reason = 'Need to figure out what to do here ! - write suitable test';
      throw NotImplementedError.im('An operation is not implemented: ' + reason);
    }
  }
  setNextChildForGrowingParent(oldParent, newParent, nextChild) {
    if (false) {
      // Inline function 'kotlin.check' call
      if (!this.i1e_1.a3(oldParent)) {
        var message = 'no growing entry for ' + toString_0(oldParent);
        throw IllegalStateException.t4(toString(message));
      }
    }
    var chain = this.i1e_1.c3(oldParent);
    var tmp1_elvis_lhs = chain == null ? null : chain.l2c(nextChild);
    var extended = tmp1_elvis_lhs == null ? Companion_instance_25.of(nextChild) : tmp1_elvis_lhs;
    setGrowingChildren(this, newParent, extended);
  }
  setSkipDataAfter(leafNodeIndex, skipData) {
    this.complete.setSkipDataAfter(leafNodeIndex, skipData);
  }
  hashCode() {
    return this.forStateSetNumber;
  }
  equals(other) {
    var tmp;
    if (!(other instanceof TreeDataGrowing)) {
      tmp = false;
    } else {
      tmp = other.forStateSetNumber === this.forStateSetNumber;
    }
    return tmp;
  }
  toString() {
    return 'TreeData{' + this.forStateSetNumber + '}';
  }
  get isClean() {
    return this.n2c();
  }
  get isEmpty() {
    return this.p11();
  }
  get growingChildren() {
    return this.o2c();
  }
}
class Companion_26 {}
class sam$kotlin_Comparator$0_13 {
  constructor(function_0) {
    this.a2d_1 = function_0;
  }
  lg(a, b) {
    return this.a2d_1(a, b);
  }
  compare(a, b) {
    return this.lg(a, b);
  }
  u3() {
    return this.a2d_1;
  }
  equals(other) {
    var tmp;
    if (!(other == null) ? isInterface(other, Comparator) : false) {
      var tmp_0;
      if (!(other == null) ? isInterface(other, FunctionAdapter) : false) {
        tmp_0 = equals(this.u3(), other.u3());
      } else {
        tmp_0 = false;
      }
      tmp = tmp_0;
    } else {
      tmp = false;
    }
    return tmp;
  }
  hashCode() {
    return hashCode(this.u3());
  }
}
class sam$net_akehurst_language_sppt_api_PathFunction$0 {
  constructor(function_0) {
    this.b2d_1 = function_0;
  }
  invoke() {
    return this.b2d_1();
  }
  u3() {
    return this.b2d_1;
  }
  equals(other) {
    var tmp;
    if (!(other == null) ? isInterface(other, PathFunction) : false) {
      var tmp_0;
      if (!(other == null) ? isInterface(other, FunctionAdapter) : false) {
        tmp_0 = equals(this.u3(), other.u3());
      } else {
        tmp_0 = false;
      }
      tmp = tmp_0;
    } else {
      tmp = false;
    }
    return tmp;
  }
  hashCode() {
    return hashCode(this.u3());
  }
}
class sam$kotlin_Comparator$0_14 {
  constructor(function_0) {
    this.c2d_1 = function_0;
  }
  lg(a, b) {
    return this.c2d_1(a, b);
  }
  compare(a, b) {
    return this.lg(a, b);
  }
  u3() {
    return this.c2d_1;
  }
  equals(other) {
    var tmp;
    if (!(other == null) ? isInterface(other, Comparator) : false) {
      var tmp_0;
      if (!(other == null) ? isInterface(other, FunctionAdapter) : false) {
        tmp_0 = equals(this.u3(), other.u3());
      } else {
        tmp_0 = false;
      }
      tmp = tmp_0;
    } else {
      tmp = false;
    }
    return tmp;
  }
  hashCode() {
    return hashCode(this.u3());
  }
}
class TreeDataWalkerDepthFirst {
  constructor(treeData) {
    this.v2b_1 = treeData;
    this.w2b_1 = mutableStackOf([]);
    this.x2b_1 = mutableStackOf([]);
  }
  y2b(callback, skipDataAsTree) {
    callback.beginTree();
    var goal = ensureNotNull(this.v2b_1.root);
    var userRoot = this.v2b_1.childrenFor(goal).i1(0).ii_1.i1(0);
    var parentAlt = new AltInfo(Companion_getInstance_11().OPTION_NONE, 0, 1);
    if (userRoot.rule.isTerminal) {
      var urchildOfTotal = new ChildInfo(0, 0, 1);
      var altOfTotal = new AltInfo(Companion_getInstance_11().OPTION_NONE, 0, 1);
      this.x2b_1.o11(new StackInfo(false, new ParsePath(emptyList()), userRoot, parentAlt, altOfTotal, urchildOfTotal, emptyMap(), -1));
    } else {
      var urchildOfTotal_0 = new ChildInfo(0, 0, 1);
      // Inline function 'kotlin.collections.sortedBy' call
      var this_0 = this.v2b_1.childrenFor(userRoot);
      // Inline function 'kotlin.comparisons.compareBy' call
      var tmp = TreeDataWalkerDepthFirst$traverse$lambda;
      var tmp$ret$0 = new sam$kotlin_Comparator$0_13(tmp);
      var uralternatives = sortedWith(this_0, tmp$ret$0);
      var altInfo = new AlternativesInfo(userRoot, true);
      this.w2b_1.o11(altInfo);
      this.x2b_1.o11(altInfo);
      // Inline function 'kotlin.collections.associate' call
      var capacity = coerceAtLeast(mapCapacity(collectionSizeOrDefault(uralternatives, 10)), 16);
      // Inline function 'kotlin.collections.associateTo' call
      var destination = LinkedHashMap.gb(capacity);
      var _iterator__ex2g4s = uralternatives.g1();
      while (_iterator__ex2g4s.f()) {
        var element = _iterator__ex2g4s.e();
        // Inline function 'kotlin.collections.plusAssign' call
        var pair = new Pair(element.hi_1, element.ii_1.h1());
        destination.f3(pair.hi_1, pair.ii_1);
      }
      var numChildrenAlternatives = destination;
      var inductionVariable = uralternatives.h1() - 1 | 0;
      if (0 <= inductionVariable)
        do {
          var i = inductionVariable;
          inductionVariable = inductionVariable + -1 | 0;
          var _destruct__k2r9zo = uralternatives.i1(i);
          var alt = _destruct__k2r9zo.ni();
          var children = _destruct__k2r9zo.oi();
          var altOfTotal_0 = new AltInfo(alt, i, uralternatives.h1());
          var tmp_0 = numSkipChildren(this, this.v2b_1.initialSkip);
          // Inline function 'kotlin.collections.filter' call
          // Inline function 'kotlin.collections.filterTo' call
          var destination_0 = ArrayList.o1();
          var _iterator__ex2g4s_0 = children.g1();
          while (_iterator__ex2g4s_0.f()) {
            var element_0 = _iterator__ex2g4s_0.e();
            if (element_0.rule.isTerminal) {
              destination_0.v(element_0);
            }
          }
          // Inline function 'kotlin.collections.fold' call
          var accumulator = 0;
          var _iterator__ex2g4s_1 = destination_0.g1();
          while (_iterator__ex2g4s_1.f()) {
            var element_1 = _iterator__ex2g4s_1.e();
            var acc = accumulator;
            var tmp0_safe_receiver = this.v2b_1.skipDataAfter(element_1);
            var tmp_1;
            if (tmp0_safe_receiver == null) {
              tmp_1 = null;
            } else {
              // Inline function 'kotlin.let' call
              tmp_1 = acc + numSkipChildren(this, tmp0_safe_receiver) | 0;
            }
            var tmp1_elvis_lhs = tmp_1;
            accumulator = tmp1_elvis_lhs == null ? acc : tmp1_elvis_lhs;
          }
          var urnumSkipChildren = tmp_0 + accumulator | 0;
          var stackData = new StackInfo(true, new ParsePath(emptyList()), userRoot, parentAlt, altOfTotal_0, urchildOfTotal_0, numChildrenAlternatives, urnumSkipChildren);
          altInfo.z2c_1.v(new Pair(stackData, children));
        }
         while (0 <= inductionVariable);
    }
    while (this.x2b_1.q11()) {
      var info = this.x2b_1.v11();
      traverseStackData(this, callback, skipDataAsTree, info);
    }
    callback.endTree();
  }
}
class AlternativesInfo {
  constructor(node, isRoot) {
    this.x2c_1 = node;
    this.y2c_1 = isRoot;
    var tmp = this;
    // Inline function 'kotlin.collections.mutableListOf' call
    tmp.z2c_1 = ArrayList.o1();
  }
  toString() {
    return 'AlternativesInfo(node=' + toString(this.x2c_1) + ', isRoot=' + this.y2c_1 + ')';
  }
  hashCode() {
    var result = hashCode(this.x2c_1);
    result = imul(result, 31) + getBooleanHashCode(this.y2c_1) | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof AlternativesInfo))
      return false;
    if (!equals(this.x2c_1, other.x2c_1))
      return false;
    if (!(this.y2c_1 === other.y2c_1))
      return false;
    return true;
  }
}
class StackInfo {
  constructor(done, path, node, parentAlt, alt, child, numChildrenAlternatives, numSkipChildren) {
    this.p2c_1 = done;
    this.q2c_1 = path;
    this.r2c_1 = node;
    this.s2c_1 = parentAlt;
    this.t2c_1 = alt;
    this.u2c_1 = child;
    this.v2c_1 = numChildrenAlternatives;
    this.w2c_1 = numSkipChildren;
  }
  f28() {
    return this.q2c_1;
  }
  o12() {
    return this.r2c_1;
  }
  g28() {
    return this.s2c_1;
  }
  h28() {
    return this.t2c_1;
  }
  i28() {
    return this.u2c_1;
  }
  j28() {
    return this.v2c_1;
  }
  l28() {
    return this.w2c_1;
  }
  k28() {
    // Inline function 'kotlin.collections.fold' call
    var accumulator = 0;
    var _iterator__ex2g4s = this.v2c_1.e3().g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      accumulator = accumulator + element | 0;
    }
    return accumulator;
  }
  toString() {
    return 'StackInfo(done=' + this.p2c_1 + ', path=' + this.q2c_1.toString() + ', node=' + toString(this.r2c_1) + ', parentAlt=' + this.s2c_1.toString() + ', alt=' + this.t2c_1.toString() + ', child=' + this.u2c_1.toString() + ', numChildrenAlternatives=' + toString(this.v2c_1) + ', numSkipChildren=' + this.w2c_1 + ')';
  }
  hashCode() {
    var result = getBooleanHashCode(this.p2c_1);
    result = imul(result, 31) + this.q2c_1.hashCode() | 0;
    result = imul(result, 31) + hashCode(this.r2c_1) | 0;
    result = imul(result, 31) + this.s2c_1.hashCode() | 0;
    result = imul(result, 31) + this.t2c_1.hashCode() | 0;
    result = imul(result, 31) + this.u2c_1.hashCode() | 0;
    result = imul(result, 31) + hashCode(this.v2c_1) | 0;
    result = imul(result, 31) + this.w2c_1 | 0;
    return result;
  }
  equals(other) {
    if (this === other)
      return true;
    if (!(other instanceof StackInfo))
      return false;
    if (!(this.p2c_1 === other.p2c_1))
      return false;
    if (!this.q2c_1.equals(other.q2c_1))
      return false;
    if (!equals(this.r2c_1, other.r2c_1))
      return false;
    if (!this.s2c_1.equals(other.s2c_1))
      return false;
    if (!this.t2c_1.equals(other.t2c_1))
      return false;
    if (!this.u2c_1.equals(other.u2c_1))
      return false;
    if (!equals(this.v2c_1, other.v2c_1))
      return false;
    if (!(this.w2c_1 === other.w2c_1))
      return false;
    return true;
  }
  get path() {
    return this.f28();
  }
  get node() {
    return this.o12();
  }
  get parentAlt() {
    return this.g28();
  }
  get alt() {
    return this.h28();
  }
  get child() {
    return this.i28();
  }
  get numChildrenAlternatives() {
    return this.j28();
  }
  get numSkipChildren() {
    return this.l28();
  }
  get totalChildrenFromAllAlternatives() {
    return this.k28();
  }
}
class IndentDelta extends Enum {
  get name() {
    return this.r3();
  }
  get ordinal() {
    return this.s3();
  }
}
class Debug_0 {
  constructor() {
    this.CHECK = false;
    this.OUTPUT_SM_BUILD = false;
    this.OUTPUT_RUNTIME_BUILD = false;
    this.OUTPUT_RUNTIME = false;
    this.OUTPUT_TREE_DATA = false;
    this.f2d_1 = '  ';
    this.g2d_1 = '';
  }
  h2d() {
    return this.CHECK;
  }
  i2d() {
    return this.OUTPUT_SM_BUILD;
  }
  j2d() {
    return this.OUTPUT_RUNTIME_BUILD;
  }
  k2d() {
    return this.OUTPUT_RUNTIME;
  }
  l2d() {
    return this.OUTPUT_TREE_DATA;
  }
  debug(indentDelta, lazyMessage) {
    if (false || false || false || false) {
      switch (indentDelta.q3_1) {
        case 3:
          this.g2d_1 = substring_0(this.g2d_1, 2);
          break;
        case 1:
          this.g2d_1 = this.g2d_1 + '  ';
          break;
        default:
          break;
      }
      println_0(this.g2d_1 + lazyMessage());
      switch (indentDelta.q3_1) {
        case 4:
          this.g2d_1 = substring_0(this.g2d_1, 2);
          break;
        case 2:
          this.g2d_1 = this.g2d_1 + '  ';
          break;
        default:
          break;
      }
    }
  }
}
class UNINITIALIZED_VALUE {}
class Companion_27 {}
class CachedValue {
  constructor(initializer) {
    this.m2d_1 = initializer;
    this.n2d_1 = UNINITIALIZED_VALUE_instance;
    var tmp = this;
    tmp.resetAction = CachedValue$resetAction$lambda;
  }
  o2d(value) {
    this.n2d_1 = value;
  }
  b2() {
    if (this.n2d_1 === UNINITIALIZED_VALUE_instance) {
      this.n2d_1 = this.m2d_1();
    }
    var tmp = this.n2d_1;
    return (tmp == null ? true : !(tmp == null)) ? tmp : THROW_CCE();
  }
  p2d(_set____db54di) {
    this.resetAction = _set____db54di;
  }
  q2d() {
    return this.resetAction;
  }
  reset() {
    if (!equals(this.n2d_1, UNINITIALIZED_VALUE_instance)) {
      var tmp = this.n2d_1;
      var old = (tmp == null ? true : !(tmp == null)) ? tmp : THROW_CCE();
      this.n2d_1 = UNINITIALIZED_VALUE_instance;
      this.resetAction(old);
    }
  }
  get value() {
    return this.b2();
  }
  set value(value) {
    this.o2d(value);
  }
}
//endregion
var BuildConfig_instance;
function BuildConfig_getInstance() {
  return BuildConfig_instance;
}
var Companion_instance;
function Companion_getInstance() {
  return Companion_instance;
}
function AutomatonForMinimal$goalRule$delegate$lambda(this$0) {
  return () => this$0.runtimeRuleSet.goalRuleFor.c3(this$0.userGoalRule);
}
function AutomatonForMinimal$_get_goalRule_$ref_bc6um1() {
  return (p0) => p0.goalRule;
}
function AutomatonForMinimal$usedRules$delegate$lambda(this$0) {
  return () => this$0.runtimeRuleSet.calcUsedRules(this$0.startState.rp.k1b_1);
}
function AutomatonForMinimal$_get_usedRules_$ref_34nyhi() {
  return (p0) => p0.usedRules;
}
function AutomatonForMinimal$usedTerminals$delegate$lambda(this$0) {
  return () => {
    // Inline function 'kotlin.collections.filter' call
    var tmp0 = this$0.usedRules;
    // Inline function 'kotlin.collections.filterTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      if (element.isTerminal) {
        destination.v(element);
      }
    }
    return toSet(destination);
  };
}
function AutomatonForMinimal$_get_usedTerminals_$ref_xd3hli() {
  return (p0) => p0.usedTerminals;
}
function AutomatonForMinimal$usedAutomatonToString$lambda(it) {
  return it.source.number;
}
function AutomatonForMinimal$usedAutomatonToString$lambda_0(it) {
  return it.target.number;
}
function AutomatonForMinimal$usedAutomatonToString$lambda_1(it) {
  return '' + it.number;
}
function AutomatonForMinimal$usedAutomatonToString$lambda_2(it) {
  return it.tag;
}
function AutomatonForMinimal$usedAutomatonToString$lambda_3(it) {
  return it.tag;
}
function mergeCompleteTransFor($this, key, tran) {
  var tmp0_elvis_lhs = $this.outCompleteTransForCtx(key);
  var existing = tmp0_elvis_lhs == null ? emptySet() : tmp0_elvis_lhs;
  var merged = Companion_instance.merge(plus(existing, tran));
  // Inline function 'kotlin.collections.set' call
  $this.outCompleteTransitionsByCtx.f3(key, merged);
}
function mergeIncompleteTransFor($this, key, tran) {
  var tmp0_elvis_lhs = $this.outIncompleteTransForCtx(key);
  var existing = tmp0_elvis_lhs == null ? emptySet() : tmp0_elvis_lhs;
  var merged = Companion_instance.merge(plus(existing, tran));
  // Inline function 'kotlin.collections.set' call
  $this.outIncompleteTransitionsByCtx.f3(key, merged);
}
function TransitionForMinimal$toString$lambda(it) {
  return it.rp.toString();
}
function skipAutomaton($this, runtimeRuleSet) {
  // Inline function 'kotlin.collections.filter' call
  var tmp0 = runtimeRuleSet.runtimeRules;
  // Inline function 'kotlin.collections.filterTo' call
  var destination = ArrayList.o1();
  var _iterator__ex2g4s = tmp0.g1();
  while (_iterator__ex2g4s.f()) {
    var element = _iterator__ex2g4s.e();
    if (element.v1d_1) {
      destination.v(element);
    }
  }
  var skipRules = destination;
  var tmp;
  if (skipRules.l1()) {
    tmp = null;
  } else {
    // Inline function 'kotlin.also' call
    var this_0 = new RuntimeRule(runtimeRuleSet.number, -4, '<SKIP-CHOICE>', false, false);
    // Inline function 'kotlin.collections.mapIndexed' call
    // Inline function 'kotlin.collections.mapIndexedTo' call
    var destination_0 = ArrayList.a1(collectionSizeOrDefault(skipRules, 10));
    var index = 0;
    var _iterator__ex2g4s_0 = skipRules.g1();
    while (_iterator__ex2g4s_0.f()) {
      var item = _iterator__ex2g4s_0.e();
      var _unary__edvuaz = index;
      index = _unary__edvuaz + 1 | 0;
      checkIndexOverflow(_unary__edvuaz);
      var tmp$ret$3 = new RuntimeRuleRhsConcatenation(this_0, listOf(item));
      destination_0.v(tmp$ret$3);
    }
    var options = destination_0;
    var rhs = new RuntimeRuleRhsChoice(this_0, RuntimeRuleChoiceKind_LONGEST_PRIORITY_getInstance(), options);
    this_0.setRhs(rhs);
    var skipChoiceRule = this_0;
    // Inline function 'kotlin.also' call
    var this_1 = new RuntimeRule(runtimeRuleSet.number, -3, '<SKIP-MULTI>', false, false);
    this_1.setRhs(new RuntimeRuleRhsListSimple(this_1, 1, -1, skipChoiceRule));
    var skipMultiRule = this_1;
    tmp = new AutomatonForMinimal(runtimeRuleSet, skipMultiRule);
  }
  return tmp;
}
function _get_complete__1az5pu($this, _this__u8e3s4) {
  return new CompleteNodeForMinimal(_this__u8e3s4.state.rp.k1b_1, _this__u8e3s4.sp, _this__u8e3s4.nip, _this__u8e3s4.nibs, _this__u8e3s4.state.rp.l1b_1, emptyList());
}
function setRoot($this, _this__u8e3s4, state, rlh, sp, nibs, nip) {
  var nn = new GSSNodeForMinimal(state, rlh, sp, nip);
  nn.nibs = nibs;
  _this__u8e3s4.root(nn);
  return nn;
}
function pushNode($this, _this__u8e3s4, prev, state, rlh, sp, nibs, nip) {
  var nn = new GSSNodeForMinimal(state, rlh, sp, nip);
  nn.nibs = nibs;
  _this__u8e3s4.push(prev, nn);
  return nn;
}
function setNextChildInParent($this, _this__u8e3s4, oldParent, newParent, nextChild) {
  if (newParent.isComplete) {
    _this__u8e3s4.setNextChildForCompleteParent(oldParent, _get_complete__1az5pu($this, newParent), nextChild, newParent.state.rp.k1b_1.isChoiceAmbiguous);
  } else {
    _this__u8e3s4.setNextChildForGrowingParent(oldParent, newParent, nextChild);
  }
}
var Companion_instance_0;
function Companion_getInstance_0() {
  return Companion_instance_0;
}
function tracePeekHead($this, curPos, hd) {
  if (!$this.isSkip) {
    println();
    println_0('At ' + curPos + ', Head: (' + hd.state.rp.toString() + '/' + hd.rlh.toString() + ')[' + hd.sp + '-' + hd.nip + ']');
  }
}
function traceTrans($this, hd, pv, tr, b) {
  if (!$this.isSkip) {
    println_0('  (' + hd.state.rp.toString() + '/' + hd.rlh.toString() + ')-->' + pv.rp.toString());
    var m = b ? 'taken' : 'ignored';
    println_0('  ' + m + ' ' + tr.toString());
  }
}
function traceTrans_0($this, hd, pv, pp, tr, b) {
  if (!$this.isSkip) {
    var tmp = hd.state.rp.toString();
    var tmp_0 = hd.rlh.toString();
    var tmp_1 = pv.state.rp.toString();
    var tmp_2 = pv.rlh.toString();
    var tmp1_safe_receiver = pp == null ? null : pp.state;
    var tmp_3 = toString_0(tmp1_safe_receiver == null ? null : tmp1_safe_receiver.rp);
    var tmp_4 = toString_0(pp == null ? null : pp.rlh);
    var tmp_5 = pp == null ? null : pp.sp;
    println_0('  (' + tmp + '/' + tmp_0 + ')-->(' + tmp_1 + '/' + tmp_2 + ')[' + pv.sp + '-' + pv.nip + ']-->(' + tmp_3 + '/' + tmp_4 + ')[' + tmp_5 + '-' + (pp == null ? null : pp.nip) + ']');
    var m = b ? 'taken' : 'ignored';
    println_0('  ' + m + ' ' + tr.toString());
  }
}
function traceDrop($this, hd) {
  if (!$this.isSkip) {
    println_0('  Dropped Stack: (' + hd.state.rp.toString() + '/' + hd.rlh.toString() + ')[' + hd.sp + '-' + hd.nip + ']');
  }
}
function parseAt($this, position, eot) {
  var tmp;
  if (null == $this.skipParser) {
    tmp = null;
  } else {
    // Inline function 'kotlin.collections.filterNot' call
    var tmp0 = firstTerminals($this, $this.ss.rp, $this.ss.rp, eot);
    // Inline function 'kotlin.collections.filterNotTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      if (!(element.terminalRule.isEmptyTerminal || element.terminalRule.isEmptyListTerminal)) {
        destination.v(element);
      }
    }
    // Inline function 'kotlin.collections.map' call
    // Inline function 'kotlin.collections.mapTo' call
    var destination_0 = ArrayList.a1(collectionSizeOrDefault(destination, 10));
    var _iterator__ex2g4s_0 = destination.g1();
    while (_iterator__ex2g4s_0.f()) {
      var item = _iterator__ex2g4s_0.e();
      var tmp$ret$3 = item.terminalRule;
      destination_0.v(tmp$ret$3);
    }
    // Inline function 'kotlin.let' call
    var slh = Companion_getInstance_7().createFromRuntimeRules(toSet(destination_0)).union(eot);
    tmp = tryParseSkip($this, position, slh);
  }
  var initialSkipData = tmp;
  var tmp1_safe_receiver = initialSkipData == null ? null : initialSkipData.root;
  var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : tmp1_safe_receiver.nextInputPosition;
  var nip = tmp2_elvis_lhs == null ? position : tmp2_elvis_lhs;
  var stNd = setRoot(Companion_instance_0, $this.gss, $this.ss, eot, position, position, nip);
  $this.sppf.initialise(stNd, initialSkipData);
  var currentNextInputPosition = nip;
  // Inline function 'kotlin.collections.mutableSetOf' call
  var doneEmpties = LinkedHashSet.j1();
  while ($this.gss.hasNextHead) {
    var hd = ensureNotNull($this.gss.peekFirstHead);
    if (false) {
      tracePeekHead($this, currentNextInputPosition, hd);
    }
    if (hd.nip > currentNextInputPosition) {
      doneEmpties.i3();
      currentNextInputPosition = hd.nip;
    }
    if (hd.isEmptyMatch && doneEmpties.p1(new Pair(hd.state, $this.gss.peekPrevious(hd)))) {
      $this.gss.dropStack(hd, MinimalParser$parseAt$lambda);
      if (false) {
        traceDrop($this, hd);
      }
    } else {
      if (hd.isEmptyMatch) {
        doneEmpties.v(new Pair(hd.state, $this.gss.peekPrevious(hd)));
      }
      if (hd.isGoal && hd.isComplete) {
        recordGoal($this, $this.sppf, hd);
      } else if (hd.isGoal && !hd.isComplete) {
        growIncomplete2($this, hd, $this.ss, eot);
      } else if (!hd.isComplete) {
        growIncomplete($this, hd, eot);
      } else if (hd.isComplete) {
        growComplete($this, hd, eot);
      }
    }
  }
  var tmp_0;
  if ($this.sppf.complete.root == null) {
    tmp_0 = null;
  } else {
    tmp_0 = $this.sppf.complete;
  }
  return tmp_0;
}
function recordGoal($this, sppf, hd) {
  sppf.complete.setRootTo(_get_complete__1az5pu(Companion_instance_0, hd));
  $this.gss.dropStack(hd, MinimalParser$recordGoal$lambda);
}
function growIncomplete($this, hd, peot) {
  var _iterator__ex2g4s = $this.gss.peekPrevious(hd).g1();
  while (_iterator__ex2g4s.f()) {
    var pv = _iterator__ex2g4s.e();
    growIncomplete2($this, hd, pv.state, peot);
  }
}
function growIncomplete2($this, hd, pv, peot) {
  var grown = false;
  var trans = transitionsIncomplete($this, hd.state, pv);
  var _iterator__ex2g4s = trans.g1();
  while (_iterator__ex2g4s.f()) {
    var tr = _iterator__ex2g4s.e();
    var tmp;
    switch (tr.action.q3_1) {
      case 2:
        tmp = doWidth($this, hd, tr, peot);
        break;
      case 4:
        tmp = doEmbed($this, hd, tr, peot);
        break;
      default:
        throw IllegalStateException.t4(toString('Error'));
    }
    var b = tmp;
    grown = grown || b;
    if (false) {
      traceTrans($this, hd, pv, tr, b);
    }
  }
  if (!grown) {
    $this.gss.dropStack(hd, MinimalParser$growIncomplete2$lambda);
  }
}
function growComplete($this, hd, peot) {
  var headGrownHeight = false;
  var headGrownGraft = false;
  // Inline function 'kotlin.collections.mutableMapOf' call
  var dropPrevs = LinkedHashMap.j4();
  var _iterator__ex2g4s = $this.gss.peekPrevious(hd).g1();
  while (_iterator__ex2g4s.f()) {
    var pv = _iterator__ex2g4s.e();
    var prevGrownHeight = false;
    var prevGrownGraft = false;
    var pps = $this.gss.peekPrevious(pv);
    if (pps.l1()) {
      var _destruct__k2r9zo = growComplete2($this, hd, pv, null, peot);
      var h = _destruct__k2r9zo.ni();
      var g = _destruct__k2r9zo.oi();
      prevGrownHeight = prevGrownHeight || h;
      prevGrownGraft = prevGrownGraft || g;
    } else {
      var _iterator__ex2g4s_0 = pps.g1();
      while (_iterator__ex2g4s_0.f()) {
        var pp = _iterator__ex2g4s_0.e();
        var _destruct__k2r9zo_0 = growComplete2($this, hd, pv, pp, peot);
        var h_0 = _destruct__k2r9zo_0.ni();
        var g_0 = _destruct__k2r9zo_0.oi();
        prevGrownHeight = prevGrownHeight || h_0;
        prevGrownGraft = prevGrownGraft || g_0;
      }
    }
    if (!prevGrownHeight) {
      // Inline function 'kotlin.collections.set' call
      var value = prevGrownGraft;
      dropPrevs.f3(pv, value);
    }
    headGrownHeight = headGrownHeight || prevGrownHeight;
    headGrownGraft = headGrownGraft || prevGrownGraft;
  }
  cleanUpGss($this, hd, headGrownHeight, headGrownGraft, dropPrevs);
}
function cleanUpGss($this, hd, headGrownHeight, headGrownGraft, dropPrevs) {
  if (!headGrownHeight && !headGrownGraft) {
    $this.gss.dropStack(hd, MinimalParser$cleanUpGss$lambda);
  } else if (headGrownHeight && !headGrownGraft) {
    $this.gss.dropStack(hd, MinimalParser$cleanUpGss$lambda_0);
  } else if (!headGrownHeight && headGrownGraft) {
    $this.gss.dropStack(hd, MinimalParser$cleanUpGss$lambda_1);
  } else if (headGrownHeight && headGrownGraft) {
    $this.gss.dropStack(hd, MinimalParser$cleanUpGss$lambda_2);
  }
  // Inline function 'kotlin.collections.forEach' call
  // Inline function 'kotlin.collections.iterator' call
  var _iterator__ex2g4s = dropPrevs.z1().g1();
  while (_iterator__ex2g4s.f()) {
    var element = _iterator__ex2g4s.e();
    if (element.b2()) {
      var tmp = element.a2();
      $this.gss.dropStack(tmp, MinimalParser$cleanUpGss$lambda_3);
    } else {
      var tmp_0 = element.a2();
      $this.gss.dropStack(tmp_0, MinimalParser$cleanUpGss$lambda_4);
    }
  }
}
function growComplete2($this, hd, pv, pp, peot) {
  var grownHeight = false;
  var grownGraft = false;
  var tmp1_elvis_lhs = pp == null ? null : pp.state;
  var pps = tmp1_elvis_lhs == null ? $this.ss : tmp1_elvis_lhs;
  var trans = transitionsComplete($this, hd.state, pv.state, pps);
  var _iterator__ex2g4s = trans.g1();
  while (_iterator__ex2g4s.f()) {
    var tr = _iterator__ex2g4s.e();
    switch (tr.action.q3_1) {
      case 3:
        var b = doGoal($this, hd, pv, tr, peot);
        grownGraft = grownGraft || b;
        if (false) {
          traceTrans_0($this, hd, pv, pp, tr, b);
        }

        break;
      case 0:
        var b_0 = doHeight($this, hd, pv, tr, peot);
        grownHeight = grownHeight || b_0;
        if (false) {
          traceTrans_0($this, hd, pv, pp, tr, b_0);
        }

        break;
      case 1:
        var b_1 = doGraft($this, hd, pv, ensureNotNull(pp), tr, peot);
        grownGraft = grownGraft || b_1;
        if (false) {
          traceTrans_0($this, hd, pv, pp, tr, b_1);
        }

        break;
      default:
        // Inline function 'kotlin.error' call

        throw IllegalStateException.t4(toString('Error'));
    }
  }
  return new Pair(grownHeight, grownGraft);
}
function doGoal($this, hd, pv, tr, peot) {
  var lh = tr.lh.resolve(peot, pv.rlh);
  var tmp;
  if ($this.scanner.p1e(ensureNotNull($this.sentence), lh, hd.nip)) {
    var nn = setRoot(Companion_instance_0, $this.gss, tr.target, pv.rlh, hd.sp, hd.nibs, hd.nip);
    setNextChildInParent(Companion_instance_0, $this.sppf, pv, nn, _get_complete__1az5pu(Companion_instance_0, hd));
    tmp = true;
  } else {
    tmp = false;
  }
  return tmp;
}
function doWidth($this, hd, tr, peot) {
  var lf = $this.scanner.findOrTryCreateLeaf(ensureNotNull($this.sentence), hd.nip, tr.target.rp.k1b_1);
  var tmp;
  if (!(null == lf)) {
    var slh = tr.lh.resolve(peot, hd.rlh);
    var skipData = tryParseSkip($this, lf.s1e_1, slh);
    var nip = !(null == skipData) ? ensureNotNull(skipData.root).nextInputPosition : lf.s1e_1;
    var tmp_0;
    if ($this.scanner.p1e(ensureNotNull($this.sentence), slh, nip)) {
      var rlh = Companion_getInstance_7().EMPTY;
      var nn = pushNode(Companion_instance_0, $this.gss, hd, tr.target, rlh, lf.r1e_1, lf.s1e_1, nip);
      if (!(null == skipData)) {
        $this.sppf.setSkipDataAfter(_get_complete__1az5pu(Companion_instance_0, nn), skipData);
      }
      tmp_0 = true;
    } else {
      tmp_0 = false;
    }
    tmp = tmp_0;
  } else {
    tmp = false;
  }
  return tmp;
}
function doHeight($this, hd, pv, tr, peot) {
  var lh = tr.lh.resolve(peot, pv.rlh);
  var nip = hd.nip;
  var tmp;
  if (ensureNotNull($this.scanner).p1e(ensureNotNull($this.sentence), lh, nip)) {
    var rlh = tr.up.resolve(peot, pv.rlh);
    var nn = pushNode(Companion_instance_0, $this.gss, pv, tr.target, rlh, hd.sp, hd.nip, hd.nip);
    var tmp_0;
    if (nn.isComplete) {
      var existing = $this.sppf.preferred(_get_complete__1az5pu(Companion_instance_0, nn));
      var tmp_1;
      if (null == existing) {
        Companion_instance_0.setFirstChildForParent($this.sppf, nn, _get_complete__1az5pu(Companion_instance_0, hd));
        tmp_1 = true;
      } else {
        var tmp_2;
        if (Companion_instance_0.length > Companion_instance_0.length) {
          tmp_2 = false;
        } else {
          Companion_instance_0.setFirstChildForParent($this.sppf, nn, _get_complete__1az5pu(Companion_instance_0, hd));
          tmp_2 = true;
        }
        tmp_1 = tmp_2;
      }
      tmp_0 = tmp_1;
    } else {
      Companion_instance_0.setFirstChildForParent($this.sppf, nn, _get_complete__1az5pu(Companion_instance_0, hd));
      tmp_0 = true;
    }
    tmp = tmp_0;
  } else {
    tmp = false;
  }
  return tmp;
}
function doGraft($this, hd, pv, pp, tr, peot) {
  var lh = tr.lh.resolve(peot, pv.rlh);
  var tmp;
  if (ensureNotNull($this.scanner).p1e(ensureNotNull($this.sentence), lh, hd.nip)) {
    var rlh = pv.rlh;
    var nn = pushNode(Companion_instance_0, $this.gss, ensureNotNull(pp), tr.target, rlh, pv.sp, hd.nibs, hd.nip);
    var tmp_0;
    if (nn.isComplete) {
      var existing = $this.sppf.preferred(_get_complete__1az5pu(Companion_instance_0, nn));
      var tmp_1;
      if (null == existing) {
        setNextChildInParent(Companion_instance_0, $this.sppf, pv, nn, _get_complete__1az5pu(Companion_instance_0, hd));
        tmp_1 = true;
      } else {
        var tmp_2;
        if (Companion_instance_0.length > Companion_instance_0.length) {
          tmp_2 = false;
        } else {
          setNextChildInParent(Companion_instance_0, $this.sppf, pv, nn, _get_complete__1az5pu(Companion_instance_0, hd));
          tmp_2 = true;
        }
        tmp_1 = tmp_2;
      }
      tmp_0 = tmp_1;
    } else {
      setNextChildInParent(Companion_instance_0, $this.sppf, pv, nn, _get_complete__1az5pu(Companion_instance_0, hd));
      tmp_0 = true;
    }
    tmp = tmp_0;
  } else {
    tmp = false;
  }
  return tmp;
}
function doEmbed($this, hd, tr, peot) {
  var tmp = tr.target.rp.k1b_1.rhs;
  var embeddedRhs = tmp instanceof RuntimeRuleRhsEmbedded ? tmp : THROW_CCE();
  var embeddedRRS = embeddedRhs.embeddedRuntimeRuleSet;
  var embeddedGoal = embeddedRhs.embeddedStartRule;
  var key = new Pair(embeddedRRS, embeddedGoal);
  var tmp_0;
  if ($this.embedded.a3(key)) {
    tmp_0 = ensureNotNull($this.embedded.c3(key));
  } else {
    var p = Companion_instance_0.parser(embeddedGoal.tag, embeddedRRS);
    // Inline function 'kotlin.collections.set' call
    $this.embedded.f3(key, p);
    tmp_0 = p;
  }
  var embeddedParser = tmp_0;
  embeddedParser.sentence = $this.sentence;
  var tmp0_safe_receiver = embeddedParser.skipParser;
  if (tmp0_safe_receiver == null)
    null;
  else {
    tmp0_safe_receiver.sentence = $this.sentence;
  }
  var embeddedEOT = tr.lh.unionContent($this.skipTerms).resolve(peot, hd.rlh);
  var embed = parseAt(embeddedParser, hd.nip, embeddedEOT);
  var tmp_1;
  if (!(null == embed)) {
    var slh = tr.lh.resolve(peot, hd.rlh);
    var skipData = tryParseSkip($this, ensureNotNull(embed.root).nextInputPosition, slh);
    var nip = !(null == skipData) ? ensureNotNull(skipData.root).nextInputPosition : ensureNotNull(embed.root).nextInputPosition;
    var rlh = Companion_getInstance_7().EMPTY;
    var nn = pushNode(Companion_instance_0, $this.gss, hd, tr.target, rlh, ensureNotNull(embed.root).startPosition, ensureNotNull(embed.root).nextInputPosition, nip);
    $this.sppf.complete.setEmbeddedTreeFor(_get_complete__1az5pu(Companion_instance_0, nn), embed);
    if (!(null == skipData)) {
      $this.sppf.setSkipDataAfter(_get_complete__1az5pu(Companion_instance_0, nn), skipData);
    }
    tmp_1 = true;
  } else {
    tmp_1 = false;
  }
  return tmp_1;
}
function tryParseSkip($this, position, slh) {
  var tmp;
  if (null == $this.skipParser) {
    tmp = null;
  } else {
    ensureNotNull($this.skipParser).reset();
    tmp = parseAt(ensureNotNull($this.skipParser), position, slh);
  }
  return tmp;
}
function transitionsIncomplete($this, hd, pv) {
  var key = pv;
  var trans = hd.outIncompleteTransForCtx(key);
  var tmp;
  if (null == trans) {
    $this.clearCache();
    var pe = hd.rp.isGoal ? Companion_getInstance_7().EOT : Companion_getInstance_7().RT;
    // Inline function 'kotlin.collections.map' call
    var this_0 = firstTerminals($this, pv.rp, hd.rp, pe);
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var action = item.terminalRule.isEmbedded ? ParseAction_EMBED_getInstance() : ParseAction_WIDTH_getInstance();
      var tgt = $this.automaton.createState(item.terminalRule.y1e());
      var tmp$ret$0 = new TransitionForMinimal(hd, tgt, action, item.parentExpectedAt, Companion_getInstance_7().EMPTY);
      destination.v(tmp$ret$0);
    }
    var ts = toSet(destination);
    var trs = Companion_instance.merge(ts);
    hd.addOutIncompleteTrans(key, trs);
    tmp = ensureNotNull(hd.outIncompleteTransForCtx(key));
  } else {
    tmp = trans;
  }
  return tmp;
}
function transitionsComplete($this, hd, pv, pp) {
  var key = new Pair(pv, pp);
  var trans = hd.outCompleteTransForCtx(key);
  var tmp;
  if (null == trans) {
    // Inline function 'kotlin.collections.map' call
    var this_0 = parentsInContext($this, pp.rp, pv.rp, hd.rp.k1b_1);
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var action = item.rulePosition.isGoal ? ParseAction_GOAL_getInstance() : item.firstPosition ? ParseAction_HEIGHT_getInstance() : ParseAction_GRAFT_getInstance();
      var tgt = item.rulePosition;
      var lh = item.expectedAt;
      var up = action.q3_1 === 0 ? item.parentExpectedAt : Companion_getInstance_7().EMPTY;
      var tmp$ret$0 = new TransitionForMinimal(hd, $this.automaton.createState(tgt), action, lh, up);
      destination.v(tmp$ret$0);
    }
    var ts = toSet(destination);
    var trs = Companion_instance.merge(ts);
    hd.addOutCompleteTrans(key, trs);
    tmp = ensureNotNull(hd.outCompleteTransForCtx(key));
  } else {
    tmp = trans;
  }
  return tmp;
}
function firstTerminals($this, pv, rp, parentFollow) {
  var tmp;
  if (rp.isGoal && rp.isAtEnd) {
    tmp = emptySet();
  } else {
    processClosure($this, new ClosureGraph(pv, rp, parentFollow));
    tmp = $this.e1e_1.c3(pv).c3(rp);
  }
  return tmp;
}
function parentsInContext($this, pp, pv, cr) {
  processClosure($this, new ClosureGraph(pp, pv, Companion_getInstance_7().RT));
  var ctx = pv;
  return $this.f1e_1.c3(ctx).c3(cr);
}
function processClosure($this, graph) {
  var todoList = mutableQueueOf([]);
  todoList.r16(graph.b1f_1);
  while (todoList.q11()) {
    var cls = todoList.s16();
    var _iterator__ex2g4s = cls.c1f().items.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      if (item.isTerminal)
        graph.e1f(cls, item.y1e());
      else if (item.isNonTerminal) {
        var childRps = item.d1f();
        var _iterator__ex2g4s_0 = childRps.g1();
        while (_iterator__ex2g4s_0.f()) {
          var childRp = _iterator__ex2g4s_0.e();
          var child = graph.e1f(cls, childRp);
          if (!(null == child)) {
            todoList.r16(child);
          }
        }
      } else {
        // Inline function 'kotlin.error' call
        var message = 'Internal Error: should never happen';
        throw IllegalStateException.t4(toString(message));
      }
    }
  }
  graph.f1f();
  var _iterator__ex2g4s_1 = graph.b1f_1.q1f().g1();
  while (_iterator__ex2g4s_1.f()) {
    var dwn = _iterator__ex2g4s_1.e();
    $this.cacheFirstTerminalInContext(graph.b1f_1.i1f_1, graph.b1f_1.h1f_1, dwn);
    $this.cachePossibleContext(graph.b1f_1.h1f_1, graph.b1f_1.i1f_1);
  }
  var _iterator__ex2g4s_2 = graph.r1f().g1();
  while (_iterator__ex2g4s_2.f()) {
    var cls_0 = _iterator__ex2g4s_2.e();
    if (cls_0.q1f().l1()) {
      $this.cachePossibleContext(cls_0.c1f(), cls_0.sb());
    } else {
      if (cls_0.c1f().isAtStart || cls_0.c1f().isTerminal) {
        $this.cacheParentInContext(cls_0.sb(), cls_0.c1f().k1b_1, cls_0.s1f());
        $this.cachePossibleContext(cls_0.c1f(), cls_0.sb());
      } else {
        // Inline function 'kotlin.collections.forEach' call
        var _iterator__ex2g4s_3 = cls_0.q1f().g1();
        while (_iterator__ex2g4s_3.f()) {
          var element = _iterator__ex2g4s_3.e();
          $this.cacheFirstTerminalInContext(cls_0.sb(), cls_0.c1f(), element);
          $this.cachePossibleContext(cls_0.c1f(), cls_0.sb());
        }
      }
    }
  }
}
function _get__possibleContexts__e1uu9v($this) {
  var tmp = KProperty1;
  return $this.g1e_1.yj($this, getPropertyCallableRef('_possibleContexts', 1, tmp, MinimalParser$_get__possibleContexts_$ref_tglonc(), null));
}
function MinimalParser$gss$lambda(parent, child) {
  return parent.nip < child.nip ? 1 : parent.nip > child.nip ? -1 : parent.state.rp.isAtEnd && child.state.rp.isAtEnd ? 0 : parent.state.rp.isAtEnd ? -1 : child.state.rp.isAtEnd ? 1 : parent.sp < child.sp ? -1 : parent.sp > child.sp ? 1 : 0;
}
function MinimalParser$skipTerms$delegate$lambda(this$0) {
  return () => this$0.automaton.runtimeRuleSet.skipTerminals;
}
function MinimalParser$_get_skipTerms_$ref_hmetp0() {
  return (p0) => p0.skipTerms;
}
function MinimalParser$skipParser$delegate$lambda(this$0) {
  return () => {
    var tmp;
    if (this$0.skipAutomaton == null) {
      tmp = null;
    } else {
      // Inline function 'kotlin.let' call
      tmp = new MinimalParser(this$0.skipAutomaton, true, null);
    }
    return tmp;
  };
}
function MinimalParser$_get_skipParser_$ref_vbmvz4() {
  return (p0) => p0.skipParser;
}
function MinimalParser$parseAt$lambda(it) {
  return Unit_instance;
}
function MinimalParser$recordGoal$lambda(it) {
  return Unit_instance;
}
function MinimalParser$growIncomplete2$lambda(it) {
  return Unit_instance;
}
function MinimalParser$cleanUpGss$lambda(it) {
  return Unit_instance;
}
function MinimalParser$cleanUpGss$lambda_0(it) {
  return Unit_instance;
}
function MinimalParser$cleanUpGss$lambda_1(it) {
  return Unit_instance;
}
function MinimalParser$cleanUpGss$lambda_2(it) {
  return Unit_instance;
}
function MinimalParser$cleanUpGss$lambda_3(it) {
  return Unit_instance;
}
function MinimalParser$cleanUpGss$lambda_4(it) {
  return Unit_instance;
}
function MinimalParser$_firstTerminal$lambda(it) {
  return lazyMutableMapNotNull(MinimalParser$_firstTerminal$lambda$lambda);
}
function MinimalParser$_firstTerminal$lambda$lambda(it) {
  // Inline function 'kotlin.collections.linkedSetOf' call
  return LinkedHashSet.j1();
}
function MinimalParser$_parentInContext$lambda(it) {
  return lazyMutableMapNotNull(MinimalParser$_parentInContext$lambda$lambda);
}
function MinimalParser$_parentInContext$lambda$lambda(it) {
  // Inline function 'kotlin.collections.linkedSetOf' call
  return LinkedHashSet.j1();
}
function MinimalParser$_possibleContexts$delegate$lambda(it) {
  // Inline function 'kotlin.collections.linkedSetOf' call
  return LinkedHashSet.j1();
}
function MinimalParser$_get__possibleContexts_$ref_tglonc() {
  return (p0) => _get__possibleContexts__e1uu9v(p0);
}
var AutomatonKind_LOOKAHEAD_NONE_instance;
var AutomatonKind_LOOKAHEAD_SIMPLE_instance;
var AutomatonKind_LOOKAHEAD_1_instance;
function values() {
  return [AutomatonKind_LOOKAHEAD_NONE_getInstance(), AutomatonKind_LOOKAHEAD_SIMPLE_getInstance(), AutomatonKind_LOOKAHEAD_1_getInstance()];
}
function valueOf(value) {
  switch (value) {
    case 'LOOKAHEAD_NONE':
      return AutomatonKind_LOOKAHEAD_NONE_getInstance();
    case 'LOOKAHEAD_SIMPLE':
      return AutomatonKind_LOOKAHEAD_SIMPLE_getInstance();
    case 'LOOKAHEAD_1':
      return AutomatonKind_LOOKAHEAD_1_getInstance();
    default:
      AutomatonKind_initEntries();
      THROW_IAE('No enum constant net.akehurst.language.automaton.api.AutomatonKind.' + value);
      break;
  }
}
var AutomatonKind_entriesInitialized;
function AutomatonKind_initEntries() {
  if (AutomatonKind_entriesInitialized)
    return Unit_instance;
  AutomatonKind_entriesInitialized = true;
  AutomatonKind_LOOKAHEAD_NONE_instance = new AutomatonKind('LOOKAHEAD_NONE', 0);
  AutomatonKind_LOOKAHEAD_SIMPLE_instance = new AutomatonKind('LOOKAHEAD_SIMPLE', 1);
  AutomatonKind_LOOKAHEAD_1_instance = new AutomatonKind('LOOKAHEAD_1', 2);
}
var ParseAction_HEIGHT_instance;
var ParseAction_GRAFT_instance;
var ParseAction_WIDTH_instance;
var ParseAction_GOAL_instance;
var ParseAction_EMBED_instance;
function values_0() {
  return [ParseAction_HEIGHT_getInstance(), ParseAction_GRAFT_getInstance(), ParseAction_WIDTH_getInstance(), ParseAction_GOAL_getInstance(), ParseAction_EMBED_getInstance()];
}
function valueOf_0(value) {
  switch (value) {
    case 'HEIGHT':
      return ParseAction_HEIGHT_getInstance();
    case 'GRAFT':
      return ParseAction_GRAFT_getInstance();
    case 'WIDTH':
      return ParseAction_WIDTH_getInstance();
    case 'GOAL':
      return ParseAction_GOAL_getInstance();
    case 'EMBED':
      return ParseAction_EMBED_getInstance();
    default:
      ParseAction_initEntries();
      THROW_IAE('No enum constant net.akehurst.language.automaton.api.ParseAction.' + value);
      break;
  }
}
var ParseAction_entriesInitialized;
function ParseAction_initEntries() {
  if (ParseAction_entriesInitialized)
    return Unit_instance;
  ParseAction_entriesInitialized = true;
  ParseAction_HEIGHT_instance = new ParseAction('HEIGHT', 0);
  ParseAction_GRAFT_instance = new ParseAction('GRAFT', 1);
  ParseAction_WIDTH_instance = new ParseAction('WIDTH', 2);
  ParseAction_GOAL_instance = new ParseAction('GOAL', 3);
  ParseAction_EMBED_instance = new ParseAction('EMBED', 4);
}
function AutomatonKind_LOOKAHEAD_NONE_getInstance() {
  AutomatonKind_initEntries();
  return AutomatonKind_LOOKAHEAD_NONE_instance;
}
function AutomatonKind_LOOKAHEAD_SIMPLE_getInstance() {
  AutomatonKind_initEntries();
  return AutomatonKind_LOOKAHEAD_SIMPLE_instance;
}
function AutomatonKind_LOOKAHEAD_1_getInstance() {
  AutomatonKind_initEntries();
  return AutomatonKind_LOOKAHEAD_1_instance;
}
function ParseAction_HEIGHT_getInstance() {
  ParseAction_initEntries();
  return ParseAction_HEIGHT_instance;
}
function ParseAction_GRAFT_getInstance() {
  ParseAction_initEntries();
  return ParseAction_GRAFT_instance;
}
function ParseAction_WIDTH_getInstance() {
  ParseAction_initEntries();
  return ParseAction_WIDTH_instance;
}
function ParseAction_GOAL_getInstance() {
  ParseAction_initEntries();
  return ParseAction_GOAL_instance;
}
function ParseAction_EMBED_getInstance() {
  ParseAction_initEntries();
  return ParseAction_EMBED_instance;
}
function aut(rrs, automatonKind, userGoalRule, isSkip, init) {
  return automaton(rrs instanceof RuntimeRuleSet ? rrs : THROW_CCE(), automatonKind, userGoalRule, isSkip, init);
}
function automaton(rrs, automatonKind, userGoalRule, isSkip, init) {
  var b = new AutomatonBuilderDefault(rrs, automatonKind, userGoalRule, isSkip);
  init(b);
  return b.e1h();
}
function _get__src__d2utae($this) {
  var tmp = $this.f1i_1;
  if (!(tmp == null))
    return tmp;
  else {
    throwUninitializedPropertyAccessException('_src');
  }
}
function _get__tgt__d2v8ix($this) {
  var tmp = $this.g1i_1;
  if (!(tmp == null))
    return tmp;
  else {
    throwUninitializedPropertyAccessException('_tgt');
  }
}
function chain($this) {
  var tmp;
  if (null == $this.parentItem) {
    tmp = '';
  } else {
    tmp = chain($this.parentItem) + '->';
  }
  var p = tmp;
  return p + $this.rulePosition.toString();
}
function BuildCacheLC1$Companion$ClosureItemLC1$allPrev$delegate$lambda(this$0) {
  return () => {
    var tmp;
    if (null == this$0.parentItem) {
      // Inline function 'kotlin.collections.mutableSetOf' call
      tmp = LinkedHashSet.j1();
    } else {
      tmp = plus(this$0.parentItem.allPrev, this$0.parentItem);
    }
    return tmp;
  };
}
function BuildCacheLC1$Companion$ClosureItemLC1$_get_allPrev_$ref_ip84s6() {
  return (p0) => p0.allPrev;
}
function BuildCacheLC1$Companion$ClosureItemLC1$allRulePositionsButTop$delegate$lambda(this$0) {
  return () => {
    var tmp;
    if (null == this$0.parentItem) {
      // Inline function 'kotlin.collections.mutableListOf' call
      tmp = ArrayList.o1();
    } else {
      tmp = plus_1(this$0.parentItem.allRulePositionsButTop, this$0.rulePosition);
    }
    return tmp;
  };
}
function BuildCacheLC1$Companion$ClosureItemLC1$_get_allRulePositionsButTop_$ref_l7n5l1() {
  return (p0) => p0.allRulePositionsButTop;
}
function BuildCacheLC1$Companion$ClosureItemLC1$toString$lambda(it) {
  return it.tag;
}
function BuildCacheLC1$Companion$PossibleState$toString$lambda(it) {
  return toString_0(it.a2());
}
var Companion_instance_1;
function Companion_getInstance_1() {
  return Companion_instance_1;
}
function _get__allRulePositionsForStates__bd3x7w($this) {
  // Inline function 'kotlin.collections.flatMap' call
  var tmp0 = $this.s1i_1.usedNonTerminalRules;
  // Inline function 'kotlin.collections.flatMapTo' call
  var destination = ArrayList.o1();
  var _iterator__ex2g4s = tmp0.g1();
  while (_iterator__ex2g4s.f()) {
    var element = _iterator__ex2g4s.e();
    var list = element.x1j();
    addAll(destination, list);
  }
  var tmp = destination;
  // Inline function 'kotlin.collections.map' call
  var this_0 = $this.s1i_1.usedTerminalRules;
  // Inline function 'kotlin.collections.mapTo' call
  var destination_0 = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
  var _iterator__ex2g4s_0 = this_0.g1();
  while (_iterator__ex2g4s_0.f()) {
    var item = _iterator__ex2g4s_0.e();
    var tmp$ret$3 = item.y1e();
    destination_0.v(tmp$ret$3);
  }
  return plus_2(tmp, destination_0);
}
function stateInfo4($this) {
  var startRulePosition = $this.s1i_1.startRulePosition;
  var context = startRulePosition;
  var parentNextFollow = Companion_getInstance_7().EOT;
  $this.u1i_1.c1k(context, startRulePosition, parentNextFollow);
  var mergedStateInfos = calcStateInfos($this);
  var _iterator__ex2g4s = mergedStateInfos.g1();
  while (_iterator__ex2g4s.f()) {
    var stateInfo = _iterator__ex2g4s.e();
    // Inline function 'kotlin.collections.mutableSetOf' call
    var transInfo = LinkedHashSet.j1();
    var _iterator__ex2g4s_0 = stateInfo.d1k_1.g1();
    while (_iterator__ex2g4s_0.f()) {
      var srcRp = _iterator__ex2g4s_0.e();
      // Inline function 'kotlin.collections.set' call
      $this.l1k_1.f3(srcRp, stateInfo);
      var ti = srcRp.isAtEnd ? calcTransInfoForComplete($this, srcRp) : calcTransInfoForIncomplete($this, srcRp);
      transInfo.k1(ti);
    }
    var merged = mergeTransInfo($this, transInfo, emptySet());
    stateInfo.e1k_1 = merged;
  }
  return mergedStateInfos;
}
function mergeStates($this, rulePositions) {
  return noMergeStates($this, rulePositions);
}
function noMergeStates($this, rulePositions) {
  // Inline function 'kotlin.collections.map' call
  // Inline function 'kotlin.collections.mapTo' call
  var destination = ArrayList.a1(collectionSizeOrDefault(rulePositions, 10));
  var _iterator__ex2g4s = rulePositions.g1();
  while (_iterator__ex2g4s.f()) {
    var item = _iterator__ex2g4s.e();
    var tmp$ret$0 = new StateInfo(setOf(item));
    destination.v(tmp$ret$0);
  }
  return toSet(destination);
}
function calcStateInfos($this) {
  var stateRps = _get__allRulePositionsForStates__bd3x7w($this);
  var merged = mergeStates($this, stateRps);
  return merged;
}
function calcTransInfoForComplete($this, srcRp) {
  if (false) {
    // Inline function 'kotlin.check' call
    if (!srcRp.isAtEnd) {
      throw IllegalStateException.t4('Check failed.');
    }
  }
  // Inline function 'kotlin.collections.mutableSetOf' call
  var transInfo = LinkedHashSet.j1();
  var contexts = $this.u1i_1.n1k(srcRp);
  var _iterator__ex2g4s = contexts.g1();
  while (_iterator__ex2g4s.f()) {
    var ctx = _iterator__ex2g4s.e();
    // Inline function 'kotlin.collections.mutableSetOf' call
    var hgtis = LinkedHashSet.j1();
    var contextContexts = $this.u1i_1.n1k(ctx);
    var _iterator__ex2g4s_0 = contextContexts.g1();
    while (_iterator__ex2g4s_0.f()) {
      var ctxCtx = _iterator__ex2g4s_0.e();
      var pns = $this.u1i_1.o1k(ctxCtx, ctx, srcRp.k1b_1);
      // Inline function 'kotlin.collections.map' call
      // Inline function 'kotlin.collections.mapTo' call
      var destination = ArrayList.a1(collectionSizeOrDefault(pns, 10));
      var _iterator__ex2g4s_1 = pns.g1();
      while (_iterator__ex2g4s_1.f()) {
        var item = _iterator__ex2g4s_1.e();
        var action = item.rulePosition.isGoal ? ParseAction_GOAL_getInstance() : item.firstPosition ? ParseAction_HEIGHT_getInstance() : ParseAction_GRAFT_getInstance();
        var tgt = item.rulePosition;
        var follow = item.expectedAt;
        var grd = follow;
        var tmp;
        switch (action.q3_1) {
          case 0:
            tmp = item.parentExpectedAt;
            break;
          case 4:
          case 2:
          case 1:
          case 3:
            tmp = Companion_getInstance_7().EMPTY;
            break;
          default:
            noWhenBranchMatchedException();
            break;
        }
        var up = tmp;
        var tmp$ret$3 = new TransInfo(setOf(new TransPrev(setOf(ctxCtx), setOf(ctx))), action, setOf(tgt), setOf(new LookaheadInfoPart(grd, up)));
        destination.v(tmp$ret$3);
      }
      var hgInfo = toSet(destination);
      hgtis.k1(hgInfo);
    }
    transInfo.k1(hgtis);
  }
  var mergedTransInfo = mergeTransInfo($this, transInfo, emptySet());
  return mergedTransInfo;
}
function calcTransInfoForIncomplete($this, srcRp) {
  if (false) {
    // Inline function 'kotlin.check' call
    if (!!srcRp.isAtEnd) {
      throw IllegalStateException.t4('Check failed.');
    }
  }
  // Inline function 'kotlin.collections.mutableSetOf' call
  var transInfo = LinkedHashSet.j1();
  var contexts = $this.u1i_1.n1k(srcRp);
  var _iterator__ex2g4s = contexts.g1();
  while (_iterator__ex2g4s.f()) {
    var ctx = _iterator__ex2g4s.e();
    var tmp;
    if (srcRp.isGoal) {
      tmp = Companion_getInstance_7().EOT;
    } else {
      var ctxCtxs = $this.u1i_1.n1k(ctx);
      // Inline function 'kotlin.collections.flatMap' call
      // Inline function 'kotlin.collections.flatMapTo' call
      var destination = ArrayList.o1();
      var _iterator__ex2g4s_0 = ctxCtxs.g1();
      while (_iterator__ex2g4s_0.f()) {
        var element = _iterator__ex2g4s_0.e();
        var list = $this.u1i_1.o1k(element, ctx, srcRp.k1b_1);
        addAll(destination, list);
      }
      var x = toSet(destination);
      // Inline function 'kotlin.collections.map' call
      // Inline function 'kotlin.collections.mapTo' call
      var destination_0 = ArrayList.a1(collectionSizeOrDefault(x, 10));
      var _iterator__ex2g4s_1 = x.g1();
      while (_iterator__ex2g4s_1.f()) {
        var item = _iterator__ex2g4s_1.e();
        var tmp$ret$5 = item.expectedAt;
        destination_0.v(tmp$ret$5);
      }
      // Inline function 'kotlin.collections.fold' call
      var accumulator = Companion_getInstance_7().EMPTY;
      var _iterator__ex2g4s_2 = destination_0.g1();
      while (_iterator__ex2g4s_2.f()) {
        var element_0 = _iterator__ex2g4s_2.e();
        accumulator = accumulator.union(element_0);
      }
      tmp = accumulator;
    }
    var parentFollow = tmp;
    var ftis = $this.u1i_1.p1k(ctx, srcRp, parentFollow);
    // Inline function 'kotlin.collections.map' call
    // Inline function 'kotlin.collections.mapTo' call
    var destination_1 = ArrayList.a1(collectionSizeOrDefault(ftis, 10));
    var _iterator__ex2g4s_3 = ftis.g1();
    while (_iterator__ex2g4s_3.f()) {
      var item_0 = _iterator__ex2g4s_3.e();
      var action = item_0.terminalRule.isEmbedded ? ParseAction_EMBED_getInstance() : ParseAction_WIDTH_getInstance();
      var trp = item_0.terminalRule.y1e();
      var lhs = item_0.parentExpectedAt;
      var tmp$ret$10 = new TransInfo(setOf(new TransPrev(emptySet(), setOf(ctx))), action, setOf(trp), setOf(new LookaheadInfoPart(lhs, Companion_getInstance_7().EMPTY)));
      destination_1.v(tmp$ret$10);
    }
    var wis = destination_1;
    transInfo.k1(toSet(wis));
  }
  var mergedTransInfo = mergeTransInfo($this, transInfo, emptySet());
  return mergedTransInfo;
}
function mergeTransInfo($this, ti1, ti2) {
  var total = null == ti1 ? ti2 : plus_3(ti1, ti2);
  // Inline function 'kotlin.collections.mutableSetOf' call
  var embed = LinkedHashSet.j1();
  // Inline function 'kotlin.collections.mutableSetOf' call
  var width = LinkedHashSet.j1();
  // Inline function 'kotlin.collections.mutableSetOf' call
  var heightComplete = LinkedHashSet.j1();
  // Inline function 'kotlin.collections.mutableSetOf' call
  var graftComplete = LinkedHashSet.j1();
  // Inline function 'kotlin.collections.mutableSetOf' call
  var heightIncomplete = LinkedHashSet.j1();
  // Inline function 'kotlin.collections.mutableSetOf' call
  var graftIncomplete = LinkedHashSet.j1();
  // Inline function 'kotlin.collections.mutableSetOf' call
  var goals = LinkedHashSet.j1();
  var _iterator__ex2g4s = total.g1();
  while (_iterator__ex2g4s.f()) {
    var ti = _iterator__ex2g4s.e();
    switch (ti.r1k_1.q3_1) {
      case 3:
        goals.v(ti);
        break;
      case 4:
        embed.v(ti);
        break;
      case 2:
        width.v(ti);
        break;
      case 1:
        if (first(ti.s1k_1).isAtEnd)
          graftComplete.v(ti);
        else
          graftIncomplete.v(ti);
        break;
      case 0:
        if (first(ti.s1k_1).isAtEnd)
          heightComplete.v(ti);
        else
          heightIncomplete.v(ti);
        break;
      default:
        noWhenBranchMatchedException();
        break;
    }
  }
  var mw = mergeWidth($this, width);
  var mhc = mergeHeightComplete($this, heightComplete);
  var mhi = mergeHeightIncomplete($this, heightIncomplete);
  var mgc = mergeGraftComplete($this, graftComplete);
  var mgi = mergeGraftIncomplete($this, graftIncomplete);
  var res = plus_3(plus_3(plus_3(plus_3(plus_3(plus_3(mw, mhc), mhi), mgc), mgi), goals), embed);
  return res;
}
function mergeWidth($this, transInfo) {
  var tmp;
  if (transInfo.l1()) {
    tmp = transInfo;
  } else {
    // Inline function 'kotlin.collections.groupBy' call
    // Inline function 'kotlin.collections.groupByTo' call
    var destination = LinkedHashMap.j4();
    var _iterator__ex2g4s = transInfo.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      var key = element.s1k_1;
      // Inline function 'kotlin.collections.getOrPut' call
      var value = destination.c3(key);
      var tmp_0;
      if (value == null) {
        var answer = ArrayList.o1();
        destination.f3(key, answer);
        tmp_0 = answer;
      } else {
        tmp_0 = value;
      }
      var list = tmp_0;
      list.v(element);
    }
    var grouped = destination;
    // Inline function 'kotlin.collections.map' call
    // Inline function 'kotlin.collections.mapTo' call
    var destination_0 = ArrayList.a1(grouped.h1());
    // Inline function 'kotlin.collections.iterator' call
    var _iterator__ex2g4s_0 = grouped.z1().g1();
    while (_iterator__ex2g4s_0.f()) {
      var item = _iterator__ex2g4s_0.e();
      // Inline function 'kotlin.collections.flatMap' call
      var tmp0 = item.b2();
      // Inline function 'kotlin.collections.flatMapTo' call
      var destination_1 = ArrayList.o1();
      var _iterator__ex2g4s_1 = tmp0.g1();
      while (_iterator__ex2g4s_1.f()) {
        var element_0 = _iterator__ex2g4s_1.e();
        var list_0 = element_0.q1k_1;
        addAll(destination_1, list_0);
      }
      var prevPairs = toSet(destination_1);
      var action = ParseAction_WIDTH_getInstance();
      // Inline function 'kotlin.collections.flatMap' call
      var tmp0_0 = item.b2();
      // Inline function 'kotlin.collections.flatMapTo' call
      var destination_2 = ArrayList.o1();
      var _iterator__ex2g4s_2 = tmp0_0.g1();
      while (_iterator__ex2g4s_2.f()) {
        var element_1 = _iterator__ex2g4s_2.e();
        var list_1 = element_1.s1k_1;
        addAll(destination_2, list_1);
      }
      var to = toSet(destination_2);
      // Inline function 'kotlin.collections.flatMap' call
      var tmp0_1 = item.b2();
      // Inline function 'kotlin.collections.flatMapTo' call
      var destination_3 = ArrayList.o1();
      var _iterator__ex2g4s_3 = tmp0_1.g1();
      while (_iterator__ex2g4s_3.f()) {
        var element_2 = _iterator__ex2g4s_3.e();
        // Inline function 'kotlin.collections.map' call
        var this_0 = element_2.t1k_1;
        // Inline function 'kotlin.collections.mapTo' call
        var destination_4 = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
        var _iterator__ex2g4s_4 = this_0.g1();
        while (_iterator__ex2g4s_4.f()) {
          var item_0 = _iterator__ex2g4s_4.e();
          var tmp$ret$12 = item_0.u1k_1;
          destination_4.v(tmp$ret$12);
        }
        var list_2 = destination_4;
        addAll(destination_3, list_2);
      }
      // Inline function 'kotlin.collections.fold' call
      var accumulator = Companion_getInstance_7().EMPTY;
      var _iterator__ex2g4s_5 = destination_3.g1();
      while (_iterator__ex2g4s_5.f()) {
        var element_3 = _iterator__ex2g4s_5.e();
        accumulator = accumulator.union(element_3);
      }
      var grd = accumulator;
      var lhs = setOf(new LookaheadInfoPart(grd, Companion_getInstance_7().EMPTY));
      var tmp$ret$20 = new TransInfo(prevPairs, action, to, lhs);
      destination_0.v(tmp$ret$20);
    }
    var merged = toSet(destination_0);
    tmp = merged;
  }
  return tmp;
}
function mergeHeightComplete($this, transInfo) {
  var tmp;
  if (transInfo.l1()) {
    tmp = transInfo;
  } else {
    // Inline function 'kotlin.collections.groupBy' call
    // Inline function 'kotlin.collections.groupByTo' call
    var destination = LinkedHashMap.j4();
    var _iterator__ex2g4s = transInfo.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      var key = element.s1k_1;
      // Inline function 'kotlin.collections.getOrPut' call
      var value = destination.c3(key);
      var tmp_0;
      if (value == null) {
        var answer = ArrayList.o1();
        destination.f3(key, answer);
        tmp_0 = answer;
      } else {
        tmp_0 = value;
      }
      var list = tmp_0;
      list.v(element);
    }
    var grouped = destination;
    // Inline function 'kotlin.collections.map' call
    // Inline function 'kotlin.collections.mapTo' call
    var destination_0 = ArrayList.a1(grouped.h1());
    // Inline function 'kotlin.collections.iterator' call
    var _iterator__ex2g4s_0 = grouped.z1().g1();
    while (_iterator__ex2g4s_0.f()) {
      var item = _iterator__ex2g4s_0.e();
      // Inline function 'kotlin.collections.flatMap' call
      var tmp0 = item.b2();
      // Inline function 'kotlin.collections.flatMapTo' call
      var destination_1 = ArrayList.o1();
      var _iterator__ex2g4s_1 = tmp0.g1();
      while (_iterator__ex2g4s_1.f()) {
        var element_0 = _iterator__ex2g4s_1.e();
        var list_0 = element_0.q1k_1;
        addAll(destination_1, list_0);
      }
      var prevPairs = toSet(destination_1);
      var action = ParseAction_HEIGHT_getInstance();
      var to = item.a2();
      var tmp_1 = Companion_getInstance_8();
      // Inline function 'kotlin.collections.flatMap' call
      var tmp0_0 = item.b2();
      // Inline function 'kotlin.collections.flatMapTo' call
      var destination_2 = ArrayList.o1();
      var _iterator__ex2g4s_2 = tmp0_0.g1();
      while (_iterator__ex2g4s_2.f()) {
        var element_1 = _iterator__ex2g4s_2.e();
        var list_1 = element_1.t1k_1;
        addAll(destination_2, list_1);
      }
      var lhs = tmp_1.merge(toSet(destination_2));
      var tmp$ret$12 = new TransInfo(prevPairs, action, to, lhs);
      destination_0.v(tmp$ret$12);
    }
    var merged = toSet(destination_0);
    tmp = merged;
  }
  return tmp;
}
function mergeHeightIncomplete($this, transInfo) {
  var tmp;
  if (transInfo.l1()) {
    tmp = transInfo;
  } else {
    // Inline function 'kotlin.collections.groupBy' call
    // Inline function 'kotlin.collections.groupByTo' call
    var destination = LinkedHashMap.j4();
    var _iterator__ex2g4s = transInfo.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      var key = element.s1k_1;
      // Inline function 'kotlin.collections.getOrPut' call
      var value = destination.c3(key);
      var tmp_0;
      if (value == null) {
        var answer = ArrayList.o1();
        destination.f3(key, answer);
        tmp_0 = answer;
      } else {
        tmp_0 = value;
      }
      var list = tmp_0;
      list.v(element);
    }
    var grouped = destination;
    // Inline function 'kotlin.collections.map' call
    // Inline function 'kotlin.collections.mapTo' call
    var destination_0 = ArrayList.a1(grouped.h1());
    // Inline function 'kotlin.collections.iterator' call
    var _iterator__ex2g4s_0 = grouped.z1().g1();
    while (_iterator__ex2g4s_0.f()) {
      var item = _iterator__ex2g4s_0.e();
      // Inline function 'kotlin.collections.flatMap' call
      var tmp0 = item.b2();
      // Inline function 'kotlin.collections.flatMapTo' call
      var destination_1 = ArrayList.o1();
      var _iterator__ex2g4s_1 = tmp0.g1();
      while (_iterator__ex2g4s_1.f()) {
        var element_0 = _iterator__ex2g4s_1.e();
        var list_0 = element_0.q1k_1;
        addAll(destination_1, list_0);
      }
      var prevPairs = toSet(destination_1);
      var action = ParseAction_HEIGHT_getInstance();
      var to = item.a2();
      var tmp_1 = Companion_getInstance_8();
      // Inline function 'kotlin.collections.flatMap' call
      var tmp0_0 = item.b2();
      // Inline function 'kotlin.collections.flatMapTo' call
      var destination_2 = ArrayList.o1();
      var _iterator__ex2g4s_2 = tmp0_0.g1();
      while (_iterator__ex2g4s_2.f()) {
        var element_1 = _iterator__ex2g4s_2.e();
        var list_1 = element_1.t1k_1;
        addAll(destination_2, list_1);
      }
      var lhs = tmp_1.merge(toSet(destination_2));
      var tmp$ret$12 = new TransInfo(prevPairs, action, to, lhs);
      destination_0.v(tmp$ret$12);
    }
    var merged = toSet(destination_0);
    tmp = merged;
  }
  return tmp;
}
function mergeGraftComplete($this, transInfo) {
  var tmp;
  if (transInfo.l1()) {
    tmp = transInfo;
  } else {
    // Inline function 'kotlin.collections.groupBy' call
    // Inline function 'kotlin.collections.groupByTo' call
    var destination = LinkedHashMap.j4();
    var _iterator__ex2g4s = transInfo.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      var key = element.s1k_1;
      // Inline function 'kotlin.collections.getOrPut' call
      var value = destination.c3(key);
      var tmp_0;
      if (value == null) {
        var answer = ArrayList.o1();
        destination.f3(key, answer);
        tmp_0 = answer;
      } else {
        tmp_0 = value;
      }
      var list = tmp_0;
      list.v(element);
    }
    var grouped = destination;
    // Inline function 'kotlin.collections.map' call
    // Inline function 'kotlin.collections.mapTo' call
    var destination_0 = ArrayList.a1(grouped.h1());
    // Inline function 'kotlin.collections.iterator' call
    var _iterator__ex2g4s_0 = grouped.z1().g1();
    while (_iterator__ex2g4s_0.f()) {
      var item = _iterator__ex2g4s_0.e();
      // Inline function 'kotlin.collections.flatMap' call
      var tmp0 = item.b2();
      // Inline function 'kotlin.collections.flatMapTo' call
      var destination_1 = ArrayList.o1();
      var _iterator__ex2g4s_1 = tmp0.g1();
      while (_iterator__ex2g4s_1.f()) {
        var element_0 = _iterator__ex2g4s_1.e();
        var list_0 = element_0.q1k_1;
        addAll(destination_1, list_0);
      }
      var prevPairs = toSet(destination_1);
      var action = ParseAction_GRAFT_getInstance();
      var to = item.a2();
      // Inline function 'kotlin.collections.flatMap' call
      var tmp0_0 = item.b2();
      // Inline function 'kotlin.collections.flatMapTo' call
      var destination_2 = ArrayList.o1();
      var _iterator__ex2g4s_2 = tmp0_0.g1();
      while (_iterator__ex2g4s_2.f()) {
        var element_1 = _iterator__ex2g4s_2.e();
        // Inline function 'kotlin.collections.map' call
        var this_0 = element_1.t1k_1;
        // Inline function 'kotlin.collections.mapTo' call
        var destination_3 = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
        var _iterator__ex2g4s_3 = this_0.g1();
        while (_iterator__ex2g4s_3.f()) {
          var item_0 = _iterator__ex2g4s_3.e();
          var tmp$ret$9 = item_0.u1k_1;
          destination_3.v(tmp$ret$9);
        }
        var list_1 = destination_3;
        addAll(destination_2, list_1);
      }
      // Inline function 'kotlin.collections.fold' call
      var accumulator = Companion_getInstance_7().EMPTY;
      var _iterator__ex2g4s_4 = destination_2.g1();
      while (_iterator__ex2g4s_4.f()) {
        var element_2 = _iterator__ex2g4s_4.e();
        accumulator = accumulator.union(element_2);
      }
      var grd = accumulator;
      var lhs = setOf(new LookaheadInfoPart(grd, Companion_getInstance_7().EMPTY));
      var tmp$ret$17 = new TransInfo(prevPairs, action, to, lhs);
      destination_0.v(tmp$ret$17);
    }
    var merged = toSet(destination_0);
    tmp = merged;
  }
  return tmp;
}
function mergeGraftIncomplete($this, transInfo) {
  var tmp;
  if (transInfo.l1()) {
    tmp = transInfo;
  } else {
    // Inline function 'kotlin.collections.groupBy' call
    // Inline function 'kotlin.collections.groupByTo' call
    var destination = LinkedHashMap.j4();
    var _iterator__ex2g4s = transInfo.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      var key = element.s1k_1;
      // Inline function 'kotlin.collections.getOrPut' call
      var value = destination.c3(key);
      var tmp_0;
      if (value == null) {
        var answer = ArrayList.o1();
        destination.f3(key, answer);
        tmp_0 = answer;
      } else {
        tmp_0 = value;
      }
      var list = tmp_0;
      list.v(element);
    }
    var grouped = destination;
    // Inline function 'kotlin.collections.map' call
    // Inline function 'kotlin.collections.mapTo' call
    var destination_0 = ArrayList.a1(grouped.h1());
    // Inline function 'kotlin.collections.iterator' call
    var _iterator__ex2g4s_0 = grouped.z1().g1();
    while (_iterator__ex2g4s_0.f()) {
      var item = _iterator__ex2g4s_0.e();
      // Inline function 'kotlin.collections.flatMap' call
      var tmp0 = item.b2();
      // Inline function 'kotlin.collections.flatMapTo' call
      var destination_1 = ArrayList.o1();
      var _iterator__ex2g4s_1 = tmp0.g1();
      while (_iterator__ex2g4s_1.f()) {
        var element_0 = _iterator__ex2g4s_1.e();
        var list_0 = element_0.q1k_1;
        addAll(destination_1, list_0);
      }
      var prevPairs = toSet(destination_1);
      var action = ParseAction_GRAFT_getInstance();
      var to = item.a2();
      // Inline function 'kotlin.collections.flatMap' call
      var tmp0_0 = item.b2();
      // Inline function 'kotlin.collections.flatMapTo' call
      var destination_2 = ArrayList.o1();
      var _iterator__ex2g4s_2 = tmp0_0.g1();
      while (_iterator__ex2g4s_2.f()) {
        var element_1 = _iterator__ex2g4s_2.e();
        // Inline function 'kotlin.collections.map' call
        var this_0 = element_1.t1k_1;
        // Inline function 'kotlin.collections.mapTo' call
        var destination_3 = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
        var _iterator__ex2g4s_3 = this_0.g1();
        while (_iterator__ex2g4s_3.f()) {
          var item_0 = _iterator__ex2g4s_3.e();
          var tmp$ret$9 = item_0.u1k_1;
          destination_3.v(tmp$ret$9);
        }
        var list_1 = destination_3;
        addAll(destination_2, list_1);
      }
      // Inline function 'kotlin.collections.fold' call
      var accumulator = Companion_getInstance_7().EMPTY;
      var _iterator__ex2g4s_4 = destination_2.g1();
      while (_iterator__ex2g4s_4.f()) {
        var element_2 = _iterator__ex2g4s_4.e();
        accumulator = accumulator.union(element_2);
      }
      var grd = accumulator;
      var lhs = setOf(new LookaheadInfoPart(grd, Companion_getInstance_7().EMPTY));
      var tmp$ret$17 = new TransInfo(prevPairs, action, to, lhs);
      destination_0.v(tmp$ret$17);
    }
    var merged = toSet(destination_0);
    tmp = merged;
  }
  return tmp;
}
function calcAndCacheHeightOrGraftInto($this, prevPrev, prev, from) {
  var hgi = calcHeightOrGraftInto($this, prevPrev, prev, from);
  cacheHeightOrGraftInto($this, prevPrev, prev, from, hgi);
  return hgi;
}
function cacheHeightOrGraftInto($this, prevPrev, prev, from, hgis) {
  var key = new Triple(prevPrev.j1i_1, prev.j1i_1, from.runtimeRules);
  var tmp0_elvis_lhs = $this.m1k_1.c3(key);
  var tmp;
  if (tmp0_elvis_lhs == null) {
    // Inline function 'kotlin.run' call
    // Inline function 'kotlin.collections.mutableMapOf' call
    var x = LinkedHashMap.j4();
    // Inline function 'kotlin.collections.set' call
    $this.m1k_1.f3(key, x);
    tmp = x;
  } else {
    tmp = tmp0_elvis_lhs;
  }
  var map = tmp;
  var _iterator__ex2g4s = hgis.g1();
  while (_iterator__ex2g4s.f()) {
    var hg = _iterator__ex2g4s.e();
    var existing = map.c3(hg.s1k_1);
    if (null == existing) {
      // Inline function 'kotlin.collections.set' call
      var key_0 = hg.s1k_1;
      map.f3(key_0, hg);
    } else {
      var lhs = union(hg.t1k_1, existing.t1k_1);
      var tmp2 = hg.s1k_1;
      // Inline function 'kotlin.collections.set' call
      var value = new TransInfo(existing.q1k_1, hg.r1k_1, hg.s1k_1, lhs);
      map.f3(tmp2, value);
    }
  }
}
function calcHeightOrGraftInto($this, prevPrev, prev, from) {
  // Inline function 'kotlin.collections.mutableSetOf' call
  var rls = LinkedHashSet.j1();
  // Inline function 'kotlin.collections.flatMap' call
  var tmp0 = prevPrev.j1i_1;
  // Inline function 'kotlin.collections.flatMapTo' call
  var destination = ArrayList.o1();
  var _iterator__ex2g4s = tmp0.g1();
  while (_iterator__ex2g4s.f()) {
    var element = _iterator__ex2g4s.e();
    // Inline function 'kotlin.collections.flatMap' call
    var tmp0_0 = prev.j1i_1;
    // Inline function 'kotlin.collections.flatMapTo' call
    var destination_0 = ArrayList.o1();
    var _iterator__ex2g4s_0 = tmp0_0.g1();
    while (_iterator__ex2g4s_0.f()) {
      var element_0 = _iterator__ex2g4s_0.e();
      // Inline function 'kotlin.collections.flatMap' call
      var tmp0_1 = from.runtimeRules;
      // Inline function 'kotlin.collections.flatMapTo' call
      var destination_1 = ArrayList.o1();
      var _iterator__ex2g4s_1 = tmp0_1.g1();
      while (_iterator__ex2g4s_1.f()) {
        var element_1 = _iterator__ex2g4s_1.e();
        var list = $this.u1i_1.o1k(element, element_0, element_1);
        addAll(destination_1, list);
      }
      var parentsOfFrom = toSet(destination_1);
      // Inline function 'kotlin.collections.map' call
      // Inline function 'kotlin.collections.mapTo' call
      var destination_2 = ArrayList.a1(collectionSizeOrDefault(parentsOfFrom, 10));
      var _iterator__ex2g4s_2 = parentsOfFrom.g1();
      while (_iterator__ex2g4s_2.f()) {
        var item = _iterator__ex2g4s_2.e();
        var action = item.rulePosition.isGoal ? ParseAction_GOAL_getInstance() : item.firstPosition ? ParseAction_HEIGHT_getInstance() : ParseAction_GRAFT_getInstance();
        var tgt = item.rulePosition;
        var grd = item.expectedAt;
        var up = item.parentExpectedAt;
        rls.v(tgt.k1b_1);
        var tmp$ret$4 = new TransInfo(setOf(new TransPrev(setOf(element), setOf(element_0))), action, setOf(tgt), setOf(new LookaheadInfoPart(grd, up)));
        destination_2.v(tmp$ret$4);
      }
      var list_0 = destination_2;
      addAll(destination_0, list_0);
    }
    var list_1 = destination_0;
    addAll(destination, list_1);
  }
  var hgInfo = toSet(destination);
  var merged = mergeTransInfo($this, hgInfo, emptySet());
  // Inline function 'kotlin.collections.flatMap' call
  // Inline function 'kotlin.collections.flatMapTo' call
  var destination_3 = ArrayList.o1();
  var _iterator__ex2g4s_3 = rls.g1();
  while (_iterator__ex2g4s_3.f()) {
    var element_2 = _iterator__ex2g4s_3.e();
    var list_2 = element_2.x1j();
    addAll(destination_3, list_2);
  }
  var rps = destination_3;
  var mergedSateInfoNotAtEnd = mergeStates($this, rps);
  // Inline function 'kotlin.collections.forEach' call
  var _iterator__ex2g4s_4 = mergedSateInfoNotAtEnd.g1();
  while (_iterator__ex2g4s_4.f()) {
    var element_3 = _iterator__ex2g4s_4.e();
    // Inline function 'kotlin.collections.forEach' call
    var _iterator__ex2g4s_5 = element_3.d1k_1.g1();
    while (_iterator__ex2g4s_5.f()) {
      var element_4 = _iterator__ex2g4s_5.e();
      // Inline function 'kotlin.collections.set' call
      $this.l1k_1.f3(element_4, element_3);
    }
  }
  return merged;
}
function BuildCacheLC1$widthInto$lambda($prevState, $fromState) {
  return () => {
    var tmp = $prevState.toString();
    var tmp_0 = $fromState.toString();
    // Inline function 'kotlin.collections.map' call
    var this_0 = $fromState.j1i_1;
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var tmp$ret$0 = item.k1b_1.tag;
      destination.v(tmp$ret$0);
    }
    return 'START calcWidthInfo(' + tmp + ', ' + tmp_0 + ') - ' + toString(destination);
  };
}
function BuildCacheLC1$widthInto$lambda_0($prevState, $fromState) {
  return () => 'FINISH calcWidthInfo(' + $prevState.toString() + ', ' + $fromState.toString() + ')';
}
function _get__doneFollow__hbu15r($this) {
  var tmp = KProperty1;
  return $this.y1j_1.yj($this, getPropertyCallableRef('_doneFollow', 1, tmp, FirstFollowCache3$_get__doneFollow_$ref_odf330(), null));
}
function _get__firstTerminal__6wo3he($this) {
  var tmp = KProperty1;
  return $this.z1j_1.yj($this, getPropertyCallableRef('_firstTerminal', 1, tmp, FirstFollowCache3$_get__firstTerminal_$ref_2tls75(), null));
}
function _get__parentInContext__7bhu5m($this) {
  var tmp = KProperty1;
  return $this.a1k_1.yj($this, getPropertyCallableRef('_parentInContext', 1, tmp, FirstFollowCache3$_get__parentInContext_$ref_v2gk5n(), null));
}
function _get__possibleContexts__e1uu9v_0($this) {
  var tmp = KProperty1;
  return $this.b1k_1.yj($this, getPropertyCallableRef('_possibleContexts', 1, tmp, FirstFollowCache3$_get__possibleContexts_$ref_3bts56(), null));
}
function processClosureFor($this, context, rulePosition, parentFollow) {
  var graph = new ClosureGraph(context, rulePosition, parentFollow);
  var cls = graph.b1f_1;
  var doit;
  switch (_get__doneFollow__hbu15r($this).c3(context).c3(cls)) {
    case null:
      doit = true;
      break;
    case true:
      doit = false;
      break;
    default:
      doit = false;
      break;
  }
  if (doit) {
    // Inline function 'kotlin.collections.set' call
    _get__doneFollow__hbu15r($this).c3(context).f3(cls, true);
    $this.z1k(graph);
  }
}
function addFirstTerminalInContext($this, prev, rulePosition, firstTerminalInfo) {
  if (false) {
    var tmp = IndentDelta_NONE_getInstance();
    debug(tmp, FirstFollowCache3$addFirstTerminalInContext$lambda(prev, rulePosition, firstTerminalInfo));
  }
  if (false) {
    // Inline function 'kotlin.check' call
    if (!!prev.isAtEnd) {
      throw IllegalStateException.t4('Check failed.');
    }
  }
  _get__firstTerminal__6wo3he($this).c3(prev).c3(rulePosition).v(firstTerminalInfo);
}
function addParentInContext($this, prev, completedRule, parentNext) {
  if (false) {
    var tmp = IndentDelta_NONE_getInstance();
    debug(tmp, FirstFollowCache3$addParentInContext$lambda(prev, completedRule, parentNext));
  }
  _get__parentInContext__7bhu5m($this).c3(prev).c3(completedRule).k1(parentNext);
}
function addPossibleContext($this, rp, ctx) {
  _get__possibleContexts__e1uu9v_0($this).c3(rp).v(ctx);
}
function cacheStuff($this, graph) {
  var _iterator__ex2g4s = graph.b1f_1.q1f().g1();
  while (_iterator__ex2g4s.f()) {
    var dwn = _iterator__ex2g4s.e();
    doForRoot($this, graph.b1f_1.h1f_1, graph.b1f_1.i1f_1, dwn);
  }
  var _iterator__ex2g4s_0 = graph.r1f().g1();
  while (_iterator__ex2g4s_0.f()) {
    var cls = _iterator__ex2g4s_0.e();
    if (cls.q1f().l1()) {
      addPossibleContext($this, cls.c1f(), cls.sb());
    } else {
      if (cls.c1f().isAtStart) {
        doForNonRoot($this, cls);
      } else if (cls.c1f().isTerminal) {
        doForNonRoot($this, cls);
      } else {
        // Inline function 'kotlin.collections.forEach' call
        var _iterator__ex2g4s_1 = cls.q1f().g1();
        while (_iterator__ex2g4s_1.f()) {
          var element = _iterator__ex2g4s_1.e();
          doForRoot($this, cls.c1f(), cls.sb(), element);
        }
      }
    }
  }
}
function doForRoot($this, rulePosition, context, downInfo) {
  addFirstTerminalInContext($this, context, rulePosition, downInfo);
  addPossibleContext($this, rulePosition, context);
}
function doForNonRoot($this, cls) {
  var context = cls.sb();
  var rulePosition = cls.c1f();
  var parentNext = cls.s1f();
  var completedRule = rulePosition.k1b_1;
  addParentInContext($this, context, completedRule, parentNext);
  addPossibleContext($this, rulePosition, context);
}
function FirstFollowCache3$_doneFollow$delegate$lambda(it) {
  // Inline function 'kotlin.collections.mutableMapOf' call
  return LinkedHashMap.j4();
}
function FirstFollowCache3$_get__doneFollow_$ref_odf330() {
  return (p0) => _get__doneFollow__hbu15r(p0);
}
function FirstFollowCache3$_firstTerminal$delegate$lambda(it) {
  return lazyMutableMapNotNull(FirstFollowCache3$_firstTerminal$delegate$lambda$lambda);
}
function FirstFollowCache3$_firstTerminal$delegate$lambda$lambda(it) {
  // Inline function 'kotlin.collections.linkedSetOf' call
  return LinkedHashSet.j1();
}
function FirstFollowCache3$_get__firstTerminal_$ref_2tls75() {
  return (p0) => _get__firstTerminal__6wo3he(p0);
}
function FirstFollowCache3$_parentInContext$delegate$lambda(it) {
  return lazyMutableMapNotNull(FirstFollowCache3$_parentInContext$delegate$lambda$lambda);
}
function FirstFollowCache3$_parentInContext$delegate$lambda$lambda(it) {
  // Inline function 'kotlin.collections.linkedSetOf' call
  return LinkedHashSet.j1();
}
function FirstFollowCache3$_get__parentInContext_$ref_v2gk5n() {
  return (p0) => _get__parentInContext__7bhu5m(p0);
}
function FirstFollowCache3$_possibleContexts$delegate$lambda(it) {
  // Inline function 'kotlin.collections.linkedSetOf' call
  return LinkedHashSet.j1();
}
function FirstFollowCache3$_get__possibleContexts_$ref_3bts56() {
  return (p0) => _get__possibleContexts__e1uu9v_0(p0);
}
function FirstFollowCache3$addFirstTerminalInContext$lambda($prev, $rulePosition, $firstTerminalInfo) {
  return () => 'add firstTerm(' + $prev.toString() + ',' + $rulePosition.toString() + ') = ' + $firstTerminalInfo.toString();
}
function FirstFollowCache3$addParentInContext$lambda($prev, $completedRule, $parentNext) {
  return () => 'add parentOf(' + $prev.toString() + ',' + $completedRule.tag + ') = ' + toString($parentNext);
}
function FirstFollowCache3$calcFirstTermClosure$lambda($graph) {
  return () => 'START calcFirstTermClosure: ' + $graph.b1f_1.toString();
}
function FirstFollowCache3$calcFirstTermClosure$lambda_0($graph) {
  return () => 'FINISH calcFirstTermClosure: ' + $graph.b1f_1.toString();
}
function FirstFollowCache3$calcAllClosure$lambda($graph) {
  return () => 'START calcFirstTermClosure: ' + $graph.b1f_1.toString();
}
function FirstFollowCache3$calcAllClosure$lambda_0($graph) {
  return () => 'FINISH calcFirstTermClosure: ' + $graph.b1f_1.toString();
}
function firstOfRpNotEmpty($this, rulePosition, doneRp, done) {
  var existing = doneRp.c3(rulePosition);
  if (null == existing) {
    if (rulePosition.isAtEnd) {
      // Inline function 'kotlin.error' call
      var message = 'Internal Error';
      throw IllegalStateException.t4(toString(message));
    }
    var needsNext = false;
    var result = Companion_getInstance_7().EMPTY;
    var rps = setOf(rulePosition);
    $l$loop: while (true) {
      // Inline function 'kotlin.collections.isNotEmpty' call
      if (!!rps.l1()) {
        break $l$loop;
      }
      // Inline function 'kotlin.collections.mutableSetOf' call
      var nrps = LinkedHashSet.j1();
      var _iterator__ex2g4s = rps.g1();
      while (_iterator__ex2g4s.f()) {
        var rp = _iterator__ex2g4s.e();
        if (rp.isAtEnd) {
          needsNext = true;
        } else {
          var _iterator__ex2g4s_0 = rp.items.g1();
          while (_iterator__ex2g4s_0.f()) {
            var item = _iterator__ex2g4s_0.e();
            var rhs = item.rhs;
            if (rhs instanceof RuntimeRuleRhsEmpty)
              nrps.k1(rp.next());
            else {
              if (rhs instanceof RuntimeRuleRhsGoal) {
                // Inline function 'kotlin.TODO' call
                throw NotImplementedError.im();
              } else {
                if (rhs instanceof RuntimeRuleRhsEmbedded) {
                  var embSS = rhs.embeddedRuntimeRuleSet.c1l(rhs.embeddedStartRule.tag, AutomatonKind_LOOKAHEAD_1_getInstance());
                  // Inline function 'kotlin.collections.hashMapOf' call
                  var tmp$ret$2 = HashMap.o7();
                  var f = firstOfNotEmpty(embSS.x1h_1, rhs.embeddedStartRule, doneRp, tmp$ret$2);
                  var embSkipTerms = rhs.embeddedRuntimeRuleSet.skipTerminals;
                  result = result.union(f.d1j_1).union(Companion_getInstance_7().createFromRuntimeRules(embSkipTerms));
                  if (f.c1j_1) {
                    needsNext = true;
                  }
                } else {
                  if (rhs instanceof RuntimeRuleRhsTerminal) {
                    result = result.union(new LookaheadSetPart(false, false, false, setOf(item)));
                  } else {
                    if (rhs instanceof RuntimeRuleRhsNonTerminal) {
                      var f_0 = firstOfNotEmpty($this, item, doneRp, done);
                      result = result.union(f_0.d1j_1);
                      if (f_0.c1j_1) {
                        var rpnxt = rp.next();
                        var notSelf = minus(rpnxt, rp);
                        nrps.k1(notSelf);
                      }
                    } else {
                      noWhenBranchMatchedException();
                    }
                  }
                }
              }
            }
          }
        }
      }
      rps = nrps;
    }
    existing = new FirstOfResult(needsNext, result);
    // Inline function 'kotlin.collections.set' call
    var value = existing;
    doneRp.f3(rulePosition, value);
  }
  return existing;
}
function firstOfNotEmpty($this, rule, doneRp, done) {
  var tmp;
  if (0 > rule.u1d_1) {
    var tmp_0;
    switch (rule.u1d_1) {
      case -1:
        throw NotImplementedError.im();
      case -2:
        throw NotImplementedError.im();
      case -3:
        tmp_0 = firstOfNotEmptySafe($this, rule, doneRp, done);
        break;
      case -4:
        tmp_0 = firstOfNotEmptySafe($this, rule, doneRp, done);
        break;
      case -6:
        throw NotImplementedError.im();
      default:
        var message = 'unsupported rule number ' + rule.toString();
        throw IllegalStateException.t4(toString(message));
    }
    tmp = tmp_0;
  } else if (done.a3(rule.u1d_1)) {
    var tmp1_elvis_lhs = $this.d1l_1.c3(rule.u1d_1);
    tmp = tmp1_elvis_lhs == null ? new FirstOfResult(false, Companion_getInstance_7().EMPTY) : tmp1_elvis_lhs;
  } else {
    var result = null;
    if (null == result) {
      // Inline function 'kotlin.collections.set' call
      var key = rule.u1d_1;
      done.f3(key, true);
      result = firstOfNotEmptySafe($this, rule, doneRp, done);
      var tmp0 = $this.d1l_1;
      var tmp2 = rule.u1d_1;
      // Inline function 'kotlin.collections.set' call
      var value = result;
      tmp0.f3(tmp2, value);
    }
    tmp = result;
  }
  return tmp;
}
function firstOfNotEmptySafe($this, rule, doneRp, done) {
  var needsNext = false;
  var result = Companion_getInstance_7().EMPTY;
  var rps = rule.d1f();
  var _iterator__ex2g4s = rps.g1();
  while (_iterator__ex2g4s.f()) {
    var rp = _iterator__ex2g4s.e();
    var _iterator__ex2g4s_0 = rp.items.g1();
    while (_iterator__ex2g4s_0.f()) {
      var item = _iterator__ex2g4s_0.e();
      var rhs = item.rhs;
      if (item.isEmptyTerminal)
        needsNext = true;
      else if (item.isEmptyListTerminal)
        needsNext = true;
      else {
        if (rhs instanceof RuntimeRuleRhsGoal) {
          // Inline function 'kotlin.error' call
          var message = 'should never happen';
          throw IllegalStateException.t4(toString(message));
        } else {
          if (rhs instanceof RuntimeRuleRhsEmbedded) {
            var embSS = rhs.embeddedRuntimeRuleSet.c1l(rhs.embeddedStartRule.tag, AutomatonKind_LOOKAHEAD_1_getInstance());
            // Inline function 'kotlin.collections.hashMapOf' call
            var tmp$ret$0 = HashMap.o7();
            var f = firstOfNotEmpty(embSS.x1h_1, rhs.embeddedStartRule, doneRp, tmp$ret$0);
            var embSkipTerms = rhs.embeddedRuntimeRuleSet.skipTerminals;
            result = result.union(f.d1j_1).union(Companion_getInstance_7().createFromRuntimeRules(embSkipTerms));
            if (f.c1j_1) {
              needsNext = true;
            }
          } else {
            if (rhs instanceof RuntimeRuleRhsTerminal)
              result = result.union(new LookaheadSetPart(false, false, false, setOf(item)));
            else {
              if (rhs instanceof RuntimeRuleRhsNonTerminal) {
                var f_0 = firstOfRpNotEmpty($this, rp, doneRp, done);
                result = result.union(f_0.d1j_1);
                needsNext = needsNext || f_0.c1j_1;
              } else {
                noWhenBranchMatchedException();
              }
            }
          }
        }
      }
    }
  }
  return new FirstOfResult(needsNext, result);
}
function Lookahead$Companion$merge$lambda(a, b) {
  // Inline function 'kotlin.comparisons.compareValuesBy' call
  var tmp = b.guardLookaheadSet.m1l().h1();
  var tmp$ret$1 = a.guardLookaheadSet.m1l().h1();
  return compareValues(tmp, tmp$ret$1);
}
var Companion_instance_2;
function Companion_getInstance_2() {
  if (Companion_instance_2 === VOID)
    new Companion_2();
  return Companion_instance_2;
}
var Companion_instance_3;
function Companion_getInstance_3() {
  if (Companion_instance_3 === VOID)
    new Companion_3();
  return Companion_instance_3;
}
function LookaheadSet$regex$delegate$lambda$lambda(it) {
  var tmp;
  if (it.isPattern) {
    var tmp_0 = it.rhs;
    tmp = (tmp_0 instanceof RuntimeRuleRhsPattern ? tmp_0 : THROW_CCE()).patternUnescaped.escapedForRegex;
  } else {
    var tmp_1 = it.rhs;
    tmp = (tmp_1 instanceof RuntimeRuleRhsLiteral ? tmp_1 : THROW_CCE()).literalUnescaped.escapedForRegex;
  }
  return tmp;
}
function LookaheadSet$regex$delegate$lambda(this$0) {
  return () => {
    var str = joinToString(this$0.k1l_1, ')|(', '(', ')', VOID, VOID, LookaheadSet$regex$delegate$lambda$lambda);
    return Regex.jf(str);
  };
}
function LookaheadSet$toString$lambda(it) {
  return it.tag;
}
var Companion_instance_4;
function Companion_getInstance_4() {
  return Companion_instance_4;
}
function ParserState$runtimeRules$delegate$lambda(this$0) {
  return () => {
    // Inline function 'kotlin.collections.map' call
    var this_0 = this$0.j1i_1;
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var tmp = item.k1b_1;
      var tmp$ret$0 = tmp instanceof RuntimeRule ? tmp : THROW_CCE();
      destination.v(tmp$ret$0);
    }
    return toList(destination);
  };
}
function ParserState$_get_runtimeRules_$ref_1hrpf1() {
  return (p0) => p0.runtimeRules;
}
function ParserState$runtimeRulesAsSet$delegate$lambda(this$0) {
  return () => {
    // Inline function 'kotlin.collections.map' call
    var this_0 = this$0.j1i_1;
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var tmp = item.k1b_1;
      var tmp$ret$0 = tmp instanceof RuntimeRule ? tmp : THROW_CCE();
      destination.v(tmp$ret$0);
    }
    return toSet(destination);
  };
}
function ParserState$_get_runtimeRulesAsSet_$ref_erejer() {
  return (p0) => p0.runtimeRulesAsSet;
}
function ParserState$optionList$delegate$lambda(this$0) {
  return () => {
    // Inline function 'kotlin.collections.map' call
    var this_0 = this$0.j1i_1;
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var tmp$ret$0 = item.l1b_1;
      destination.v(tmp$ret$0);
    }
    return toList(destination);
  };
}
function ParserState$_get_optionList_$ref_cldr7r() {
  return (p0) => p0.optionList;
}
function ParserState$isChoice$delegate$lambda(this$0) {
  return () => this$0.firstRule.isChoice;
}
function ParserState$_get_isChoice_$ref_g739j5() {
  return (p0) => p0.isChoice;
}
function ParserState$isOptional$delegate$lambda(this$0) {
  return () => this$0.firstRule.isOptional;
}
function ParserState$_get_isOptional_$ref_gnza8u() {
  return (p0) => p0.isOptional;
}
function ParserState$isList$delegate$lambda(this$0) {
  return () => this$0.firstRule.isList;
}
function ParserState$_get_isList_$ref_pqc12c() {
  return (p0) => p0.isList;
}
function buildAndTraverse($this) {
  var stateInfos = $this.x1m().y1i();
  var _iterator__ex2g4s = stateInfos.g1();
  while (_iterator__ex2g4s.f()) {
    var si = _iterator__ex2g4s.e();
    if (!equals(si.d1k_1, $this.startState.j1i_1)) {
      if (false) {
        var tmp0 = $this.q1h_1;
        var tmp$ret$0;
        $l$block_0: {
          // Inline function 'kotlin.collections.any' call
          if (tmp0.l1()) {
            tmp$ret$0 = false;
            break $l$block_0;
          }
          // Inline function 'kotlin.collections.iterator' call
          var _iterator__ex2g4s_0 = tmp0.z1().g1();
          while (_iterator__ex2g4s_0.f()) {
            var element = _iterator__ex2g4s_0.e();
            if (equals(toSet(element.a2()), si.d1k_1)) {
              tmp$ret$0 = true;
              break $l$block_0;
            }
          }
          tmp$ret$0 = false;
        }
        // Inline function 'kotlin.check' call
        if (!!tmp$ret$0) {
          var message = 'State already created for ' + si.toString() + '.rulePositions';
          throw IllegalStateException.t4(toString(message));
        }
      }
      var state = $this.y1m(toList(si.d1k_1));
    }
  }
  var _iterator__ex2g4s_1 = stateInfos.g1();
  while (_iterator__ex2g4s_1.f()) {
    var si_0 = _iterator__ex2g4s_1.e();
    var state_0 = ensureNotNull($this.z1m(toList(si_0.d1k_1)));
    var _iterator__ex2g4s_2 = si_0.e1k_1.g1();
    while (_iterator__ex2g4s_2.f()) {
      var ti = _iterator__ex2g4s_2.e();
      var from = state_0;
      var action = ti.r1k_1;
      var tmp0_elvis_lhs = $this.a1n(toList(ti.s1k_1));
      var tmp;
      if (tmp0_elvis_lhs == null) {
        var message_0 = 'Internal error, state not created for ' + toString(ti.s1k_1);
        throw IllegalStateException.t4(toString(message_0));
      } else {
        tmp = tmp0_elvis_lhs;
      }
      var to = tmp;
      // Inline function 'kotlin.collections.map' call
      var this_0 = ti.t1k_1;
      // Inline function 'kotlin.collections.mapTo' call
      var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
      var _iterator__ex2g4s_3 = this_0.g1();
      while (_iterator__ex2g4s_3.f()) {
        var item = _iterator__ex2g4s_3.e();
        var tmp$ret$5 = new Lookahead(Companion_instance_4.lhs(item.u1k_1, $this), Companion_instance_4.lhs(item.v1k_1, $this));
        destination.v(tmp$ret$5);
      }
      var lhs = toSet(destination);
      var _iterator__ex2g4s_4 = ti.q1k_1.g1();
      while (_iterator__ex2g4s_4.f()) {
        var pp = _iterator__ex2g4s_4.e();
        var tmp1_elvis_lhs = $this.a1n(toList(pp.c1n_1));
        var tmp_0;
        if (tmp1_elvis_lhs == null) {
          var message_1 = 'Internal error, state not created for ' + toString(pp.c1n_1);
          throw IllegalStateException.t4(toString(message_1));
        } else {
          tmp_0 = tmp1_elvis_lhs;
        }
        var prev = tmp_0;
        if (state_0.isNotAtEnd) {
          state_0.outTransitions.createTransitionForIncomplete(prev, from, action, to, lhs);
        } else {
          var tmp2_elvis_lhs = $this.a1n(toList(pp.b1n_1));
          var tmp_1;
          if (tmp2_elvis_lhs == null) {
            var message_2 = 'Internal error, state not created for ' + toString(pp.b1n_1);
            throw IllegalStateException.t4(toString(message_2));
          } else {
            tmp_1 = tmp2_elvis_lhs;
          }
          var prevPrev = tmp_1;
          state_0.outTransitions.createTransitionForComplete(prev, prevPrev, from, action, to, lhs);
        }
      }
    }
  }
}
function ParserStateSet$buildCache$delegate$lambda(this$0) {
  return () => {
    var tmp;
    switch (this$0.automatonKind.q3_1) {
      case 0:
        throw NotImplementedError.im();
      case 1:
        throw NotImplementedError.im();
      case 2:
        tmp = new BuildCacheLC1(this$0);
        break;
      default:
        noWhenBranchMatchedException();
        break;
    }
    return tmp;
  };
}
function ParserStateSet$_get_buildCache_$ref_7quire() {
  return (p0) => p0.x1m();
}
function ParserStateSet$usedRules$delegate$lambda(this$0) {
  return () => this$0.runtimeRuleSet.calcUsedRules(first_0(this$0.startState.runtimeRules));
}
function ParserStateSet$_get_usedRules_$ref_a9jloy() {
  return (p0) => p0.usedRules;
}
function ParserStateSet$usedTerminalRules$delegate$lambda(this$0) {
  return () => {
    // Inline function 'kotlin.collections.filter' call
    var tmp0 = this$0.usedRules;
    // Inline function 'kotlin.collections.filterTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      if (element.isTerminal) {
        destination.v(element);
      }
    }
    return toSet(destination);
  };
}
function ParserStateSet$_get_usedTerminalRules_$ref_xaekha() {
  return (p0) => p0.usedTerminalRules;
}
function ParserStateSet$usedNonTerminalRules$delegate$lambda(this$0) {
  return () => {
    // Inline function 'kotlin.collections.filter' call
    var tmp0 = this$0.usedRules;
    // Inline function 'kotlin.collections.filterTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      if (element.isNonTerminal) {
        destination.v(element);
      }
    }
    return toSet(destination);
  };
}
function ParserStateSet$_get_usedNonTerminalRules_$ref_z5pug3() {
  return (p0) => p0.usedNonTerminalRules;
}
function ParserStateSet$firstTerminals$delegate$lambda(this$0) {
  return () => {
    // Inline function 'kotlin.collections.map' call
    var this_0 = this$0.startState.transitionsGoal(this$0.startState);
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var tmp$ret$0 = item.f1n_1.firstRule;
      destination.v(tmp$ret$0);
    }
    return toSet(destination);
  };
}
function ParserStateSet$_get_firstTerminals_$ref_2rxbfd() {
  return (p0) => p0.firstTerminals;
}
function ParserStateSet$embeddedRuntimeRuleSet$delegate$lambda(this$0) {
  return () => {
    // Inline function 'kotlin.collections.filter' call
    var tmp0 = this$0.usedRules;
    // Inline function 'kotlin.collections.filterTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      if (element.isEmbedded) {
        destination.v(element);
      }
    }
    var embRules = toSet(destination);
    // Inline function 'kotlin.collections.map' call
    // Inline function 'kotlin.collections.mapTo' call
    var destination_0 = ArrayList.a1(collectionSizeOrDefault(embRules, 10));
    var _iterator__ex2g4s_0 = embRules.g1();
    while (_iterator__ex2g4s_0.f()) {
      var item = _iterator__ex2g4s_0.e();
      var tmp = item.rhs;
      var rhs = tmp instanceof RuntimeRuleRhsEmbedded ? tmp : THROW_CCE();
      var tmp$ret$3 = rhs.embeddedRuntimeRuleSet;
      destination_0.v(tmp$ret$3);
    }
    return toSet(destination_0);
  };
}
function ParserStateSet$_get_embeddedRuntimeRuleSet_$ref_4teomu() {
  return (p0) => p0.embeddedRuntimeRuleSet;
}
function ParserStateSet$goalRule$delegate$lambda(this$0) {
  return () => this$0.runtimeRuleSet.goalRuleFor.c3(this$0.userGoalRule);
}
function ParserStateSet$_get_goalRule_$ref_eaq6qn() {
  return (p0) => p0.goalRule;
}
function ParserStateSet$startRulePosition$delegate$lambda(this$0) {
  return () => {
    var tmp = this$0.goalRule;
    return new RulePositionRuntime(tmp instanceof RuntimeRule ? tmp : THROW_CCE(), Companion_getInstance_11().OPTION_NONE, 0);
  };
}
function ParserStateSet$_get_startRulePosition_$ref_byigx1() {
  return (p0) => p0.startRulePosition;
}
function ParserStateSet$finishRulePosition$delegate$lambda(this$0) {
  return () => {
    var tmp = this$0.goalRule;
    return new RulePositionRuntime(tmp instanceof RuntimeRule ? tmp : THROW_CCE(), Companion_getInstance_11().OPTION_NONE, -1);
  };
}
function ParserStateSet$_get_finishRulePosition_$ref_5204i2() {
  return (p0) => p0.finishRulePosition;
}
function ParserStateSet$startState$delegate$lambda(this$0) {
  return () => this$0.y1h(listOf(this$0.startRulePosition));
}
function ParserStateSet$_get_startState_$ref_budccf() {
  return (p0) => p0.startState;
}
function ParserStateSet$finishState$delegate$lambda(this$0) {
  return () => this$0.y1h(listOf(this$0.finishRulePosition));
}
function ParserStateSet$_get_finishState_$ref_kmsh5a() {
  return (p0) => p0.finishState;
}
function ParserStateSet$usedAutomatonToString$lambda(it) {
  return toString(it);
}
function ParserStateSet$usedAutomatonToString$lambda_0(a, b) {
  // Inline function 'kotlin.comparisons.compareValuesBy' call
  var tmp = toString(a.e1n_1.j1i_1);
  var tmp$ret$1 = toString(b.e1n_1.j1i_1);
  return compareValues(tmp, tmp$ret$1);
}
function ParserStateSet$usedAutomatonToString$lambda_1(a, b) {
  // Inline function 'kotlin.comparisons.compareValuesBy' call
  var tmp = toString(a.f1n_1.j1i_1);
  var tmp$ret$1 = toString(b.f1n_1.j1i_1);
  return compareValues(tmp, tmp$ret$1);
}
function ParserStateSet$usedAutomatonToString$lambda_2(it) {
  return toString(it);
}
function ParserStateSet$usedAutomatonToString$lambda_3(it) {
  return it.toString();
}
function ParserStateSet$usedAutomatonToString$lambda_4(it) {
  var tmp = it.guardLookaheadSet.m1l();
  var tmp_0 = joinToString(tmp, VOID, VOID, VOID, VOID, VOID, ParserStateSet$usedAutomatonToString$lambda$lambda);
  var tmp_1 = it.upLookaheadSet.m1l();
  return '[' + tmp_0 + '](' + joinToString(tmp_1, VOID, VOID, VOID, VOID, VOID, ParserStateSet$usedAutomatonToString$lambda$lambda_0) + ')';
}
function ParserStateSet$usedAutomatonToString$lambda$lambda(it) {
  return it.tag;
}
function ParserStateSet$usedAutomatonToString$lambda$lambda_0(it) {
  return it.tag;
}
function createWidthOrEmbeddedTransition($this, sourceState, wi) {
  var rp = wi.x1k_1;
  var lookaheadInfo = new Lookahead(Companion_instance_4.lhs(wi.y1k_1, $this.s1m_1), Companion_getInstance_3().EMPTY);
  var to = $this.s1m_1.y1m(listOf(rp));
  return new Transition(sourceState, to, wi.w1k_1, setOf(lookaheadInfo));
}
function createHeightTransition3($this, sourceState, hg) {
  var to = $this.s1m_1.y1m(toList(hg.s1k_1));
  // Inline function 'kotlin.collections.map' call
  var this_0 = hg.t1k_1;
  // Inline function 'kotlin.collections.mapTo' call
  var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
  var _iterator__ex2g4s = this_0.g1();
  while (_iterator__ex2g4s.f()) {
    var item = _iterator__ex2g4s.e();
    var tmp$ret$0 = new Lookahead(Companion_instance_4.lhs(item.u1k_1, $this.s1m_1), Companion_instance_4.lhs(item.v1k_1, $this.s1m_1));
    destination.v(tmp$ret$0);
  }
  var lookaheadInfo = toSet(destination);
  var trs = new Transition(sourceState, to, ParseAction_HEIGHT_getInstance(), lookaheadInfo);
  return trs;
}
function createGraftTransition3($this, sourceState, hg) {
  var to = $this.s1m_1.y1m(toList(hg.s1k_1));
  // Inline function 'kotlin.collections.map' call
  var this_0 = hg.t1k_1;
  // Inline function 'kotlin.collections.mapTo' call
  var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
  var _iterator__ex2g4s = this_0.g1();
  while (_iterator__ex2g4s.f()) {
    var item = _iterator__ex2g4s.e();
    var tmp$ret$0 = new Lookahead(Companion_instance_4.lhs(item.u1k_1, $this.s1m_1), Companion_getInstance_3().EMPTY);
    destination.v(tmp$ret$0);
  }
  var lookaheadInfo = toSet(destination);
  var trs = new Transition(sourceState, to, ParseAction_GRAFT_getInstance(), lookaheadInfo);
  return trs;
}
function createGoalTransition3($this, sourceState, hg) {
  var to = $this.s1m_1.finishState;
  // Inline function 'kotlin.collections.map' call
  var this_0 = hg.t1k_1;
  // Inline function 'kotlin.collections.mapTo' call
  var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
  var _iterator__ex2g4s = this_0.g1();
  while (_iterator__ex2g4s.f()) {
    var item = _iterator__ex2g4s.e();
    var tmp$ret$0 = new Lookahead(Companion_getInstance_3().EOT, Companion_getInstance_3().EMPTY);
    destination.v(tmp$ret$0);
  }
  var lookaheadInfo = toSet(destination);
  var trs = new Transition(sourceState, to, ParseAction_GOAL_getInstance(), lookaheadInfo);
  return trs;
}
var DefaultRuntimeGuard_instance;
function DefaultRuntimeGuard_getInstance() {
  return DefaultRuntimeGuard_instance;
}
var Companion_instance_5;
function Companion_getInstance_5() {
  return Companion_instance_5;
}
function _get_hashCode_cache__hrfw4t($this) {
  var tmp0 = $this.i1n_1;
  var tmp = KProperty1;
  // Inline function 'kotlin.getValue' call
  getPropertyCallableRef('hashCode_cache', 1, tmp, Transition$_get_hashCode_cache_$ref_ergbf9(), null);
  return tmp0.b2();
}
function Transition$context$delegate$lambda(this$0) {
  return () => toSet(this$0.e1n_1.outTransitions.previousFor(this$0));
}
function Transition$_get_context_$ref_7yxvsu() {
  return (p0) => p0.context;
}
function Transition$hashCode_cache$delegate$lambda(this$0) {
  return () => arrayListOf([this$0.e1n_1, this$0.f1n_1, this$0.g1n_1, this$0.lookaheadGuard]).hashCode();
}
function Transition$_get_hashCode_cache_$ref_ergbf9() {
  return (p0) => _get_hashCode_cache__hrfw4t(p0);
}
function Transition$toString$lambda(it) {
  return toString(it);
}
function Transition$toString$lambda_0(it) {
  var tmp = it.guardLookaheadSet.m1l();
  var tmp_0 = joinToString(tmp, VOID, VOID, VOID, VOID, VOID, Transition$toString$lambda$lambda);
  var tmp_1 = it.upLookaheadSet.m1l();
  return '[' + tmp_0 + '](' + joinToString(tmp_1, VOID, VOID, VOID, VOID, VOID, Transition$toString$lambda$lambda_0) + ')';
}
function Transition$toString$lambda$lambda(it) {
  return it.tag;
}
function Transition$toString$lambda$lambda_0(it) {
  return it.tag;
}
function merge($this, automaton, set) {
  // Inline function 'kotlin.collections.groupBy' call
  // Inline function 'kotlin.collections.groupByTo' call
  var destination = LinkedHashMap.j4();
  var _iterator__ex2g4s = set.g1();
  while (_iterator__ex2g4s.f()) {
    var element = _iterator__ex2g4s.e();
    var key = listOf_0([element.e1n_1, element.g1n_1, element.f1n_1]);
    // Inline function 'kotlin.collections.getOrPut' call
    var value = destination.c3(key);
    var tmp;
    if (value == null) {
      var answer = ArrayList.o1();
      destination.f3(key, answer);
      tmp = answer;
    } else {
      tmp = value;
    }
    var list = tmp;
    list.v(element);
  }
  var grouped = destination;
  // Inline function 'kotlin.collections.map' call
  // Inline function 'kotlin.collections.mapTo' call
  var destination_0 = ArrayList.a1(grouped.h1());
  // Inline function 'kotlin.collections.iterator' call
  var _iterator__ex2g4s_0 = grouped.z1().g1();
  while (_iterator__ex2g4s_0.f()) {
    var item = _iterator__ex2g4s_0.e();
    var tmp_0 = item.a2().i1(0);
    var from = tmp_0 instanceof ParserState ? tmp_0 : THROW_CCE();
    var tmp_1 = item.a2().i1(1);
    var action = tmp_1 instanceof ParseAction ? tmp_1 : THROW_CCE();
    var tmp_2 = item.a2().i1(2);
    var to = tmp_2 instanceof ParserState ? tmp_2 : THROW_CCE();
    var tmp_3 = Companion_getInstance_2();
    // Inline function 'kotlin.collections.flatMap' call
    var tmp0 = item.b2();
    // Inline function 'kotlin.collections.flatMapTo' call
    var destination_1 = ArrayList.o1();
    var _iterator__ex2g4s_1 = tmp0.g1();
    while (_iterator__ex2g4s_1.f()) {
      var element_0 = _iterator__ex2g4s_1.e();
      var list_0 = element_0.lookaheadGuard;
      addAll(destination_1, list_0);
    }
    var lhs = tmp_3.merge(automaton, toSet(destination_1));
    var tmp$ret$9 = new Transition(from, to, action, lhs);
    destination_0.v(tmp$ret$9);
  }
  var merged = destination_0;
  var tmp_4;
  if (merged.h1() === 1) {
    tmp_4 = first_0(merged);
  } else {
    if (false) {
      var tmp_5 = Debug_instance;
      var tmp_6 = IndentDelta_NONE_getInstance();
      tmp_5.debug(tmp_6, TransitionCacheLC1$Companion$merge$lambda(set));
    }
    // Inline function 'kotlin.error' call
    var message = 'Internal Error: transitions not merged\n' + joinToString(merged, '\n', VOID, VOID, VOID, VOID, TransitionCacheLC1$Companion$merge$lambda_0);
    throw IllegalStateException.t4(toString(message));
  }
  return tmp_4;
}
function TransitionCacheLC1$Companion$merge$lambda$lambda(it) {
  return it.toString();
}
function TransitionCacheLC1$Companion$merge$lambda($set) {
  return () => 'Tried to Merge:\n  ' + joinToString($set, '\n  ', VOID, VOID, VOID, VOID, TransitionCacheLC1$Companion$merge$lambda$lambda);
}
function TransitionCacheLC1$Companion$merge$lambda_0(it) {
  return it.toString();
}
var Companion_instance_6;
function Companion_getInstance_6() {
  return Companion_instance_6;
}
function _get__allBuiltIncomplete__j98m7d($this) {
  return flatten($this.s1o_1.e3());
}
function _get__allBuiltComplete__fb3q3g($this) {
  return flatten($this.r1o_1.e3());
}
function _get__allPreviousIncomplete__5lazpo($this) {
  // Inline function 'kotlin.collections.map' call
  var this_0 = $this.s1o_1.d3();
  // Inline function 'kotlin.collections.mapTo' call
  var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
  var _iterator__ex2g4s = this_0.g1();
  while (_iterator__ex2g4s.f()) {
    var item = _iterator__ex2g4s.e();
    var tmp$ret$0 = new IncompleteKey(item);
    destination.v(tmp$ret$0);
  }
  return destination;
}
function _get__allPreviousComplete__hn51vr($this) {
  // Inline function 'kotlin.collections.map' call
  var this_0 = $this.r1o_1.d3();
  // Inline function 'kotlin.collections.mapTo' call
  var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
  var _iterator__ex2g4s = this_0.g1();
  while (_iterator__ex2g4s.f()) {
    var item = _iterator__ex2g4s.e();
    destination.v(item);
  }
  return destination;
}
function updateIncompleteByPrevious($this, previousSet, oldTransition, newTransition) {
  var _iterator__ex2g4s = previousSet.g1();
  while (_iterator__ex2g4s.f()) {
    var pS = _iterator__ex2g4s.e();
    var trans = $this.s1o_1.c3(pS);
    if (null == trans) {
      trans = mutableListOf([newTransition]);
      var tmp0 = $this.s1o_1;
      // Inline function 'kotlin.collections.set' call
      var value = trans;
      tmp0.f3(pS, value);
    } else {
      if (!(null == oldTransition)) {
        trans.j3(oldTransition);
      }
      trans.v(newTransition);
    }
  }
}
function updateCompleteByPrevious($this, prevKeySet, oldTransition, newTransition) {
  var _iterator__ex2g4s = prevKeySet.g1();
  while (_iterator__ex2g4s.f()) {
    var pk = _iterator__ex2g4s.e();
    var trans = $this.r1o_1.c3(pk);
    if (null == trans) {
      trans = mutableListOf([newTransition]);
      var tmp0 = $this.r1o_1;
      // Inline function 'kotlin.collections.set' call
      var value = trans;
      tmp0.f3(pk, value);
    } else {
      if (!(null == oldTransition)) {
        trans.j3(oldTransition);
      }
      trans.v(newTransition);
    }
  }
}
function TransitionCacheLC1$addTransitionForComplete$lambda$lambda(it) {
  return it.toString();
}
function TransitionCacheLC1$addTransitionForComplete$lambda($toMerge) {
  return () => 'Merged:\n  ' + joinToString($toMerge, '\n  ', VOID, VOID, VOID, VOID, TransitionCacheLC1$addTransitionForComplete$lambda$lambda);
}
function TransitionCacheLC1$addTransitionForComplete$lambda_0($mergedTr) {
  return () => 'Into:\n  ' + $mergedTr.toString();
}
function TransitionCacheLC1$addTransitionForIncomplete$lambda$lambda(it) {
  return it.toString();
}
function TransitionCacheLC1$addTransitionForIncomplete$lambda($toMerge) {
  return () => 'Merged:\n  ' + joinToString($toMerge, '\n  ', VOID, VOID, VOID, VOID, TransitionCacheLC1$addTransitionForIncomplete$lambda$lambda);
}
function TransitionCacheLC1$addTransitionForIncomplete$lambda_0($mergedTr) {
  return () => 'Into:\n  ' + $mergedTr.toString();
}
var Companion_instance_7;
function Companion_getInstance_7() {
  if (Companion_instance_7 === VOID)
    new Companion_7();
  return Companion_instance_7;
}
function LookaheadSetPart$regex$delegate$lambda$lambda(it) {
  var tmp0_subject = it.rhs;
  var tmp;
  if (tmp0_subject instanceof RuntimeRuleRhsLiteral) {
    var tmp_0 = it.rhs;
    tmp = (tmp_0 instanceof RuntimeRuleRhsLiteral ? tmp_0 : THROW_CCE()).literalUnescaped.escapedForRegex;
  } else {
    if (tmp0_subject instanceof RuntimeRuleRhsPattern) {
      var tmp_1 = it.rhs;
      tmp = (tmp_1 instanceof RuntimeRuleRhsPattern ? tmp_1 : THROW_CCE()).patternUnescaped.escapedForRegex;
    } else {
      var message = 'Internal Error: rhs not a literal that can be joined to a regex';
      throw IllegalStateException.t4(toString(message));
    }
  }
  return tmp;
}
function LookaheadSetPart$regex$delegate$lambda(this$0) {
  return () => {
    var str = joinToString(this$0.content, ')|(', '(', ')', VOID, VOID, LookaheadSetPart$regex$delegate$lambda$lambda);
    return Regex.jf(str);
  };
}
function LookaheadSetPart$_get_regex_$ref_i6110o() {
  return (p0) => p0.regex;
}
function LookaheadSetPart$toString$lambda(a, b) {
  // Inline function 'kotlin.comparisons.compareValuesBy' call
  var tmp = a.tag;
  var tmp$ret$1 = b.tag;
  return compareValues(tmp, tmp$ret$1);
}
function LookaheadSetPart$toString$lambda_0(it) {
  return it.tag;
}
function LookaheadInfoPart$Companion$merge1$lambda(a, b) {
  // Inline function 'kotlin.comparisons.compareValuesBy' call
  var tmp = b.u1k_1.fullContent.h1();
  var tmp$ret$1 = a.u1k_1.fullContent.h1();
  return compareValues(tmp, tmp$ret$1);
}
var Companion_instance_8;
function Companion_getInstance_8() {
  if (Companion_instance_8 === VOID)
    new Companion_8();
  return Companion_instance_8;
}
function ClosureGraph$Companion$ClosureItemAbstractGraph$expectedAt$delegate$lambda(this$0) {
  return () => Companion_getInstance_9().expectedAt(this$0.h1f_1, this$0.j1f_1);
}
function ClosureGraph$Companion$ClosureItemAbstractGraph$_get_expectedAt_$ref_p3bkd0() {
  return (p0) => p0.e1p();
}
function ClosureGraph$Companion$ClosureItemAbstractGraph$children$delegate$lambda(this$0) {
  return () => this$0.g1f_1.g1p(this$0);
}
function ClosureGraph$Companion$ClosureItemAbstractGraph$_get_children_$ref_yo8ks8() {
  return (p0) => p0.o15();
}
function ClosureGraph$Companion$ClosureItemAbstractGraph$parents$delegate$lambda(this$0) {
  return () => this$0.g1f_1.h1p(this$0);
}
function ClosureGraph$Companion$ClosureItemAbstractGraph$_get_parents_$ref_9fhpsq() {
  return (p0) => p0.i1p();
}
function ClosureGraph$Companion$ClosureItemAbstractGraph$parentNext$delegate$lambda(this$0) {
  return () => Companion_getInstance_9().parentNext(this$0.g1f_1.h1p(this$0));
}
function ClosureGraph$Companion$ClosureItemAbstractGraph$_get_parentNext_$ref_58nkue() {
  return (p0) => p0.s1f();
}
function ClosureGraph$Companion$ClosureItemChildGraph$toStringRec$lambda($done, this$0) {
  return (it) => {
    var s = it.j1p($done);
    return this$0.h1f_1.toString() + '-->' + s;
  };
}
var Companion_instance_9;
function Companion_getInstance_9() {
  if (Companion_instance_9 === VOID)
    new Companion_9();
  return Companion_instance_9;
}
function _get__childrenOf__aagwgs($this) {
  var tmp = KProperty1;
  return $this.z1e_1.yj($this, getPropertyCallableRef('_childrenOf', 1, tmp, ClosureGraph$_get__childrenOf_$ref_kbxe1m(), null));
}
function _get__parentsOf__h88uxi($this) {
  var tmp = KProperty1;
  return $this.a1f_1.yj($this, getPropertyCallableRef('_parentsOf', 1, tmp, ClosureGraph$_get__parentsOf_$ref_uqqsnq(), null));
}
function ClosureGraph$_childrenOf$delegate$lambda(it) {
  return lazyMutableMapNotNull(ClosureGraph$_childrenOf$delegate$lambda$lambda);
}
function ClosureGraph$_childrenOf$delegate$lambda$lambda(it) {
  // Inline function 'kotlin.collections.linkedSetOf' call
  return LinkedHashSet.j1();
}
function ClosureGraph$_get__childrenOf_$ref_kbxe1m() {
  return (p0) => _get__childrenOf__aagwgs(p0);
}
function ClosureGraph$_parentsOf$delegate$lambda(it) {
  // Inline function 'kotlin.collections.linkedSetOf' call
  return LinkedHashSet.j1();
}
function ClosureGraph$_get__parentsOf_$ref_uqqsnq() {
  return (p0) => _get__parentsOf__h88uxi(p0);
}
var LanguageIssueKind_ERROR_instance;
var LanguageIssueKind_WARNING_instance;
var LanguageIssueKind_INFORMATION_instance;
function values_1() {
  return [LanguageIssueKind_ERROR_getInstance(), LanguageIssueKind_WARNING_getInstance(), LanguageIssueKind_INFORMATION_getInstance()];
}
function valueOf_1(value) {
  switch (value) {
    case 'ERROR':
      return LanguageIssueKind_ERROR_getInstance();
    case 'WARNING':
      return LanguageIssueKind_WARNING_getInstance();
    case 'INFORMATION':
      return LanguageIssueKind_INFORMATION_getInstance();
    default:
      LanguageIssueKind_initEntries();
      THROW_IAE('No enum constant net.akehurst.language.issues.api.LanguageIssueKind.' + value);
      break;
  }
}
var LanguageIssueKind_entriesInitialized;
function LanguageIssueKind_initEntries() {
  if (LanguageIssueKind_entriesInitialized)
    return Unit_instance;
  LanguageIssueKind_entriesInitialized = true;
  LanguageIssueKind_ERROR_instance = new LanguageIssueKind('ERROR', 0);
  LanguageIssueKind_WARNING_instance = new LanguageIssueKind('WARNING', 1);
  LanguageIssueKind_INFORMATION_instance = new LanguageIssueKind('INFORMATION', 2);
}
var LanguageProcessorPhase_GRAMMAR_instance;
var LanguageProcessorPhase_SCAN_instance;
var LanguageProcessorPhase_PARSE_instance;
var LanguageProcessorPhase_SYNTAX_ANALYSIS_instance;
var LanguageProcessorPhase_SEMANTIC_ANALYSIS_instance;
var LanguageProcessorPhase_INTERPRET_instance;
var LanguageProcessorPhase_GENERATE_instance;
var LanguageProcessorPhase_FORMAT_instance;
var LanguageProcessorPhase_ALL_instance;
function values_2() {
  return [LanguageProcessorPhase_GRAMMAR_getInstance(), LanguageProcessorPhase_SCAN_getInstance(), LanguageProcessorPhase_PARSE_getInstance(), LanguageProcessorPhase_SYNTAX_ANALYSIS_getInstance(), LanguageProcessorPhase_SEMANTIC_ANALYSIS_getInstance(), LanguageProcessorPhase_INTERPRET_getInstance(), LanguageProcessorPhase_GENERATE_getInstance(), LanguageProcessorPhase_FORMAT_getInstance(), LanguageProcessorPhase_ALL_getInstance()];
}
function valueOf_2(value) {
  switch (value) {
    case 'GRAMMAR':
      return LanguageProcessorPhase_GRAMMAR_getInstance();
    case 'SCAN':
      return LanguageProcessorPhase_SCAN_getInstance();
    case 'PARSE':
      return LanguageProcessorPhase_PARSE_getInstance();
    case 'SYNTAX_ANALYSIS':
      return LanguageProcessorPhase_SYNTAX_ANALYSIS_getInstance();
    case 'SEMANTIC_ANALYSIS':
      return LanguageProcessorPhase_SEMANTIC_ANALYSIS_getInstance();
    case 'INTERPRET':
      return LanguageProcessorPhase_INTERPRET_getInstance();
    case 'GENERATE':
      return LanguageProcessorPhase_GENERATE_getInstance();
    case 'FORMAT':
      return LanguageProcessorPhase_FORMAT_getInstance();
    case 'ALL':
      return LanguageProcessorPhase_ALL_getInstance();
    default:
      LanguageProcessorPhase_initEntries();
      THROW_IAE('No enum constant net.akehurst.language.issues.api.LanguageProcessorPhase.' + value);
      break;
  }
}
var LanguageProcessorPhase_entriesInitialized;
function LanguageProcessorPhase_initEntries() {
  if (LanguageProcessorPhase_entriesInitialized)
    return Unit_instance;
  LanguageProcessorPhase_entriesInitialized = true;
  LanguageProcessorPhase_GRAMMAR_instance = new LanguageProcessorPhase('GRAMMAR', 0);
  LanguageProcessorPhase_SCAN_instance = new LanguageProcessorPhase('SCAN', 1);
  LanguageProcessorPhase_PARSE_instance = new LanguageProcessorPhase('PARSE', 2);
  LanguageProcessorPhase_SYNTAX_ANALYSIS_instance = new LanguageProcessorPhase('SYNTAX_ANALYSIS', 3);
  LanguageProcessorPhase_SEMANTIC_ANALYSIS_instance = new LanguageProcessorPhase('SEMANTIC_ANALYSIS', 4);
  LanguageProcessorPhase_INTERPRET_instance = new LanguageProcessorPhase('INTERPRET', 5);
  LanguageProcessorPhase_GENERATE_instance = new LanguageProcessorPhase('GENERATE', 6);
  LanguageProcessorPhase_FORMAT_instance = new LanguageProcessorPhase('FORMAT', 7);
  LanguageProcessorPhase_ALL_instance = new LanguageProcessorPhase('ALL', 8);
}
function LanguageIssueKind_ERROR_getInstance() {
  LanguageIssueKind_initEntries();
  return LanguageIssueKind_ERROR_instance;
}
function LanguageIssueKind_WARNING_getInstance() {
  LanguageIssueKind_initEntries();
  return LanguageIssueKind_WARNING_instance;
}
function LanguageIssueKind_INFORMATION_getInstance() {
  LanguageIssueKind_initEntries();
  return LanguageIssueKind_INFORMATION_instance;
}
function LanguageProcessorPhase_GRAMMAR_getInstance() {
  LanguageProcessorPhase_initEntries();
  return LanguageProcessorPhase_GRAMMAR_instance;
}
function LanguageProcessorPhase_SCAN_getInstance() {
  LanguageProcessorPhase_initEntries();
  return LanguageProcessorPhase_SCAN_instance;
}
function LanguageProcessorPhase_PARSE_getInstance() {
  LanguageProcessorPhase_initEntries();
  return LanguageProcessorPhase_PARSE_instance;
}
function LanguageProcessorPhase_SYNTAX_ANALYSIS_getInstance() {
  LanguageProcessorPhase_initEntries();
  return LanguageProcessorPhase_SYNTAX_ANALYSIS_instance;
}
function LanguageProcessorPhase_SEMANTIC_ANALYSIS_getInstance() {
  LanguageProcessorPhase_initEntries();
  return LanguageProcessorPhase_SEMANTIC_ANALYSIS_instance;
}
function LanguageProcessorPhase_INTERPRET_getInstance() {
  LanguageProcessorPhase_initEntries();
  return LanguageProcessorPhase_INTERPRET_instance;
}
function LanguageProcessorPhase_GENERATE_getInstance() {
  LanguageProcessorPhase_initEntries();
  return LanguageProcessorPhase_GENERATE_instance;
}
function LanguageProcessorPhase_FORMAT_getInstance() {
  LanguageProcessorPhase_initEntries();
  return LanguageProcessorPhase_FORMAT_instance;
}
function LanguageProcessorPhase_ALL_getInstance() {
  LanguageProcessorPhase_initEntries();
  return LanguageProcessorPhase_ALL_instance;
}
function plus_4(_this__u8e3s4, other) {
  var issues = new IssueHolder(LanguageProcessorPhase_ALL_getInstance());
  issues.addAllFrom(_this__u8e3s4);
  issues.addAllFrom(other);
  return issues;
}
function IssueHolder$toString$lambda(it) {
  return it.toString();
}
var SentenceIdentityFunctionNull_instance;
function SentenceIdentityFunctionNull_getInstance() {
  return SentenceIdentityFunctionNull_instance;
}
function createParseIssuesFromFailures($this, sentence, options, rp) {
  if (options.reportErrors) {
    var map1 = rp.z1s_1;
    // Inline function 'kotlin.collections.flatMap' call
    var tmp0 = flatten(map1.e3());
    // Inline function 'kotlin.collections.flatMapTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      var tmp;
      if (element instanceof FailedParseReasonEmbedded) {
        // Inline function 'kotlin.collections.map' call
        var this_0 = element.j1t_1;
        // Inline function 'kotlin.collections.mapTo' call
        var destination_0 = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
        var _iterator__ex2g4s_0 = this_0.g1();
        while (_iterator__ex2g4s_0.f()) {
          var item = _iterator__ex2g4s_0.e();
          destination_0.v(item);
        }
        tmp = destination_0;
      } else {
        tmp = listOf(element);
      }
      var list = tmp;
      addAll(destination, list);
    }
    // Inline function 'kotlin.collections.groupBy' call
    // Inline function 'kotlin.collections.groupByTo' call
    var destination_1 = LinkedHashMap.j4();
    var _iterator__ex2g4s_1 = destination.g1();
    while (_iterator__ex2g4s_1.f()) {
      var element_0 = _iterator__ex2g4s_1.e();
      var key = element_0.m1t_1;
      // Inline function 'kotlin.collections.getOrPut' call
      var value = destination_1.c3(key);
      var tmp_0;
      if (value == null) {
        var answer = ArrayList.o1();
        destination_1.f3(key, answer);
        tmp_0 = answer;
      } else {
        tmp_0 = value;
      }
      var list_0 = tmp_0;
      list_0.v(element_0);
    }
    var map2 = destination_1;
    // Inline function 'kotlin.collections.isNotEmpty' call
    if (!map2.l1()) {
      var failedAtPosition = max(map2.d3());
      var tmp0_safe_receiver = map2.c3(failedAtPosition);
      var tmp_1;
      if (tmp0_safe_receiver == null) {
        tmp_1 = null;
      } else {
        // Inline function 'kotlin.collections.filter' call
        // Inline function 'kotlin.collections.filterTo' call
        var destination_2 = ArrayList.o1();
        var _iterator__ex2g4s_2 = tmp0_safe_receiver.g1();
        while (_iterator__ex2g4s_2.f()) {
          var element_1 = _iterator__ex2g4s_2.e();
          if (!element_1.q1t()) {
            destination_2.v(element_1);
          }
        }
        tmp_1 = destination_2;
      }
      var tmp1_safe_receiver = tmp_1;
      var tmp_2;
      if (tmp1_safe_receiver == null) {
        tmp_2 = null;
      } else {
        // Inline function 'kotlin.collections.map' call
        // Inline function 'kotlin.collections.mapTo' call
        var destination_3 = ArrayList.a1(collectionSizeOrDefault(tmp1_safe_receiver, 10));
        var _iterator__ex2g4s_3 = tmp1_safe_receiver.g1();
        while (_iterator__ex2g4s_3.f()) {
          var item_0 = _iterator__ex2g4s_3.e();
          var tmp$ret$15 = item_0.r1t();
          destination_3.v(tmp$ret$15);
        }
        tmp_2 = destination_3;
      }
      var tmp2_elvis_lhs = tmp_2;
      var nextExpected = tmp2_elvis_lhs == null ? emptyList() : tmp2_elvis_lhs;
      var loc = sentence.locationFor(failedAtPosition, 0);
      addParseIssue($this, sentence, loc, nextExpected);
    }
  }
}
function createRuntimeParser($this, sentence, goalRuleName, scanner, automatonKind, cacheSkip) {
  var goalRule = $this.s1t_1.findRuntimeRule(goalRuleName);
  var s0 = $this.s1t_1.c1l(goalRuleName, automatonKind).startState;
  var skipStateSet = $this.s1t_1.skipParserStateSet;
  return new RuntimeParserAgl(sentence, false, s0.stateSet, skipStateSet, cacheSkip, goalRule, scanner, $this.u1t_1);
}
function addParseIssue($this, sentence, lastLocation, nextExpected) {
  // Inline function 'kotlin.collections.flatMap' call
  // Inline function 'kotlin.collections.flatMapTo' call
  var destination = ArrayList.o1();
  var _iterator__ex2g4s = nextExpected.g1();
  while (_iterator__ex2g4s.f()) {
    var element = _iterator__ex2g4s.e();
    var list = element.expectedNextTerminals;
    addAll(destination, list);
  }
  var expectedTerminals = toSet(destination);
  // Inline function 'kotlin.collections.map' call
  // Inline function 'kotlin.collections.mapTo' call
  var destination_0 = ArrayList.a1(collectionSizeOrDefault(expectedTerminals, 10));
  var _iterator__ex2g4s_0 = expectedTerminals.g1();
  while (_iterator__ex2g4s_0.f()) {
    var item = _iterator__ex2g4s_0.e();
    var tmp$ret$3 = item.tag;
    destination_0.v(tmp$ret$3);
  }
  var expected = toSet(destination_0);
  var errorPos = lastLocation.position + lastLocation.length | 0;
  var errorLength = 1;
  var location = sentence.locationFor(errorPos, errorLength);
  // Inline function 'kotlin.collections.map' call
  // Inline function 'kotlin.collections.mapTo' call
  var destination_1 = ArrayList.a1(collectionSizeOrDefault(nextExpected, 10));
  var _iterator__ex2g4s_1 = nextExpected.g1();
  while (_iterator__ex2g4s_1.f()) {
    var item_0 = _iterator__ex2g4s_1.e();
    var tmp$ret$6 = last(item_0.elements).rule.tag;
    destination_1.v(tmp$ret$6);
  }
  var p = joinToString(sorted(toSet(destination_1)), ' | ');
  var contextInText = sentence.contextInText(location.position);
  var message = 'Failed to match {' + p + '} at: ' + contextInText;
  $this.u1t_1.error(location, message, expected);
}
function findReverseStartPosition($this, sentenceText, position, options) {
  var previousText = substring(sentenceText, 0, position);
  var tmp;
  if (options.reverseFindWordStartBySkipRules) {
    var tmp0_safe_receiver = $this.s1t_1.skipParserStateSet;
    var tmp_0;
    if (tmp0_safe_receiver == null) {
      tmp_0 = null;
    } else {
      // Inline function 'kotlin.let' call
      // Inline function 'kotlin.collections.mapNotNull' call
      var tmp0 = tmp0_safe_receiver.usedTerminalRules;
      // Inline function 'kotlin.collections.mapNotNullTo' call
      var destination = ArrayList.o1();
      // Inline function 'kotlin.collections.forEach' call
      var _iterator__ex2g4s = tmp0.g1();
      while (_iterator__ex2g4s.f()) {
        var element = _iterator__ex2g4s.e();
        var tmp_1 = element.rhs;
        var tmp0_safe_receiver_0 = (tmp_1 instanceof RuntimeRuleRhsTerminal ? tmp_1 : THROW_CCE()).matchable;
        if (tmp0_safe_receiver_0 == null)
          null;
        else {
          // Inline function 'kotlin.let' call
          destination.v(tmp0_safe_receiver_0);
        }
      }
      tmp_0 = destination;
    }
    var matchables = tmp_0;
    var tmp_2;
    if (matchables == null) {
      tmp_2 = 0;
    } else {
      var tmp2_elvis_lhs = findLastMatchOf2($this, previousText, matchables);
      var revPos = tmp2_elvis_lhs == null ? position : tmp2_elvis_lhs;
      tmp_2 = revPos;
    }
    tmp = tmp_2;
  } else if (!(null == options.reverseFindWordStartRegex)) {
    // Inline function 'kotlin.text.toRegex' call
    var this_0 = ensureNotNull(options.reverseFindWordStartRegex);
    var regex = Regex.jf(this_0);
    // Inline function 'kotlin.text.reversed' call
    // Inline function 'kotlin.let' call
    var it = toString(reversed(isCharSequence(previousText) ? previousText : THROW_CCE()));
    var tmp0_safe_receiver_1 = regex.mf(it);
    var tmp1_safe_receiver = tmp0_safe_receiver_1 == null ? null : tmp0_safe_receiver_1.eg();
    var tmp3_elvis_lhs = tmp1_safe_receiver == null ? null : tmp1_safe_receiver.jg();
    tmp = tmp3_elvis_lhs == null ? 0 : tmp3_elvis_lhs;
  } else {
    tmp = 0;
  }
  return tmp;
}
function findLastMatchOf2($this, text, matchables) {
  var str = joinToString(matchables, '|', VOID, VOID, VOID, VOID, LeftCornerParser$findLastMatchOf2$lambda);
  // Inline function 'kotlin.text.toRegex' call
  var regex = Regex.jf(str);
  var pos = text.length - 1 | 0;
  var lastMatchLen = null;
  $l$loop: while (null == lastMatchLen && pos >= 0) {
    var match = regex.pf(text, pos);
    if (null != match) {
      if ((text.length - 1 | 0) === match.eg().dk_1) {
        lastMatchLen = pos + match.b2().length | 0;
      } else {
        lastMatchLen = null;
        break $l$loop;
      }
    }
    pos = pos - 1 | 0;
  }
  var tmp0_safe_receiver = lastMatchLen;
  var tmp;
  if (tmp0_safe_receiver == null) {
    tmp = null;
  } else {
    // Inline function 'kotlin.let' call
    tmp = text.length - tmp0_safe_receiver | 0;
  }
  return tmp;
}
function LeftCornerParser$findLastMatchOf2$lambda(it) {
  return it.kind.q3_1 === 0 ? '' : '(' + it.expression.escapedForRegex + ')';
}
var Companion_instance_10;
function Companion_getInstance_10() {
  if (Companion_instance_10 === VOID)
    new Companion_10();
  return Companion_instance_10;
}
function growHead($this, head, possibleEndOfText, growArgs) {
  return head.h19() ? growGoal($this, head, possibleEndOfText, growArgs) : head.o1c() ? growComplete_0($this, head, possibleEndOfText, growArgs) : growIncomplete_0($this, head, possibleEndOfText, growArgs);
}
function growGoal($this, head, possibleEndOfText, parseArgs) {
  var tmp;
  if (head.o1c()) {
    $this.y1s_1.l1v(head);
    $this.y1s_1.m1v(head);
    if (false) {
      var tmp_0 = Debug_instance;
      var tmp_1 = IndentDelta_NONE_getInstance();
      tmp_0.debug(tmp_1, RuntimeParserAgl$growGoal$lambda(head));
    }
    tmp = false;
  } else {
    var runtimeContext = new RuntimeContext(head, null, null);
    var grown = false;
    // Inline function 'kotlin.collections.mutableSetOf' call
    var transTaken = LinkedHashSet.j1();
    var transitions = head.x1u_1.j1v($this.s1s_1.startState);
    var trans2 = resolveTransitionAmbiguity($this, runtimeContext, transitions, possibleEndOfText, parseArgs);
    if (false) {
      var tmp_2 = Debug_instance;
      var tmp_3 = IndentDelta_NONE_getInstance();
      tmp_2.debug(tmp_3, RuntimeParserAgl$growGoal$lambda_0(trans2));
    }
    var _iterator__ex2g4s = trans2.g1();
    while (_iterator__ex2g4s.f()) {
      var tr = _iterator__ex2g4s.e();
      var tmp_4;
      switch (tr.g1n_1.q3_1) {
        case 2:
          tmp_4 = doWidth_0($this, head, tr, possibleEndOfText, parseArgs);
          break;
        case 4:
          tmp_4 = $this.k1v(head, tr, possibleEndOfText, parseArgs);
          break;
        default:
          var message = 'Internal Error: should only have WIDTH or EMBED transitions here';
          throw IllegalStateException.t4(toString(message));
      }
      var b = tmp_4;
      if (b) {
        transTaken.v(tr);
      }
      grown = grown || b;
    }
    if (!grown) {
      doNoTransitionsTaken($this, head);
    }
    tmp = grown;
  }
  return tmp;
}
function growIncomplete_0($this, head, possibleEndOfText, parseArgs) {
  var grown = false;
  var prevSet = $this.y1s_1.n1v(head);
  // Inline function 'kotlin.collections.mutableSetOf' call
  var transTaken = LinkedHashSet.j1();
  var _iterator__ex2g4s = prevSet.g1();
  while (_iterator__ex2g4s.f()) {
    var previous = _iterator__ex2g4s.e();
    var runtimeContext = new RuntimeContext(head, previous, null);
    var transitions = head.x1u_1.o1v(previous.i1c());
    var trans2 = resolveTransitionAmbiguity($this, runtimeContext, transitions, possibleEndOfText, parseArgs);
    if (false) {
      var tmp = Debug_instance;
      var tmp_0 = IndentDelta_NONE_getInstance();
      tmp.debug(tmp_0, RuntimeParserAgl$growIncomplete$lambda(trans2));
    }
    var _iterator__ex2g4s_0 = trans2.g1();
    while (_iterator__ex2g4s_0.f()) {
      var tr = _iterator__ex2g4s_0.e();
      var tmp_1;
      switch (tr.g1n_1.q3_1) {
        case 2:
          tmp_1 = doWidth_0($this, head, tr, possibleEndOfText, parseArgs);
          break;
        case 4:
          tmp_1 = $this.k1v(head, tr, possibleEndOfText, parseArgs);
          break;
        default:
          var message = 'Internal Error: should only have WIDTH or EMBED transitions here';
          throw IllegalStateException.t4(toString(message));
      }
      var b = tmp_1;
      if (b) {
        transTaken.v(tr);
      }
      grown = grown || b;
    }
  }
  if (!grown) {
    doNoTransitionsTaken($this, head);
  }
  return grown;
}
function growComplete_0($this, head, possibleEndOfText, growArgs) {
  var headGrownHeight = false;
  var headGrownGraft = false;
  var prevSet = $this.y1s_1.n1v(head);
  // Inline function 'kotlin.collections.mutableMapOf' call
  var dropPrevs = LinkedHashMap.j4();
  var _iterator__ex2g4s = prevSet.g1();
  while (_iterator__ex2g4s.f()) {
    var previous = _iterator__ex2g4s.e();
    var prevGrownHeight = false;
    var prevGrownGraft = false;
    var prevPrevSet = $this.y1s_1.n1v(previous);
    if (prevPrevSet.l1()) {
      var _destruct__k2r9zo = growComplete2_0($this, head, previous, null, possibleEndOfText, growArgs);
      var h = _destruct__k2r9zo.ni();
      var g = _destruct__k2r9zo.oi();
      prevGrownHeight = prevGrownHeight || h;
      prevGrownGraft = prevGrownGraft || g;
    } else {
      var _iterator__ex2g4s_0 = prevPrevSet.g1();
      while (_iterator__ex2g4s_0.f()) {
        var prevPrev = _iterator__ex2g4s_0.e();
        var _destruct__k2r9zo_0 = growComplete2_0($this, head, previous, prevPrev, possibleEndOfText, growArgs);
        var h_0 = _destruct__k2r9zo_0.ni();
        var g_0 = _destruct__k2r9zo_0.oi();
        prevGrownHeight = prevGrownHeight || h_0;
        prevGrownGraft = prevGrownGraft || g_0;
      }
    }
    if (!prevGrownHeight) {
      // Inline function 'kotlin.collections.set' call
      var value = prevGrownGraft;
      dropPrevs.f3(previous, value);
    }
    headGrownHeight = headGrownHeight || prevGrownHeight;
    headGrownGraft = headGrownGraft || prevGrownGraft;
  }
  if (!headGrownHeight && !headGrownGraft) {
    doNoTransitionsTaken($this, head);
  } else if (headGrownHeight && !headGrownGraft) {
    $this.y1s_1.m1v(head);
    if (false) {
      var tmp = Debug_instance;
      var tmp_0 = IndentDelta_NONE_getInstance();
      tmp.debug(tmp_0, RuntimeParserAgl$growComplete$lambda(head));
    }
  } else if (!headGrownHeight && headGrownGraft) {
    $this.y1s_1.m1v(head);
    if (false) {
      var tmp_1 = Debug_instance;
      var tmp_2 = IndentDelta_NONE_getInstance();
      tmp_1.debug(tmp_2, RuntimeParserAgl$growComplete$lambda_0(head));
    }
  } else if (headGrownHeight && headGrownGraft) {
    $this.y1s_1.m1v(head);
    if (false) {
      var tmp_3 = Debug_instance;
      var tmp_4 = IndentDelta_NONE_getInstance();
      tmp_3.debug(tmp_4, RuntimeParserAgl$growComplete$lambda_1(head));
    }
  }
  // Inline function 'kotlin.collections.forEach' call
  // Inline function 'kotlin.collections.iterator' call
  var _iterator__ex2g4s_1 = dropPrevs.z1().g1();
  while (_iterator__ex2g4s_1.f()) {
    var element = _iterator__ex2g4s_1.e();
    if (element.b2()) {
      $this.y1s_1.m1v(element.a2());
      if (false) {
        var tmp_5 = Debug_instance;
        var tmp_6 = IndentDelta_NONE_getInstance();
        tmp_5.debug(tmp_6, RuntimeParserAgl$growComplete$lambda_2(element));
      }
    } else {
      doNoTransitionsTaken($this, element.a2());
    }
  }
  return headGrownHeight || headGrownGraft;
}
function matchedLookahead($this, position, lookahead, possibleEndOfText, runtimeLhs, acceptEOT) {
  var tmp;
  // Inline function 'kotlin.collections.map' call
  // Inline function 'kotlin.collections.mapTo' call
  var destination = ArrayList.a1(collectionSizeOrDefault(lookahead, 10));
  var _iterator__ex2g4s = lookahead.g1();
  while (_iterator__ex2g4s.f()) {
    var item = _iterator__ex2g4s.e();
    var tmp$ret$0 = item.guardLookaheadSet.b1m();
    destination.v(tmp$ret$0);
  }
  // Inline function 'kotlin.collections.fold' call
  var accumulator = Companion_getInstance_7().EMPTY;
  var _iterator__ex2g4s_0 = destination.g1();
  while (_iterator__ex2g4s_0.f()) {
    var element = _iterator__ex2g4s_0.e();
    accumulator = accumulator.union(element);
  }
  var lh1 = accumulator;
  // Inline function 'kotlin.collections.map' call
  // Inline function 'kotlin.collections.mapTo' call
  var destination_0 = ArrayList.a1(collectionSizeOrDefault(possibleEndOfText, 10));
  var _iterator__ex2g4s_1 = possibleEndOfText.g1();
  while (_iterator__ex2g4s_1.f()) {
    var item_0 = _iterator__ex2g4s_1.e();
    var tmp$ret$5 = item_0.b1m();
    destination_0.v(tmp$ret$5);
  }
  // Inline function 'kotlin.collections.fold' call
  var accumulator_0 = Companion_getInstance_7().EMPTY;
  var _iterator__ex2g4s_2 = destination_0.g1();
  while (_iterator__ex2g4s_2.f()) {
    var element_0 = _iterator__ex2g4s_2.e();
    accumulator_0 = accumulator_0.union(element_0);
  }
  var eot = accumulator_0;
  // Inline function 'kotlin.collections.map' call
  // Inline function 'kotlin.collections.mapTo' call
  var destination_1 = ArrayList.a1(collectionSizeOrDefault(runtimeLhs, 10));
  var _iterator__ex2g4s_3 = runtimeLhs.g1();
  while (_iterator__ex2g4s_3.f()) {
    var item_1 = _iterator__ex2g4s_3.e();
    var tmp$ret$10 = item_1.b1m();
    destination_1.v(tmp$ret$10);
  }
  // Inline function 'kotlin.collections.fold' call
  var accumulator_1 = Companion_getInstance_7().EMPTY;
  var _iterator__ex2g4s_4 = destination_1.g1();
  while (_iterator__ex2g4s_4.f()) {
    var element_1 = _iterator__ex2g4s_4.e();
    accumulator_1 = accumulator_1.union(element_1);
  }
  var rt = accumulator_1;
  var tmp_0;
  switch (acceptEOT) {
    case true:
      tmp_0 = lh1.union(Companion_getInstance_7().EOT);
      break;
    case false:
      tmp_0 = lh1;
      break;
    default:
      noWhenBranchMatchedException();
      break;
  }
  var lh = tmp_0;
  var lookingAt = $this.y1s_1.p1v(lh, eot, rt, position);
  var resolved = lh.resolve(eot, rt);
  tmp = new Pair(lookingAt, resolved);
  return tmp;
}
function growComplete2_0($this, head, previous, prevPrev, possibleEndOfText, parseArgs) {
  var runtimeContext = new RuntimeContext(head, previous, prevPrev);
  var grownHeight = false;
  var grownGraft = false;
  var tmp = previous.i1c();
  var tmp1_elvis_lhs = prevPrev == null ? null : prevPrev.i1c();
  var transitions = head.x1u_1.q1v(tmp, tmp1_elvis_lhs == null ? $this.s1s_1.startState : tmp1_elvis_lhs);
  var trans2 = resolveTransitionAmbiguity($this, runtimeContext, transitions, possibleEndOfText, parseArgs);
  if (false) {
    var tmp_0 = Debug_instance;
    var tmp_1 = IndentDelta_NONE_getInstance();
    tmp_0.debug(tmp_1, RuntimeParserAgl$growComplete2$lambda(trans2));
  }
  // Inline function 'kotlin.collections.groupBy' call
  // Inline function 'kotlin.collections.groupByTo' call
  var destination = LinkedHashMap.j4();
  var _iterator__ex2g4s = trans2.g1();
  while (_iterator__ex2g4s.f()) {
    var element = _iterator__ex2g4s.e();
    var key = element.f1n_1.runtimeRulesAsSet;
    // Inline function 'kotlin.collections.getOrPut' call
    var value = destination.c3(key);
    var tmp_2;
    if (value == null) {
      var answer = ArrayList.o1();
      destination.f3(key, answer);
      tmp_2 = answer;
    } else {
      tmp_2 = value;
    }
    var list = tmp_2;
    list.v(element);
  }
  var grouped = destination;
  // Inline function 'kotlin.collections.iterator' call
  var _iterator__ex2g4s_0 = grouped.z1().g1();
  while (_iterator__ex2g4s_0.f()) {
    var grp = _iterator__ex2g4s_0.e();
    if (1 === grp.b2().h1()) {
      var tr = grp.b2().i1(0);
      switch (tr.g1n_1.q3_1) {
        case 0:
          var b = doHeight_0($this, head, previous, tr, possibleEndOfText, parseArgs);
          grownHeight = grownHeight || b;
          break;
        case 1:
          var b_0 = doGraft_0($this, head, previous, prevPrev, tr, possibleEndOfText, parseArgs);
          grownGraft = grownGraft || b_0;
          break;
        case 3:
          var b_1 = doGoal_0($this, head, previous, tr, possibleEndOfText, parseArgs);
          grownGraft = grownGraft || b_1;
          break;
        default:
          // Inline function 'kotlin.error' call

          var message = 'Internal Error: should only have GOAL, HEIGHT or GRAFT transitions here';
          throw IllegalStateException.t4(toString(message));
      }
    } else {
      // Inline function 'kotlin.collections.mutableListOf' call
      var trgs = ArrayList.o1();
      // Inline function 'kotlin.collections.mutableListOf' call
      var trhs = ArrayList.o1();
      var _iterator__ex2g4s_1 = grp.b2().g1();
      while (_iterator__ex2g4s_1.f()) {
        var tr_0 = _iterator__ex2g4s_1.e();
        switch (tr_0.g1n_1.q3_1) {
          case 1:
            trgs.v(tr_0);
            break;
          case 0:
            trhs.v(tr_0);
            break;
          default:
            // Inline function 'kotlin.error' call

            var message_0 = 'should not happen';
            throw IllegalStateException.t4(toString(message_0));
        }
      }
      var tmp_3 = RuntimeParserAgl$growComplete2$lambda_0;
      sortWith(trgs, new sam$kotlin_Comparator$0_4(tmp_3));
      var tmp_4;
      // Inline function 'kotlin.collections.isNotEmpty' call
      if (!trgs.l1()) {
        // Inline function 'kotlin.collections.isNotEmpty' call
        tmp_4 = !trhs.l1();
      } else {
        tmp_4 = false;
      }
      if (tmp_4) {
        var doneIt = false;
        var i = 0;
        while (!doneIt && i < trgs.h1()) {
          var b_2 = doGraft_0($this, head, previous, prevPrev, trgs.i1(i), possibleEndOfText, parseArgs);
          grownGraft = grownGraft || b_2;
          doneIt = doneIt || b_2;
          i = i + 1 | 0;
        }
        i = 0;
        while (!doneIt && i < trhs.h1()) {
          var b_3 = doHeight_0($this, head, previous, trhs.i1(i), possibleEndOfText, parseArgs);
          grownHeight = grownHeight || b_3;
          doneIt = doneIt || b_3;
          i = i + 1 | 0;
        }
      } else {
        var _iterator__ex2g4s_2 = grp.b2().g1();
        while (_iterator__ex2g4s_2.f()) {
          var tr_1 = _iterator__ex2g4s_2.e();
          switch (tr_1.g1n_1.q3_1) {
            case 0:
              var b_4 = doHeight_0($this, head, previous, tr_1, possibleEndOfText, parseArgs);
              grownHeight = grownHeight || b_4;
              break;
            case 1:
              var b_5 = doGraft_0($this, head, previous, prevPrev, tr_1, possibleEndOfText, parseArgs);
              grownGraft = grownGraft || b_5;
              break;
            case 3:
              var b_6 = doGoal_0($this, head, previous, tr_1, possibleEndOfText, parseArgs);
              grownGraft = grownGraft || b_6;
              break;
            default:
              // Inline function 'kotlin.error' call

              var message_1 = 'Internal Error: should only have HEIGHT or GRAFT or GOAL transitions here';
              throw IllegalStateException.t4(toString(message_1));
          }
        }
      }
    }
  }
  return new Pair(grownHeight, grownGraft);
}
function resolveGrafts1($this, grafts) {
  var tmp = RuntimeParserAgl$resolveGrafts1$lambda;
  sortedWith(grafts, new sam$kotlin_Comparator$0_5(tmp));
  return listOf(last(grafts).hi_1);
}
function resolveTransitionAmbiguity($this, runtimeContext, transitions, possibleEndOfText, parseArgs) {
  var tmp;
  if (runtimeContext.r1v_1.o1c()) {
    if (null == runtimeContext.s1v_1) {
      // Inline function 'kotlin.error' call
      var message = 'previous must have a value if head is incomplete';
      throw IllegalStateException.t4(toString(message));
    }
    var tmp_0;
    if (parseArgs.noLookahead) {
      // Inline function 'kotlin.collections.map' call
      // Inline function 'kotlin.collections.mapTo' call
      var destination = ArrayList.a1(collectionSizeOrDefault(transitions, 10));
      var _iterator__ex2g4s = transitions.g1();
      while (_iterator__ex2g4s.f()) {
        var item = _iterator__ex2g4s.e();
        var tmp$ret$0 = new Pair(item, Companion_getInstance_7().ANY);
        destination.v(tmp$ret$0);
      }
      tmp_0 = destination;
    } else {
      // Inline function 'kotlin.collections.mapNotNull' call
      // Inline function 'kotlin.collections.mapNotNullTo' call
      var destination_0 = ArrayList.o1();
      // Inline function 'kotlin.collections.forEach' call
      var _iterator__ex2g4s_0 = transitions.g1();
      while (_iterator__ex2g4s_0.f()) {
        var element = _iterator__ex2g4s_0.e();
        var m = matchedLookahead($this, runtimeContext.r1v_1.a1v_1, element.lookaheadGuard, possibleEndOfText, runtimeContext.s1v_1.x1u_1.g1v_1, parseArgs.allowEOTAfterSkip);
        var tmp0_safe_receiver = m.hi_1 ? new Pair(element, m.ii_1) : null;
        if (tmp0_safe_receiver == null)
          null;
        else {
          // Inline function 'kotlin.let' call
          destination_0.v(tmp0_safe_receiver);
        }
      }
      tmp_0 = destination_0;
    }
    var transWithValidLookahead = tmp_0;
    // Inline function 'kotlin.collections.map' call
    // Inline function 'kotlin.collections.mapTo' call
    var destination_1 = ArrayList.a1(collectionSizeOrDefault(transWithValidLookahead, 10));
    var _iterator__ex2g4s_1 = transWithValidLookahead.g1();
    while (_iterator__ex2g4s_1.f()) {
      var item_0 = _iterator__ex2g4s_1.e();
      var tmp$ret$10 = item_0.hi_1;
      destination_1.v(tmp$ret$10);
    }
    // Inline function 'kotlin.collections.forEach' call
    var _iterator__ex2g4s_2 = minus_0(transitions, destination_1).g1();
    while (_iterator__ex2g4s_2.f()) {
      var element_0 = _iterator__ex2g4s_2.e();
      switch (element_0.g1n_1.q3_1) {
        case 0:
          recordFailedHeightLh($this, parseArgs, runtimeContext.r1v_1, element_0, runtimeContext.s1v_1.x1u_1.g1v_1, possibleEndOfText);
          break;
        case 1:
          recordFailedGraftLH($this, parseArgs, runtimeContext.r1v_1, element_0, runtimeContext.s1v_1.x1u_1.g1v_1, possibleEndOfText);
          break;
        case 3:
          recordFailedGraftLH($this, parseArgs, runtimeContext.r1v_1, element_0, runtimeContext.s1v_1.x1u_1.g1v_1, possibleEndOfText);
          break;
        default:
          // Inline function 'kotlin.error' call

          var message_0 = 'Internal Error: should never happen - transition is: ' + element_0.toString();
          throw IllegalStateException.t4(toString(message_0));
      }
    }
    tmp = resolvePrecedence($this, transWithValidLookahead, runtimeContext);
  } else {
    tmp = transitions;
  }
  var trans2 = tmp;
  if (parseArgs.reportGrammarAmbiguities && trans2.h1() > 1) {
    ambiguity($this, runtimeContext, trans2, possibleEndOfText);
  }
  return trans2;
}
function precedenceSpineMatches($this, prOpt, to, runtimeContext) {
  var optSpineRev = reversed_0(prOpt.v1v_1);
  var tmp;
  if (optSpineRev.h1() > 2) {
    var message = 'Unsupported';
    throw IllegalStateException.t4(toString(message));
  } else if (!to.l1b_1.equals(prOpt.w1v_1)) {
    tmp = false;
  } else if (!to.k1b_1.equals(first_0(optSpineRev))) {
    tmp = false;
  } else if (optSpineRev.h1() > 1 && !optSpineRev.i1(1).equals(ensureNotNull(runtimeContext.s1v_1).i1c().firstRule)) {
    tmp = false;
  } else {
    tmp = true;
  }
  return tmp;
}
function precedenceFor($this, precRules, to, lh, runtimeContext) {
  // Inline function 'kotlin.collections.filter' call
  var tmp0 = precRules.a1w_1;
  // Inline function 'kotlin.collections.filterTo' call
  var destination = ArrayList.o1();
  var _iterator__ex2g4s = tmp0.g1();
  while (_iterator__ex2g4s.f()) {
    var element = _iterator__ex2g4s.e();
    var tmp$ret$0;
    $l$block_0: {
      // Inline function 'kotlin.collections.any' call
      var tmp;
      if (isInterface(to, Collection)) {
        tmp = to.l1();
      } else {
        tmp = false;
      }
      if (tmp) {
        tmp$ret$0 = false;
        break $l$block_0;
      }
      var _iterator__ex2g4s_0 = to.g1();
      while (_iterator__ex2g4s_0.f()) {
        var element_0 = _iterator__ex2g4s_0.e();
        if (precedenceSpineMatches($this, element, element_0, runtimeContext)) {
          tmp$ret$0 = true;
          break $l$block_0;
        }
      }
      tmp$ret$0 = false;
    }
    var rpMatch = tmp$ret$0;
    var tmp_0;
    if (rpMatch) {
      var tmp0_0 = element.x1v_1;
      var tmp$ret$2;
      $l$block_2: {
        // Inline function 'kotlin.collections.any' call
        var tmp_1;
        if (isInterface(tmp0_0, Collection)) {
          tmp_1 = tmp0_0.l1();
        } else {
          tmp_1 = false;
        }
        if (tmp_1) {
          tmp$ret$2 = false;
          break $l$block_2;
        }
        var _iterator__ex2g4s_1 = tmp0_0.g1();
        while (_iterator__ex2g4s_1.f()) {
          var element_1 = _iterator__ex2g4s_1.e();
          if (lh.fullContent.p1(element_1)) {
            tmp$ret$2 = true;
            break $l$block_2;
          }
        }
        tmp$ret$2 = false;
      }
      tmp_0 = tmp$ret$2;
    } else {
      tmp_0 = false;
    }
    if (tmp_0) {
      destination.v(element);
    }
  }
  var r = destination;
  return r;
}
function resolvePrecedence($this, transitions, runtimeContext) {
  var tmp;
  if (2 > transitions.h1()) {
    // Inline function 'kotlin.collections.map' call
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(transitions, 10));
    var _iterator__ex2g4s = transitions.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var tmp$ret$0 = item.hi_1;
      destination.v(tmp$ret$0);
    }
    tmp = destination;
  } else {
    var precRules = $this.s1s_1.precedenceRulesFor(runtimeContext.r1v_1.i1c());
    var tmp_0;
    if (null == precRules) {
      // Inline function 'kotlin.collections.groupBy' call
      // Inline function 'kotlin.collections.groupByTo' call
      var destination_0 = LinkedHashMap.j4();
      var _iterator__ex2g4s_0 = transitions.g1();
      while (_iterator__ex2g4s_0.f()) {
        var element = _iterator__ex2g4s_0.e();
        var key = element.hi_1.f1n_1.runtimeRulesAsSet;
        // Inline function 'kotlin.collections.getOrPut' call
        var value = destination_0.c3(key);
        var tmp_1;
        if (value == null) {
          var answer = ArrayList.o1();
          destination_0.f3(key, answer);
          tmp_1 = answer;
        } else {
          tmp_1 = value;
        }
        var list = tmp_1;
        list.v(element);
      }
      var toGrp = destination_0;
      // Inline function 'kotlin.collections.flatMap' call
      // Inline function 'kotlin.collections.flatMapTo' call
      var destination_1 = ArrayList.o1();
      // Inline function 'kotlin.collections.iterator' call
      var _iterator__ex2g4s_1 = toGrp.z1().g1();
      while (_iterator__ex2g4s_1.f()) {
        var element_0 = _iterator__ex2g4s_1.e();
        // Inline function 'kotlin.collections.groupBy' call
        var tmp0 = element_0.b2();
        // Inline function 'kotlin.collections.groupByTo' call
        var destination_2 = LinkedHashMap.j4();
        var _iterator__ex2g4s_2 = tmp0.g1();
        while (_iterator__ex2g4s_2.f()) {
          var element_1 = _iterator__ex2g4s_2.e();
          var key_0 = element_1.hi_1.g1n_1;
          // Inline function 'kotlin.collections.getOrPut' call
          var value_0 = destination_2.c3(key_0);
          var tmp_2;
          if (value_0 == null) {
            var answer_0 = ArrayList.o1();
            destination_2.f3(key_0, answer_0);
            tmp_2 = answer_0;
          } else {
            tmp_2 = value_0;
          }
          var list_0 = tmp_2;
          list_0.v(element_1);
        }
        var actGrp = destination_2;
        var tmp_3;
        if (2 > actGrp.h1()) {
          // Inline function 'kotlin.collections.map' call
          var this_0 = element_0.b2();
          // Inline function 'kotlin.collections.mapTo' call
          var destination_3 = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
          var _iterator__ex2g4s_3 = this_0.g1();
          while (_iterator__ex2g4s_3.f()) {
            var item_0 = _iterator__ex2g4s_3.e();
            var tmp$ret$14 = item_0.hi_1;
            destination_3.v(tmp$ret$14);
          }
          tmp_3 = destination_3;
        } else {
          var grafts = ensureNotNull(actGrp.c3(ParseAction_GRAFT_getInstance()));
          tmp_3 = resolveGrafts1($this, grafts);
        }
        var list_1 = tmp_3;
        addAll(destination_1, list_1);
      }
      tmp_0 = destination_1;
    } else {
      // Inline function 'kotlin.collections.flatMap' call
      // Inline function 'kotlin.collections.flatMapTo' call
      var destination_4 = ArrayList.o1();
      var _iterator__ex2g4s_4 = transitions.g1();
      while (_iterator__ex2g4s_4.f()) {
        var element_2 = _iterator__ex2g4s_4.e();
        var tr = element_2.ni();
        var lh = element_2.oi();
        var lhf = lh;
        var prec = precedenceFor($this, precRules, tr.f1n_1.j1i_1, lhf, runtimeContext);
        // Inline function 'kotlin.collections.map' call
        // Inline function 'kotlin.collections.mapTo' call
        var destination_5 = ArrayList.a1(collectionSizeOrDefault(prec, 10));
        var _iterator__ex2g4s_5 = prec.g1();
        while (_iterator__ex2g4s_5.f()) {
          var item_1 = _iterator__ex2g4s_5.e();
          var tmp$ret$20 = new Pair(tr, item_1);
          destination_5.v(tmp$ret$20);
        }
        var list_2 = destination_5;
        addAll(destination_4, list_2);
      }
      var precedence = destination_4;
      var tmp_4;
      if (precedence.l1()) {
        // Inline function 'kotlin.collections.map' call
        // Inline function 'kotlin.collections.mapTo' call
        var destination_6 = ArrayList.a1(collectionSizeOrDefault(transitions, 10));
        var _iterator__ex2g4s_6 = transitions.g1();
        while (_iterator__ex2g4s_6.f()) {
          var item_2 = _iterator__ex2g4s_6.e();
          var tmp$ret$26 = item_2.hi_1;
          destination_6.v(tmp$ret$26);
        }
        tmp_4 = destination_6;
      } else {
        // Inline function 'kotlin.collections.map' call
        // Inline function 'kotlin.collections.mapTo' call
        var destination_7 = ArrayList.a1(collectionSizeOrDefault(precedence, 10));
        var _iterator__ex2g4s_7 = precedence.g1();
        while (_iterator__ex2g4s_7.f()) {
          var item_3 = _iterator__ex2g4s_7.e();
          var tmp$ret$29 = item_3.ii_1.u1v_1;
          destination_7.v(tmp$ret$29);
        }
        var tmp0_elvis_lhs = maxOrNull(destination_7);
        var max = tmp0_elvis_lhs == null ? 0 : tmp0_elvis_lhs;
        // Inline function 'kotlin.collections.filter' call
        // Inline function 'kotlin.collections.filterTo' call
        var destination_8 = ArrayList.o1();
        var _iterator__ex2g4s_8 = precedence.g1();
        while (_iterator__ex2g4s_8.f()) {
          var element_3 = _iterator__ex2g4s_8.e();
          if (max === element_3.ii_1.u1v_1) {
            destination_8.v(element_3);
          }
        }
        var maxPrec = destination_8;
        // Inline function 'kotlin.collections.groupBy' call
        // Inline function 'kotlin.collections.groupByTo' call
        var destination_9 = LinkedHashMap.j4();
        var _iterator__ex2g4s_9 = maxPrec.g1();
        while (_iterator__ex2g4s_9.f()) {
          var element_4 = _iterator__ex2g4s_9.e();
          var key_1 = new Pair(element_4.hi_1.f1n_1.runtimeRules, element_4.ii_1.y1v_1);
          // Inline function 'kotlin.collections.getOrPut' call
          var value_1 = destination_9.c3(key_1);
          var tmp_5;
          if (value_1 == null) {
            var answer_1 = ArrayList.o1();
            destination_9.f3(key_1, answer_1);
            tmp_5 = answer_1;
          } else {
            tmp_5 = value_1;
          }
          var list_3 = tmp_5;
          list_3.v(element_4);
        }
        var byTarget = destination_9;
        // Inline function 'kotlin.collections.flatMap' call
        // Inline function 'kotlin.collections.flatMapTo' call
        var destination_10 = ArrayList.o1();
        // Inline function 'kotlin.collections.iterator' call
        var _iterator__ex2g4s_10 = byTarget.z1().g1();
        while (_iterator__ex2g4s_10.f()) {
          var element_5 = _iterator__ex2g4s_10.e();
          var tmp_6;
          switch (element_5.a2().ii_1.q3_1) {
            case 0:
              tmp_6 = element_5.b2();
              break;
            case 1:
              var tmp_7;
              if (element_5.a2().hi_1.i1(0).isList) {
                // Inline function 'kotlin.collections.filter' call
                var tmp0_0 = element_5.b2();
                // Inline function 'kotlin.collections.filterTo' call
                var destination_11 = ArrayList.o1();
                var _iterator__ex2g4s_11 = tmp0_0.g1();
                while (_iterator__ex2g4s_11.f()) {
                  var element_6 = _iterator__ex2g4s_11.e();
                  if (element_6.hi_1.g1n_1.equals(ParseAction_GRAFT_getInstance())) {
                    destination_11.v(element_6);
                  }
                }
                var grafts_0 = destination_11;
                // Inline function 'kotlin.collections.filter' call
                // Inline function 'kotlin.collections.filterTo' call
                var destination_12 = ArrayList.o1();
                var _iterator__ex2g4s_12 = grafts_0.g1();
                while (_iterator__ex2g4s_12.f()) {
                  var element_7 = _iterator__ex2g4s_12.e();
                  if (!element_7.hi_1.f1n_1.j1i_1.i1(0).isAtEnd) {
                    destination_12.v(element_7);
                  }
                }
                var left = destination_12;
                var tmp_8;
                switch (left.l1()) {
                  case true:
                    tmp_8 = grafts_0;
                    break;
                  case false:
                    tmp_8 = left;
                    break;
                  default:
                    noWhenBranchMatchedException();
                    break;
                }
                tmp_7 = tmp_8;
              } else {
                // Inline function 'kotlin.collections.filter' call
                var tmp0_1 = element_5.b2();
                // Inline function 'kotlin.collections.filterTo' call
                var destination_13 = ArrayList.o1();
                var _iterator__ex2g4s_13 = tmp0_1.g1();
                while (_iterator__ex2g4s_13.f()) {
                  var element_8 = _iterator__ex2g4s_13.e();
                  if (element_8.hi_1.g1n_1.equals(ParseAction_GRAFT_getInstance())) {
                    destination_13.v(element_8);
                  }
                }
                tmp_7 = destination_13;
              }

              tmp_6 = tmp_7;
              break;
            case 2:
              var tmp_9;
              if (element_5.a2().hi_1.i1(0).isList) {
                // Inline function 'kotlin.collections.filter' call
                var tmp0_2 = element_5.b2();
                // Inline function 'kotlin.collections.filterTo' call
                var destination_14 = ArrayList.o1();
                var _iterator__ex2g4s_14 = tmp0_2.g1();
                while (_iterator__ex2g4s_14.f()) {
                  var element_9 = _iterator__ex2g4s_14.e();
                  if (element_9.hi_1.g1n_1.equals(ParseAction_HEIGHT_getInstance())) {
                    destination_14.v(element_9);
                  }
                }
                var heights = destination_14;
                // Inline function 'kotlin.collections.filter' call
                // Inline function 'kotlin.collections.filterTo' call
                var destination_15 = ArrayList.o1();
                var _iterator__ex2g4s_15 = heights.g1();
                while (_iterator__ex2g4s_15.f()) {
                  var element_10 = _iterator__ex2g4s_15.e();
                  if (!element_10.hi_1.f1n_1.j1i_1.i1(0).isAtEnd) {
                    destination_15.v(element_10);
                  }
                }
                var right = destination_15;
                var tmp_10;
                switch (right.l1()) {
                  case true:
                    tmp_10 = heights;
                    break;
                  case false:
                    tmp_10 = right;
                    break;
                  default:
                    noWhenBranchMatchedException();
                    break;
                }
                tmp_9 = tmp_10;
              } else {
                // Inline function 'kotlin.collections.filter' call
                var tmp0_3 = element_5.b2();
                // Inline function 'kotlin.collections.filterTo' call
                var destination_16 = ArrayList.o1();
                var _iterator__ex2g4s_16 = tmp0_3.g1();
                while (_iterator__ex2g4s_16.f()) {
                  var element_11 = _iterator__ex2g4s_16.e();
                  if (element_11.hi_1.g1n_1.equals(ParseAction_HEIGHT_getInstance())) {
                    destination_16.v(element_11);
                  }
                }
                tmp_9 = destination_16;
              }

              tmp_6 = tmp_9;
              break;
            default:
              noWhenBranchMatchedException();
              break;
          }
          var list_4 = tmp_6;
          addAll(destination_10, list_4);
        }
        var assoc = destination_10;
        var tmp_11;
        if (assoc.h1() === 0) {
          // Inline function 'kotlin.collections.map' call
          // Inline function 'kotlin.collections.mapTo' call
          var destination_17 = ArrayList.a1(collectionSizeOrDefault(maxPrec, 10));
          var _iterator__ex2g4s_17 = maxPrec.g1();
          while (_iterator__ex2g4s_17.f()) {
            var item_4 = _iterator__ex2g4s_17.e();
            var tmp$ret$62 = item_4.hi_1;
            destination_17.v(tmp$ret$62);
          }
          tmp_11 = destination_17;
        } else {
          // Inline function 'kotlin.collections.map' call
          // Inline function 'kotlin.collections.mapTo' call
          var destination_18 = ArrayList.a1(collectionSizeOrDefault(assoc, 10));
          var _iterator__ex2g4s_18 = assoc.g1();
          while (_iterator__ex2g4s_18.f()) {
            var item_5 = _iterator__ex2g4s_18.e();
            var tmp$ret$65 = item_5.hi_1;
            destination_18.v(tmp$ret$65);
          }
          tmp_11 = destination_18;
        }
        tmp_4 = tmp_11;
      }
      tmp_0 = tmp_4;
    }
    tmp = tmp_0;
  }
  return tmp;
}
function doNoTransitionsTaken($this, head) {
  $this.y1s_1.m1v(head);
  if (false) {
    var tmp = Debug_instance;
    var tmp_0 = IndentDelta_NONE_getInstance();
    tmp.debug(tmp_0, RuntimeParserAgl$doNoTransitionsTaken$lambda(head));
  }
}
function doGoal_0($this, head, previous, transition, possibleEndOfText, growArgs) {
  var tmp;
  if (growArgs.nonEmptyWidthOnly) {
    tmp = false;
  } else {
    var tmp_0;
    if (transition.runtimeGuard.execute(ensureNotNull(previous).b1v_1)) {
      var runtimeLhs = head.x1u_1.g1v_1;
      // Inline function 'kotlin.collections.filter' call
      var tmp0 = transition.lookaheadGuard;
      // Inline function 'kotlin.collections.filterTo' call
      var destination = ArrayList.o1();
      var _iterator__ex2g4s = tmp0.g1();
      while (_iterator__ex2g4s.f()) {
        var element = _iterator__ex2g4s.e();
        var tmp$ret$0;
        $l$block_2: {
          // Inline function 'kotlin.collections.any' call
          var tmp_1;
          if (isInterface(possibleEndOfText, Collection)) {
            tmp_1 = possibleEndOfText.l1();
          } else {
            tmp_1 = false;
          }
          if (tmp_1) {
            tmp$ret$0 = false;
            break $l$block_2;
          }
          var _iterator__ex2g4s_0 = possibleEndOfText.g1();
          while (_iterator__ex2g4s_0.f()) {
            var element_0 = _iterator__ex2g4s_0.e();
            var tmp$ret$1;
            $l$block_1: {
              // Inline function 'kotlin.collections.any' call
              var tmp_2;
              if (isInterface(runtimeLhs, Collection)) {
                tmp_2 = runtimeLhs.l1();
              } else {
                tmp_2 = false;
              }
              if (tmp_2) {
                tmp$ret$1 = false;
                break $l$block_1;
              }
              var _iterator__ex2g4s_1 = runtimeLhs.g1();
              while (_iterator__ex2g4s_1.f()) {
                var element_1 = _iterator__ex2g4s_1.e();
                if ($this.y1s_1.b1w(element.guardLookaheadSet, element_0, element_1, head.a1v_1)) {
                  tmp$ret$1 = true;
                  break $l$block_1;
                }
              }
              tmp$ret$1 = false;
            }
            if (tmp$ret$1) {
              tmp$ret$0 = true;
              break $l$block_2;
            }
          }
          tmp$ret$0 = false;
        }
        if (tmp$ret$0) {
          destination.v(element);
        }
      }
      var lhWithMatch = destination;
      // Inline function 'kotlin.collections.isNotEmpty' call
      var hasLh = !lhWithMatch.l1();
      var tmp_3;
      if (growArgs.noLookahead || hasLh) {
        if (false) {
          var tmp_4 = Debug_instance;
          var tmp_5 = IndentDelta_NONE_getInstance();
          tmp_4.debug(tmp_5, RuntimeParserAgl$doGoal$lambda(head, transition));
        }
        tmp_3 = $this.y1s_1.c1w(head, previous, null, transition.f1n_1, runtimeLhs);
      } else {
        tmp_3 = false;
      }
      tmp_0 = tmp_3;
    } else {
      tmp_0 = false;
    }
    tmp = tmp_0;
  }
  return tmp;
}
function doWidth_0($this, head, transition, possibleEndOfText, parseArgs) {
  var tmp;
  if (parseArgs.heightGraftOnly) {
    tmp = false;
  } else if (parseArgs.nonEmptyWidthOnly && (transition.f1n_1.firstRule.isEmptyTerminal || transition.f1n_1.firstRule.isEmptyListTerminal)) {
    tmp = false;
  } else {
    var l = $this.y1s_1.z1t_1.findOrTryCreateLeaf($this.q1s_1, head.a1v_1, transition.f1n_1.firstRule);
    var tmp_0;
    if (!(null == l)) {
      // Inline function 'kotlin.collections.map' call
      var this_0 = transition.lookaheadGuard;
      // Inline function 'kotlin.collections.mapTo' call
      var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
      var _iterator__ex2g4s = this_0.g1();
      while (_iterator__ex2g4s.f()) {
        var item = _iterator__ex2g4s.e();
        var tmp$ret$0 = item.guardLookaheadSet;
        destination.v(tmp$ret$0);
      }
      // Inline function 'kotlin.collections.reduce' call
      var iterator = destination.g1();
      if (!iterator.f())
        throw UnsupportedOperationException.g9("Empty collection can't be reduced.");
      var accumulator = iterator.e();
      while (iterator.f()) {
        var tmp0 = accumulator;
        var e = iterator.e();
        accumulator = tmp0.o1l($this.s1s_1, e);
      }
      var lh1 = accumulator;
      var tmp_1;
      switch (parseArgs.allowEOTAfterSkip) {
        case true:
          tmp_1 = lh1.o1l($this.s1s_1, Companion_getInstance_3().EOT);
          break;
        case false:
          tmp_1 = lh1;
          break;
        default:
          noWhenBranchMatchedException();
          break;
      }
      var lh = tmp_1;
      var runtimeLhs = head.x1u_1.g1v_1;
      var _destruct__k2r9zo = $this.d1w(head.a1v_1, l.nextInputPosition, runtimeLhs, lh, possibleEndOfText, parseArgs);
      var skipData = _destruct__k2r9zo.ni();
      var skipFailed = _destruct__k2r9zo.oi();
      var tmp_2;
      if (!skipFailed || get_isEmptyMatch(l)) {
        var tmp2_safe_receiver = skipData == null ? null : skipData.root;
        var tmp3_elvis_lhs = tmp2_safe_receiver == null ? null : tmp2_safe_receiver.nextInputNoSkip;
        var nextInputPositionAfterSkip = tmp3_elvis_lhs == null ? l.nextInputPosition : tmp3_elvis_lhs;
        var tmp$ret$5;
        $l$block_2: {
          // Inline function 'kotlin.collections.any' call
          var tmp_3;
          if (isInterface(possibleEndOfText, Collection)) {
            tmp_3 = possibleEndOfText.l1();
          } else {
            tmp_3 = false;
          }
          if (tmp_3) {
            tmp$ret$5 = false;
            break $l$block_2;
          }
          var _iterator__ex2g4s_0 = possibleEndOfText.g1();
          while (_iterator__ex2g4s_0.f()) {
            var element = _iterator__ex2g4s_0.e();
            var tmp$ret$6;
            $l$block_1: {
              // Inline function 'kotlin.collections.any' call
              var tmp_4;
              if (isInterface(runtimeLhs, Collection)) {
                tmp_4 = runtimeLhs.l1();
              } else {
                tmp_4 = false;
              }
              if (tmp_4) {
                tmp$ret$6 = false;
                break $l$block_1;
              }
              var _iterator__ex2g4s_1 = runtimeLhs.g1();
              while (_iterator__ex2g4s_1.f()) {
                var element_0 = _iterator__ex2g4s_1.e();
                if ($this.y1s_1.b1w(lh, element, element_0, nextInputPositionAfterSkip)) {
                  tmp$ret$6 = true;
                  break $l$block_1;
                }
              }
              tmp$ret$6 = false;
            }
            if (tmp$ret$6) {
              tmp$ret$5 = true;
              break $l$block_2;
            }
          }
          tmp$ret$5 = false;
        }
        var hasLh = tmp$ret$5;
        var tmp_5;
        if (parseArgs.noLookahead || hasLh) {
          var startPosition = l.startPosition;
          var nextInputPosition = l.nextInputPosition;
          if (false) {
            var tmp_6 = Debug_instance;
            var tmp_7 = IndentDelta_NONE_getInstance();
            tmp_6.debug(tmp_7, RuntimeParserAgl$doWidth$lambda(head, transition));
          }
          tmp_5 = $this.y1s_1.e1w(head, transition.f1n_1, setOf(Companion_getInstance_3().EMPTY), startPosition, nextInputPosition, skipData);
        } else {
          var tmp_8;
          var tmp_9;
          if (!(null == $this.c1t_1)) {
            // Inline function 'kotlin.collections.isNotEmpty' call
            tmp_9 = !$this.c1t_1.z1s_1.l1();
          } else {
            tmp_9 = false;
          }
          if (tmp_9) {
            tmp_8 = max($this.c1t_1.z1s_1.d3());
          } else {
            tmp_8 = nextInputPositionAfterSkip;
          }
          var pos = tmp_8;
          recordFailedWidthLH($this, parseArgs, head, pos, transition, runtimeLhs, possibleEndOfText);
          tmp_5 = false;
        }
        tmp_2 = tmp_5;
      } else {
        recordFailedExpectedSkipAfter($this, parseArgs, head, l, transition);
        tmp_2 = false;
      }
      tmp_0 = tmp_2;
    } else {
      recordFailedWidthTo($this, parseArgs, head, transition);
      tmp_0 = false;
    }
    tmp = tmp_0;
  }
  return tmp;
}
function doHeight_0($this, head, previous, transition, possibleEndOfText, parseArgs) {
  var tmp;
  if (parseArgs.nonEmptyWidthOnly) {
    tmp = false;
  } else {
    var runtimeLhs = ensureNotNull(previous).x1u_1.g1v_1;
    // Inline function 'kotlin.collections.flatMap' call
    var tmp0 = transition.lookaheadGuard;
    // Inline function 'kotlin.collections.flatMapTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      // Inline function 'kotlin.collections.flatMap' call
      // Inline function 'kotlin.collections.flatMapTo' call
      var destination_0 = ArrayList.o1();
      var _iterator__ex2g4s_0 = possibleEndOfText.g1();
      while (_iterator__ex2g4s_0.f()) {
        var element_0 = _iterator__ex2g4s_0.e();
        // Inline function 'kotlin.collections.mapNotNull' call
        // Inline function 'kotlin.collections.mapNotNullTo' call
        var destination_1 = ArrayList.o1();
        // Inline function 'kotlin.collections.forEach' call
        var _iterator__ex2g4s_1 = runtimeLhs.g1();
        while (_iterator__ex2g4s_1.f()) {
          var element_1 = _iterator__ex2g4s_1.e();
          var tmp_0;
          switch (parseArgs.allowEOTAfterSkip) {
            case true:
              tmp_0 = element.guardLookaheadSet.o1l($this.s1s_1, Companion_getInstance_3().EOT);
              break;
            case false:
              tmp_0 = element.guardLookaheadSet;
              break;
            default:
              noWhenBranchMatchedException();
              break;
          }
          var lhg = tmp_0;
          var b = $this.y1s_1.b1w(lhg, element_0, element_1, head.a1v_1);
          var tmp0_safe_receiver = b ? new Triple(element_0, element_1, element.upLookaheadSet) : null;
          if (tmp0_safe_receiver == null)
            null;
          else {
            // Inline function 'kotlin.let' call
            destination_1.v(tmp0_safe_receiver);
          }
        }
        var list = destination_1;
        addAll(destination_0, list);
      }
      var list_0 = destination_0;
      addAll(destination, list_0);
    }
    var lhWithMatch = destination;
    var hasLh = true;
    var tmp_1;
    if (parseArgs.noLookahead || hasLh) {
      var tmp_2;
      if (parseArgs.noLookahead) {
        // Inline function 'kotlin.collections.flatMap' call
        var tmp0_0 = transition.lookaheadGuard;
        // Inline function 'kotlin.collections.flatMapTo' call
        var destination_2 = ArrayList.o1();
        var _iterator__ex2g4s_2 = tmp0_0.g1();
        while (_iterator__ex2g4s_2.f()) {
          var element_2 = _iterator__ex2g4s_2.e();
          var up = element_2.upLookaheadSet;
          // Inline function 'kotlin.collections.flatMap' call
          // Inline function 'kotlin.collections.flatMapTo' call
          var destination_3 = ArrayList.o1();
          var _iterator__ex2g4s_3 = possibleEndOfText.g1();
          while (_iterator__ex2g4s_3.f()) {
            var element_3 = _iterator__ex2g4s_3.e();
            // Inline function 'kotlin.collections.map' call
            // Inline function 'kotlin.collections.mapTo' call
            var destination_4 = ArrayList.a1(collectionSizeOrDefault(runtimeLhs, 10));
            var _iterator__ex2g4s_4 = runtimeLhs.g1();
            while (_iterator__ex2g4s_4.f()) {
              var item = _iterator__ex2g4s_4.e();
              var tmp_3;
              if (up.h1l_1 || up.i1l_1) {
                tmp_3 = $this.s1s_1.y1n(up.c1m(element_3, item));
              } else {
                tmp_3 = up;
              }
              var tmp$ret$13 = tmp_3;
              destination_4.v(tmp$ret$13);
            }
            var list_1 = destination_4;
            addAll(destination_3, list_1);
          }
          var list_2 = destination_3;
          addAll(destination_2, list_2);
        }
        tmp_2 = toSet(destination_2);
      } else {
        // Inline function 'kotlin.collections.map' call
        // Inline function 'kotlin.collections.mapTo' call
        var destination_5 = ArrayList.a1(collectionSizeOrDefault(lhWithMatch, 10));
        var _iterator__ex2g4s_5 = lhWithMatch.g1();
        while (_iterator__ex2g4s_5.f()) {
          var item_0 = _iterator__ex2g4s_5.e();
          var eot = item_0.jm_1;
          var rt = item_0.km_1;
          var up_0 = item_0.lm_1;
          var tmp_4;
          if (up_0.h1l_1 || up_0.i1l_1) {
            tmp_4 = $this.s1s_1.y1n(up_0.c1m(eot, rt));
          } else {
            tmp_4 = up_0;
          }
          var tmp$ret$22 = tmp_4;
          destination_5.v(tmp$ret$22);
        }
        tmp_2 = toSet(destination_5);
      }
      var newRuntimeLhs = tmp_2;
      if (false) {
        var tmp_5 = Debug_instance;
        var tmp_6 = IndentDelta_NONE_getInstance();
        tmp_5.debug(tmp_6, RuntimeParserAgl$doHeight$lambda(head, transition));
      }
      tmp_1 = $this.y1s_1.f1w(head, previous, transition.f1n_1, newRuntimeLhs);
    } else {
      recordFailedHeightLh($this, parseArgs, head, transition, runtimeLhs, possibleEndOfText);
      tmp_1 = false;
    }
    return tmp_1;
  }
  return tmp;
}
function doGraft_0($this, head, previous, prevPrev, transition, possibleEndOfText, parseArgs) {
  var tmp;
  if (parseArgs.nonEmptyWidthOnly) {
    tmp = false;
  } else {
    var tmp_0;
    if (transition.runtimeGuard.execute(ensureNotNull(previous).b1v_1)) {
      var runtimeLhs = previous.x1u_1.g1v_1;
      var lhWithMatch = matchedLookahead($this, head.a1v_1, transition.lookaheadGuard, possibleEndOfText, runtimeLhs, parseArgs.allowEOTAfterSkip);
      var hasLh = lhWithMatch.hi_1;
      var tmp_1;
      if (parseArgs.noLookahead || hasLh) {
        if (false) {
          var tmp_2 = Debug_instance;
          var tmp_3 = IndentDelta_NONE_getInstance();
          tmp_2.debug(tmp_3, RuntimeParserAgl$doGraft$lambda(head, transition));
        }
        tmp_1 = $this.y1s_1.c1w(head, previous, prevPrev, transition.f1n_1, runtimeLhs);
      } else {
        recordFailedGraftLH($this, parseArgs, head, transition, runtimeLhs, possibleEndOfText);
        tmp_1 = false;
      }
      tmp_0 = tmp_1;
    } else {
      recordFailedGraftRTG($this, parseArgs, head, transition, previous.b1v_1);
      tmp_0 = false;
    }
    tmp = tmp_0;
  }
  return tmp;
}
function tryParseSkipUntilNone($this, possibleEndOfSkip, startPosition, growArgs) {
  var tmp;
  switch (growArgs.allowEOTAfterSkip) {
    case true:
      tmp = plus(possibleEndOfSkip, Companion_getInstance_3().EOT);
      break;
    case false:
      tmp = possibleEndOfSkip;
      break;
    default:
      noWhenBranchMatchedException();
      break;
  }
  var slh = tmp;
  var tmp_0;
  if ($this.u1s_1) {
    var key = new Pair(startPosition, slh);
    var tmp_1;
    if ($this.b1t_1.a3(key)) {
      tmp_1 = $this.b1t_1.c3(key);
    } else {
      var skipData = $this.c1t_1 == null ? null : tryParseSkip_0($this, slh, startPosition, growArgs);
      // Inline function 'kotlin.collections.set' call
      $this.b1t_1.f3(key, skipData);
      tmp_1 = skipData;
    }
    tmp_0 = tmp_1;
  } else {
    tmp_0 = tryParseSkip_0($this, slh, startPosition, growArgs);
  }
  return tmp_0;
}
function tryParseSkip_0($this, possibleEndOfSkip, startPosition, growArgs) {
  if (false) {
    println_0('*** Start skip Parser');
  }
  ensureNotNull($this.c1t_1).f1u();
  $this.c1t_1.h1u(startPosition, possibleEndOfSkip, growArgs);
  do {
    $this.c1t_1.l1u(possibleEndOfSkip, growArgs);
  }
   while ($this.c1t_1.y1s_1.m1u() && ($this.c1t_1.y1s_1.k1u().l1() || !$this.c1t_1.y1s_1.e1u_1));
  if (false) {
    println_0('*** End skip Parser');
  }
  var tmp;
  if ($this.c1t_1.y1s_1.k1u().l1()) {
    tmp = null;
  } else {
    tmp = $this.c1t_1.y1s_1.d1u_1.complete;
  }
  return tmp;
}
function ambiguity($this, runtimeContext, trans, possibleEndOfText) {
  var tmp = runtimeContext.r1v_1.x1u_1.f1v_1.runtimeRules;
  var from = joinToString(tmp, ',', VOID, VOID, VOID, VOID, RuntimeParserAgl$ambiguity$lambda);
  // Inline function 'kotlin.collections.map' call
  // Inline function 'kotlin.collections.mapTo' call
  var destination = ArrayList.a1(collectionSizeOrDefault(trans, 10));
  var _iterator__ex2g4s = trans.g1();
  while (_iterator__ex2g4s.f()) {
    var item = _iterator__ex2g4s.e();
    // Inline function 'kotlin.collections.map' call
    var this_0 = item.lookaheadGuard;
    // Inline function 'kotlin.collections.mapTo' call
    var destination_0 = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var _iterator__ex2g4s_0 = this_0.g1();
    while (_iterator__ex2g4s_0.f()) {
      var item_0 = _iterator__ex2g4s_0.e();
      var tmp$ret$0 = item_0.guardLookaheadSet.b1m();
      destination_0.v(tmp$ret$0);
    }
    // Inline function 'kotlin.collections.fold' call
    var accumulator = Companion_getInstance_7().EMPTY;
    var _iterator__ex2g4s_1 = destination_0.g1();
    while (_iterator__ex2g4s_1.f()) {
      var element = _iterator__ex2g4s_1.e();
      accumulator = accumulator.union(element);
    }
    var lh = accumulator;
    // Inline function 'kotlin.collections.map' call
    // Inline function 'kotlin.collections.mapTo' call
    var destination_1 = ArrayList.a1(collectionSizeOrDefault(possibleEndOfText, 10));
    var _iterator__ex2g4s_2 = possibleEndOfText.g1();
    while (_iterator__ex2g4s_2.f()) {
      var item_1 = _iterator__ex2g4s_2.e();
      var tmp$ret$5 = item_1.b1m();
      destination_1.v(tmp$ret$5);
    }
    // Inline function 'kotlin.collections.fold' call
    var accumulator_0 = Companion_getInstance_7().EMPTY;
    var _iterator__ex2g4s_3 = destination_1.g1();
    while (_iterator__ex2g4s_3.f()) {
      var element_0 = _iterator__ex2g4s_3.e();
      accumulator_0 = accumulator_0.union(element_0);
    }
    var eot = accumulator_0;
    // Inline function 'kotlin.collections.map' call
    var this_1 = runtimeContext.r1v_1.x1u_1.g1v_1;
    // Inline function 'kotlin.collections.mapTo' call
    var destination_2 = ArrayList.a1(collectionSizeOrDefault(this_1, 10));
    var _iterator__ex2g4s_4 = this_1.g1();
    while (_iterator__ex2g4s_4.f()) {
      var item_2 = _iterator__ex2g4s_4.e();
      var tmp$ret$10 = item_2.b1m();
      destination_2.v(tmp$ret$10);
    }
    // Inline function 'kotlin.collections.fold' call
    var accumulator_1 = Companion_getInstance_7().EMPTY;
    var _iterator__ex2g4s_5 = destination_2.g1();
    while (_iterator__ex2g4s_5.f()) {
      var element_1 = _iterator__ex2g4s_5.e();
      accumulator_1 = accumulator_1.union(element_1);
    }
    var rt = accumulator_1;
    var lhr = lh.resolve(eot, rt).fullContent;
    var tmp_0;
    switch (item.g1n_1.q3_1) {
      case 3:
        tmp_0 = '';
        break;
      case 1:
        tmp_0 = ensureNotNull(runtimeContext.t1v_1).i1c().firstRule.tag + ' <- ';
        break;
      case 0:
        tmp_0 = ensureNotNull(runtimeContext.s1v_1).i1c().firstRule.tag + ' <-- ';
        break;
      case 2:
        tmp_0 = '';
        break;
      case 4:
        tmp_0 = '';
        break;
      default:
        noWhenBranchMatchedException();
        break;
    }
    var spine = tmp_0;
    // Inline function 'kotlin.collections.map' call
    var this_2 = item.f1n_1.j1i_1;
    // Inline function 'kotlin.collections.mapTo' call
    var destination_3 = ArrayList.a1(collectionSizeOrDefault(this_2, 10));
    var _iterator__ex2g4s_6 = this_2.g1();
    while (_iterator__ex2g4s_6.f()) {
      var item_3 = _iterator__ex2g4s_6.e();
      var tmp$ret$15 = '(' + item_3.k1b_1.tag + ',' + item_3.l1b_1.toString() + ')';
      destination_3.v(tmp$ret$15);
    }
    var tmp_1 = toString(destination_3);
    // Inline function 'kotlin.collections.map' call
    // Inline function 'kotlin.collections.mapTo' call
    var destination_4 = ArrayList.a1(collectionSizeOrDefault(lhr, 10));
    var _iterator__ex2g4s_7 = lhr.g1();
    while (_iterator__ex2g4s_7.f()) {
      var item_4 = _iterator__ex2g4s_7.e();
      var tmp$ret$18 = item_4.tag;
      destination_4.v(tmp$ret$18);
    }
    var tmp$ret$21 = spine + tmp_1 + ' on ' + toString(destination_4);
    destination.v(tmp$ret$21);
  }
  var ambigStr = destination;
  // Inline function 'kotlin.collections.map' call
  // Inline function 'kotlin.collections.mapTo' call
  var destination_5 = ArrayList.a1(collectionSizeOrDefault(trans, 10));
  var _iterator__ex2g4s_8 = trans.g1();
  while (_iterator__ex2g4s_8.f()) {
    var item_5 = _iterator__ex2g4s_8.e();
    var tmp$ret$24 = item_5.g1n_1;
    destination_5.v(tmp$ret$24);
  }
  var ambigOn = toSet(destination_5);
  var ambigOnStr = joinToString(ambigOn, '/', VOID, VOID, VOID, VOID, RuntimeParserAgl$ambiguity$lambda_0);
  var tmp_2;
  if (ambigStr.h1() === 1) {
    tmp_2 = first_0(ambigStr);
  } else {
    tmp_2 = joinToString(ambigStr, '\n    ', '\n    ', '\n', VOID, VOID, RuntimeParserAgl$ambiguity$lambda_1);
  }
  var into = tmp_2;
  var loc = $this.q1s_1.locationFor(runtimeContext.r1v_1.a1v_1, 1);
  $this.x1s_1.raise(LanguageIssueKind_WARNING_getInstance(), LanguageProcessorPhase_GRAMMAR_getInstance(), loc, 'Ambiguity in parse (on ' + ambigOnStr + '):\n  (' + from + ') into ' + into, ambigOn);
}
function failedReasonsClear($this, beforePosition) {
  // Inline function 'kotlin.collections.filter' call
  var tmp0 = $this.z1s_1.d3();
  // Inline function 'kotlin.collections.filterTo' call
  var destination = ArrayList.o1();
  var _iterator__ex2g4s = tmp0.g1();
  while (_iterator__ex2g4s.f()) {
    var element = _iterator__ex2g4s.e();
    if (element < beforePosition) {
      destination.v(element);
    }
  }
  var rmv = destination;
  // Inline function 'kotlin.collections.forEach' call
  var _iterator__ex2g4s_0 = rmv.g1();
  while (_iterator__ex2g4s_0.f()) {
    var element_0 = _iterator__ex2g4s_0.e();
    $this.z1s_1.g3(element_0);
  }
}
function failedReasonsAdd($this, fr) {
  var l = $this.z1s_1.c3(fr.m1t_1);
  if (null == l) {
    var tmp0 = $this.z1s_1;
    var tmp2 = fr.m1t_1;
    // Inline function 'kotlin.collections.set' call
    var value = mutableListOf([fr]);
    tmp0.f3(tmp2, value);
  } else {
    l.v(fr);
  }
}
function recordFailedExpectedSkipAfter($this, parseArgs, head, nextLeaf, transition) {
  if (parseArgs.reportErrors) {
    var failedAtPosition = nextLeaf.nextInputNoSkip;
    var tmp;
    if (parseArgs.snapshoGss) {
      var tmp0_elvis_lhs = $this.y1s_1.c1u_1.snapshotFor(head);
      tmp = tmp0_elvis_lhs == null ? emptyMap() : tmp0_elvis_lhs;
    } else {
      tmp = emptyMap();
    }
    var gssSnapshot = tmp;
    var tmp1_safe_receiver = $this.t1s_1;
    var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : tmp1_safe_receiver.firstTerminals;
    var skipTerms = tmp2_elvis_lhs == null ? emptySet() : tmp2_elvis_lhs;
    failedReasonsAdd($this, new FailedParseExpectedSkipAfter($this.r1s_1, failedAtPosition, head, transition, gssSnapshot, skipTerms));
  }
}
function recordFailedWidthTo($this, parseArgs, head, transition) {
  if (parseArgs.reportErrors) {
    var failedAtPosition = head.a1v_1;
    var tmp;
    if (parseArgs.snapshoGss) {
      var tmp0_elvis_lhs = $this.y1s_1.c1u_1.snapshotFor(head);
      tmp = tmp0_elvis_lhs == null ? emptyMap() : tmp0_elvis_lhs;
    } else {
      tmp = emptyMap();
    }
    var gssSnapshot = tmp;
    failedReasonsAdd($this, new FailedParseReasonWidthTo($this.r1s_1, failedAtPosition, head, transition, gssSnapshot));
  }
}
function recordFailedWidthLH($this, parseArgs, head, failedAtPosition, transition, runtimeLhs, possibleEndOfText) {
  if (parseArgs.reportErrors) {
    var tmp;
    if (parseArgs.snapshoGss) {
      var tmp0_elvis_lhs = $this.y1s_1.c1u_1.snapshotFor(head);
      tmp = tmp0_elvis_lhs == null ? emptyMap() : tmp0_elvis_lhs;
    } else {
      tmp = emptyMap();
    }
    var gssSnapshot = tmp;
    failedReasonsAdd($this, new FailedParseReasonLookahead($this.r1s_1, failedAtPosition, head, transition, gssSnapshot, runtimeLhs, possibleEndOfText));
  }
}
function recordFailedEmbedded($this, parseArgs, head, transition, failedEmbeddedReasons) {
  if (parseArgs.reportErrors) {
    var failedAtPosition = head.a1v_1;
    var tmp;
    if (parseArgs.snapshoGss) {
      var tmp0_elvis_lhs = $this.y1s_1.c1u_1.snapshotFor(head);
      tmp = tmp0_elvis_lhs == null ? emptyMap() : tmp0_elvis_lhs;
    } else {
      tmp = emptyMap();
    }
    var gssSnapshot = tmp;
    var fr = ensureNotNull(failedEmbeddedReasons.c3(max(failedEmbeddedReasons.d3())));
    failedReasonsAdd($this, new FailedParseReasonEmbedded($this.r1s_1, failedAtPosition, head, transition, gssSnapshot, fr));
  }
}
function recordFailedHeightLh($this, parseArgs, head, transition, runtimeLhs, possibleEndOfText) {
  if (parseArgs.reportErrors) {
    var failedAtPosition = head.a1v_1;
    var tmp;
    if (parseArgs.snapshoGss) {
      var tmp0_elvis_lhs = $this.y1s_1.c1u_1.snapshotFor(head);
      tmp = tmp0_elvis_lhs == null ? emptyMap() : tmp0_elvis_lhs;
    } else {
      tmp = emptyMap();
    }
    var gssSnapshot = tmp;
    failedReasonsAdd($this, new FailedParseReasonLookahead($this.r1s_1, failedAtPosition, head, transition, gssSnapshot, runtimeLhs, possibleEndOfText));
  }
}
function recordFailedGraftRTG($this, parseArgs, head, transition, prevNumNonSkipChildren) {
  if (parseArgs.reportErrors) {
    var failedAtPosition = head.a1v_1;
    var tmp;
    if (parseArgs.snapshoGss) {
      var tmp0_elvis_lhs = $this.y1s_1.c1u_1.snapshotFor(head);
      tmp = tmp0_elvis_lhs == null ? emptyMap() : tmp0_elvis_lhs;
    } else {
      tmp = emptyMap();
    }
    var gssSnapshot = tmp;
    failedReasonsAdd($this, new FailedParseReasonGraftRTG($this.r1s_1, failedAtPosition, head, transition, gssSnapshot, prevNumNonSkipChildren));
  }
}
function recordFailedGraftLH($this, parseArgs, head, transition, runtimeLhs, possibleEndOfText) {
  if (parseArgs.reportErrors) {
    var failedAtPosition = head.a1v_1;
    var tmp;
    if (parseArgs.snapshoGss) {
      var tmp0_elvis_lhs = $this.y1s_1.c1u_1.snapshotFor(head);
      tmp = tmp0_elvis_lhs == null ? emptyMap() : tmp0_elvis_lhs;
    } else {
      tmp = emptyMap();
    }
    var gssSnapshot = tmp;
    failedReasonsAdd($this, new FailedParseReasonLookahead($this.r1s_1, failedAtPosition, head, transition, gssSnapshot, runtimeLhs, possibleEndOfText));
  }
}
function RuntimeParserAgl$grow3$lambda(it) {
  return 0;
}
function RuntimeParserAgl$growGoal$lambda($head) {
  return () => 'Dropped: ' + $head.toString();
}
function RuntimeParserAgl$growGoal$lambda$lambda(it) {
  return '  ' + it.toString();
}
function RuntimeParserAgl$growGoal$lambda_0($trans2) {
  return () => 'Choices:\n' + joinToString($trans2, '\n', VOID, VOID, VOID, VOID, RuntimeParserAgl$growGoal$lambda$lambda);
}
function RuntimeParserAgl$growIncomplete$lambda$lambda(it) {
  return '  ' + it.toString();
}
function RuntimeParserAgl$growIncomplete$lambda($trans2) {
  return () => 'Choices:\n' + joinToString($trans2, '\n', VOID, VOID, VOID, VOID, RuntimeParserAgl$growIncomplete$lambda$lambda);
}
function RuntimeParserAgl$growComplete$lambda($head) {
  return () => 'Dropped: ' + $head.toString();
}
function RuntimeParserAgl$growComplete$lambda_0($head) {
  return () => 'Dropped: ' + $head.toString();
}
function RuntimeParserAgl$growComplete$lambda_1($head) {
  return () => 'Dropped: ' + $head.toString();
}
function RuntimeParserAgl$growComplete$lambda_2($it) {
  return () => 'Dropped: ' + toString($it);
}
function RuntimeParserAgl$growComplete2$lambda$lambda(it) {
  return '  ' + it.toString();
}
function RuntimeParserAgl$growComplete2$lambda($trans2) {
  return () => 'Choices:\n' + joinToString($trans2, '\n', VOID, VOID, VOID, VOID, RuntimeParserAgl$growComplete2$lambda$lambda);
}
function RuntimeParserAgl$growComplete2$lambda_0(t1, t2) {
  var p1 = first_0(t1.f1n_1.j1i_1).m1b_1;
  var p2 = first_0(t2.f1n_1.j1i_1).m1b_1;
  return p1 === p2 ? 0 : -1 === p1 ? 1 : -1 === p2 ? -1 : p1 > p2 ? 1 : p1 < p2 ? -1 : 0;
}
function RuntimeParserAgl$resolveGrafts1$lambda(t1, t2) {
  var p1 = first_0(t1.hi_1.f1n_1.j1i_1).m1b_1;
  var p2 = first_0(t2.hi_1.f1n_1.j1i_1).m1b_1;
  return p1 === p2 ? 0 : -1 === p1 ? 1 : -1 === p2 ? -1 : p1 > p2 ? 1 : p1 < p2 ? -1 : 0;
}
function RuntimeParserAgl$doNoTransitionsTaken$lambda($head) {
  return () => 'Dropped stack with Head: ' + $head.toString();
}
function RuntimeParserAgl$doGoal$lambda($head, $transition) {
  return () => 'For ' + $head.toString() + '\n  taking: ' + $transition.toString();
}
function RuntimeParserAgl$doWidth$lambda($head, $transition) {
  return () => 'For ' + $head.toString() + '\n  taking: ' + $transition.toString();
}
function RuntimeParserAgl$doHeight$lambda($head, $transition) {
  return () => 'For ' + $head.toString() + '\n  taking: ' + $transition.toString();
}
function RuntimeParserAgl$doGraft$lambda($head, $transition) {
  return () => 'For ' + $head.toString() + '\n  taking: ' + $transition.toString();
}
function RuntimeParserAgl$doEmbedded$lambda($head, $transition) {
  return () => 'For ' + $head.toString() + '\n  taking: ' + $transition.toString();
}
function RuntimeParserAgl$ambiguity$lambda(it) {
  return it.tag;
}
function RuntimeParserAgl$ambiguity$lambda_0(it) {
  return it.toString();
}
function RuntimeParserAgl$ambiguity$lambda_1(it) {
  return it;
}
function FailedParseReasonEmbedded$spine$delegate$lambda($transition, $head, this$0, $gssSnapshot) {
  return () => {
    var tmp = first_0($transition.f1n_1.runtimeRules).rhs;
    var embeddedRhs = tmp instanceof RuntimeRuleRhsEmbedded ? tmp : THROW_CCE();
    var embeddedStateSet = embeddedRhs.embeddedRuntimeRuleSet.c1l(embeddedRhs.embeddedStartRule.tag, $head.i1c().stateSet.automatonKind);
    // Inline function 'kotlin.collections.map' call
    var this_0 = this$0.j1t_1;
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var tmp$ret$0 = item.r1t();
      destination.v(tmp$ret$0);
    }
    var x = destination;
    var embeddedRuntimeRuleSet = embeddedRhs.embeddedRuntimeRuleSet;
    var embeddedTerms = embeddedRuntimeRuleSet.c1l(embeddedRhs.embeddedStartRule.tag, $head.i1c().stateSet.automatonKind).usedTerminalRules;
    var tmp0_safe_receiver = $head.i1c().stateSet.runtimeRuleSet.skipParserStateSet;
    var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.usedTerminalRules;
    var skipTerms = tmp1_elvis_lhs == null ? emptySet() : tmp1_elvis_lhs;
    // Inline function 'kotlin.collections.flatMap' call
    // Inline function 'kotlin.collections.flatMapTo' call
    var destination_0 = ArrayList.o1();
    var _iterator__ex2g4s_0 = x.g1();
    while (_iterator__ex2g4s_0.f()) {
      var element = _iterator__ex2g4s_0.e();
      var list = element.q1w_1;
      addAll(destination_0, list);
    }
    var exp = toSet(minus_0(destination_0, minus_1(skipTerms, embeddedTerms)));
    return new RuntimeSpineDefault($head, $gssSnapshot, exp, $head.b1v_1);
  };
}
function FailedParseReasonEmbedded$_get_spine_$ref_696nsz() {
  return (p0) => p0.r1t();
}
function FailedParseReasonLookahead$spine$delegate$lambda(this$0, $transition, $head, $gssSnapshot) {
  return () => {
    // Inline function 'kotlin.collections.flatMap' call
    var tmp0 = this$0.z1w_1;
    // Inline function 'kotlin.collections.flatMapTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      // Inline function 'kotlin.collections.flatMap' call
      var tmp0_0 = this$0.y1w_1;
      // Inline function 'kotlin.collections.flatMapTo' call
      var destination_0 = ArrayList.o1();
      var _iterator__ex2g4s_0 = tmp0_0.g1();
      while (_iterator__ex2g4s_0.f()) {
        var element_0 = _iterator__ex2g4s_0.e();
        // Inline function 'kotlin.collections.flatMap' call
        var tmp0_1 = $transition.lookaheadGuard;
        // Inline function 'kotlin.collections.flatMapTo' call
        var destination_1 = ArrayList.o1();
        var _iterator__ex2g4s_1 = tmp0_1.g1();
        while (_iterator__ex2g4s_1.f()) {
          var element_1 = _iterator__ex2g4s_1.e();
          var list = element_1.guardLookaheadSet.c1m(element, element_0).fullContent;
          addAll(destination_1, list);
        }
        var list_0 = destination_1;
        addAll(destination_0, list_0);
      }
      var list_1 = destination_0;
      addAll(destination, list_1);
    }
    var expected = toSet(destination);
    var terms = $head.i1c().stateSet.usedTerminalRules;
    // Inline function 'kotlin.collections.flatMap' call
    var tmp0_2 = $head.i1c().stateSet.embeddedRuntimeRuleSet;
    // Inline function 'kotlin.collections.flatMapTo' call
    var destination_2 = ArrayList.o1();
    var _iterator__ex2g4s_2 = tmp0_2.g1();
    while (_iterator__ex2g4s_2.f()) {
      var element_2 = _iterator__ex2g4s_2.e();
      var list_2 = element_2.skipTerminals;
      addAll(destination_2, list_2);
    }
    var embeddedSkipTerms = toSet(destination_2);
    var exp = minus_1(expected, minus_1(embeddedSkipTerms, terms));
    return new RuntimeSpineDefault($head, $gssSnapshot, exp, $head.b1v_1 + 1 | 0);
  };
}
function FailedParseReasonLookahead$_get_spine_$ref_6f8gap() {
  return (p0) => p0.r1t();
}
function FailedParseReasonGraftRTG$spine$delegate$lambda($transition, this$0, $head, $gssSnapshot) {
  return () => {
    var exp = $transition.runtimeGuard.expectedWhenFailed(this$0.s1x_1);
    return new RuntimeSpineDefault($head, $gssSnapshot, exp, $head.b1v_1);
  };
}
function FailedParseReasonGraftRTG$_get_spine_$ref_mtwlws() {
  return (p0) => p0.r1t();
}
var Assoc_NONE_instance;
var Assoc_LEFT_instance;
var Assoc_RIGHT_instance;
function values_3() {
  return [Assoc_NONE_getInstance(), Assoc_LEFT_getInstance(), Assoc_RIGHT_getInstance()];
}
function valueOf_3(value) {
  switch (value) {
    case 'NONE':
      return Assoc_NONE_getInstance();
    case 'LEFT':
      return Assoc_LEFT_getInstance();
    case 'RIGHT':
      return Assoc_RIGHT_getInstance();
    default:
      Assoc_initEntries();
      THROW_IAE('No enum constant net.akehurst.language.parser.api.Assoc.' + value);
      break;
  }
}
var Assoc_entriesInitialized;
function Assoc_initEntries() {
  if (Assoc_entriesInitialized)
    return Unit_instance;
  Assoc_entriesInitialized = true;
  Assoc_NONE_instance = new Assoc('NONE', 0);
  Assoc_LEFT_instance = new Assoc('LEFT', 1);
  Assoc_RIGHT_instance = new Assoc('RIGHT', 2);
}
var Companion_instance_11;
function Companion_getInstance_11() {
  if (Companion_instance_11 === VOID)
    new Companion_11();
  return Companion_instance_11;
}
function Assoc_NONE_getInstance() {
  Assoc_initEntries();
  return Assoc_NONE_instance;
}
function Assoc_LEFT_getInstance() {
  Assoc_initEntries();
  return Assoc_LEFT_instance;
}
function Assoc_RIGHT_getInstance() {
  Assoc_initEntries();
  return Assoc_RIGHT_instance;
}
var IssueMessage_instance;
function IssueMessage_getInstance() {
  return IssueMessage_instance;
}
var Companion_instance_12;
function Companion_getInstance_12() {
  if (Companion_instance_12 === VOID)
    new Companion_12();
  return Companion_instance_12;
}
function check($this) {
  // Inline function 'kotlin.collections.mutableMapOf' call
  var next = LinkedHashMap.j4();
  // Inline function 'kotlin.collections.forEach' call
  var _iterator__ex2g4s = $this.f20_1.d3().g1();
  while (_iterator__ex2g4s.f()) {
    var element = _iterator__ex2g4s.e();
    // Inline function 'kotlin.collections.mutableSetOf' call
    // Inline function 'kotlin.collections.set' call
    var value = LinkedHashSet.j1();
    next.f3(element, value);
  }
  // Inline function 'kotlin.collections.filter' call
  var tmp0 = $this.g20_1.z1();
  // Inline function 'kotlin.collections.filterTo' call
  var destination = ArrayList.o1();
  var _iterator__ex2g4s_0 = tmp0.g1();
  while (_iterator__ex2g4s_0.f()) {
    var element_0 = _iterator__ex2g4s_0.e();
    if (element_0.b2() === 0) {
      destination.v(element_0);
    }
  }
  // Inline function 'kotlin.collections.map' call
  // Inline function 'kotlin.collections.mapTo' call
  var destination_0 = ArrayList.a1(collectionSizeOrDefault(destination, 10));
  var _iterator__ex2g4s_1 = destination.g1();
  while (_iterator__ex2g4s_1.f()) {
    var item = _iterator__ex2g4s_1.e();
    var tmp$ret$8 = item.a2();
    destination_0.v(tmp$ret$8);
  }
  var heads = destination_0;
  var check = toList(heads);
  $l$loop: while (true) {
    // Inline function 'kotlin.collections.isNotEmpty' call
    if (!!check.l1()) {
      break $l$loop;
    }
    // Inline function 'kotlin.collections.flatMap' call
    var tmp0_0 = check;
    // Inline function 'kotlin.collections.flatMapTo' call
    var destination_1 = ArrayList.o1();
    var _iterator__ex2g4s_2 = tmp0_0.g1();
    while (_iterator__ex2g4s_2.f()) {
      var element_1 = _iterator__ex2g4s_2.e();
      var prev = ensureNotNull($this.f20_1.c3(element_1));
      // Inline function 'kotlin.collections.forEach' call
      var _iterator__ex2g4s_3 = prev.g1();
      while (_iterator__ex2g4s_3.f()) {
        var element_2 = _iterator__ex2g4s_3.e();
        ensureNotNull(next.c3(element_2)).v(element_1);
      }
      var list = prev;
      addAll(destination_1, list);
    }
    var p = destination_1;
    check = p;
  }
  var tmp$ret$17;
  $l$block_0: {
    // Inline function 'kotlin.collections.any' call
    if (next.l1()) {
      tmp$ret$17 = false;
      break $l$block_0;
    }
    // Inline function 'kotlin.collections.iterator' call
    var _iterator__ex2g4s_4 = next.z1().g1();
    while (_iterator__ex2g4s_4.f()) {
      var element_3 = _iterator__ex2g4s_4.e();
      // Inline function 'kotlin.collections.component1' call
      var k = element_3.a2();
      // Inline function 'kotlin.collections.component2' call
      var v = element_3.b2();
      if (!($this.g20_1.c3(k) === v.h1())) {
        tmp$ret$17 = true;
        break $l$block_0;
      }
    }
    tmp$ret$17 = false;
  }
  if (tmp$ret$17) {
    // Inline function 'kotlin.error' call
    var message = 'GSS is broken';
    throw IllegalStateException.t4(toString(message));
  }
}
function removeStack($this, node, ifDropped) {
  var count = $this.g20_1.c3(node);
  var tmp;
  switch (count) {
    case null:
      tmp = true;
      break;
    case 0:
      $this.g20_1.g3(node);
      var prev = ensureNotNull($this.f20_1.g3(node));
      // Inline function 'kotlin.collections.forEach' call

      var _iterator__ex2g4s = prev.g1();
      while (_iterator__ex2g4s.f()) {
        var element = _iterator__ex2g4s.e();
        var c = ensureNotNull($this.g20_1.c3(element));
        var tmp0 = $this.g20_1;
        // Inline function 'kotlin.collections.set' call
        var value = c - 1 | 0;
        tmp0.f3(element, value);
        removeStack($this, element, ifDropped);
      }

      ifDropped(node);
      tmp = true;
      break;
    default:
      tmp = false;
      break;
  }
  return tmp;
}
function prevOfToString($this, n) {
  var prev = toList($this.peekPrevious(n));
  var tmp;
  if (prev.l1()) {
    tmp = '';
  } else if (1 === prev.h1()) {
    var p = first_0(prev);
    tmp = ' --> ' + toString_0(p) + prevOfToString($this, p);
  } else {
    var p_0 = first_0(prev);
    tmp = ' -' + prev.h1() + '-> ' + toString_0(p_0) + prevOfToString($this, p_0);
  }
  return tmp;
}
function GraphStructuredStack$toString$lambda(this$0) {
  return (h) => {
    var p = prevOfToString(this$0, h.a2());
    return toString_0(h.a2()) + p;
  };
}
var Companion_instance_13;
function Companion_getInstance_13() {
  return Companion_instance_13;
}
var MergeReason_LENGTH_instance;
var MergeReason_CHOICE_RULE_LENGTH_instance;
var MergeReason_CHOICE_RULE_PRIORITY_instance;
var MergeReason_CHOICE_RULE_AMBIGUOUS_instance;
var MergeReason_NUM_NON_SKIP_CHILDREN_instance;
var MergeReason_DYNAMIC_PRIORITY_instance;
var MergeReason_OPTIONAL_EMPTY_instance;
function values_4() {
  return [MergeReason_LENGTH_getInstance(), MergeReason_CHOICE_RULE_LENGTH_getInstance(), MergeReason_CHOICE_RULE_PRIORITY_getInstance(), MergeReason_CHOICE_RULE_AMBIGUOUS_getInstance(), MergeReason_NUM_NON_SKIP_CHILDREN_getInstance(), MergeReason_DYNAMIC_PRIORITY_getInstance(), MergeReason_OPTIONAL_EMPTY_getInstance()];
}
function valueOf_4(value) {
  switch (value) {
    case 'LENGTH':
      return MergeReason_LENGTH_getInstance();
    case 'CHOICE_RULE_LENGTH':
      return MergeReason_CHOICE_RULE_LENGTH_getInstance();
    case 'CHOICE_RULE_PRIORITY':
      return MergeReason_CHOICE_RULE_PRIORITY_getInstance();
    case 'CHOICE_RULE_AMBIGUOUS':
      return MergeReason_CHOICE_RULE_AMBIGUOUS_getInstance();
    case 'NUM_NON_SKIP_CHILDREN':
      return MergeReason_NUM_NON_SKIP_CHILDREN_getInstance();
    case 'DYNAMIC_PRIORITY':
      return MergeReason_DYNAMIC_PRIORITY_getInstance();
    case 'OPTIONAL_EMPTY':
      return MergeReason_OPTIONAL_EMPTY_getInstance();
    default:
      MergeReason_initEntries();
      THROW_IAE('No enum constant net.akehurst.language.agl.runtime.graph.ParseGraph.MergeReason.' + value);
      break;
  }
}
var MergeReason_entriesInitialized;
function MergeReason_initEntries() {
  if (MergeReason_entriesInitialized)
    return Unit_instance;
  MergeReason_entriesInitialized = true;
  MergeReason_LENGTH_instance = new MergeReason('LENGTH', 0);
  MergeReason_CHOICE_RULE_LENGTH_instance = new MergeReason('CHOICE_RULE_LENGTH', 1);
  MergeReason_CHOICE_RULE_PRIORITY_instance = new MergeReason('CHOICE_RULE_PRIORITY', 2);
  MergeReason_CHOICE_RULE_AMBIGUOUS_instance = new MergeReason('CHOICE_RULE_AMBIGUOUS', 3);
  MergeReason_NUM_NON_SKIP_CHILDREN_instance = new MergeReason('NUM_NON_SKIP_CHILDREN', 4);
  MergeReason_DYNAMIC_PRIORITY_instance = new MergeReason('DYNAMIC_PRIORITY', 5);
  MergeReason_OPTIONAL_EMPTY_instance = new MergeReason('OPTIONAL_EMPTY', 6);
}
var MergeChoice_PREFER_EXISTING_instance;
var MergeChoice_PREFER_NEW_instance;
var MergeChoice_UNDECIDABLE_instance;
var MergeChoice_KEEP_BOTH_AS_ALTERNATIVES_instance;
function values_5() {
  return [MergeChoice_PREFER_EXISTING_getInstance(), MergeChoice_PREFER_NEW_getInstance(), MergeChoice_UNDECIDABLE_getInstance(), MergeChoice_KEEP_BOTH_AS_ALTERNATIVES_getInstance()];
}
function valueOf_5(value) {
  switch (value) {
    case 'PREFER_EXISTING':
      return MergeChoice_PREFER_EXISTING_getInstance();
    case 'PREFER_NEW':
      return MergeChoice_PREFER_NEW_getInstance();
    case 'UNDECIDABLE':
      return MergeChoice_UNDECIDABLE_getInstance();
    case 'KEEP_BOTH_AS_ALTERNATIVES':
      return MergeChoice_KEEP_BOTH_AS_ALTERNATIVES_getInstance();
    default:
      MergeChoice_initEntries();
      THROW_IAE('No enum constant net.akehurst.language.agl.runtime.graph.ParseGraph.MergeChoice.' + value);
      break;
  }
}
var MergeChoice_entriesInitialized;
function MergeChoice_initEntries() {
  if (MergeChoice_entriesInitialized)
    return Unit_instance;
  MergeChoice_entriesInitialized = true;
  MergeChoice_PREFER_EXISTING_instance = new MergeChoice('PREFER_EXISTING', 0);
  MergeChoice_PREFER_NEW_instance = new MergeChoice('PREFER_NEW', 1);
  MergeChoice_UNDECIDABLE_instance = new MergeChoice('UNDECIDABLE', 2);
  MergeChoice_KEEP_BOTH_AS_ALTERNATIVES_instance = new MergeChoice('KEEP_BOTH_AS_ALTERNATIVES', 3);
}
var Companion_instance_14;
function Companion_getInstance_14() {
  return Companion_instance_14;
}
function addGrowingHead($this, oldHead, next) {
  if (null == oldHead) {
    $this.c1u_1.root(next);
  } else {
    $this.c1u_1.push(oldHead, next);
    var new_0 = Unit_instance;
  }
}
function preferNewCompleteParentFirstChild($this, oldParent, newParent, child, previous) {
  $this.d1u_1.setFirstChildForComplete(newParent.b21(), child, false);
  addGrowingHead($this, previous, newParent);
  return true;
}
function preferNewCompleteParentLastChild($this, oldParent, newParent, child, previous) {
  $this.d1u_1.setNextChildForCompleteParent(oldParent, newParent.b21(), child, false);
  $this.c21(oldParent);
  addGrowingHead($this, previous, newParent);
  return true;
}
function preferExistingCompleteParentFirstChild($this, oldParent, newParent, child, previous) {
  return false;
}
function preferExistingCompleteParentLastChild($this, oldParent, newParent, child, previous) {
  return false;
}
function keepBothCompleteParentsFirstChild($this, oldParent, newParent, child, previous) {
  $this.d1u_1.setFirstChildForComplete(newParent.b21(), child, true);
  addGrowingHead($this, previous, newParent);
  return true;
}
function keepBothCompleteParentsLastChild($this, oldParent, newParent, child, previous) {
  $this.d1u_1.setNextChildForCompleteParent(oldParent, newParent.b21(), child, true);
  addGrowingHead($this, previous, newParent);
  return true;
}
function useExistingCompleteParentFirstChild($this, newParent, child, previous) {
  addGrowingHead($this, previous, newParent);
  return true;
}
function useExistingCompleteParentLastChild($this, newParent, child, previous) {
  addGrowingHead($this, previous, newParent);
  return true;
}
function mergeDecisionOnLength($this, existingParent, newParent, reasonList, ifEqual) {
  var newReasonList = plus_1(reasonList, MergeReason_LENGTH_getInstance());
  var existingLength = existingParent.nextInputPosition - existingParent.startPosition | 0;
  var newLength = newParent.nextInputPosition - newParent.startPosition | 0;
  return newLength > existingLength ? new MergeDecision(newReasonList, MergeChoice_PREFER_NEW_getInstance(), '' + newLength + ' > ' + existingLength) : newLength < existingLength ? new MergeDecision(newReasonList, MergeChoice_PREFER_EXISTING_getInstance(), '' + newLength + ' < ' + existingLength) : ifEqual(newReasonList);
}
function mergeDecisionOnPriority($this, existingParent, newParent, reasonList, ifEqual) {
  if (false) {
    // Inline function 'kotlin.check' call
    if (!(existingParent.rule.isChoice && newParent.rule.isChoice && equals(existingParent.rule, newParent.rule))) {
      throw IllegalStateException.t4('Check failed.');
    }
  }
  var newReasonList = plus_1(reasonList, MergeReason_CHOICE_RULE_PRIORITY_getInstance());
  var existingPriority = existingParent.option.asIndex;
  var newPriority = newParent.option.asIndex;
  return newPriority > existingPriority ? new MergeDecision(newReasonList, MergeChoice_PREFER_NEW_getInstance(), '' + newPriority + ' > ' + existingPriority) : newPriority < existingPriority ? new MergeDecision(newReasonList, MergeChoice_PREFER_EXISTING_getInstance(), '' + newPriority + ' < ' + existingPriority) : ifEqual(newReasonList);
}
function mergeDecisionOnNumberOfChildren($this, existingParent, newParent, reasonList, ifEqual) {
  var newReasonList = plus_1(reasonList, MergeReason_NUM_NON_SKIP_CHILDREN_getInstance());
  var newNumCh = newParent.dynamicPriority.h1();
  var extNumCh = existingParent.dynamicPriority.h1();
  var tmp;
  if (newNumCh > extNumCh) {
    return new MergeDecision(newReasonList, MergeChoice_PREFER_NEW_getInstance(), '' + newNumCh + ' > ' + extNumCh);
  } else if (newNumCh < extNumCh) {
    return new MergeDecision(newReasonList, MergeChoice_PREFER_EXISTING_getInstance(), '' + newNumCh + ' < ' + extNumCh);
  } else {
    tmp = ifEqual(newReasonList);
  }
  return tmp;
}
function mergeDecisionOnEmpty($this, existingParent, newParent, reasonList, ifEqual) {
  var newReasonList = plus_1(reasonList, MergeReason_OPTIONAL_EMPTY_getInstance());
  var extOption = existingParent.option;
  var newOption = newParent.option;
  if (extOption.isEmpty && !newOption.isEmpty)
    return new MergeDecision(newReasonList, MergeChoice_PREFER_EXISTING_getInstance(), 'existing EMPTY wins over zero-length content');
  else if (newOption.isEmpty && !extOption.isEmpty)
    return new MergeDecision(newReasonList, MergeChoice_PREFER_NEW_getInstance(), 'new EMPTY wins over zero-length content');
  return ifEqual(newReasonList);
}
function mergeDecisionOnDynamicPriority($this, existingParent, newParent, reasonList, ifEqual) {
  var newReasonList = plus_1(reasonList, MergeReason_DYNAMIC_PRIORITY_getInstance());
  var extList = existingParent.dynamicPriority;
  var newList = newParent.dynamicPriority;
  var inductionVariable = 0;
  var last = extList.h1() - 1 | 0;
  if (inductionVariable <= last)
    do {
      var i = inductionVariable;
      inductionVariable = inductionVariable + 1 | 0;
      var e = extList.i1(i);
      var n = newList.i1(i);
      if (n > e)
        return new MergeDecision(newReasonList, MergeChoice_PREFER_NEW_getInstance(), toString(newList) + ' > ' + toString(extList));
      else if (n < e)
        return new MergeDecision(newReasonList, MergeChoice_PREFER_EXISTING_getInstance(), toString(newList) + ' < ' + toString(extList));
    }
     while (inductionVariable <= last);
  return ifEqual(newReasonList);
}
function mergeDecision($this, existingParent, newParent) {
  var tmp;
  if (newParent.rule.isChoice) {
    var tmp_0 = newParent.rule;
    var rhs = (tmp_0 instanceof RuntimeRule ? tmp_0 : THROW_CCE()).rhs;
    var tmp_1;
    if (rhs instanceof RuntimeRuleRhsChoice) {
      tmp_1 = rhs.choiceKind;
    } else {
      tmp_1 = null;
    }
    var choiceKind = tmp_1;
    var tmp_2;
    switch (ensureNotNull(choiceKind).q3_1) {
      case 0:
        var message = 'should never happen';
        throw IllegalStateException.t4(toString(message));
      case 2:
        var tmp_3 = emptyList();
        tmp_2 = mergeDecisionOnLength($this, existingParent, newParent, tmp_3, ParseGraph$mergeDecision$lambda($this, existingParent, newParent));
        break;
      case 3:
        var tmp_4 = emptyList();
        tmp_2 = mergeDecisionOnPriority($this, existingParent, newParent, tmp_4, ParseGraph$mergeDecision$lambda_0($this, existingParent, newParent));
        break;
      case 1:
        tmp_2 = new MergeDecision(listOf(MergeReason_CHOICE_RULE_AMBIGUOUS_getInstance()), MergeChoice_KEEP_BOTH_AS_ALTERNATIVES_getInstance(), '');
        break;
      default:
        noWhenBranchMatchedException();
        break;
    }
    tmp = tmp_2;
  } else if (newParent.rule.isList) {
    var tmp_5 = emptyList();
    tmp = mergeDecisionOnLength($this, existingParent, newParent, tmp_5, ParseGraph$mergeDecision$lambda_1($this, existingParent, newParent));
  } else if (newParent.rule.isOptional) {
    var tmp_6 = emptyList();
    tmp = mergeDecisionOnLength($this, existingParent, newParent, tmp_6, ParseGraph$mergeDecision$lambda_2($this, existingParent, newParent));
  } else {
    var tmp_7 = emptyList();
    tmp = mergeDecisionOnLength($this, existingParent, newParent, tmp_7, ParseGraph$mergeDecision$lambda_3($this, existingParent, newParent));
  }
  return tmp;
}
function doRecordGoal($this, goal) {
  $this.d1u_1.complete.setRootTo(goal);
  $this.b1u_1.v(goal);
  $this.e1u_1 = $this.z1t_1.isEnd($this.y1t_1, goal.nextInputPosition);
}
function prevOfToString_0($this, n) {
  var prev = toList($this.c1u_1.peekPrevious(n));
  var tmp;
  if (prev.l1()) {
    tmp = '';
  } else if (1 === prev.h1()) {
    var p = first_0(prev);
    tmp = ' --> ' + p.toString() + prevOfToString_0($this, p);
  } else {
    var p_0 = first_0(prev);
    tmp = ' -' + prev.h1() + '-> ' + p_0.toString() + prevOfToString_0($this, p_0);
  }
  return tmp;
}
function ParseGraph$_gss$lambda(parent, child) {
  var tmp;
  if (parent.a1v_1 < child.a1v_1) {
    tmp = 1;
  } else if (parent.a1v_1 > child.a1v_1) {
    tmp = -1;
  } else {
    var tmp_0;
    if (parent.i1c().isAtEnd && child.i1c().isAtEnd) {
      var tmp_1;
      if (equals(parent.i1c().runtimeRules, child.i1c().runtimeRules)) {
        var tmp_2;
        if (parent.i1c().isChoice && child.i1c().isChoice) {
          tmp_2 = parent.i1c().priorityList.i1(0) > child.i1c().priorityList.i1(0) ? 1 : parent.i1c().priorityList.i1(0) < child.i1c().priorityList.i1(0) ? -1 : 0;
        } else if (parent.i1c().isChoice) {
          tmp_2 = -1;
        } else if (child.i1c().isChoice) {
          tmp_2 = 1;
        } else {
          tmp_2 = 0;
        }
        tmp_1 = tmp_2;
      } else {
        tmp_1 = parent.y1u_1 < child.y1u_1 ? 1 : parent.y1u_1 > child.y1u_1 ? -1 : 0;
      }
      tmp_0 = tmp_1;
    } else if (parent.i1c().isAtEnd) {
      tmp_0 = -1;
    } else if (child.i1c().isAtEnd) {
      tmp_0 = 1;
    } else {
      tmp_0 = parent.y1u_1 < child.y1u_1 ? 1 : parent.y1u_1 > child.y1u_1 ? -1 : 0;
    }
    tmp = tmp_0;
  }
  return tmp;
}
function ParseGraph$mergeDecision$lambda$lambda$lambda($newParent, $existingParent) {
  return (rl3) => new MergeDecision(rl3, MergeChoice_UNDECIDABLE_getInstance(), toString($newParent.dynamicPriority) + ' == ' + toString($existingParent.dynamicPriority));
}
function ParseGraph$mergeDecision$lambda$lambda(this$0, $existingParent, $newParent) {
  return (rl2) => mergeDecisionOnDynamicPriority(this$0, $existingParent, $newParent, rl2, ParseGraph$mergeDecision$lambda$lambda$lambda($newParent, $existingParent));
}
function ParseGraph$mergeDecision$lambda(this$0, $existingParent, $newParent) {
  return (rl) => mergeDecisionOnPriority(this$0, $existingParent, $newParent, rl, ParseGraph$mergeDecision$lambda$lambda(this$0, $existingParent, $newParent));
}
function ParseGraph$mergeDecision$lambda$lambda$lambda_0($newParent, $existingParent) {
  return (rl3) => new MergeDecision(rl3, MergeChoice_UNDECIDABLE_getInstance(), toString($newParent.dynamicPriority) + ' == ' + toString($existingParent.dynamicPriority));
}
function ParseGraph$mergeDecision$lambda$lambda_0(this$0, $existingParent, $newParent) {
  return (rl2) => mergeDecisionOnDynamicPriority(this$0, $existingParent, $newParent, rl2, ParseGraph$mergeDecision$lambda$lambda$lambda_0($newParent, $existingParent));
}
function ParseGraph$mergeDecision$lambda_0(this$0, $existingParent, $newParent) {
  return (rl) => mergeDecisionOnLength(this$0, $existingParent, $newParent, rl, ParseGraph$mergeDecision$lambda$lambda_0(this$0, $existingParent, $newParent));
}
function ParseGraph$mergeDecision$lambda$lambda$lambda_1($newParent, $existingParent) {
  return (rl3) => new MergeDecision(rl3, MergeChoice_UNDECIDABLE_getInstance(), toString($newParent.dynamicPriority) + ' == ' + toString($existingParent.dynamicPriority));
}
function ParseGraph$mergeDecision$lambda$lambda_1(this$0, $existingParent, $newParent) {
  return (rl2) => mergeDecisionOnDynamicPriority(this$0, $existingParent, $newParent, rl2, ParseGraph$mergeDecision$lambda$lambda$lambda_1($newParent, $existingParent));
}
function ParseGraph$mergeDecision$lambda_1(this$0, $existingParent, $newParent) {
  return (rl1) => mergeDecisionOnNumberOfChildren(this$0, $existingParent, $newParent, rl1, ParseGraph$mergeDecision$lambda$lambda_1(this$0, $existingParent, $newParent));
}
function ParseGraph$mergeDecision$lambda$lambda_2(rl2) {
  return new MergeDecision(rl2, MergeChoice_UNDECIDABLE_getInstance(), 'both EMPTY or both 0 length');
}
function ParseGraph$mergeDecision$lambda_2(this$0, $existingParent, $newParent) {
  return (rl) => mergeDecisionOnEmpty(this$0, $existingParent, $newParent, rl, ParseGraph$mergeDecision$lambda$lambda_2);
}
function ParseGraph$mergeDecision$lambda$lambda_3($newParent, $existingParent) {
  return (rl2) => new MergeDecision(rl2, MergeChoice_UNDECIDABLE_getInstance(), toString($newParent.dynamicPriority) + ' == ' + toString($existingParent.dynamicPriority));
}
function ParseGraph$mergeDecision$lambda_3(this$0, $existingParent, $newParent) {
  return (rl) => mergeDecisionOnDynamicPriority(this$0, $existingParent, $newParent, rl, ParseGraph$mergeDecision$lambda$lambda_3($newParent, $existingParent));
}
function ParseGraph$dropStackWithHead$lambda(this$0) {
  return (n) => {
    this$0.e21(n);
    return Unit_instance;
  };
}
function ParseGraph$toString$lambda(this$0) {
  return (h) => {
    var p = prevOfToString_0(this$0, h);
    return '  ' + h.toString() + p;
  };
}
function MergeReason_LENGTH_getInstance() {
  MergeReason_initEntries();
  return MergeReason_LENGTH_instance;
}
function MergeReason_CHOICE_RULE_LENGTH_getInstance() {
  MergeReason_initEntries();
  return MergeReason_CHOICE_RULE_LENGTH_instance;
}
function MergeReason_CHOICE_RULE_PRIORITY_getInstance() {
  MergeReason_initEntries();
  return MergeReason_CHOICE_RULE_PRIORITY_instance;
}
function MergeReason_CHOICE_RULE_AMBIGUOUS_getInstance() {
  MergeReason_initEntries();
  return MergeReason_CHOICE_RULE_AMBIGUOUS_instance;
}
function MergeReason_NUM_NON_SKIP_CHILDREN_getInstance() {
  MergeReason_initEntries();
  return MergeReason_NUM_NON_SKIP_CHILDREN_instance;
}
function MergeReason_DYNAMIC_PRIORITY_getInstance() {
  MergeReason_initEntries();
  return MergeReason_DYNAMIC_PRIORITY_instance;
}
function MergeReason_OPTIONAL_EMPTY_getInstance() {
  MergeReason_initEntries();
  return MergeReason_OPTIONAL_EMPTY_instance;
}
function MergeChoice_PREFER_EXISTING_getInstance() {
  MergeChoice_initEntries();
  return MergeChoice_PREFER_EXISTING_instance;
}
function MergeChoice_PREFER_NEW_getInstance() {
  MergeChoice_initEntries();
  return MergeChoice_PREFER_NEW_instance;
}
function MergeChoice_UNDECIDABLE_getInstance() {
  MergeChoice_initEntries();
  return MergeChoice_UNDECIDABLE_instance;
}
function MergeChoice_KEEP_BOTH_AS_ALTERNATIVES_getInstance() {
  MergeChoice_initEntries();
  return MergeChoice_KEEP_BOTH_AS_ALTERNATIVES_instance;
}
function RuntimeState$uncompressed$delegate$lambda(this$0) {
  return () => {
    // Inline function 'kotlin.collections.flatMap' call
    var tmp0 = this$0.f1v_1.j1i_1;
    // Inline function 'kotlin.collections.flatMapTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      // Inline function 'kotlin.collections.map' call
      var this_0 = this$0.g1v_1;
      // Inline function 'kotlin.collections.mapTo' call
      var destination_0 = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
      var _iterator__ex2g4s_0 = this_0.g1();
      while (_iterator__ex2g4s_0.f()) {
        var item = _iterator__ex2g4s_0.e();
        var tmp$ret$0 = new StateInfoUncompressed(element, item.m1l());
        destination_0.v(tmp$ret$0);
      }
      var list = destination_0;
      addAll(destination, list);
    }
    return toSet(destination);
  };
}
function RuntimeState$toString$lambda(it) {
  var tmp = it.m1l();
  return joinToString(tmp, VOID, VOID, VOID, VOID, VOID, RuntimeState$toString$lambda$lambda);
}
function RuntimeState$toString$lambda$lambda(it) {
  return it.tag;
}
var Companion_instance_15;
function Companion_getInstance_15() {
  return Companion_instance_15;
}
function GrowingNodeIndex$complete$delegate$lambda(this$0) {
  return () => {
    var rule = this$0.x1u_1.f1v_1.firstRule;
    var option = this$0.x1u_1.k1m().i1(0);
    return new CompleteTreeDataNode(rule, this$0.y1u_1, this$0.a1v_1, this$0.z1u_1, option, this$0.d1d());
  };
}
function GrowingNodeIndex$_get_complete_$ref_4k948s() {
  return (p0) => p0.b21();
}
function GrowingNodeIndex$toString$lambda(it) {
  return it.tag;
}
function GrowingNodeIndex$toString$lambda_0(it) {
  return it;
}
function RulePositionRuntime$_get_asString_$lambda_kh5w9a($items) {
  return (it) => $items.i1(it).tag;
}
function RulePositionRuntime$_get_asString_$lambda_kh5w9a_0($items) {
  return (it) => $items.i1(it).tag;
}
function RulePositionRuntime$_get_asString_$lambda_kh5w9a_1($items) {
  return (it) => $items.i1(it).tag;
}
function RulePositionRuntime$_get_asString_$lambda_kh5w9a_2($items) {
  return (it) => $items.i1(it).tag;
}
function _get__rhs__d2tz9p($this) {
  var tmp = $this.x1d_1;
  if (!(tmp == null))
    return tmp;
  else {
    throwUninitializedPropertyAccessException('_rhs');
  }
}
function RuntimeRule$asTerminalRulePosition$delegate$lambda(this$0) {
  return () => new RulePositionRuntime(this$0, Companion_getInstance_11().OPTION_NONE, -1);
}
function RuntimeRule$_get_asTerminalRulePosition_$ref_m1naq1() {
  return (p0) => p0.y1e();
}
var RuntimeRuleKind_GOAL_instance;
var RuntimeRuleKind_NON_TERMINAL_instance;
var RuntimeRuleKind_TERMINAL_instance;
var RuntimeRuleKind_EMBEDDED_instance;
function values_6() {
  return [RuntimeRuleKind_GOAL_getInstance(), RuntimeRuleKind_NON_TERMINAL_getInstance(), RuntimeRuleKind_TERMINAL_getInstance(), RuntimeRuleKind_EMBEDDED_getInstance()];
}
function valueOf_6(value) {
  switch (value) {
    case 'GOAL':
      return RuntimeRuleKind_GOAL_getInstance();
    case 'NON_TERMINAL':
      return RuntimeRuleKind_NON_TERMINAL_getInstance();
    case 'TERMINAL':
      return RuntimeRuleKind_TERMINAL_getInstance();
    case 'EMBEDDED':
      return RuntimeRuleKind_EMBEDDED_getInstance();
    default:
      RuntimeRuleKind_initEntries();
      THROW_IAE('No enum constant net.akehurst.language.agl.runtime.structure.RuntimeRuleKind.' + value);
      break;
  }
}
var RuntimeRuleKind_entriesInitialized;
function RuntimeRuleKind_initEntries() {
  if (RuntimeRuleKind_entriesInitialized)
    return Unit_instance;
  RuntimeRuleKind_entriesInitialized = true;
  RuntimeRuleKind_GOAL_instance = new RuntimeRuleKind('GOAL', 0);
  RuntimeRuleKind_NON_TERMINAL_instance = new RuntimeRuleKind('NON_TERMINAL', 1);
  RuntimeRuleKind_TERMINAL_instance = new RuntimeRuleKind('TERMINAL', 2);
  RuntimeRuleKind_EMBEDDED_instance = new RuntimeRuleKind('EMBEDDED', 3);
}
var RuntimeRuleRhsItemsKind_EMPTY_instance;
var RuntimeRuleRhsItemsKind_CONCATENATION_instance;
var RuntimeRuleRhsItemsKind_CHOICE_instance;
var RuntimeRuleRhsItemsKind_LIST_instance;
function values_7() {
  return [RuntimeRuleRhsItemsKind_EMPTY_getInstance(), RuntimeRuleRhsItemsKind_CONCATENATION_getInstance(), RuntimeRuleRhsItemsKind_CHOICE_getInstance(), RuntimeRuleRhsItemsKind_LIST_getInstance()];
}
function valueOf_7(value) {
  switch (value) {
    case 'EMPTY':
      return RuntimeRuleRhsItemsKind_EMPTY_getInstance();
    case 'CONCATENATION':
      return RuntimeRuleRhsItemsKind_CONCATENATION_getInstance();
    case 'CHOICE':
      return RuntimeRuleRhsItemsKind_CHOICE_getInstance();
    case 'LIST':
      return RuntimeRuleRhsItemsKind_LIST_getInstance();
    default:
      RuntimeRuleRhsItemsKind_initEntries();
      THROW_IAE('No enum constant net.akehurst.language.agl.runtime.structure.RuntimeRuleRhsItemsKind.' + value);
      break;
  }
}
var RuntimeRuleRhsItemsKind_entriesInitialized;
function RuntimeRuleRhsItemsKind_initEntries() {
  if (RuntimeRuleRhsItemsKind_entriesInitialized)
    return Unit_instance;
  RuntimeRuleRhsItemsKind_entriesInitialized = true;
  RuntimeRuleRhsItemsKind_EMPTY_instance = new RuntimeRuleRhsItemsKind('EMPTY', 0);
  RuntimeRuleRhsItemsKind_CONCATENATION_instance = new RuntimeRuleRhsItemsKind('CONCATENATION', 1);
  RuntimeRuleRhsItemsKind_CHOICE_instance = new RuntimeRuleRhsItemsKind('CHOICE', 2);
  RuntimeRuleRhsItemsKind_LIST_instance = new RuntimeRuleRhsItemsKind('LIST', 3);
}
var RuntimeRuleListKind_MULTI_instance;
var RuntimeRuleListKind_SEPARATED_LIST_instance;
var RuntimeRuleListKind_LEFT_ASSOCIATIVE_LIST_instance;
var RuntimeRuleListKind_RIGHT_ASSOCIATIVE_LIST_instance;
var RuntimeRuleListKind_UNORDERED_instance;
function values_8() {
  return [RuntimeRuleListKind_MULTI_getInstance(), RuntimeRuleListKind_SEPARATED_LIST_getInstance(), RuntimeRuleListKind_LEFT_ASSOCIATIVE_LIST_getInstance(), RuntimeRuleListKind_RIGHT_ASSOCIATIVE_LIST_getInstance(), RuntimeRuleListKind_UNORDERED_getInstance()];
}
function valueOf_8(value) {
  switch (value) {
    case 'MULTI':
      return RuntimeRuleListKind_MULTI_getInstance();
    case 'SEPARATED_LIST':
      return RuntimeRuleListKind_SEPARATED_LIST_getInstance();
    case 'LEFT_ASSOCIATIVE_LIST':
      return RuntimeRuleListKind_LEFT_ASSOCIATIVE_LIST_getInstance();
    case 'RIGHT_ASSOCIATIVE_LIST':
      return RuntimeRuleListKind_RIGHT_ASSOCIATIVE_LIST_getInstance();
    case 'UNORDERED':
      return RuntimeRuleListKind_UNORDERED_getInstance();
    default:
      RuntimeRuleListKind_initEntries();
      THROW_IAE('No enum constant net.akehurst.language.agl.runtime.structure.RuntimeRuleListKind.' + value);
      break;
  }
}
var RuntimeRuleListKind_entriesInitialized;
function RuntimeRuleListKind_initEntries() {
  if (RuntimeRuleListKind_entriesInitialized)
    return Unit_instance;
  RuntimeRuleListKind_entriesInitialized = true;
  RuntimeRuleListKind_MULTI_instance = new RuntimeRuleListKind('MULTI', 0);
  RuntimeRuleListKind_SEPARATED_LIST_instance = new RuntimeRuleListKind('SEPARATED_LIST', 1);
  RuntimeRuleListKind_LEFT_ASSOCIATIVE_LIST_instance = new RuntimeRuleListKind('LEFT_ASSOCIATIVE_LIST', 2);
  RuntimeRuleListKind_RIGHT_ASSOCIATIVE_LIST_instance = new RuntimeRuleListKind('RIGHT_ASSOCIATIVE_LIST', 3);
  RuntimeRuleListKind_UNORDERED_instance = new RuntimeRuleListKind('UNORDERED', 4);
}
function RuntimeRuleKind_GOAL_getInstance() {
  RuntimeRuleKind_initEntries();
  return RuntimeRuleKind_GOAL_instance;
}
function RuntimeRuleKind_NON_TERMINAL_getInstance() {
  RuntimeRuleKind_initEntries();
  return RuntimeRuleKind_NON_TERMINAL_instance;
}
function RuntimeRuleKind_TERMINAL_getInstance() {
  RuntimeRuleKind_initEntries();
  return RuntimeRuleKind_TERMINAL_instance;
}
function RuntimeRuleKind_EMBEDDED_getInstance() {
  RuntimeRuleKind_initEntries();
  return RuntimeRuleKind_EMBEDDED_instance;
}
function RuntimeRuleRhsItemsKind_EMPTY_getInstance() {
  RuntimeRuleRhsItemsKind_initEntries();
  return RuntimeRuleRhsItemsKind_EMPTY_instance;
}
function RuntimeRuleRhsItemsKind_CONCATENATION_getInstance() {
  RuntimeRuleRhsItemsKind_initEntries();
  return RuntimeRuleRhsItemsKind_CONCATENATION_instance;
}
function RuntimeRuleRhsItemsKind_CHOICE_getInstance() {
  RuntimeRuleRhsItemsKind_initEntries();
  return RuntimeRuleRhsItemsKind_CHOICE_instance;
}
function RuntimeRuleRhsItemsKind_LIST_getInstance() {
  RuntimeRuleRhsItemsKind_initEntries();
  return RuntimeRuleRhsItemsKind_LIST_instance;
}
function RuntimeRuleListKind_MULTI_getInstance() {
  RuntimeRuleListKind_initEntries();
  return RuntimeRuleListKind_MULTI_instance;
}
function RuntimeRuleListKind_SEPARATED_LIST_getInstance() {
  RuntimeRuleListKind_initEntries();
  return RuntimeRuleListKind_SEPARATED_LIST_instance;
}
function RuntimeRuleListKind_LEFT_ASSOCIATIVE_LIST_getInstance() {
  RuntimeRuleListKind_initEntries();
  return RuntimeRuleListKind_LEFT_ASSOCIATIVE_LIST_instance;
}
function RuntimeRuleListKind_RIGHT_ASSOCIATIVE_LIST_getInstance() {
  RuntimeRuleListKind_initEntries();
  return RuntimeRuleListKind_RIGHT_ASSOCIATIVE_LIST_instance;
}
function RuntimeRuleListKind_UNORDERED_getInstance() {
  RuntimeRuleListKind_initEntries();
  return RuntimeRuleListKind_UNORDERED_instance;
}
var RuntimeRuleChoiceKind_NONE_instance;
var RuntimeRuleChoiceKind_AMBIGUOUS_instance;
var RuntimeRuleChoiceKind_LONGEST_PRIORITY_instance;
var RuntimeRuleChoiceKind_PRIORITY_LONGEST_instance;
function values_9() {
  return [RuntimeRuleChoiceKind_NONE_getInstance(), RuntimeRuleChoiceKind_AMBIGUOUS_getInstance(), RuntimeRuleChoiceKind_LONGEST_PRIORITY_getInstance(), RuntimeRuleChoiceKind_PRIORITY_LONGEST_getInstance()];
}
function valueOf_9(value) {
  switch (value) {
    case 'NONE':
      return RuntimeRuleChoiceKind_NONE_getInstance();
    case 'AMBIGUOUS':
      return RuntimeRuleChoiceKind_AMBIGUOUS_getInstance();
    case 'LONGEST_PRIORITY':
      return RuntimeRuleChoiceKind_LONGEST_PRIORITY_getInstance();
    case 'PRIORITY_LONGEST':
      return RuntimeRuleChoiceKind_PRIORITY_LONGEST_getInstance();
    default:
      RuntimeRuleChoiceKind_initEntries();
      THROW_IAE('No enum constant net.akehurst.language.agl.runtime.structure.RuntimeRuleChoiceKind.' + value);
      break;
  }
}
var RuntimeRuleChoiceKind_entriesInitialized;
function RuntimeRuleChoiceKind_initEntries() {
  if (RuntimeRuleChoiceKind_entriesInitialized)
    return Unit_instance;
  RuntimeRuleChoiceKind_entriesInitialized = true;
  RuntimeRuleChoiceKind_NONE_instance = new RuntimeRuleChoiceKind('NONE', 0);
  RuntimeRuleChoiceKind_AMBIGUOUS_instance = new RuntimeRuleChoiceKind('AMBIGUOUS', 1);
  RuntimeRuleChoiceKind_LONGEST_PRIORITY_instance = new RuntimeRuleChoiceKind('LONGEST_PRIORITY', 2);
  RuntimeRuleChoiceKind_PRIORITY_LONGEST_instance = new RuntimeRuleChoiceKind('PRIORITY_LONGEST', 3);
}
function RuntimeRuleRhsCommonTerminal$matchable$delegate$lambda($rule) {
  return () => new Matchable($rule.t1d_1, $rule.u1d_1, $rule.tag, new UnescapedLiteral(''), MatchableKind_EOT_getInstance());
}
function RuntimeRuleRhsCommonTerminal$_get_matchable_$ref_xni4p9() {
  return (p0) => p0.matchable;
}
function RuntimeRuleRhsPattern$matchable$delegate$lambda($rule, this$0) {
  return () => new Matchable($rule.t1d_1, $rule.u1d_1, $rule.tag, this$0.patternUnescaped, MatchableKind_REGEX_getInstance());
}
function RuntimeRuleRhsPattern$_get_matchable_$ref_fs06ck() {
  return (p0) => p0.matchable;
}
function RuntimeRuleRhsLiteral$matchable$delegate$lambda($rule, this$0) {
  return () => new Matchable($rule.t1d_1, $rule.u1d_1, $rule.tag, this$0.literalUnescaped, MatchableKind_LITERAL_getInstance());
}
function RuntimeRuleRhsLiteral$_get_matchable_$ref_p6e18j() {
  return (p0) => p0.matchable;
}
function _get__rulePositions__zi96g4($this) {
  // Inline function 'kotlin.collections.mapIndexedNotNull' call
  var tmp0 = $this.concatItems;
  // Inline function 'kotlin.collections.mapIndexedNotNullTo' call
  var destination = ArrayList.o1();
  // Inline function 'kotlin.collections.forEachIndexed' call
  var index = 0;
  var _iterator__ex2g4s = tmp0.g1();
  while (_iterator__ex2g4s.f()) {
    var item = _iterator__ex2g4s.e();
    var _unary__edvuaz = index;
    index = _unary__edvuaz + 1 | 0;
    var index_0 = checkIndexOverflow(_unary__edvuaz);
    var tmp0_safe_receiver = 0 === index_0 ? null : new RulePositionRuntime($this.rule, Companion_getInstance_11().OPTION_NONE, index_0);
    if (tmp0_safe_receiver == null)
      null;
    else {
      // Inline function 'kotlin.let' call
      destination.v(tmp0_safe_receiver);
    }
  }
  return plus_1(destination, new RulePositionRuntime($this.rule, Companion_getInstance_11().OPTION_NONE, -1));
}
function RuntimeRuleRhsConcatenation$_get_asString_$lambda_a0weeq(it) {
  return it.tag;
}
function RuntimeRuleRhsConcatenation$toString$lambda(it) {
  return it.tag + '[' + it.u1d_1 + ']';
}
function RuntimeRuleRhsChoice$_get_asString_$lambda_pebp4n(it) {
  return it.asString;
}
function RuntimeRuleRhsChoice$toString$lambda(it) {
  return toString(it);
}
var Companion_instance_16;
function Companion_getInstance_16() {
  return Companion_instance_16;
}
function RuntimeRuleChoiceKind_NONE_getInstance() {
  RuntimeRuleChoiceKind_initEntries();
  return RuntimeRuleChoiceKind_NONE_instance;
}
function RuntimeRuleChoiceKind_AMBIGUOUS_getInstance() {
  RuntimeRuleChoiceKind_initEntries();
  return RuntimeRuleChoiceKind_AMBIGUOUS_instance;
}
function RuntimeRuleChoiceKind_LONGEST_PRIORITY_getInstance() {
  RuntimeRuleChoiceKind_initEntries();
  return RuntimeRuleChoiceKind_LONGEST_PRIORITY_instance;
}
function RuntimeRuleChoiceKind_PRIORITY_LONGEST_getInstance() {
  RuntimeRuleChoiceKind_initEntries();
  return RuntimeRuleChoiceKind_PRIORITY_LONGEST_instance;
}
function RuntimeRuleSet$Companion$numberForGrammar$delegate$lambda(it) {
  var _unary__edvuaz = Companion_getInstance_17().nextRuntimeRuleSetNumber;
  Companion_getInstance_17().nextRuntimeRuleSetNumber = _unary__edvuaz + 1 | 0;
  return _unary__edvuaz;
}
function RuntimeRuleSet$Companion$_get_numberForGrammar_$ref_uvduo1() {
  return (p0) => p0.numberForGrammar;
}
var Companion_instance_17;
function Companion_getInstance_17() {
  if (Companion_instance_17 === VOID)
    new Companion_17();
  return Companion_instance_17;
}
function _get_rulesByTag__jkorgf($this) {
  var tmp0 = $this.l1d_1;
  var tmp = KProperty1;
  // Inline function 'kotlin.getValue' call
  getPropertyCallableRef('rulesByTag', 1, tmp, RuntimeRuleSet$_get_rulesByTag_$ref_ifel44(), null);
  return tmp0.b2();
}
function _get_terminalByTag__v6rb4a($this) {
  var tmp0 = $this.n1d_1;
  var tmp = KProperty1;
  // Inline function 'kotlin.getValue' call
  getPropertyCallableRef('terminalByTag', 1, tmp, RuntimeRuleSet$_get_terminalByTag_$ref_90rg3n(), null);
  return tmp0.b2();
}
function RuntimeRuleSet$goalRuleFor$delegate$lambda(this$0) {
  return (it) => {
    var ug = it instanceof RuntimeRule ? it : THROW_CCE();
    var gr = new RuntimeRule(this$0.number, -1, '<GOAL>', false, false);
    gr.setRhs(new RuntimeRuleRhsGoal(gr, ug));
    return gr;
  };
}
function RuntimeRuleSet$_get_goalRuleFor_$ref_fo2hrk() {
  return (p0) => p0.goalRuleFor;
}
function RuntimeRuleSet$skipRules$delegate$lambda(this$0) {
  return () => {
    // Inline function 'kotlin.collections.filter' call
    var tmp0 = this$0.runtimeRules;
    // Inline function 'kotlin.collections.filterTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      if (element.v1d_1) {
        destination.v(element);
      }
    }
    return destination;
  };
}
function RuntimeRuleSet$_get_skipRules_$ref_ccw8tq() {
  return (p0) => p0.skipRules;
}
function RuntimeRuleSet$skipTerminals$delegate$lambda(this$0) {
  return () => {
    var tmp0_safe_receiver = this$0.skipParserStateSet;
    var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.usedTerminalRules;
    return tmp1_elvis_lhs == null ? emptySet() : tmp1_elvis_lhs;
  };
}
function RuntimeRuleSet$_get_skipTerminals_$ref_1r14nm() {
  return (p0) => p0.skipTerminals;
}
function RuntimeRuleSet$nonSkipRules$delegate$lambda(this$0) {
  return () => {
    // Inline function 'kotlin.collections.filter' call
    var tmp0 = this$0.runtimeRules;
    // Inline function 'kotlin.collections.filterTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      if (!element.v1d_1) {
        destination.v(element);
      }
    }
    // Inline function 'kotlin.collections.toTypedArray' call
    return copyToArray(destination);
  };
}
function RuntimeRuleSet$_get_nonSkipRules_$ref_p1qrhh() {
  return (p0) => p0.nonSkipRules;
}
function RuntimeRuleSet$nonSkipTerminals$delegate$lambda(this$0) {
  return () => {
    // Inline function 'kotlin.collections.flatMap' call
    var tmp0 = this$0.runtimeRules;
    // Inline function 'kotlin.collections.flatMapTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      var tmp;
      if (element.isEmbedded) {
        var tmp_0 = element.rhs;
        tmp = toList((tmp_0 instanceof RuntimeRuleRhsEmbedded ? tmp_0 : THROW_CCE()).embeddedRuntimeRuleSet.nonSkipTerminals);
      } else if (element.isTerminal && !element.v1d_1) {
        tmp = listOf(element);
      } else {
        tmp = emptyList();
      }
      var list = tmp;
      addAll(destination, list);
    }
    return destination;
  };
}
function RuntimeRuleSet$_get_nonSkipTerminals_$ref_b8veed() {
  return (p0) => p0.nonSkipTerminals;
}
function RuntimeRuleSet$terminals$delegate$lambda(this$0) {
  return () => toList(_get_terminalByTag__v6rb4a(this$0).e3());
}
function RuntimeRuleSet$_get_terminals_$ref_y2xogd() {
  return (p0) => p0.terminals;
}
function RuntimeRuleSet$embeddedTerminals$delegate$lambda(this$0) {
  return () => {
    // Inline function 'kotlin.collections.flatMap' call
    var tmp0 = this$0.findEmbeddedRuleSets();
    // Inline function 'kotlin.collections.flatMapTo' call
    var destination = ArrayList.o1();
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      var list = element.terminals;
      addAll(destination, list);
    }
    return toList(toSet(destination));
  };
}
function RuntimeRuleSet$_get_embeddedTerminals_$ref_g9kh0d() {
  return (p0) => p0.embeddedTerminals;
}
function RuntimeRuleSet$rulesByTag$delegate$lambda(this$0) {
  return () => {
    // Inline function 'kotlin.collections.associate' call
    var this_0 = this$0.runtimeRules;
    var capacity = coerceAtLeast(mapCapacity(collectionSizeOrDefault(this_0, 10)), 16);
    // Inline function 'kotlin.collections.associateTo' call
    var destination = LinkedHashMap.gb(capacity);
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      // Inline function 'kotlin.collections.plusAssign' call
      var pair = new Pair(element.tag, element);
      destination.f3(pair.hi_1, pair.ii_1);
    }
    return destination;
  };
}
function RuntimeRuleSet$_get_rulesByTag_$ref_ifel44() {
  return (p0) => _get_rulesByTag__jkorgf(p0);
}
function RuntimeRuleSet$nonTerminalRuleNumber$delegate$lambda(this$0) {
  return () => {
    // Inline function 'kotlin.collections.filter' call
    var tmp0 = _get_rulesByTag__jkorgf(this$0);
    // Inline function 'kotlin.collections.filterTo' call
    var destination = LinkedHashMap.j4();
    // Inline function 'kotlin.collections.iterator' call
    var _iterator__ex2g4s = tmp0.z1().g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      // Inline function 'kotlin.collections.component1' call
      var k = element.a2();
      // Inline function 'kotlin.collections.component2' call
      var v = element.b2();
      if (v.isNonTerminal) {
        destination.f3(element.a2(), element.b2());
      }
    }
    // Inline function 'kotlin.collections.associate' call
    var this_0 = destination.z1();
    var capacity = coerceAtLeast(mapCapacity(collectionSizeOrDefault(this_0, 10)), 16);
    // Inline function 'kotlin.collections.associateTo' call
    var destination_0 = LinkedHashMap.gb(capacity);
    var _iterator__ex2g4s_0 = this_0.g1();
    while (_iterator__ex2g4s_0.f()) {
      var element_0 = _iterator__ex2g4s_0.e();
      // Inline function 'kotlin.collections.component1' call
      var k_0 = element_0.a2();
      // Inline function 'kotlin.collections.component2' call
      var v_0 = element_0.b2();
      // Inline function 'kotlin.collections.plusAssign' call
      var pair = new Pair(k_0, v_0.u1d_1);
      destination_0.f3(pair.hi_1, pair.ii_1);
    }
    return destination_0;
  };
}
function RuntimeRuleSet$terminalByTag$delegate$lambda(this$0) {
  return () => {
    // Inline function 'kotlin.collections.filter' call
    var tmp0 = _get_rulesByTag__jkorgf(this$0);
    // Inline function 'kotlin.collections.filterTo' call
    var destination = LinkedHashMap.j4();
    // Inline function 'kotlin.collections.iterator' call
    var _iterator__ex2g4s = tmp0.z1().g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      // Inline function 'kotlin.collections.component1' call
      var k = element.a2();
      // Inline function 'kotlin.collections.component2' call
      var v = element.b2();
      if (v.isTerminal) {
        destination.f3(element.a2(), element.b2());
      }
    }
    return destination;
  };
}
function RuntimeRuleSet$_get_terminalByTag_$ref_90rg3n() {
  return (p0) => _get_terminalByTag__v6rb4a(p0);
}
function RuntimeRuleSet$embeddedRuleNumber$delegate$lambda(this$0) {
  return () => {
    // Inline function 'kotlin.collections.filter' call
    var tmp0 = _get_rulesByTag__jkorgf(this$0);
    // Inline function 'kotlin.collections.filterTo' call
    var destination = LinkedHashMap.j4();
    // Inline function 'kotlin.collections.iterator' call
    var _iterator__ex2g4s = tmp0.z1().g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      // Inline function 'kotlin.collections.component1' call
      var k = element.a2();
      // Inline function 'kotlin.collections.component2' call
      var v = element.b2();
      if (v.isEmbedded) {
        destination.f3(element.a2(), element.b2());
      }
    }
    // Inline function 'kotlin.collections.associate' call
    var this_0 = destination.z1();
    var capacity = coerceAtLeast(mapCapacity(collectionSizeOrDefault(this_0, 10)), 16);
    // Inline function 'kotlin.collections.associateTo' call
    var destination_0 = LinkedHashMap.gb(capacity);
    var _iterator__ex2g4s_0 = this_0.g1();
    while (_iterator__ex2g4s_0.f()) {
      var element_0 = _iterator__ex2g4s_0.e();
      // Inline function 'kotlin.collections.component1' call
      var k_0 = element_0.a2();
      // Inline function 'kotlin.collections.component2' call
      var v_0 = element_0.b2();
      // Inline function 'kotlin.collections.plusAssign' call
      var pair = new Pair(k_0, v_0.u1d_1);
      destination_0.f3(pair.hi_1, pair.ii_1);
    }
    return destination_0;
  };
}
function RuntimeRuleSet$skipParserStateSet$delegate$lambda(this$0) {
  return () => {
    var tmp;
    if (this$0.skipRules.l1()) {
      tmp = null;
    } else {
      // Inline function 'kotlin.also' call
      var this_0 = new RuntimeRule(this$0.number, -4, '<SKIP-CHOICE>', false, false);
      // Inline function 'kotlin.collections.map' call
      var this_1 = this$0.skipRules;
      // Inline function 'kotlin.collections.mapTo' call
      var destination = ArrayList.a1(collectionSizeOrDefault(this_1, 10));
      var _iterator__ex2g4s = this_1.g1();
      while (_iterator__ex2g4s.f()) {
        var item = _iterator__ex2g4s.e();
        var tmp$ret$0 = new RuntimeRuleRhsConcatenation(this_0, listOf(item));
        destination.v(tmp$ret$0);
      }
      var options = destination;
      var rhs = new RuntimeRuleRhsChoice(this_0, RuntimeRuleChoiceKind_LONGEST_PRIORITY_getInstance(), options);
      this_0.setRhs(rhs);
      var skipChoiceRule = this_0;
      // Inline function 'kotlin.also' call
      var this_2 = new RuntimeRule(this$0.number, -3, '<SKIP-MULTI>', false, false);
      this_2.setRhs(new RuntimeRuleRhsListSimple(this_2, 1, -1, skipChoiceRule));
      var skipMultiRule = this_2;
      var _unary__edvuaz = this$0.s1d_1;
      this$0.s1d_1 = _unary__edvuaz + 1 | 0;
      var ss = new ParserStateSet(_unary__edvuaz, this$0, skipMultiRule, true, AutomatonKind_LOOKAHEAD_1_getInstance(), false);
      tmp = ss;
    }
    return tmp;
  };
}
function RuntimeRuleSet$_get_skipParserStateSet_$ref_cbiz4v() {
  return (p0) => p0.skipParserStateSet;
}
function RuntimeRuleSet$toString$lambda(a, b) {
  // Inline function 'kotlin.comparisons.compareValuesBy' call
  var tmp = a.tag;
  var tmp$ret$1 = b.tag;
  return compareValues(tmp, tmp$ret$1);
}
function RuntimeRuleSet$toString$lambda_0(a, b) {
  // Inline function 'kotlin.comparisons.compareValuesBy' call
  var tmp = a.contextRule.tag;
  var tmp$ret$1 = b.contextRule.tag;
  return compareValues(tmp, tmp$ret$1);
}
function RuntimeRuleSet$toString$lambda_1(it) {
  var tmp = it.options;
  var opts = joinToString(tmp, '\n', VOID, VOID, VOID, VOID, RuntimeRuleSet$toString$lambda$lambda);
  return '  PREC ' + it.contextRule.tag + ' {\n' + opts + '\n  }';
}
function RuntimeRuleSet$toString$lambda$lambda(it) {
  var tmp = it.precedence;
  var tmp_0 = it.associativity.toString();
  var tmp_1 = it.spine;
  return '    ' + tmp + ' ' + tmp_0 + ' ' + joinToString(tmp_1, '<-', VOID, VOID, VOID, VOID, RuntimeRuleSet$toString$lambda$lambda$lambda) + ' ' + it.option.toString() + ' ' + toString(it.operators);
}
function RuntimeRuleSet$toString$lambda$lambda$lambda(it) {
  return it.tag;
}
function ruleSet(name, init) {
  return runtimeRuleSet(name, init);
}
function runtimeRuleSet(qualifiedName, init) {
  qualifiedName = qualifiedName === VOID ? 'RRS' : qualifiedName;
  var b = new RuntimeRuleSetBuilder2(qualifiedName);
  init(b);
  return b.e1h();
}
function RuntimeSpineDefault$elements$delegate$lambda(this$0) {
  return () => {
    var list = mutableListOf([first_0(this$0.o1w_1.i1c().j1i_1)]);
    var next = this$0.p1w_1.c3(this$0.o1w_1);
    $l$loop: while (true) {
      var tmp;
      if (!(null == next)) {
        // Inline function 'kotlin.collections.isNotEmpty' call
        tmp = !next.l1();
      } else {
        tmp = false;
      }
      if (!tmp) {
        break $l$loop;
      }
      var nh = first(next);
      list.v(first_0(nh.i1c().j1i_1));
      next = this$0.p1w_1.c3(nh);
    }
    return list;
  };
}
function RuntimeSpineDefault$_get_elements_$ref_2lq9f3() {
  return (p0) => p0.elements;
}
function RuntimeSpineDefault$toString$lambda(it) {
  return it.toString();
}
var ScannerKind_OnDemand_instance;
var ScannerKind_Classic_instance;
function values_10() {
  return [ScannerKind_OnDemand_getInstance(), ScannerKind_Classic_getInstance()];
}
function valueOf_10(value) {
  switch (value) {
    case 'OnDemand':
      return ScannerKind_OnDemand_getInstance();
    case 'Classic':
      return ScannerKind_Classic_getInstance();
    default:
      ScannerKind_initEntries();
      THROW_IAE('No enum constant net.akehurst.language.scanner.api.ScannerKind.' + value);
      break;
  }
}
var ScannerKind_entriesInitialized;
function ScannerKind_initEntries() {
  if (ScannerKind_entriesInitialized)
    return Unit_instance;
  ScannerKind_entriesInitialized = true;
  ScannerKind_OnDemand_instance = new ScannerKind('OnDemand', 0);
  ScannerKind_Classic_instance = new ScannerKind('Classic', 1);
}
var MatchableKind_EOT_instance;
var MatchableKind_LITERAL_instance;
var MatchableKind_REGEX_instance;
function values_11() {
  return [MatchableKind_EOT_getInstance(), MatchableKind_LITERAL_getInstance(), MatchableKind_REGEX_getInstance()];
}
function valueOf_11(value) {
  switch (value) {
    case 'EOT':
      return MatchableKind_EOT_getInstance();
    case 'LITERAL':
      return MatchableKind_LITERAL_getInstance();
    case 'REGEX':
      return MatchableKind_REGEX_getInstance();
    default:
      MatchableKind_initEntries();
      THROW_IAE('No enum constant net.akehurst.language.scanner.api.MatchableKind.' + value);
      break;
  }
}
var MatchableKind_entriesInitialized;
function MatchableKind_initEntries() {
  if (MatchableKind_entriesInitialized)
    return Unit_instance;
  MatchableKind_entriesInitialized = true;
  MatchableKind_EOT_instance = new MatchableKind('EOT', 0);
  MatchableKind_LITERAL_instance = new MatchableKind('LITERAL', 1);
  MatchableKind_REGEX_instance = new MatchableKind('REGEX', 2);
}
function ScannerKind_OnDemand_getInstance() {
  ScannerKind_initEntries();
  return ScannerKind_OnDemand_instance;
}
function ScannerKind_Classic_getInstance() {
  ScannerKind_initEntries();
  return ScannerKind_Classic_instance;
}
function MatchableKind_EOT_getInstance() {
  MatchableKind_initEntries();
  return MatchableKind_EOT_instance;
}
function MatchableKind_LITERAL_getInstance() {
  MatchableKind_initEntries();
  return MatchableKind_LITERAL_instance;
}
function MatchableKind_REGEX_getInstance() {
  MatchableKind_initEntries();
  return MatchableKind_REGEX_instance;
}
function ScanResultDefault$allTokens$delegate$lambda(this$0) {
  return () => flatten(this$0.r25_1);
}
function ScanResultDefault$_get_allTokens_$ref_k49c9k() {
  return (p0) => p0.allTokens;
}
function ScannerAbstract$matchables$delegate$lambda(this$0) {
  return () => {
    // Inline function 'kotlin.collections.mapNotNull' call
    var tmp0 = this$0.validTerminals;
    // Inline function 'kotlin.collections.mapNotNullTo' call
    var destination = ArrayList.o1();
    // Inline function 'kotlin.collections.forEach' call
    var _iterator__ex2g4s = tmp0.g1();
    while (_iterator__ex2g4s.f()) {
      var element = _iterator__ex2g4s.e();
      var tmp = (element instanceof RuntimeRule ? element : THROW_CCE()).rhs;
      var tmp0_safe_receiver = (tmp instanceof RuntimeRuleRhsTerminal ? tmp : THROW_CCE()).matchable;
      var tmp0_safe_receiver_0 = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.using(this$0.regexEngine);
      if (tmp0_safe_receiver_0 == null)
        null;
      else {
        // Inline function 'kotlin.let' call
        destination.v(tmp0_safe_receiver_0);
      }
    }
    return toList(toSet(destination));
  };
}
function ScannerAbstract$_get_matchables_$ref_gpomd2() {
  return (p0) => p0.matchables;
}
function ScannerAbstract$scan$lambda(l1, l2) {
  return !l1.isPattern && l2.isPattern ? 1 : l1.isPattern && !l2.isPattern ? -1 : l1.length > l2.length ? 1 : l2.length > l1.length ? -1 : 0;
}
function ScannerAbstract$scanByLine$lambda(l1, l2) {
  return !l1.isPattern && l2.isPattern ? 1 : l1.isPattern && !l2.isPattern ? -1 : l1.length > l2.length ? 1 : l2.length > l1.length ? -1 : 0;
}
var Companion_instance_18;
function Companion_getInstance_18() {
  if (Companion_instance_18 === VOID)
    new Companion_18();
  return Companion_instance_18;
}
function scanAt($this, sentence, position) {
  // Inline function 'kotlin.collections.mapNotNull' call
  var tmp0 = $this.h26_1;
  // Inline function 'kotlin.collections.mapNotNullTo' call
  var destination = ArrayList.o1();
  // Inline function 'kotlin.collections.forEach' call
  var _iterator__ex2g4s = tmp0.g1();
  while (_iterator__ex2g4s.f()) {
    var element = _iterator__ex2g4s.e();
    var tmp = (element instanceof RuntimeRule ? element : THROW_CCE()).rhs;
    var matchLength = ensureNotNull((tmp instanceof RuntimeRuleRhsTerminal ? tmp : THROW_CCE()).matchable).matchedLength(sentence, position);
    var tmp_0;
    switch (matchLength) {
      case -1:
        tmp_0 = null;
        break;
      case 0:
        tmp_0 = null;
        break;
      default:
        var nip = position + matchLength | 0;
        tmp_0 = new CompleteTreeDataNode(element, position, nip, nip, Companion_getInstance_11().OPTION_NONE, emptyList());
        break;
    }
    var tmp0_safe_receiver = tmp_0;
    if (tmp0_safe_receiver == null)
      null;
    else {
      // Inline function 'kotlin.let' call
      destination.v(tmp0_safe_receiver);
    }
  }
  var matches = destination;
  var tmp_1 = ScannerClassic$scanAt$lambda;
  var longest = maxWithOrNull(matches, new sam$kotlin_Comparator$0_10(tmp_1));
  return longest == null ? Companion_getInstance_18().LEAF_NONE : longest;
}
function ScannerClassic$scanAt$lambda(l1, l2) {
  return !l1.q1e_1.isPattern && l2.q1e_1.isPattern ? 1 : l1.q1e_1.isPattern && !l2.q1e_1.isPattern ? -1 : l1.s1e_1 > l2.s1e_1 ? 1 : l2.s1e_1 > l1.s1e_1 ? -1 : 0;
}
var Companion_instance_19;
function Companion_getInstance_19() {
  if (Companion_instance_19 === VOID)
    new Companion_19();
  return Companion_instance_19;
}
function tryCreateLeaf($this, sentence, position, terminalRuntimeRule) {
  var tmp0_subject = terminalRuntimeRule.rhs;
  var tmp;
  if (tmp0_subject instanceof RuntimeRuleRhsEmpty) {
    var leaf = new CompleteTreeDataNode(terminalRuntimeRule, position, position, position, Companion_getInstance_11().OPTION_NONE, emptyList());
    $this.m1e_1.d20(terminalRuntimeRule, position, leaf);
    tmp = leaf;
  } else {
    if (tmp0_subject instanceof RuntimeRuleRhsEmptyList) {
      var leaf_0 = new CompleteTreeDataNode(terminalRuntimeRule, position, position, position, Companion_getInstance_11().OPTION_NONE, emptyList());
      $this.m1e_1.d20(terminalRuntimeRule, position, leaf_0);
      tmp = leaf_0;
    } else {
      var matchLength = $this.r26(sentence, position, terminalRuntimeRule);
      var tmp_0;
      if (-1 === matchLength) {
        $this.m1e_1.d20(terminalRuntimeRule, position, Companion_getInstance_19().LEAF_NONE);
        tmp_0 = Companion_getInstance_19().LEAF_NONE;
      } else {
        var nextInputPosition = position + matchLength | 0;
        var leaf_1 = new CompleteTreeDataNode(terminalRuntimeRule, position, nextInputPosition, nextInputPosition, Companion_getInstance_11().OPTION_NONE, emptyList());
        $this.m1e_1.d20(terminalRuntimeRule, position, leaf_1);
        tmp_0 = leaf_1;
      }
      tmp = tmp_0;
    }
  }
  return tmp;
}
function SentenceDefault$Companion$eolPositions$lambda(it) {
  return it.eg().ck_1;
}
var Companion_instance_20;
function Companion_getInstance_20() {
  if (Companion_instance_20 === VOID)
    new Companion_20();
  return Companion_instance_20;
}
function SentenceDefault$eolPositions$delegate$lambda(this$0) {
  return () => Companion_getInstance_20().eolPositions(this$0.u26_1);
}
function SentenceDefault$_get_eolPositions_$ref_e1vexk() {
  return (p0) => p0.eolPositions;
}
var Companion_instance_21;
function Companion_getInstance_21() {
  return Companion_instance_21;
}
function get_isEmptyMatch(_this__u8e3s4) {
  return _this__u8e3s4.startPosition === _this__u8e3s4.nextInputPosition;
}
function CountTreesVisitor$visitBranch$lambda(a, b) {
  // Inline function 'kotlin.comparisons.compareValuesBy' call
  var tmp = a.a2();
  var tmp$ret$1 = b.a2();
  return compareValues(tmp, tmp$ret$1);
}
function _get__tokensByLine__ebyq43($this) {
  var tmp0 = $this.a29_1;
  var tmp = KProperty1;
  // Inline function 'kotlin.getValue' call
  getPropertyCallableRef('_tokensByLine', 1, tmp, SPPTFromTreeData$_get__tokensByLine_$ref_sfh7n9(), null);
  return tmp0.b2();
}
function SPPTFromTreeData$_tokensByLine$delegate$lambda(this$0) {
  return () => {
    var visitor = new TokensByLineVisitor(this$0.sentence);
    visitor.h29(this$0, emptyList());
    return visitor.g29_1;
  };
}
function SPPTFromTreeData$_get__tokensByLine_$ref_sfh7n9() {
  return (p0) => _get__tokensByLine__ebyq43(p0);
}
function SPPTFromTreeData$asSentence$delegate$lambda$lambda(a, b) {
  // Inline function 'kotlin.comparisons.compareValuesBy' call
  var tmp = a.length;
  var tmp$ret$1 = b.length;
  return compareValues(tmp, tmp$ret$1);
}
function SPPTFromTreeData$asSentence$delegate$lambda(this$0) {
  return () => {
    var walker = new SpptWalkerToInputSentence(this$0.sentence);
    this$0.x28_1.traverseTreeDepthFirst(walker, false);
    // Inline function 'kotlin.collections.sortedBy' call
    var this_0 = walker.k29();
    // Inline function 'kotlin.comparisons.compareBy' call
    var tmp = SPPTFromTreeData$asSentence$delegate$lambda$lambda;
    var tmp$ret$0 = new sam$kotlin_Comparator$0_12(tmp);
    var tmp$ret$1 = sortedWith(this_0, tmp$ret$0);
    return last(tmp$ret$1);
  };
}
function SPPTFromTreeData$_get_asSentence_$ref_19101i() {
  return (p0) => p0.asSentence;
}
function SPPTFromTreeData$countTrees$delegate$lambda(this$0) {
  return () => (new CountTreesVisitor()).visitTree(this$0, Unit_instance);
}
function SPPTFromTreeData$_get_countTrees_$ref_xsxrlx() {
  return (p0) => p0.countTrees;
}
function SPPTFromTreeData$toStringAll$delegate$lambda(this$0) {
  return () => this$0.toStringAllWithIndent('  ', true);
}
function SPPTFromTreeData$_get_toStringAll_$ref_5gchp6() {
  return (p0) => p0.toStringAll;
}
function _get_rootRuntimeRuleSet__c3cqbf($this) {
  var tmp = $this.rootRuleSet;
  return tmp instanceof RuntimeRuleSet ? tmp : THROW_CCE();
}
function scanError($this) {
  // Inline function 'kotlin.comparisons.maxOf' call
  var b = $this.s29_1.d2a_1 - 5 | 0;
  var tmp$ret$0 = Math.max(0, b);
  var before = substring($this.q29_1, tmp$ret$0, $this.s29_1.d2a_1);
  var tmp = $this.s29_1.d2a_1;
  var tmp0 = $this.q29_1.length;
  // Inline function 'kotlin.comparisons.minOf' call
  var b_0 = $this.s29_1.d2a_1 + 5 | 0;
  var tmp$ret$1 = Math.min(tmp0, b_0);
  var after = substring($this.q29_1, tmp, tmp$ret$1);
  var seg = before + '^' + after;
  // Inline function 'kotlin.error' call
  var message = 'Tree String invalid at position ' + $this.s29_1.d2a_1 + ', ...' + seg + '...';
  throw IllegalStateException.t4(toString(message));
}
function scanEmpty($this) {
  $this.s29_1.q2a(Tokens_getInstance().f2a_1);
  $this.t29_1 = $this.u29_1;
  var emptyNode = emptyLeaf($this, $this.t29_1, $this.u29_1);
  $this.x29_1.s11().v(emptyNode);
}
function scanEmptyList($this) {
  $this.s29_1.q2a(Tokens_getInstance().g2a_1);
  $this.t29_1 = $this.u29_1;
  var emptyNode = emptyListLeaf($this, $this.t29_1, $this.u29_1);
  $this.x29_1.s11().v(emptyNode);
}
function scanLiteral($this) {
  var literal = $this.s29_1.q2a(Tokens_getInstance().l2a_1);
  var textWithQuotes = literal;
  var text = removeSurrounding(textWithQuotes, "'");
  var textUnescaped = CommonRegexPatterns_getInstance().unescape_LITERAL(text);
  $this.t29_1 = $this.u29_1;
  $this.u29_1 = $this.u29_1 + textUnescaped.w1a_1.length | 0;
  var literalUnescaped = CommonRegexPatterns_getInstance().unescape_LITERAL(literal);
  leaf($this, literalUnescaped.w1a_1, textUnescaped.w1a_1, $this.t29_1, $this.u29_1);
}
function scanLeafLiteral($this) {
  var id = $this.s29_1.q2a(Tokens_getInstance().i2a_1);
  $this.s29_1.q2a(Tokens_getInstance().n2a_1);
  var textWithQuotes = $this.s29_1.q2a(Tokens_getInstance().l2a_1);
  var text = removeSurrounding(textWithQuotes, "'");
  var textUnescaped = CommonRegexPatterns_getInstance().unescape_LITERAL(text);
  $this.t29_1 = $this.u29_1;
  $this.u29_1 = $this.u29_1 + textUnescaped.w1a_1.length | 0;
  leaf($this, id, textUnescaped.w1a_1, $this.t29_1, $this.u29_1);
}
function scanPattern($this) {
  var pattern = $this.s29_1.q2a(Tokens_getInstance().m2a_1);
  $this.s29_1.q2a(Tokens_getInstance().n2a_1);
  var textWithQuotes = $this.s29_1.q2a(Tokens_getInstance().l2a_1);
  var text = substring(textWithQuotes, 1, textWithQuotes.length - 1 | 0);
  var textUnescaped = CommonRegexPatterns_getInstance().unescape_LITERAL(text);
  $this.t29_1 = $this.u29_1;
  $this.u29_1 = $this.u29_1 + textUnescaped.w1a_1.length | 0;
  var patternUnescaped = CommonRegexPatterns_getInstance().unescape_PATTERN(pattern);
  leaf($this, patternUnescaped.u1a_1, textUnescaped.w1a_1, $this.t29_1, $this.u29_1);
}
function scanBranchStart($this) {
  var id = $this.s29_1.q2a(Tokens_getInstance().i2a_1);
  $this.s29_1.q2a(Tokens_getInstance().o2a_1);
  beginBranch($this, id, Companion_getInstance_11().OPTION_NONE);
}
function scanBranchStartWithOption($this) {
  var id = $this.s29_1.q2a(Tokens_getInstance().i2a_1);
  var option = new OptionNum(toInt(substring_0($this.s29_1.q2a(Tokens_getInstance().k2a_1), 1)));
  $this.s29_1.q2a(Tokens_getInstance().o2a_1);
  beginBranch($this, id, option);
}
function scanBranchEnd($this) {
  $this.s29_1.q2a(Tokens_getInstance().p2a_1);
  endBranch($this);
}
function scanEmbedded($this) {
  var leafId = $this.s29_1.q2a(Tokens_getInstance().i2a_1);
  $this.s29_1.q2a(Tokens_getInstance().n2a_1);
  var embGram = $this.s29_1.q2a(Tokens_getInstance().i2a_1);
  $this.s29_1.q2a(Tokens_getInstance().j2a_1);
  var embGoal = $this.s29_1.q2a(Tokens_getInstance().i2a_1);
  $this.s29_1.q2a(Tokens_getInstance().o2a_1);
  beginEmbedded($this, leafId, embGram, embGoal);
  new RuleReference(new QName(embGram), embGoal);
}
function beginTree($this, rrs, oldTree) {
  var treeData_0 = oldTree == null ? treeData(rrs.number) : oldTree;
  $this.v29_1.o11(treeData_0);
  $this.y29_1.o11(rrs);
}
function endTree($this, userGoalNode) {
  var rrs = $this.y29_1.v11();
  var treeData = $this.v29_1.v11();
  var gr = ensureNotNull(rrs.goalRuleFor.c3(userGoalNode.q1e_1));
  var pseudoRoot = new CompleteTreeDataNode(gr, userGoalNode.r1e_1, userGoalNode.s1e_1, userGoalNode.t1e_1, Companion_getInstance_11().OPTION_NONE, emptyList());
  treeData.setChildren(pseudoRoot, listOf(userGoalNode), false);
  treeData.setRootTo(pseudoRoot);
  return treeData;
}
function emptyLeaf($this, startPosition, nextInputPosition) {
  var terminalRule = Companion_getInstance_17().EMPTY;
  return new CompleteTreeDataNode(terminalRule, startPosition, nextInputPosition, nextInputPosition, Companion_getInstance_11().OPTION_NONE, emptyList());
}
function emptyListLeaf($this, startPosition, nextInputPosition) {
  var terminalRule = Companion_getInstance_17().EMPTY_LIST;
  return new CompleteTreeDataNode(terminalRule, startPosition, nextInputPosition, nextInputPosition, Companion_getInstance_11().OPTION_NONE, emptyList());
}
function leaf($this, tag, text, startPosition, nextInputPosition) {
  $this.z29_1.ya(text);
  var terminalRule = $this.y29_1.s11().findTerminalRule(tag);
  var leaf = new CompleteTreeDataNode(terminalRule, startPosition, nextInputPosition, nextInputPosition, Companion_getInstance_11().OPTION_NONE, emptyList());
  $this.x29_1.s11().v(leaf);
}
function beginBranch($this, ruleName, option) {
  $this.w29_1.o11(new NodeStart(new RuleReference(null, ruleName), option, $this.t29_1, $this.u29_1));
  // Inline function 'kotlin.collections.mutableListOf' call
  var tmp$ret$0 = ArrayList.o1();
  $this.x29_1.o11(tmp$ret$0);
}
function endBranch($this) {
  var lastNodeStart = $this.w29_1.v11();
  var ntRef = lastNodeStart.r2a_1;
  var rr = $this.y29_1.s11().findRuntimeRule(ntRef.w2a_1);
  var children = $this.x29_1.v11();
  var tmp0_safe_receiver = firstOrNull(children);
  var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.r1e_1;
  var startPosition = tmp1_elvis_lhs == null ? 0 : tmp1_elvis_lhs;
  var tmp2_safe_receiver = lastOrNull(children);
  var tmp3_elvis_lhs = tmp2_safe_receiver == null ? null : tmp2_safe_receiver.s1e_1;
  var nextInputPosition = tmp3_elvis_lhs == null ? 0 : tmp3_elvis_lhs;
  var tmp4_safe_receiver = lastOrNull(children);
  var tmp5_elvis_lhs = tmp4_safe_receiver == null ? null : tmp4_safe_receiver.t1e_1;
  var nextInputNoSkip = tmp5_elvis_lhs == null ? 0 : tmp5_elvis_lhs;
  var tn = rr.isOptional ? children.i1(0).q1e_1.isEmptyTerminal ? new CompleteTreeDataNode(rr, startPosition, nextInputPosition, nextInputNoSkip, Companion_getInstance_11().OPTION_OPTIONAL_EMPTY, emptyList()) : new CompleteTreeDataNode(rr, startPosition, nextInputPosition, nextInputNoSkip, Companion_getInstance_11().OPTION_OPTIONAL_ITEM, emptyList()) : rr.isListSimple ? children.i1(0).q1e_1.isEmptyListTerminal ? new CompleteTreeDataNode(rr, startPosition, nextInputPosition, nextInputNoSkip, Companion_getInstance_11().OPTION_MULTI_EMPTY, emptyList()) : new CompleteTreeDataNode(rr, startPosition, nextInputPosition, nextInputNoSkip, Companion_getInstance_11().OPTION_MULTI_ITEM, emptyList()) : rr.isListSeparated ? children.i1(0).q1e_1.isEmptyListTerminal ? new CompleteTreeDataNode(rr, startPosition, nextInputPosition, nextInputNoSkip, Companion_getInstance_11().OPTION_SLIST_EMPTY, emptyList()) : new CompleteTreeDataNode(rr, startPosition, nextInputPosition, nextInputNoSkip, Companion_getInstance_11().OPTION_SLIST_ITEM_OR_SEPERATOR, emptyList()) : new CompleteTreeDataNode(rr, startPosition, nextInputPosition, nextInputNoSkip, lastNodeStart.s2a_1, emptyList());
  // Inline function 'kotlin.collections.isNotEmpty' call
  var isAlternative = !$this.v29_1.s11().childrenFor(tn).l1();
  $this.v29_1.s11().setChildren(tn, children, isAlternative);
  if (ntRef.x2a())
    endEmbedded($this, tn);
  else
    $this.x29_1.s11().v(tn);
}
function beginEmbedded($this, embLeafName, embGramPossiblyQualifiedName, embGoalName) {
  $this.w29_1.o11(new NodeStart(new RuleReference(null, embLeafName), Companion_getInstance_11().OPTION_NONE, $this.t29_1, $this.u29_1));
  $this.w29_1.o11(new NodeStart(new RuleReference(new QName(embGramPossiblyQualifiedName), embGoalName), Companion_getInstance_11().OPTION_NONE, $this.t29_1, $this.u29_1));
  // Inline function 'kotlin.collections.mutableListOf' call
  var tmp$ret$0 = ArrayList.o1();
  $this.x29_1.o11(tmp$ret$0);
  var currentQn = $this.y29_1.s11().qualifiedName;
  var currentNs = substringBeforeLast(currentQn, '.');
  var embQn = contains(embGramPossiblyQualifiedName, '.') ? embGramPossiblyQualifiedName : currentNs + '.' + embGramPossiblyQualifiedName;
  var tmp0_elvis_lhs = $this.r29_1.c3(embQn);
  var tmp;
  if (tmp0_elvis_lhs == null) {
    var message = "No embedded RuntimeRuleSet with name '" + embGramPossiblyQualifiedName + "' passed to SPPTParser";
    throw IllegalStateException.t4(toString(message));
  } else {
    tmp = tmp0_elvis_lhs;
  }
  var embrrs = tmp;
  $this.y29_1.o11(embrrs);
  var embTreeData = treeData(embrrs.number);
  $this.v29_1.o11(embTreeData);
}
function endEmbedded($this, embUserRoot) {
  var lastNodeStart = $this.w29_1.v11();
  var embLeafName = lastNodeStart.r2a_1.w2a_1;
  var embTreeData = endTree($this, embUserRoot);
  var emRoot = ensureNotNull(embTreeData.root);
  var terminalRule = $this.y29_1.s11().findTerminalRule(embLeafName);
  var startPosition = emRoot.startPosition;
  var nextInputPosition = emRoot.nextInputPosition;
  var nextInputNoSkip = emRoot.nextInputNoSkip;
  var leaf = new CompleteTreeDataNode(terminalRule, startPosition, nextInputPosition, nextInputNoSkip, Companion_getInstance_11().OPTION_NONE, emptyList());
  $this.x29_1.s11().v(leaf);
  $this.v29_1.s11().setEmbeddedTreeFor(leaf, embTreeData);
  return embTreeData;
}
var Tokens_instance;
function Tokens_getInstance() {
  if (Tokens_instance === VOID)
    new Tokens();
  return Tokens_instance;
}
function matchedTextNoSkip(_this__u8e3s4, node) {
  return substring(_this__u8e3s4.text, node.startPosition, node.nextInputNoSkip);
}
function locationForNode(_this__u8e3s4, node) {
  return _this__u8e3s4.locationFor(node.startPosition, node.nextInputNoSkip - node.startPosition | 0);
}
var Companion_instance_22;
function Companion_getInstance_22() {
  return Companion_instance_22;
}
function pushText($this, nodeInfo, text) {
  if (null == nodeInfo) {
    $this.j29_1.o11(new Pair(nodeInfo, text));
  } else if ($this.j29_1.p11()) {
    $this.j29_1.o11(new Pair(nodeInfo, text));
  } else if (nodeInfo.node.rule.isChoiceAmbiguous) {
    var tmp0_elvis_lhs = $this.j29_1.s11().hi_1;
    var tmp;
    if (tmp0_elvis_lhs == null) {
      var message = 'Should not happen';
      throw IllegalStateException.t4(toString(message));
    } else {
      tmp = tmp0_elvis_lhs;
    }
    var top = tmp;
    if (equals(top.node.rule, nodeInfo.node.rule)) {
      $this.j29_1.v11();
      $this.j29_1.o11(new Pair(nodeInfo, text));
    } else {
      $this.j29_1.o11(new Pair(nodeInfo, text));
    }
  } else {
    $this.j29_1.o11(new Pair(nodeInfo, text));
  }
}
function SpptWalkerToInputSentence$endBranch$lambda(it) {
  return it.ii_1;
}
function SpptWalkerToInputSentence$endEmbedded$lambda(it) {
  return it.ii_1;
}
function treeData(forStateSetNumber) {
  return new TreeDataComplete2(forStateSetNumber);
}
function _get_preferred__p9krn4($this, _this__u8e3s4) {
  return new PreferredNode(_this__u8e3s4.rule, _this__u8e3s4.startPosition);
}
var Companion_instance_23;
function Companion_getInstance_23() {
  return Companion_instance_23;
}
function setCompletedBy($this, parent, children, isAlternative) {
  var alternatives = $this.p2b_1.c3(parent);
  if (null == alternatives) {
    alternatives = mutableMapOf([to(parent.option, children)]);
    var tmp0 = $this.p2b_1;
    // Inline function 'kotlin.collections.set' call
    var value = alternatives;
    tmp0.f3(parent, value);
    if (isAlternative) {
      $this.q2b_1.g3(_get_preferred__p9krn4(Companion_instance_23, parent));
    } else {
      var tmp0_0 = $this.q2b_1;
      // Inline function 'kotlin.collections.set' call
      var key = _get_preferred__p9krn4(Companion_instance_23, parent);
      tmp0_0.f3(key, parent);
    }
  } else {
    if (isAlternative) {
      $this.q2b_1.g3(_get_preferred__p9krn4(Companion_instance_23, parent));
    } else {
      var tmp0_1 = $this.q2b_1;
      // Inline function 'kotlin.collections.set' call
      var key_0 = _get_preferred__p9krn4(Companion_instance_23, parent);
      tmp0_1.f3(key_0, parent);
      alternatives.i3();
    }
    var tmp0_2 = alternatives;
    // Inline function 'kotlin.collections.set' call
    var key_1 = parent.option;
    tmp0_2.f3(key_1, children);
  }
}
function _get_preferred__p9krn4_0($this, _this__u8e3s4) {
  return new PreferredNode(_this__u8e3s4.rule, _this__u8e3s4.startPosition);
}
var Companion_instance_24;
function Companion_getInstance_24() {
  return Companion_instance_24;
}
function setCompletedBy_0($this, parent, children, isAlternative) {
  var ck = parent;
  var alternatives = $this._complete.c3(ck);
  if (null == alternatives) {
    alternatives = mutableMapOf([to(parent.option, children)]);
    var tmp0 = $this._complete;
    // Inline function 'kotlin.collections.set' call
    var value = alternatives;
    tmp0.f3(ck, value);
    if (isAlternative) {
      $this._preferred.g3(_get_preferred__p9krn4_0(Companion_instance_24, ck));
    } else {
      var tmp0_0 = $this._preferred;
      // Inline function 'kotlin.collections.set' call
      var key = _get_preferred__p9krn4_0(Companion_instance_24, ck);
      tmp0_0.f3(key, parent);
    }
  } else {
    if (isAlternative) {
      $this._preferred.g3(_get_preferred__p9krn4_0(Companion_instance_24, ck));
    } else {
      var tmp0_1 = $this._preferred;
      // Inline function 'kotlin.collections.set' call
      var key_0 = _get_preferred__p9krn4_0(Companion_instance_24, ck);
      tmp0_1.f3(key_0, parent);
      alternatives.i3();
    }
    var tmp0_2 = alternatives;
    // Inline function 'kotlin.collections.set' call
    var key_1 = parent.option;
    tmp0_2.f3(key_1, children);
  }
}
var Companion_instance_25;
function Companion_getInstance_25() {
  return Companion_instance_25;
}
function setGrowingChildren($this, parent, children) {
  if (false) {
    var tmp = Debug_instance;
    var tmp_0 = IndentDelta_NONE_getInstance();
    tmp.debug(tmp_0, TreeDataGrowing$setGrowingChildren$lambda(parent, children));
  }
  // Inline function 'kotlin.collections.set' call
  $this.i1e_1.f3(parent, children);
}
function removeGrowingNode($this, gni) {
  if (false) {
    var tmp = Debug_instance;
    var tmp_0 = IndentDelta_NONE_getInstance();
    tmp.debug(tmp_0, TreeDataGrowing$removeGrowingNode$lambda(gni));
  }
  return $this.i1e_1.g3(gni);
}
function TreeDataGrowing$setGrowingChildren$lambda($parent, $children) {
  return () => 'Set growing children: ' + toString_0($parent) + ' = ' + toString_0($children);
}
function TreeDataGrowing$removeGrowingNode$lambda($gni) {
  return () => 'Remove growing parent: ' + toString_0($gni);
}
var Companion_instance_26;
function Companion_getInstance_26() {
  return Companion_instance_26;
}
function numSkipChildren($this, skipData) {
  var tmp;
  if (null == skipData) {
    tmp = 0;
  } else {
    var goal = ensureNotNull(skipData.root);
    var skipMulti = skipData.childrenFor(goal).i1(0).ii_1.i1(0);
    var multi = skipData.childrenFor(skipMulti).i1(0).ii_1;
    tmp = multi.h1();
  }
  return tmp;
}
function traverseSkip($this, callback, skipDataAsTree) {
  var goal = ensureNotNull($this.v2b_1.root);
  var skipMulti = $this.v2b_1.childrenFor(goal).i1(0).ii_1.i1(0);
  var multi = $this.v2b_1.childrenFor(skipMulti).i1(0).ii_1;
  var parentAlt = new AltInfo(Companion_getInstance_11().OPTION_NONE, 0, 1);
  var inductionVariable = multi.h1() - 1 | 0;
  if (0 <= inductionVariable)
    do {
      var i = inductionVariable;
      inductionVariable = inductionVariable + -1 | 0;
      var n = multi.i1(i);
      var childOfTotal = new ChildInfo(i, i, multi.h1() + 1 | 0);
      var skp = $this.v2b_1.childrenFor(n).i1(0).ii_1.i1(0);
      var skpPath = new ParsePath(emptyList());
      $this.x2b_1.o11(new StackInfo(false, skpPath, skp, parentAlt, new AltInfo(Companion_getInstance_11().OPTION_NONE, 0, 1), childOfTotal, emptyMap(), -1));
    }
     while (0 <= inductionVariable);
  while ($this.x2b_1.q11()) {
    var info = $this.x2b_1.v11();
    traverseStackData($this, callback, skipDataAsTree, info);
  }
}
function traverseSkipData($this, callback, skipDataAsTree, skipData) {
  if (!(null == skipData)) {
    if (skipDataAsTree) {
      var walker = new TreeDataWalkerDepthFirst(skipData);
      traverseSkip(walker, callback, skipDataAsTree);
    } else {
      callback.skip(skipData);
    }
  }
}
function traverseStackData($this, callback, skipDataAsTree, stackData) {
  if (stackData instanceof StackInfo) {
    if (stackData.r2c_1.rule.isTerminal) {
      traverseLeaf($this, callback, skipDataAsTree, stackData);
    } else {
      traverseBranch($this, callback, skipDataAsTree, stackData);
    }
  } else {
    if (stackData instanceof AlternativesInfo) {
      traverseAlternative($this, callback, skipDataAsTree, stackData);
    } else {
      // Inline function 'kotlin.error' call
      var message = 'Internal Error: Should not happen';
      throw IllegalStateException.t4(toString(message));
    }
  }
}
function traverseAlternative($this, callback, skipDataAsTree, info) {
  if (0 === info.z2c_1.h1()) {
    $this.w2b_1.v11();
  } else {
    var altChildrenInfo = info.z2c_1.o3(get_lastIndex(info.z2c_1));
    var nodeInfo = altChildrenInfo.hi_1;
    var children = altChildrenInfo.ii_1;
    $this.x2b_1.o11(info);
    $this.x2b_1.o11(nodeInfo);
    callback.beginBranch(nodeInfo);
    if (info.y2c_1) {
      traverseSkipData($this, callback, skipDataAsTree, $this.v2b_1.initialSkip);
    }
    var totChildrenIncSkip = children.h1() + nodeInfo.w2c_1 | 0;
    var inductionVariable = children.h1() - 1 | 0;
    if (0 <= inductionVariable)
      do {
        var i = inductionVariable;
        inductionVariable = inductionVariable + -1 | 0;
        var ch = children.i1(i);
        var propertyIndex = nodeInfo.r2c_1.rule.isList ? 0 : i;
        var childOfTotal = new ChildInfo(propertyIndex, i, totChildrenIncSkip);
        var childPath = nodeInfo.r2c_1.rule.isList ? nodeInfo.q2c_1.plus(i.toString()).plus(ch.rule.tag) : nodeInfo.q2c_1.plus(ch.rule.tag);
        $this.x2b_1.o11(new StackInfo(false, childPath, ch, nodeInfo.s2c_1, nodeInfo.t2c_1, childOfTotal, emptyMap(), -1));
      }
       while (0 <= inductionVariable);
  }
}
function traverseBranch($this, callback, skipDataAsTree, nodeInfo) {
  if (nodeInfo.p2c_1) {
    callback.endBranch(nodeInfo);
  } else {
    var altInfo = new AlternativesInfo(nodeInfo.r2c_1, false);
    var tmp0 = $this.w2b_1.r11();
    var tmp$ret$0;
    $l$block_0: {
      // Inline function 'kotlin.collections.any' call
      var tmp;
      if (isInterface(tmp0, Collection)) {
        tmp = tmp0.l1();
      } else {
        tmp = false;
      }
      if (tmp) {
        tmp$ret$0 = false;
        break $l$block_0;
      }
      var _iterator__ex2g4s = tmp0.g1();
      while (_iterator__ex2g4s.f()) {
        var element = _iterator__ex2g4s.e();
        if (equals(element.x2c_1, altInfo.x2c_1)) {
          tmp$ret$0 = true;
          break $l$block_0;
        }
      }
      tmp$ret$0 = false;
    }
    if (tmp$ret$0) {
      var tmp_0 = TreeDataWalkerDepthFirst$traverseBranch$lambda($this);
      callback.treeError('Loop in Tree, Grammar has a recursive path that does not consume any input.', new sam$net_akehurst_language_sppt_api_PathFunction$0(tmp_0));
    } else {
      // Inline function 'kotlin.collections.sortedBy' call
      var this_0 = $this.v2b_1.childrenFor(nodeInfo.r2c_1);
      // Inline function 'kotlin.comparisons.compareBy' call
      var tmp_1 = TreeDataWalkerDepthFirst$traverseBranch$lambda_0;
      var tmp$ret$2 = new sam$kotlin_Comparator$0_14(tmp_1);
      var alternatives = sortedWith(this_0, tmp$ret$2);
      $this.w2b_1.o11(altInfo);
      $this.x2b_1.o11(altInfo);
      // Inline function 'kotlin.collections.associate' call
      var capacity = coerceAtLeast(mapCapacity(collectionSizeOrDefault(alternatives, 10)), 16);
      // Inline function 'kotlin.collections.associateTo' call
      var destination = LinkedHashMap.gb(capacity);
      var _iterator__ex2g4s_0 = alternatives.g1();
      while (_iterator__ex2g4s_0.f()) {
        var element_0 = _iterator__ex2g4s_0.e();
        // Inline function 'kotlin.collections.plusAssign' call
        var pair = new Pair(element_0.hi_1, element_0.ii_1.h1());
        destination.f3(pair.hi_1, pair.ii_1);
      }
      var numChildrenAlternatives = destination;
      var inductionVariable = alternatives.h1() - 1 | 0;
      if (0 <= inductionVariable)
        do {
          var i = inductionVariable;
          inductionVariable = inductionVariable + -1 | 0;
          var _destruct__k2r9zo = alternatives.i1(i);
          var alt = _destruct__k2r9zo.ni();
          var children = _destruct__k2r9zo.oi();
          var altOfTotal = new AltInfo(alt, i, alternatives.h1());
          // Inline function 'kotlin.collections.filter' call
          // Inline function 'kotlin.collections.filterTo' call
          var destination_0 = ArrayList.o1();
          var _iterator__ex2g4s_1 = children.g1();
          while (_iterator__ex2g4s_1.f()) {
            var element_1 = _iterator__ex2g4s_1.e();
            if (element_1.rule.isTerminal) {
              destination_0.v(element_1);
            }
          }
          // Inline function 'kotlin.collections.fold' call
          var accumulator = 0;
          var _iterator__ex2g4s_2 = destination_0.g1();
          while (_iterator__ex2g4s_2.f()) {
            var element_2 = _iterator__ex2g4s_2.e();
            var acc = accumulator;
            var tmp0_safe_receiver = $this.v2b_1.skipDataAfter(element_2);
            var tmp_2;
            if (tmp0_safe_receiver == null) {
              tmp_2 = null;
            } else {
              // Inline function 'kotlin.let' call
              tmp_2 = acc + numSkipChildren($this, tmp0_safe_receiver) | 0;
            }
            var tmp1_elvis_lhs = tmp_2;
            accumulator = tmp1_elvis_lhs == null ? acc : tmp1_elvis_lhs;
          }
          var numSkipChildren_0 = accumulator;
          var stackData = new StackInfo(true, nodeInfo.q2c_1, nodeInfo.r2c_1, nodeInfo.t2c_1, altOfTotal, nodeInfo.u2c_1, numChildrenAlternatives, numSkipChildren_0);
          altInfo.z2c_1.v(new Pair(stackData, children));
        }
         while (0 <= inductionVariable);
    }
  }
}
function traverseLeaf($this, callback, skipDataAsTree, nodeInfo) {
  if (nodeInfo.r2c_1.rule.isEmbedded) {
    var tmp0_elvis_lhs = $this.v2b_1.embeddedFor(nodeInfo.r2c_1);
    var tmp;
    if (tmp0_elvis_lhs == null) {
      var message = "Cannot find embedded TreeData for '" + toString(nodeInfo.r2c_1) + "'";
      throw IllegalStateException.t4(toString(message));
    } else {
      tmp = tmp0_elvis_lhs;
    }
    var ed = tmp;
    var numChildrenAlternatives = mapOf(to(Companion_getInstance_11().OPTION_NONE, 1));
    var tmp1_safe_receiver = $this.v2b_1.skipDataAfter(nodeInfo.r2c_1);
    var tmp_0;
    if (tmp1_safe_receiver == null) {
      tmp_0 = null;
    } else {
      // Inline function 'kotlin.let' call
      tmp_0 = numSkipChildren($this, tmp1_safe_receiver);
    }
    var tmp2_elvis_lhs = tmp_0;
    var numSkipChildren_0 = tmp2_elvis_lhs == null ? 0 : tmp2_elvis_lhs;
    var embPath = nodeInfo.q2c_1;
    var stackData = new StackInfo(true, embPath, nodeInfo.r2c_1, nodeInfo.s2c_1, nodeInfo.t2c_1, nodeInfo.u2c_1, numChildrenAlternatives, numSkipChildren_0);
    callback.beginEmbedded(stackData);
    ed.traverseTreeDepthFirst(callback, skipDataAsTree);
    traverseSkipData($this, callback, skipDataAsTree, $this.v2b_1.skipDataAfter(nodeInfo.r2c_1));
    callback.endEmbedded(stackData);
  } else {
    callback.leaf(nodeInfo);
    traverseSkipData($this, callback, skipDataAsTree, $this.v2b_1.skipDataAfter(nodeInfo.r2c_1));
  }
}
function TreeDataWalkerDepthFirst$traverse$lambda(a, b) {
  // Inline function 'kotlin.comparisons.compareValuesBy' call
  var tmp = a.hi_1.asIndex;
  var tmp$ret$1 = b.hi_1.asIndex;
  return compareValues(tmp, tmp$ret$1);
}
function TreeDataWalkerDepthFirst$traverseBranch$lambda(this$0) {
  return () => {
    // Inline function 'kotlin.collections.map' call
    var this_0 = this$0.w2b_1.r11();
    // Inline function 'kotlin.collections.mapTo' call
    var destination = ArrayList.a1(collectionSizeOrDefault(this_0, 10));
    var _iterator__ex2g4s = this_0.g1();
    while (_iterator__ex2g4s.f()) {
      var item = _iterator__ex2g4s.e();
      var tmp$ret$0 = item.x2c_1;
      destination.v(tmp$ret$0);
    }
    return destination;
  };
}
function TreeDataWalkerDepthFirst$traverseBranch$lambda_0(a, b) {
  // Inline function 'kotlin.comparisons.compareValuesBy' call
  var tmp = a.hi_1;
  var tmp$ret$1 = b.hi_1;
  return compareValues(tmp, tmp$ret$1);
}
function debug(indentDelta, lazyMessage) {
  return Debug_instance.debug(indentDelta, lazyMessage);
}
var IndentDelta_NONE_instance;
var IndentDelta_INC_BEFORE_instance;
var IndentDelta_INC_AFTER_instance;
var IndentDelta_DEC_BEFORE_instance;
var IndentDelta_DEC_AFTER_instance;
function values_12() {
  return [IndentDelta_NONE_getInstance(), IndentDelta_INC_BEFORE_getInstance(), IndentDelta_INC_AFTER_getInstance(), IndentDelta_DEC_BEFORE_getInstance(), IndentDelta_DEC_AFTER_getInstance()];
}
function valueOf_12(value) {
  switch (value) {
    case 'NONE':
      return IndentDelta_NONE_getInstance();
    case 'INC_BEFORE':
      return IndentDelta_INC_BEFORE_getInstance();
    case 'INC_AFTER':
      return IndentDelta_INC_AFTER_getInstance();
    case 'DEC_BEFORE':
      return IndentDelta_DEC_BEFORE_getInstance();
    case 'DEC_AFTER':
      return IndentDelta_DEC_AFTER_getInstance();
    default:
      IndentDelta_initEntries();
      THROW_IAE('No enum constant net.akehurst.language.agl.util.Debug.IndentDelta.' + value);
      break;
  }
}
var IndentDelta_entriesInitialized;
function IndentDelta_initEntries() {
  if (IndentDelta_entriesInitialized)
    return Unit_instance;
  IndentDelta_entriesInitialized = true;
  IndentDelta_NONE_instance = new IndentDelta('NONE', 0);
  IndentDelta_INC_BEFORE_instance = new IndentDelta('INC_BEFORE', 1);
  IndentDelta_INC_AFTER_instance = new IndentDelta('INC_AFTER', 2);
  IndentDelta_DEC_BEFORE_instance = new IndentDelta('DEC_BEFORE', 3);
  IndentDelta_DEC_AFTER_instance = new IndentDelta('DEC_AFTER', 4);
}
function IndentDelta_NONE_getInstance() {
  IndentDelta_initEntries();
  return IndentDelta_NONE_instance;
}
function IndentDelta_INC_BEFORE_getInstance() {
  IndentDelta_initEntries();
  return IndentDelta_INC_BEFORE_instance;
}
function IndentDelta_INC_AFTER_getInstance() {
  IndentDelta_initEntries();
  return IndentDelta_INC_AFTER_instance;
}
function IndentDelta_DEC_BEFORE_getInstance() {
  IndentDelta_initEntries();
  return IndentDelta_DEC_BEFORE_instance;
}
function IndentDelta_DEC_AFTER_getInstance() {
  IndentDelta_initEntries();
  return IndentDelta_DEC_AFTER_instance;
}
var Debug_instance;
function Debug_getInstance() {
  return Debug_instance;
}
function cached(initializer) {
  return new CachedValue(initializer);
}
var UNINITIALIZED_VALUE_instance;
function UNINITIALIZED_VALUE_getInstance() {
  return UNINITIALIZED_VALUE_instance;
}
var Companion_instance_27;
function Companion_getInstance_27() {
  return Companion_instance_27;
}
function CachedValue$resetAction$lambda(it) {
  return Unit_instance;
}
//region block: post-declaration
initMetadataForObject(BuildConfig_0, 'BuildConfig');
initMetadataForCompanion(Companion);
initMetadataForClass(AutomatonForMinimal, 'AutomatonForMinimal');
initMetadataForClass(StateForMinimal, 'StateForMinimal');
initMetadataForClass(TransitionForMinimal, 'TransitionForMinimal');
initMetadataForClass(GSSNodeForMinimal, 'GSSNodeForMinimal');
initMetadataForInterface(SpptDataNode, 'SpptDataNode');
initMetadataForClass(CompleteNodeForMinimal, 'CompleteNodeForMinimal', VOID, VOID, [SpptDataNode]);
initMetadataForCompanion(Companion_0);
initMetadataForClass(sam$kotlin_Comparator$0, 'sam$kotlin_Comparator$0', VOID, VOID, [Comparator, FunctionAdapter]);
initMetadataForClass(MinimalParser, 'MinimalParser');
initMetadataForClass(AutomatonKind, 'AutomatonKind');
initMetadataForClass(StateNumber, 'StateNumber');
initMetadataForInterface(Automaton, 'Automaton');
initMetadataForInterface(AutomatonState, 'AutomatonState');
initMetadataForInterface(AutomatonTransition, 'AutomatonTransition');
initMetadataForInterface(TransitionContext, 'TransitionContext');
initMetadataForInterface(LookaheadGuard, 'LookaheadGuard');
initMetadataForClass(ParseAction, 'ParseAction');
initMetadataForInterface(AutomatonBuilder, 'AutomatonBuilder');
initMetadataForInterface(TransitionBuilder, 'TransitionBuilder');
initMetadataForClass(AutomatonBuilderDefault, 'AutomatonBuilderDefault', VOID, VOID, [AutomatonBuilder]);
initMetadataForClass(TransitionBuilderDefault, 'TransitionBuilderDefault', VOID, VOID, [TransitionBuilder]);
initMetadataForClass(BuildCacheAbstract, 'BuildCacheAbstract');
initMetadataForClass(FirstOfResult, 'FirstOfResult');
initMetadataForClass(ClosureItemLC1, 'ClosureItemLC1');
initMetadataForClass(PossibleTransInfo, 'PossibleTransInfo');
initMetadataForClass(PossibleState, 'PossibleState');
initMetadataForCompanion(Companion_1);
initMetadataForClass(BuildCacheLC1, 'BuildCacheLC1');
initMetadataForClass(FirstFollowCache3, 'FirstFollowCache3', FirstFollowCache3);
initMetadataForClass(FirstOf, 'FirstOf', FirstOf);
initMetadataForClass(sam$kotlin_Comparator$0_0, 'sam$kotlin_Comparator$0', VOID, VOID, [Comparator, FunctionAdapter]);
initMetadataForCompanion(Companion_2);
initMetadataForClass(Lookahead, 'Lookahead', VOID, VOID, [LookaheadGuard]);
initMetadataForCompanion(Companion_3);
initMetadataForClass(LookaheadSet, 'LookaheadSet');
initMetadataForCompanion(Companion_4);
initMetadataForClass(ParserState, 'ParserState', VOID, VOID, [AutomatonState]);
initMetadataForClass(sam$kotlin_Comparator$0_1, 'sam$kotlin_Comparator$0', VOID, VOID, [Comparator, FunctionAdapter]);
protoOf(ParserStateSet).asString = asString;
initMetadataForClass(ParserStateSet, 'ParserStateSet', VOID, VOID, [Automaton]);
initMetadataForClass(RuntimeTransitionCalculator, 'RuntimeTransitionCalculator');
initMetadataForInterface(RuntimeGuard, 'RuntimeGuard');
initMetadataForClass(ToEndMultiGraftRuntimeGuard, 'ToEndMultiGraftRuntimeGuard', VOID, VOID, [RuntimeGuard]);
initMetadataForClass(ToItemMultiGraftRuntimeGuard, 'ToItemMultiGraftRuntimeGuard', VOID, VOID, [RuntimeGuard]);
initMetadataForClass(ToEndSListGraftRuntimeGuard, 'ToEndSListGraftRuntimeGuard', VOID, VOID, [RuntimeGuard]);
initMetadataForClass(ToItemSListGraftRuntimeGuard, 'ToItemSListGraftRuntimeGuard', VOID, VOID, [RuntimeGuard]);
initMetadataForClass(ToSeparatorSListGraftRuntimeGuard, 'ToSeparatorSListGraftRuntimeGuard', VOID, VOID, [RuntimeGuard]);
initMetadataForObject(DefaultRuntimeGuard, 'DefaultRuntimeGuard', VOID, VOID, [RuntimeGuard]);
initMetadataForCompanion(Companion_5);
initMetadataForClass(Transition, 'Transition', VOID, VOID, [AutomatonTransition]);
initMetadataForInterface(TransitionCache, 'TransitionCache');
initMetadataForInterface(TransitionPrevInfoKey, 'TransitionPrevInfoKey');
initMetadataForClass(CompleteKey, 'CompleteKey', VOID, VOID, [TransitionPrevInfoKey, TransitionContext]);
initMetadataForClass(IncompleteKey, 'IncompleteKey', VOID, VOID, [TransitionPrevInfoKey]);
initMetadataForCompanion(Companion_6);
initMetadataForClass(TransitionCacheLC1, 'TransitionCacheLC1', TransitionCacheLC1, VOID, [TransitionCache]);
initMetadataForCompanion(Companion_7);
initMetadataForClass(sam$kotlin_Comparator$0_2, 'sam$kotlin_Comparator$0', VOID, VOID, [Comparator, FunctionAdapter]);
initMetadataForClass(LookaheadSetPart, 'LookaheadSetPart');
initMetadataForClass(sam$kotlin_Comparator$0_3, 'sam$kotlin_Comparator$0', VOID, VOID, [Comparator, FunctionAdapter]);
initMetadataForCompanion(Companion_8);
initMetadataForClass(LookaheadInfoPart, 'LookaheadInfoPart');
initMetadataForClass(StateInfo, 'StateInfo');
initMetadataForClass(TransInfo, 'TransInfo');
initMetadataForClass(TransPrev, 'TransPrev');
initMetadataForClass(WidthInfo, 'WidthInfo');
initMetadataForClass(FirstTerminalInfo, 'FirstTerminalInfo');
initMetadataForClass(ParentNext, 'ParentNext');
initMetadataForInterface(ClosureItem, 'ClosureItem');
initMetadataForClass(ClosureItemAbstractGraph, 'ClosureItemAbstractGraph', VOID, VOID, [ClosureItem]);
initMetadataForClass(ClosureItemRootGraph, 'ClosureItemRootGraph', VOID, VOID, [ClosureItemAbstractGraph, ClosureItem]);
initMetadataForClass(ClosureItemChildGraph, 'ClosureItemChildGraph', VOID, VOID, [ClosureItemAbstractGraph, ClosureItem]);
initMetadataForCompanion(Companion_9);
initMetadataForClass(ClosureGraph, 'ClosureGraph');
initMetadataForClass(LanguageIssueKind, 'LanguageIssueKind');
initMetadataForClass(LanguageProcessorPhase, 'LanguageProcessorPhase');
initMetadataForClass(LanguageIssue, 'LanguageIssue');
initMetadataForInterface(IssueCollection, 'IssueCollection', VOID, VOID, [Collection]);
initMetadataForClass(IssueHolder, 'IssueHolder', IssueHolder, VOID, [IssueCollection]);
initMetadataForInterface(SentenceIdentityFunction, 'SentenceIdentityFunction');
initMetadataForObject(SentenceIdentityFunctionNull_0, 'SentenceIdentityFunctionNull', VOID, VOID, [SentenceIdentityFunction]);
initMetadataForInterface(ParseOptions, 'ParseOptions');
initMetadataForClass(ParseOptionsDefault, 'ParseOptionsDefault', ParseOptionsDefault, VOID, [ParseOptions]);
initMetadataForInterface(ParseResult, 'ParseResult');
initMetadataForClass(ParseResultDefault, 'ParseResultDefault', VOID, VOID, [ParseResult]);
initMetadataForInterface(ParseFailure, 'ParseFailure');
initMetadataForClass(ParseFailureRuntime, 'ParseFailureRuntime', VOID, VOID, [ParseFailure]);
initMetadataForInterface(ExpectedAtResult, 'ExpectedAtResult');
initMetadataForClass(ExpectedAtResultDefault, 'ExpectedAtResultDefault', VOID, VOID, [ExpectedAtResult]);
initMetadataForInterface(Parser, 'Parser');
initMetadataForClass(LeftCornerParser, 'LeftCornerParser', VOID, VOID, [Parser]);
initMetadataForClass(GrowArgs, 'GrowArgs');
initMetadataForCompanion(Companion_10);
initMetadataForClass(sam$kotlin_Comparator$0_4, 'sam$kotlin_Comparator$0', VOID, VOID, [Comparator, FunctionAdapter]);
initMetadataForClass(sam$kotlin_Comparator$0_5, 'sam$kotlin_Comparator$0', VOID, VOID, [Comparator, FunctionAdapter]);
initMetadataForInterface(RuntimeParser, 'RuntimeParser');
initMetadataForClass(RuntimeParserAgl, 'RuntimeParserAgl', VOID, VOID, [RuntimeParser]);
initMetadataForClass(RuntimeContext, 'RuntimeContext');
initMetadataForClass(RuntimeParserExternal, 'RuntimeParserExternal', RuntimeParserExternal, VOID, [RuntimeParser]);
initMetadataForClass(FailedParseReason, 'FailedParseReason');
initMetadataForClass(FailedParseReasonEmbedded, 'FailedParseReasonEmbedded');
initMetadataForClass(FailedParseReasonLookahead, 'FailedParseReasonLookahead');
initMetadataForClass(FailedParseReasonWidthTo, 'FailedParseReasonWidthTo');
initMetadataForClass(FailedParseExpectedSkipAfter, 'FailedParseExpectedSkipAfter');
initMetadataForClass(FailedParseReasonGraftRTG, 'FailedParseReasonGraftRTG');
initMetadataForInterface(RuleSet, 'RuleSet');
initMetadataForInterface(Rule, 'Rule');
initMetadataForInterface(PrefRule, 'PrefRule');
initMetadataForClass(Assoc, 'Assoc');
initMetadataForInterface(PrefOption, 'PrefOption');
initMetadataForClass(OptionNum, 'OptionNum', VOID, VOID, [Comparable]);
initMetadataForCompanion(Companion_11);
initMetadataForInterface(RulePosition_0, 'RulePosition');
initMetadataForInterface(RuntimeSpine, 'RuntimeSpine');
initMetadataForClass(ParserTerminatedException, 'ParserTerminatedException', ParserTerminatedException.v1z);
initMetadataForInterface(ConcatenationBuilder, 'ConcatenationBuilder');
initMetadataForInterface(ChoiceBuilder, 'ChoiceBuilder');
initMetadataForInterface(PrecedenceBuilder, 'PrecedenceBuilder');
initMetadataForObject(IssueMessage_0, 'IssueMessage');
initMetadataForCompanion(Companion_12);
initMetadataForClass(CompletedNodesStore, 'CompletedNodesStore');
initMetadataForClass(GraphStructuredStack, 'GraphStructuredStack');
initMetadataForCompanion(Companion_13);
initMetadataForClass(ToProcessPrevious, 'ToProcessPrevious');
initMetadataForClass(NextToProcess, 'NextToProcess');
initMetadataForClass(ToProcessTriple, 'ToProcessTriple');
initMetadataForCompanion(Companion_14);
initMetadataForClass(MergeDecision, 'MergeDecision');
initMetadataForClass(MergeReason, 'MergeReason');
initMetadataForClass(MergeChoice, 'MergeChoice');
initMetadataForClass(sam$kotlin_Comparator$0_6, 'sam$kotlin_Comparator$0', VOID, VOID, [Comparator, FunctionAdapter]);
initMetadataForClass(ParseGraph, 'ParseGraph');
initMetadataForClass(RuntimeState, 'RuntimeState');
initMetadataForClass(StateInfoUncompressed, 'StateInfoUncompressed');
initMetadataForCompanion(Companion_15);
initMetadataForClass(GrowingNodeIndex, 'GrowingNodeIndex');
initMetadataForClass(RuleOption, 'RuleOption');
initMetadataForClass(RulePositionRuntime, 'RulePositionRuntime', VOID, VOID, [RulePosition_0]);
initMetadataForClass(RuntimePreferenceOption, 'RuntimePreferenceOption', VOID, VOID, [PrefOption]);
initMetadataForClass(RuntimePreferenceRule, 'RuntimePreferenceRule', VOID, VOID, [PrefRule]);
initMetadataForClass(RuntimeRule, 'RuntimeRule', VOID, VOID, [Rule]);
initMetadataForClass(RuntimeRuleKind, 'RuntimeRuleKind');
initMetadataForClass(RuntimeRuleRhsItemsKind, 'RuntimeRuleRhsItemsKind');
initMetadataForClass(RuntimeRuleListKind, 'RuntimeRuleListKind');
initMetadataForClass(RuntimeRuleChoiceKind, 'RuntimeRuleChoiceKind');
initMetadataForClass(RuntimeRuleRhs, 'RuntimeRuleRhs');
initMetadataForClass(RuntimeRuleRhsTerminal, 'RuntimeRuleRhsTerminal');
initMetadataForClass(RuntimeRuleRhsEmpty, 'RuntimeRuleRhsEmpty');
initMetadataForClass(RuntimeRuleRhsEmptyList, 'RuntimeRuleRhsEmptyList');
initMetadataForClass(RuntimeRuleRhsCommonTerminal, 'RuntimeRuleRhsCommonTerminal');
initMetadataForClass(RuntimeRuleRhsPattern, 'RuntimeRuleRhsPattern');
initMetadataForClass(RuntimeRuleRhsLiteral, 'RuntimeRuleRhsLiteral');
initMetadataForClass(RuntimeRuleRhsEmbedded, 'RuntimeRuleRhsEmbedded');
initMetadataForClass(RuntimeRuleRhsNonTerminal, 'RuntimeRuleRhsNonTerminal');
initMetadataForClass(RuntimeRuleRhsGoal, 'RuntimeRuleRhsGoal');
initMetadataForClass(RuntimeRuleRhsConcatenation, 'RuntimeRuleRhsConcatenation');
initMetadataForClass(RuntimeRuleRhsChoice, 'RuntimeRuleRhsChoice');
initMetadataForClass(RuntimeRuleRhsOptional, 'RuntimeRuleRhsOptional');
initMetadataForCompanion(Companion_16);
initMetadataForClass(RuntimeRuleRhsList, 'RuntimeRuleRhsList');
initMetadataForClass(RuntimeRuleRhsListSimple, 'RuntimeRuleRhsListSimple');
initMetadataForClass(RuntimeRuleRhsListSeparated, 'RuntimeRuleRhsListSeparated');
initMetadataForCompanion(Companion_17);
initMetadataForClass(sam$kotlin_Comparator$0_7, 'sam$kotlin_Comparator$0', VOID, VOID, [Comparator, FunctionAdapter]);
initMetadataForClass(RuntimeRuleSet, 'RuntimeRuleSet', VOID, VOID, [RuleSet]);
initMetadataForClass(Quad, 'Quad');
initMetadataForClass(RuntimeRuleSetBuilder2, 'RuntimeRuleSetBuilder2');
initMetadataForClass(RuntimeSpineDefault, 'RuntimeSpineDefault', VOID, VOID, [RuntimeSpine]);
initMetadataForInterface(ScanResult, 'ScanResult');
initMetadataForClass(ScannerKind, 'ScannerKind');
initMetadataForInterface(Scanner, 'Scanner');
initMetadataForInterface(ScanOptions, 'ScanOptions');
initMetadataForClass(MatchableKind, 'MatchableKind');
initMetadataForClass(Matchable, 'Matchable');
initMetadataForClass(ScanOptionsDefault, 'ScanOptionsDefault', ScanOptionsDefault, VOID, [ScanOptions]);
initMetadataForClass(ScanResultDefault, 'ScanResultDefault', VOID, VOID, [ScanResult]);
initMetadataForClass(ScanByLineEndState, 'ScanByLineEndState');
initMetadataForClass(sam$kotlin_Comparator$0_8, 'sam$kotlin_Comparator$0', VOID, VOID, [Comparator, FunctionAdapter]);
initMetadataForClass(sam$kotlin_Comparator$0_9, 'sam$kotlin_Comparator$0', VOID, VOID, [Comparator, FunctionAdapter]);
protoOf(ScannerAbstract).scan = scan;
initMetadataForClass(ScannerAbstract, 'ScannerAbstract', VOID, VOID, [Scanner]);
initMetadataForCompanion(Companion_18);
initMetadataForClass(sam$kotlin_Comparator$0_10, 'sam$kotlin_Comparator$0', VOID, VOID, [Comparator, FunctionAdapter]);
initMetadataForClass(ScannerClassic, 'ScannerClassic');
initMetadataForClass(ScannerFromMatchables, 'ScannerFromMatchables');
initMetadataForCompanion(Companion_19);
initMetadataForClass(IsLookingAtMask, 'IsLookingAtMask', IsLookingAtMask);
initMetadataForClass(ScannerOnDemand, 'ScannerOnDemand');
initMetadataForCompanion(Companion_20);
initMetadataForInterface(Sentence, 'Sentence');
initMetadataForClass(SentenceAbstract, 'SentenceAbstract', VOID, VOID, [Sentence]);
initMetadataForClass(SentenceDefault, 'SentenceDefault');
initMetadataForCompanion(Companion_21);
initMetadataForClass(InputLocation, 'InputLocation');
initMetadataForInterface(SPPTNode, 'SPPTNode');
initMetadataForInterface(SPPTBranch, 'SPPTBranch', VOID, VOID, [SPPTNode]);
initMetadataForInterface(SPPTLeaf, 'SPPTLeaf', VOID, VOID, [SPPTNode]);
initMetadataForInterface(SPPTParser, 'SPPTParser');
initMetadataForClass(ChildInfo, 'ChildInfo');
initMetadataForClass(AltInfo, 'AltInfo');
initMetadataForClass(ParsePath, 'ParsePath', ParsePath);
initMetadataForInterface(SpptDataNodeInfo, 'SpptDataNodeInfo');
initMetadataForInterface(PathFunction, 'PathFunction');
initMetadataForInterface(SpptWalker, 'SpptWalker');
initMetadataForClass(LeafData, 'LeafData');
initMetadataForInterface(TreeData, 'TreeData');
initMetadataForInterface(SharedPackedParseTree, 'SharedPackedParseTree');
initMetadataForInterface(SharedPackedParseTreeVisitor, 'SharedPackedParseTreeVisitor');
initMetadataForClass(sam$kotlin_Comparator$0_11, 'sam$kotlin_Comparator$0', VOID, VOID, [Comparator, FunctionAdapter]);
protoOf(CountTreesVisitor).visitNode = visitNode;
initMetadataForClass(CountTreesVisitor, 'CountTreesVisitor', CountTreesVisitor, VOID, [SharedPackedParseTreeVisitor]);
initMetadataForClass(sam$kotlin_Comparator$0_12, 'sam$kotlin_Comparator$0', VOID, VOID, [Comparator, FunctionAdapter]);
protoOf(SPPTFromTreeData).toStringAllWithIndent = toStringAllWithIndent;
initMetadataForClass(SPPTFromTreeData, 'SPPTFromTreeData', VOID, VOID, [SharedPackedParseTree]);
protoOf(SPPTParserDefault).parse = parse;
initMetadataForClass(SPPTParserDefault, 'SPPTParserDefault', VOID, VOID, [SPPTParser]);
initMetadataForClass(TreeParser, 'TreeParser');
initMetadataForClass(SimpleScanner, 'SimpleScanner');
initMetadataForObject(Tokens, 'Tokens');
initMetadataForClass(NodeStart, 'NodeStart');
initMetadataForClass(RuleReference, 'RuleReference');
initMetadataForClass(QName, 'QName');
initMetadataForCompanion(Companion_22);
initMetadataForClass(SpptWalkerToInputSentence, 'SpptWalkerToInputSentence', VOID, VOID, [SpptWalker]);
initMetadataForClass(SpptWalkerToString, 'SpptWalkerToString', VOID, VOID, [SpptWalker]);
initMetadataForClass(TokensByLineVisitor$visitTree$callback$1, VOID, VOID, VOID, [SpptWalker]);
initMetadataForClass(TokensByLineVisitor, 'TokensByLineVisitor');
initMetadataForClass(PreferredNode, 'PreferredNode');
initMetadataForClass(CompleteTreeDataNode, 'CompleteTreeDataNode', VOID, VOID, [SpptDataNode]);
initMetadataForCompanion(Companion_23);
initMetadataForClass(TreeDataComplete, 'TreeDataComplete', VOID, VOID, [TreeData]);
initMetadataForClass(CompleteKey_0, 'CompleteKey');
initMetadataForCompanion(Companion_24);
initMetadataForClass(TreeDataComplete2, 'TreeDataComplete2', VOID, VOID, [TreeData]);
initMetadataForCompanion(Companion_25);
initMetadataForClass(ChildChain, 'ChildChain');
initMetadataForClass(TreeDataGrowing, 'TreeDataGrowing');
initMetadataForCompanion(Companion_26);
initMetadataForClass(sam$kotlin_Comparator$0_13, 'sam$kotlin_Comparator$0', VOID, VOID, [Comparator, FunctionAdapter]);
initMetadataForClass(sam$net_akehurst_language_sppt_api_PathFunction$0, 'sam$net_akehurst_language_sppt_api_PathFunction$0', VOID, VOID, [PathFunction, FunctionAdapter]);
initMetadataForClass(sam$kotlin_Comparator$0_14, 'sam$kotlin_Comparator$0', VOID, VOID, [Comparator, FunctionAdapter]);
initMetadataForClass(TreeDataWalkerDepthFirst, 'TreeDataWalkerDepthFirst');
initMetadataForClass(AlternativesInfo, 'AlternativesInfo');
initMetadataForClass(StackInfo, 'StackInfo', VOID, VOID, [SpptDataNodeInfo]);
initMetadataForClass(IndentDelta, 'IndentDelta');
initMetadataForObject(Debug_0, 'Debug');
initMetadataForObject(UNINITIALIZED_VALUE, 'UNINITIALIZED_VALUE');
initMetadataForCompanion(Companion_27);
initMetadataForClass(CachedValue, 'CachedValue');
//endregion
//region block: init
BuildConfig_instance = new BuildConfig_0();
Companion_instance = new Companion();
Companion_instance_0 = new Companion_0();
Companion_instance_1 = new Companion_1();
Companion_instance_4 = new Companion_4();
DefaultRuntimeGuard_instance = new DefaultRuntimeGuard();
Companion_instance_5 = new Companion_5();
Companion_instance_6 = new Companion_6();
SentenceIdentityFunctionNull_instance = new SentenceIdentityFunctionNull_0();
IssueMessage_instance = new IssueMessage_0();
Companion_instance_13 = new Companion_13();
Companion_instance_14 = new Companion_14();
Companion_instance_15 = new Companion_15();
Companion_instance_16 = new Companion_16();
Companion_instance_21 = new Companion_21();
Companion_instance_22 = new Companion_22();
Companion_instance_23 = new Companion_23();
Companion_instance_24 = new Companion_24();
Companion_instance_25 = new Companion_25();
Companion_instance_26 = new Companion_26();
Debug_instance = new Debug_0();
UNINITIALIZED_VALUE_instance = new UNINITIALIZED_VALUE();
Companion_instance_27 = new Companion_27();
//endregion
//region block: exports
var BuildConfig = {getInstance: BuildConfig_getInstance};
defineProp(AutomatonForMinimal, 'Companion', Companion_getInstance, VOID, true);
defineProp(MinimalParser, 'Companion', Companion_getInstance_0, VOID, true);
AutomatonKind.values = values;
AutomatonKind.valueOf = valueOf;
defineProp(AutomatonKind, 'LOOKAHEAD_NONE', AutomatonKind_LOOKAHEAD_NONE_getInstance, VOID, true);
defineProp(AutomatonKind, 'LOOKAHEAD_SIMPLE', AutomatonKind_LOOKAHEAD_SIMPLE_getInstance, VOID, true);
defineProp(AutomatonKind, 'LOOKAHEAD_1', AutomatonKind_LOOKAHEAD_1_getInstance, VOID, true);
ParseAction.values = values_0;
ParseAction.valueOf = valueOf_0;
defineProp(ParseAction, 'HEIGHT', ParseAction_HEIGHT_getInstance, VOID, true);
defineProp(ParseAction, 'GRAFT', ParseAction_GRAFT_getInstance, VOID, true);
defineProp(ParseAction, 'WIDTH', ParseAction_WIDTH_getInstance, VOID, true);
defineProp(ParseAction, 'GOAL', ParseAction_GOAL_getInstance, VOID, true);
defineProp(ParseAction, 'EMBED', ParseAction_EMBED_getInstance, VOID, true);
defineProp(Lookahead, 'Companion', Companion_getInstance_2, VOID, true);
defineProp(ParserState, 'Companion', Companion_getInstance_4, VOID, true);
defineProp(Transition, 'Companion', Companion_getInstance_5, VOID, true);
Companion_5.prototype.ToEndMultiGraftRuntimeGuard = ToEndMultiGraftRuntimeGuard;
Companion_5.prototype.ToItemMultiGraftRuntimeGuard = ToItemMultiGraftRuntimeGuard;
Companion_5.prototype.ToEndSListGraftRuntimeGuard = ToEndSListGraftRuntimeGuard;
Companion_5.prototype.ToItemSListGraftRuntimeGuard = ToItemSListGraftRuntimeGuard;
Companion_5.prototype.ToSeparatorSListGraftRuntimeGuard = ToSeparatorSListGraftRuntimeGuard;
defineProp(Companion_5.prototype, 'DefaultRuntimeGuard', DefaultRuntimeGuard_getInstance, VOID, true);
defineProp(TransitionCacheLC1, 'Companion', Companion_getInstance_6, VOID, true);
defineProp(LookaheadSetPart, 'Companion', Companion_getInstance_7, VOID, true);
LanguageIssueKind.values = values_1;
LanguageIssueKind.valueOf = valueOf_1;
defineProp(LanguageIssueKind, 'ERROR', LanguageIssueKind_ERROR_getInstance, VOID, true);
defineProp(LanguageIssueKind, 'WARNING', LanguageIssueKind_WARNING_getInstance, VOID, true);
defineProp(LanguageIssueKind, 'INFORMATION', LanguageIssueKind_INFORMATION_getInstance, VOID, true);
LanguageProcessorPhase.values = values_2;
LanguageProcessorPhase.valueOf = valueOf_2;
defineProp(LanguageProcessorPhase, 'GRAMMAR', LanguageProcessorPhase_GRAMMAR_getInstance, VOID, true);
defineProp(LanguageProcessorPhase, 'SCAN', LanguageProcessorPhase_SCAN_getInstance, VOID, true);
defineProp(LanguageProcessorPhase, 'PARSE', LanguageProcessorPhase_PARSE_getInstance, VOID, true);
defineProp(LanguageProcessorPhase, 'SYNTAX_ANALYSIS', LanguageProcessorPhase_SYNTAX_ANALYSIS_getInstance, VOID, true);
defineProp(LanguageProcessorPhase, 'SEMANTIC_ANALYSIS', LanguageProcessorPhase_SEMANTIC_ANALYSIS_getInstance, VOID, true);
defineProp(LanguageProcessorPhase, 'INTERPRET', LanguageProcessorPhase_INTERPRET_getInstance, VOID, true);
defineProp(LanguageProcessorPhase, 'GENERATE', LanguageProcessorPhase_GENERATE_getInstance, VOID, true);
defineProp(LanguageProcessorPhase, 'FORMAT', LanguageProcessorPhase_FORMAT_getInstance, VOID, true);
defineProp(LanguageProcessorPhase, 'ALL', LanguageProcessorPhase_ALL_getInstance, VOID, true);
var SentenceIdentityFunctionNull = {getInstance: SentenceIdentityFunctionNull_getInstance};
Assoc.values = values_3;
Assoc.valueOf = valueOf_3;
defineProp(Assoc, 'NONE', Assoc_NONE_getInstance, VOID, true);
defineProp(Assoc, 'LEFT', Assoc_LEFT_getInstance, VOID, true);
defineProp(Assoc, 'RIGHT', Assoc_RIGHT_getInstance, VOID, true);
var RulePosition = {getInstance: Companion_getInstance_11};
var IssueMessage = {getInstance: IssueMessage_getInstance};
RuntimePreferenceRule.RuntimePreferenceOption = RuntimePreferenceOption;
RuntimeRuleKind.values = values_6;
RuntimeRuleKind.valueOf = valueOf_6;
defineProp(RuntimeRuleKind, 'GOAL', RuntimeRuleKind_GOAL_getInstance, VOID, true);
defineProp(RuntimeRuleKind, 'NON_TERMINAL', RuntimeRuleKind_NON_TERMINAL_getInstance, VOID, true);
defineProp(RuntimeRuleKind, 'TERMINAL', RuntimeRuleKind_TERMINAL_getInstance, VOID, true);
defineProp(RuntimeRuleKind, 'EMBEDDED', RuntimeRuleKind_EMBEDDED_getInstance, VOID, true);
RuntimeRuleRhsItemsKind.values = values_7;
RuntimeRuleRhsItemsKind.valueOf = valueOf_7;
defineProp(RuntimeRuleRhsItemsKind, 'EMPTY', RuntimeRuleRhsItemsKind_EMPTY_getInstance, VOID, true);
defineProp(RuntimeRuleRhsItemsKind, 'CONCATENATION', RuntimeRuleRhsItemsKind_CONCATENATION_getInstance, VOID, true);
defineProp(RuntimeRuleRhsItemsKind, 'CHOICE', RuntimeRuleRhsItemsKind_CHOICE_getInstance, VOID, true);
defineProp(RuntimeRuleRhsItemsKind, 'LIST', RuntimeRuleRhsItemsKind_LIST_getInstance, VOID, true);
RuntimeRuleListKind.values = values_8;
RuntimeRuleListKind.valueOf = valueOf_8;
defineProp(RuntimeRuleListKind, 'MULTI', RuntimeRuleListKind_MULTI_getInstance, VOID, true);
defineProp(RuntimeRuleListKind, 'SEPARATED_LIST', RuntimeRuleListKind_SEPARATED_LIST_getInstance, VOID, true);
defineProp(RuntimeRuleListKind, 'LEFT_ASSOCIATIVE_LIST', RuntimeRuleListKind_LEFT_ASSOCIATIVE_LIST_getInstance, VOID, true);
defineProp(RuntimeRuleListKind, 'RIGHT_ASSOCIATIVE_LIST', RuntimeRuleListKind_RIGHT_ASSOCIATIVE_LIST_getInstance, VOID, true);
defineProp(RuntimeRuleListKind, 'UNORDERED', RuntimeRuleListKind_UNORDERED_getInstance, VOID, true);
RuntimeRuleChoiceKind.values = values_9;
RuntimeRuleChoiceKind.valueOf = valueOf_9;
defineProp(RuntimeRuleChoiceKind, 'NONE', RuntimeRuleChoiceKind_NONE_getInstance, VOID, true);
defineProp(RuntimeRuleChoiceKind, 'AMBIGUOUS', RuntimeRuleChoiceKind_AMBIGUOUS_getInstance, VOID, true);
defineProp(RuntimeRuleChoiceKind, 'LONGEST_PRIORITY', RuntimeRuleChoiceKind_LONGEST_PRIORITY_getInstance, VOID, true);
defineProp(RuntimeRuleChoiceKind, 'PRIORITY_LONGEST', RuntimeRuleChoiceKind_PRIORITY_LONGEST_getInstance, VOID, true);
defineProp(RuntimeRuleRhsList, 'Companion', Companion_getInstance_16, VOID, true);
defineProp(RuntimeRuleSet, 'Companion', Companion_getInstance_17, VOID, true);
ScannerKind.values = values_10;
ScannerKind.valueOf = valueOf_10;
defineProp(ScannerKind, 'OnDemand', ScannerKind_OnDemand_getInstance, VOID, true);
defineProp(ScannerKind, 'Classic', ScannerKind_Classic_getInstance, VOID, true);
MatchableKind.values = values_11;
MatchableKind.valueOf = valueOf_11;
defineProp(MatchableKind, 'EOT', MatchableKind_EOT_getInstance, VOID, true);
defineProp(MatchableKind, 'LITERAL', MatchableKind_LITERAL_getInstance, VOID, true);
defineProp(MatchableKind, 'REGEX', MatchableKind_REGEX_getInstance, VOID, true);
defineProp(ScannerClassic, 'Companion', Companion_getInstance_18, VOID, true);
defineProp(ScannerOnDemand, 'Companion', Companion_getInstance_19, VOID, true);
defineProp(SentenceDefault, 'Companion', Companion_getInstance_20, VOID, true);
defineProp(SentenceAbstract, 'Companion', Companion_getInstance_21, VOID, true);
defineProp(TreeDataComplete, 'Companion', Companion_getInstance_23, VOID, true);
defineProp(TreeDataComplete2, 'Companion', Companion_getInstance_24, VOID, true);
var Debug = {getInstance: Debug_getInstance};
Debug_0.prototype.IndentDelta = IndentDelta;
Debug_0.prototype.IndentDelta.values = values_12;
Debug_0.prototype.IndentDelta.valueOf = valueOf_12;
defineProp(Debug_0.prototype.IndentDelta, 'NONE', IndentDelta_NONE_getInstance, VOID, true);
defineProp(Debug_0.prototype.IndentDelta, 'INC_BEFORE', IndentDelta_INC_BEFORE_getInstance, VOID, true);
defineProp(Debug_0.prototype.IndentDelta, 'INC_AFTER', IndentDelta_INC_AFTER_getInstance, VOID, true);
defineProp(Debug_0.prototype.IndentDelta, 'DEC_BEFORE', IndentDelta_DEC_BEFORE_getInstance, VOID, true);
defineProp(Debug_0.prototype.IndentDelta, 'DEC_AFTER', IndentDelta_DEC_AFTER_getInstance, VOID, true);
defineProp(CachedValue, 'Companion', Companion_getInstance_27, VOID, true);
export {
  BuildConfig as BuildConfig,
  AutomatonForMinimal as AutomatonForMinimal,
  StateForMinimal as StateForMinimal,
  TransitionForMinimal as TransitionForMinimal,
  GSSNodeForMinimal as GSSNodeForMinimal,
  CompleteNodeForMinimal as CompleteNodeForMinimal,
  MinimalParser as MinimalParser,
  AutomatonKind as AutomatonKind,
  StateNumber as StateNumber,
  ParseAction as ParseAction,
  aut as aut,
  Lookahead as Lookahead,
  ParserState as ParserState,
  ParserStateSet as ParserStateSet,
  Transition as Transition,
  CompleteKey as CompleteKey,
  IncompleteKey as IncompleteKey,
  TransitionCacheLC1 as TransitionCacheLC1,
  LookaheadSetPart as LookaheadSetPart,
  FirstTerminalInfo as FirstTerminalInfo,
  ParentNext as ParentNext,
  LanguageIssueKind as LanguageIssueKind,
  LanguageProcessorPhase as LanguageProcessorPhase,
  LanguageIssue as LanguageIssue,
  plus_4 as plus,
  IssueHolder as IssueHolder,
  SentenceIdentityFunctionNull as SentenceIdentityFunctionNull,
  ParseOptionsDefault as ParseOptionsDefault,
  ParseResultDefault as ParseResultDefault,
  ParseFailureRuntime as ParseFailureRuntime,
  ExpectedAtResultDefault as ExpectedAtResultDefault,
  LeftCornerParser as LeftCornerParser,
  RuntimeParserExternal as RuntimeParserExternal,
  Assoc as Assoc,
  OptionNum as OptionNum,
  RulePosition as RulePosition,
  ParserTerminatedException as ParserTerminatedException,
  IssueMessage as IssueMessage,
  GraphStructuredStack as GraphStructuredStack,
  RuleOption as RuleOption,
  RulePositionRuntime as RulePositionRuntime,
  RuntimePreferenceRule as RuntimePreferenceRule,
  RuntimeRule as RuntimeRule,
  RuntimeRuleKind as RuntimeRuleKind,
  RuntimeRuleRhsItemsKind as RuntimeRuleRhsItemsKind,
  RuntimeRuleListKind as RuntimeRuleListKind,
  RuntimeRuleChoiceKind as RuntimeRuleChoiceKind,
  RuntimeRuleRhs as RuntimeRuleRhs,
  RuntimeRuleRhsTerminal as RuntimeRuleRhsTerminal,
  RuntimeRuleRhsEmpty as RuntimeRuleRhsEmpty,
  RuntimeRuleRhsEmptyList as RuntimeRuleRhsEmptyList,
  RuntimeRuleRhsCommonTerminal as RuntimeRuleRhsCommonTerminal,
  RuntimeRuleRhsPattern as RuntimeRuleRhsPattern,
  RuntimeRuleRhsLiteral as RuntimeRuleRhsLiteral,
  RuntimeRuleRhsEmbedded as RuntimeRuleRhsEmbedded,
  RuntimeRuleRhsNonTerminal as RuntimeRuleRhsNonTerminal,
  RuntimeRuleRhsGoal as RuntimeRuleRhsGoal,
  RuntimeRuleRhsConcatenation as RuntimeRuleRhsConcatenation,
  RuntimeRuleRhsChoice as RuntimeRuleRhsChoice,
  RuntimeRuleRhsOptional as RuntimeRuleRhsOptional,
  RuntimeRuleRhsList as RuntimeRuleRhsList,
  RuntimeRuleRhsListSimple as RuntimeRuleRhsListSimple,
  RuntimeRuleRhsListSeparated as RuntimeRuleRhsListSeparated,
  RuntimeRuleSet as RuntimeRuleSet,
  ruleSet as ruleSet,
  ScannerKind as ScannerKind,
  MatchableKind as MatchableKind,
  Matchable as Matchable,
  ScanOptionsDefault as ScanOptionsDefault,
  ScanResultDefault as ScanResultDefault,
  ScanByLineEndState as ScanByLineEndState,
  ScannerAbstract as ScannerAbstract,
  ScannerClassic as ScannerClassic,
  ScannerFromMatchables as ScannerFromMatchables,
  ScannerOnDemand as ScannerOnDemand,
  SentenceDefault as SentenceDefault,
  SentenceAbstract as SentenceAbstract,
  InputLocation as InputLocation,
  ChildInfo as ChildInfo,
  AltInfo as AltInfo,
  ParsePath as ParsePath,
  LeafData as LeafData,
  SPPTFromTreeData as SPPTFromTreeData,
  SPPTParserDefault as SPPTParserDefault,
  matchedTextNoSkip as matchedTextNoSkip,
  locationForNode as locationForNode,
  SpptWalkerToString as SpptWalkerToString,
  PreferredNode as PreferredNode,
  CompleteTreeDataNode as CompleteTreeDataNode,
  treeData as treeData,
  TreeDataComplete as TreeDataComplete,
  TreeDataComplete2 as TreeDataComplete2,
  TreeDataGrowing as TreeDataGrowing,
  debug as debug,
  Debug as Debug,
  cached as cached,
  CachedValue as CachedValue,
};
export {
  RuntimeRuleChoiceKind_AMBIGUOUS_getInstance as RuntimeRuleChoiceKind_AMBIGUOUS_getInstance1a3dibimxhzjl,
  RuntimeRuleChoiceKind_LONGEST_PRIORITY_getInstance as RuntimeRuleChoiceKind_LONGEST_PRIORITY_getInstance2v2v40i66o6ro,
  RuntimeRuleChoiceKind_PRIORITY_LONGEST_getInstance as RuntimeRuleChoiceKind_PRIORITY_LONGEST_getInstance39jh2zozfz8kf,
  RuntimeRuleKind_TERMINAL_getInstance as RuntimeRuleKind_TERMINAL_getInstance2z6h0oor9hmxh,
  AutomatonKind_LOOKAHEAD_1_getInstance as AutomatonKind_LOOKAHEAD_1_getInstance3ap1behu05whe,
  ParseAction_GOAL_getInstance as ParseAction_GOAL_getInstance3kbva460yqr33,
  ParseAction_GRAFT_getInstance as ParseAction_GRAFT_getInstance3eo41rdir0pp2,
  ParseAction_HEIGHT_getInstance as ParseAction_HEIGHT_getInstance2ppj0m6oi4m5,
  ParseAction_WIDTH_getInstance as ParseAction_WIDTH_getInstance1jgn744q2e5ss,
  LanguageIssueKind_ERROR_getInstance as LanguageIssueKind_ERROR_getInstance2gtfxqc6kqenm,
  LanguageIssueKind_WARNING_getInstance as LanguageIssueKind_WARNING_getInstance2v8473qrq12fa,
  LanguageProcessorPhase_ALL_getInstance as LanguageProcessorPhase_ALL_getInstance3i5seax5fyxfp,
  LanguageProcessorPhase_FORMAT_getInstance as LanguageProcessorPhase_FORMAT_getInstance35g23pmhsbpbv,
  LanguageProcessorPhase_INTERPRET_getInstance as LanguageProcessorPhase_INTERPRET_getInstance21ck7e26xqqbm,
  LanguageProcessorPhase_SEMANTIC_ANALYSIS_getInstance as LanguageProcessorPhase_SEMANTIC_ANALYSIS_getInstance1p2ji795kcz9h,
  LanguageProcessorPhase_SYNTAX_ANALYSIS_getInstance as LanguageProcessorPhase_SYNTAX_ANALYSIS_getInstance7jswelyysdo4,
  Assoc_LEFT_getInstance as Assoc_LEFT_getInstance9mqkhxiqzeoz,
  Assoc_RIGHT_getInstance as Assoc_RIGHT_getInstancenq9mtl25yjxj,
  ScannerKind_OnDemand_getInstance as ScannerKind_OnDemand_getInstance1fjjlf4bva4ap,
  Companion_getInstance_17 as Companion_getInstance2w5y6rst5kfau,
  Companion_getInstance_11 as Companion_getInstance2eemeen1xooss,
  RulePositionRuntime as RulePositionRuntime19wtz7t2hizg4,
  RuntimePreferenceOption as RuntimePreferenceOptionl8946ir2vbd,
  RuntimePreferenceRule as RuntimePreferenceRule2mpjpum5dlrmb,
  RuntimeRuleRhsChoice as RuntimeRuleRhsChoice9mtudo7pk6hx,
  RuntimeRuleRhsConcatenation as RuntimeRuleRhsConcatenation1kfkpq1vatnqj,
  RuntimeRuleRhsEmbedded as RuntimeRuleRhsEmbedded3kpb9lqtr3yqu,
  RuntimeRuleRhsGoal as RuntimeRuleRhsGoal1ph4kee007aef,
  RuntimeRuleRhsListSeparated as RuntimeRuleRhsListSeparated3nkq2abf529fd,
  RuntimeRuleRhsListSimple as RuntimeRuleRhsListSimple1lfx632r9rbd2,
  RuntimeRuleRhsLiteral as RuntimeRuleRhsLiteral3sbwo9jvqui8v,
  RuntimeRuleRhsOptional as RuntimeRuleRhsOptionaluuf4vhyg0czu,
  RuntimeRuleRhsPattern as RuntimeRuleRhsPattern3jp5r4no3945l,
  RuntimeRuleSet as RuntimeRuleSet2buzu7gfhi4ce,
  RuntimeRule as RuntimeRulekprsqj399oq0,
  ParserStateSet as ParserStateSet1u5hn5w646r2p,
  LanguageIssue as LanguageIssue20o6d2o89qtfq,
  IssueHolder as IssueHolder39atakzjd4kvn,
  plus_4 as plusg9sbs2lzk8v8,
  OptionNum as OptionNum3o6wvcwbdp8bn,
  LeftCornerParser as LeftCornerParsertj6xpf8f0s4d,
  ParseOptionsDefault as ParseOptionsDefault34j6tsmvtsecq,
  ScanOptionsDefault as ScanOptionsDefault25ekig3kk7ndj,
  ScannerClassic as ScannerClassic2uadtaovtpl2a,
  ScannerOnDemand as ScannerOnDemand1qe6dkocbwuld,
  SentenceDefault as SentenceDefault4rp4zw27zpbp,
  ParsePath as ParsePath2l5dv3crq1by6,
  SpptWalker as SpptWalkern8pvvurx4wdl,
  SPPTFromTreeData as SPPTFromTreeData3b4f3pp8qykr8,
  SPPTParserDefault as SPPTParserDefault18kntl3vonjtf,
  locationForNode as locationForNodejw3iwfncg5l7,
  matchedTextNoSkip as matchedTextNoSkipbu44x75g3dj8,
  cached as cached318xiqa8svyjm,
};
//endregion

//# sourceMappingURL=net.akehurst.language-agl-parser.mjs.map