@vuu-ui/vuu-table 0.8.0-debug → 0.8.1-debug

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/index.js CHANGED
@@ -2586,26 +2586,58 @@ var Stack = class {
2586
2586
  // be done.
2587
2587
  /// @internal
2588
2588
  forceReduce() {
2589
- let reduce = this.p.parser.stateSlot(
2589
+ let { parser: parser2 } = this.p;
2590
+ let reduce = parser2.stateSlot(
2590
2591
  this.state,
2591
2592
  5
2592
2593
  /* ParseState.ForcedReduce */
2593
2594
  );
2594
2595
  if ((reduce & 65536) == 0)
2595
2596
  return false;
2596
- let { parser: parser2 } = this.p;
2597
2597
  if (!parser2.validAction(this.state, reduce)) {
2598
2598
  let depth = reduce >> 19, term = reduce & 65535;
2599
2599
  let target = this.stack.length - depth * 3;
2600
- if (target < 0 || parser2.getGoto(this.stack[target], term, false) < 0)
2601
- return false;
2602
- this.storeNode(0, this.reducePos, this.reducePos, 4, true);
2600
+ if (target < 0 || parser2.getGoto(this.stack[target], term, false) < 0) {
2601
+ let backup = this.findForcedReduction();
2602
+ if (backup == null)
2603
+ return false;
2604
+ reduce = backup;
2605
+ }
2606
+ this.storeNode(0, this.pos, this.pos, 4, true);
2603
2607
  this.score -= 100;
2604
2608
  }
2605
2609
  this.reducePos = this.pos;
2606
2610
  this.reduce(reduce);
2607
2611
  return true;
2608
2612
  }
2613
+ /// Try to scan through the automaton to find some kind of reduction
2614
+ /// that can be applied. Used when the regular ForcedReduce field
2615
+ /// isn't a valid action. @internal
2616
+ findForcedReduction() {
2617
+ let { parser: parser2 } = this.p, seen = [];
2618
+ let explore = (state, depth) => {
2619
+ if (seen.includes(state))
2620
+ return;
2621
+ seen.push(state);
2622
+ return parser2.allActions(state, (action) => {
2623
+ if (action & (262144 | 131072))
2624
+ ;
2625
+ else if (action & 65536) {
2626
+ let rDepth = (action >> 19) - depth;
2627
+ if (rDepth > 1) {
2628
+ let term = action & 65535, target = this.stack.length - rDepth * 3;
2629
+ if (target >= 0 && parser2.getGoto(this.stack[target], term, false) >= 0)
2630
+ return rDepth << 19 | 65536 | term;
2631
+ }
2632
+ } else {
2633
+ let found = explore(action, depth + 1);
2634
+ if (found != null)
2635
+ return found;
2636
+ }
2637
+ });
2638
+ };
2639
+ return explore(this.state, 0);
2640
+ }
2609
2641
  /// @internal
2610
2642
  forceAll() {
2611
2643
  while (!this.p.parser.stateFlag(
@@ -2674,13 +2706,13 @@ var Stack = class {
2674
2706
  emitContext() {
2675
2707
  let last = this.buffer.length - 1;
2676
2708
  if (last < 0 || this.buffer[last] != -3)
2677
- this.buffer.push(this.curContext.hash, this.reducePos, this.reducePos, -3);
2709
+ this.buffer.push(this.curContext.hash, this.pos, this.pos, -3);
2678
2710
  }
2679
2711
  /// @internal
2680
2712
  emitLookAhead() {
2681
2713
  let last = this.buffer.length - 1;
2682
2714
  if (last < 0 || this.buffer[last] != -4)
2683
- this.buffer.push(this.lookAhead, this.reducePos, this.reducePos, -4);
2715
+ this.buffer.push(this.lookAhead, this.pos, this.pos, -4);
2684
2716
  }
2685
2717
  updateContext(context) {
2686
2718
  if (context != this.curContext.context) {
@@ -3037,16 +3069,17 @@ var LocalTokenGroup = class {
3037
3069
  token(input, stack) {
3038
3070
  let start = input.pos, skipped = 0;
3039
3071
  for (; ; ) {
3072
+ let atEof = input.next < 0, nextPos = input.resolveOffset(1, 1);
3040
3073
  readToken(this.data, input, stack, 0, this.data, this.precTable);
3041
3074
  if (input.token.value > -1)
3042
3075
  break;
3043
3076
  if (this.elseToken == null)
3044
3077
  return;
3045
- if (input.next < 0)
3078
+ if (!atEof)
3079
+ skipped++;
3080
+ if (nextPos == null)
3046
3081
  break;
3047
- input.advance();
3048
- input.reset(input.pos, input.token);
3049
- skipped++;
3082
+ input.reset(nextPos, input.token);
3050
3083
  }
3051
3084
  if (skipped) {
3052
3085
  input.reset(start, input.token);
@@ -3759,26 +3792,30 @@ var LRParser = class extends Parser {
3759
3792
  }
3760
3793
  /// @internal
3761
3794
  validAction(state, action) {
3762
- if (action == this.stateSlot(
3795
+ return !!this.allActions(state, (a) => a == action ? true : null);
3796
+ }
3797
+ /// @internal
3798
+ allActions(state, action) {
3799
+ let deflt = this.stateSlot(
3763
3800
  state,
3764
3801
  4
3765
3802
  /* ParseState.DefaultReduce */
3766
- ))
3767
- return true;
3803
+ );
3804
+ let result = deflt ? action(deflt) : void 0;
3768
3805
  for (let i = this.stateSlot(
3769
3806
  state,
3770
3807
  1
3771
3808
  /* ParseState.Actions */
3772
- ); ; i += 3) {
3809
+ ); result == null; i += 3) {
3773
3810
  if (this.data[i] == 65535) {
3774
3811
  if (this.data[i + 1] == 1)
3775
3812
  i = pair(this.data, i + 2);
3776
3813
  else
3777
- return false;
3814
+ break;
3778
3815
  }
3779
- if (action == pair(this.data, i + 1))
3780
- return true;
3816
+ result = action(pair(this.data, i + 1));
3781
3817
  }
3818
+ return result;
3782
3819
  }
3783
3820
  /// Get the states that can follow this one through shift actions or
3784
3821
  /// goto jumps. @internal