@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/cjs/index.js CHANGED
@@ -2590,26 +2590,58 @@ var Stack = class {
2590
2590
  // be done.
2591
2591
  /// @internal
2592
2592
  forceReduce() {
2593
- let reduce = this.p.parser.stateSlot(
2593
+ let { parser: parser2 } = this.p;
2594
+ let reduce = parser2.stateSlot(
2594
2595
  this.state,
2595
2596
  5
2596
2597
  /* ParseState.ForcedReduce */
2597
2598
  );
2598
2599
  if ((reduce & 65536) == 0)
2599
2600
  return false;
2600
- let { parser: parser2 } = this.p;
2601
2601
  if (!parser2.validAction(this.state, reduce)) {
2602
2602
  let depth = reduce >> 19, term = reduce & 65535;
2603
2603
  let target = this.stack.length - depth * 3;
2604
- if (target < 0 || parser2.getGoto(this.stack[target], term, false) < 0)
2605
- return false;
2606
- this.storeNode(0, this.reducePos, this.reducePos, 4, true);
2604
+ if (target < 0 || parser2.getGoto(this.stack[target], term, false) < 0) {
2605
+ let backup = this.findForcedReduction();
2606
+ if (backup == null)
2607
+ return false;
2608
+ reduce = backup;
2609
+ }
2610
+ this.storeNode(0, this.pos, this.pos, 4, true);
2607
2611
  this.score -= 100;
2608
2612
  }
2609
2613
  this.reducePos = this.pos;
2610
2614
  this.reduce(reduce);
2611
2615
  return true;
2612
2616
  }
2617
+ /// Try to scan through the automaton to find some kind of reduction
2618
+ /// that can be applied. Used when the regular ForcedReduce field
2619
+ /// isn't a valid action. @internal
2620
+ findForcedReduction() {
2621
+ let { parser: parser2 } = this.p, seen = [];
2622
+ let explore = (state, depth) => {
2623
+ if (seen.includes(state))
2624
+ return;
2625
+ seen.push(state);
2626
+ return parser2.allActions(state, (action) => {
2627
+ if (action & (262144 | 131072))
2628
+ ;
2629
+ else if (action & 65536) {
2630
+ let rDepth = (action >> 19) - depth;
2631
+ if (rDepth > 1) {
2632
+ let term = action & 65535, target = this.stack.length - rDepth * 3;
2633
+ if (target >= 0 && parser2.getGoto(this.stack[target], term, false) >= 0)
2634
+ return rDepth << 19 | 65536 | term;
2635
+ }
2636
+ } else {
2637
+ let found = explore(action, depth + 1);
2638
+ if (found != null)
2639
+ return found;
2640
+ }
2641
+ });
2642
+ };
2643
+ return explore(this.state, 0);
2644
+ }
2613
2645
  /// @internal
2614
2646
  forceAll() {
2615
2647
  while (!this.p.parser.stateFlag(
@@ -2678,13 +2710,13 @@ var Stack = class {
2678
2710
  emitContext() {
2679
2711
  let last = this.buffer.length - 1;
2680
2712
  if (last < 0 || this.buffer[last] != -3)
2681
- this.buffer.push(this.curContext.hash, this.reducePos, this.reducePos, -3);
2713
+ this.buffer.push(this.curContext.hash, this.pos, this.pos, -3);
2682
2714
  }
2683
2715
  /// @internal
2684
2716
  emitLookAhead() {
2685
2717
  let last = this.buffer.length - 1;
2686
2718
  if (last < 0 || this.buffer[last] != -4)
2687
- this.buffer.push(this.lookAhead, this.reducePos, this.reducePos, -4);
2719
+ this.buffer.push(this.lookAhead, this.pos, this.pos, -4);
2688
2720
  }
2689
2721
  updateContext(context) {
2690
2722
  if (context != this.curContext.context) {
@@ -3041,16 +3073,17 @@ var LocalTokenGroup = class {
3041
3073
  token(input, stack) {
3042
3074
  let start = input.pos, skipped = 0;
3043
3075
  for (; ; ) {
3076
+ let atEof = input.next < 0, nextPos = input.resolveOffset(1, 1);
3044
3077
  readToken(this.data, input, stack, 0, this.data, this.precTable);
3045
3078
  if (input.token.value > -1)
3046
3079
  break;
3047
3080
  if (this.elseToken == null)
3048
3081
  return;
3049
- if (input.next < 0)
3082
+ if (!atEof)
3083
+ skipped++;
3084
+ if (nextPos == null)
3050
3085
  break;
3051
- input.advance();
3052
- input.reset(input.pos, input.token);
3053
- skipped++;
3086
+ input.reset(nextPos, input.token);
3054
3087
  }
3055
3088
  if (skipped) {
3056
3089
  input.reset(start, input.token);
@@ -3763,26 +3796,30 @@ var LRParser = class extends Parser {
3763
3796
  }
3764
3797
  /// @internal
3765
3798
  validAction(state, action) {
3766
- if (action == this.stateSlot(
3799
+ return !!this.allActions(state, (a) => a == action ? true : null);
3800
+ }
3801
+ /// @internal
3802
+ allActions(state, action) {
3803
+ let deflt = this.stateSlot(
3767
3804
  state,
3768
3805
  4
3769
3806
  /* ParseState.DefaultReduce */
3770
- ))
3771
- return true;
3807
+ );
3808
+ let result = deflt ? action(deflt) : void 0;
3772
3809
  for (let i = this.stateSlot(
3773
3810
  state,
3774
3811
  1
3775
3812
  /* ParseState.Actions */
3776
- ); ; i += 3) {
3813
+ ); result == null; i += 3) {
3777
3814
  if (this.data[i] == 65535) {
3778
3815
  if (this.data[i + 1] == 1)
3779
3816
  i = pair(this.data, i + 2);
3780
3817
  else
3781
- return false;
3818
+ break;
3782
3819
  }
3783
- if (action == pair(this.data, i + 1))
3784
- return true;
3820
+ result = action(pair(this.data, i + 1));
3785
3821
  }
3822
+ return result;
3786
3823
  }
3787
3824
  /// Get the states that can follow this one through shift actions or
3788
3825
  /// goto jumps. @internal