@tabnas/parser 0.8.1 → 0.8.3

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/dist/defaults.js CHANGED
@@ -260,6 +260,9 @@ Unexpected end of source.`,
260
260
  // Empty string is allowed and returns undefined
261
261
  empty: true,
262
262
  emptyResult: undefined,
263
+ // Negotiated lexing off: grammars written for a tokenising lexer
264
+ // never need it. Scannerless front-ends (GBNF) opt in.
265
+ relex: false,
263
266
  },
264
267
  // Parser
265
268
  parse: {
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAQzD,+CAA+C;AAC/C,yDAAyD;AACzD,2DAA2D;AAC3D,mCASgB;AAGhB,MAAM,QAAQ,GAAkB;IAC9B,8BAA8B;IAC9B,IAAI,EAAE;QACJ,GAAG,EAAE,IAAI;KACV;IAED,8BAA8B;IAC9B,GAAG,EAAE,GAAG;IAER,sBAAsB;IACtB,KAAK,EAAE;QACL,uCAAuC;QACvC,GAAG,EAAE,IAAI;QAET,eAAe;QACf,KAAK,EAAE;YACL,KAAK,EAAE,GAAG;YACV,KAAK,EAAE,GAAG;YACV,KAAK,EAAE,GAAG;YACV,KAAK,EAAE,GAAG;YACV,KAAK,EAAE,GAAG;YACV,KAAK,EAAE,GAAG;SACX;KACF;IAED,KAAK,EAAE;QACL,GAAG,EAAE,IAAI;QACT,KAAK,EAAE,EAAE;KACV;IAED,cAAc;IACd,QAAQ,EAAE;QACR,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC;QAC7B,GAAG,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC;QACjC,GAAG,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC;KAClC;IAED,2CAA2C;IAC3C,KAAK,EAAE;QACL,gCAAgC;QAChC,GAAG,EA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AE;QACN,OAAO,EAAE,EAAE;KACZ;IAED,yBAAyB;IACzB,MAAM,EAAE;QACN,2BAA2B;QAC3B,MAAM,EAAE,EAAE;KACX;IAED,2BAA2B;IAC3B,MAAM,EAAE;QACN,KAAK,EAAE,SAAS;KACjB;CACF,CAAA;AAEQ,4BAAQ"}
package/dist/lexer.d.ts CHANGED
@@ -76,7 +76,18 @@ declare class Lex {
76
76
  pnt: Point;
77
77
  fwd: string;
78
78
  fwdSI: number;
79
+ want: Tin[] | null;
80
+ relexUndo: {
81
+ sI: number;
82
+ rI: number;
83
+ cI: number;
84
+ token: Token[];
85
+ end: Token | undefined;
86
+ };
79
87
  refwd(): string;
88
+ relex(from: Token, want: Tin[], rule: Rule): Token | undefined;
89
+ unrelex(sI: number, rI: number, cI: number, token: Token[], end: Token | undefined): void;
90
+ speculate(mat: LexMatcher, rule: Rule, tI?: number): Token | undefined;
80
91
  constructor(ctx: Context);
81
92
  token(ref: Tin | string, val: any, src: string | undefined, pnt?: Point, use?: any, why?: string, len?: number): Token;
82
93
  next(rule: Rule, alt?: NormAltSpec, altI?: number, tI?: number): Token;
package/dist/lexer.js CHANGED
@@ -396,7 +396,14 @@ let makeFixedMatcher = (cfg, _opts) => {
396
396
  const cands = cc < 256 ? table[cc] : wide;
397
397
  if (undefined === cands)
398
398
  return undefined;
399
+ // Negotiated lexing: only candidates the requesting alternate wants
400
+ // may match. Longest-match-wins still holds among those, so a
401
+ // shorter wanted token can win over a longer unwanted one — which
402
+ // is the point: the alternate knows which cut it needs.
403
+ const want = lex.want;
399
404
  for (const cand of cands) {
405
+ if (null != want && !want.includes(cand.tin))
406
+ continue;
400
407
  // Single-char Latin-1 candidates already matched via the table
401
408
  // index; longer (or wide-char) candidates verify in place.
402
409
  if ((1 === cand.len && cc < 256) || src.startsWith(cand.src, pnt.sI)) {
@@ -428,30 +435,35 @@ let makeMatchMatcher = (cfg, _opts) => {
428
435
  // remainder string, so materialize it (memoized per position).
429
436
  let fwd = lex.refwd();
430
437
  let oc = 'o' === rule.state ? 0 : 1;
431
- for (let valueMatcher of valueMatchers) {
432
- if (valueMatcher.match instanceof RegExp) {
433
- // TODO: only match VL if present in rule
434
- let m = fwd.match(valueMatcher.match);
435
- if (m) {
436
- let msrc = m[0];
437
- let mlen = msrc.length;
438
- if (0 < mlen) {
439
- let tkn = undefined;
440
- let val = valueMatcher.val ? valueMatcher.val(m) : msrc;
441
- tkn = lex.token('#VL', val, msrc, pnt);
442
- pnt.sI += mlen;
443
- pnt.cI += mlen;
444
- return tkn;
438
+ // Under a negotiated-lexing constraint, value matchers are skipped
439
+ // outright: they produce value tokens (#VL) by content, not by the
440
+ // requesting alternate's tin list, so they cannot serve a want.
441
+ const want = lex.want;
442
+ if (null == want)
443
+ for (let valueMatcher of valueMatchers) {
444
+ if (valueMatcher.match instanceof RegExp) {
445
+ // TODO: only match VL if present in rule
446
+ let m = fwd.match(valueMatcher.match);
447
+ if (m) {
448
+ let msrc = m[0];
449
+ let mlen = msrc.length;
450
+ if (0 < mlen) {
451
+ let tkn = undefined;
452
+ let val = valueMatcher.val ? valueMatcher.val(m) : msrc;
453
+ tkn = lex.token('#VL', val, msrc, pnt);
454
+ pnt.sI += mlen;
455
+ pnt.cI += mlen;
456
+ return tkn;
457
+ }
445
458
  }
446
459
  }
447
- }
448
- else {
449
- let tkn = valueMatcher.match(lex, rule);
450
- if (null != tkn) {
451
- return tkn;
460
+ else {
461
+ let tkn = valueMatcher.match(lex, rule);
462
+ if (null != tkn) {
463
+ return tkn;
464
+ }
452
465
  }
453
466
  }
454
- }
455
467
  for (let tokenMatcher of tokenMatchers) {
456
468
  // Only match Token if present in Rule sequence.
457
469
  // Exception: an `eager$` flag on the matcher opts out of
@@ -462,7 +474,15 @@ let makeMatchMatcher = (cfg, _opts) => {
462
474
  // literal's own tin even when the current rule's tcol is
463
475
  // narrower, so the next rule up the stack can see the token
464
476
  // as its proper type rather than falling through to #TX.
465
- if (tokenMatcher.tin$ &&
477
+ if (null != want) {
478
+ // Negotiated lexing: the alternate's own tin list replaces tcol
479
+ // gating — only matchers able to produce a wanted tin run.
480
+ if (!tokenMatcher.tin$ ||
481
+ !want.includes(tokenMatcher.tin$)) {
482
+ continue;
483
+ }
484
+ }
485
+ else if (tokenMatcher.tin$ &&
466
486
  !tokenMatcher.eager$ &&
467
487
  !rule.spec.def.tcol[oc][tI].includes(tokenMatcher.tin$)) {
468
488
  continue;
@@ -819,29 +839,58 @@ let makeNumberMatcher = (cfg, _opts) => {
819
839
  let mcfg = cfg.number;
820
840
  // Sticky ('y') so the regex runs against the full source at an offset
821
841
  // (ender.lastIndex = pnt.sI) instead of an allocated remainder slice.
822
- let ender = (0, utility_1.regexp)('y', [
823
- '([-+]?(0(',
824
- [
825
- mcfg.hex ? 'x[0-9a-fA-F_]+' : null,
826
- mcfg.oct ? 'o[0-7_]+' : null,
827
- mcfg.bin ? 'b[01_]+' : null,
828
- ]
829
- .filter((s) => null != s)
830
- .join('|'),
831
- // ')|[.0-9]+([0-9_]*[0-9])?)',
832
- ')|\\.?[0-9]+([0-9_]*[0-9])?)',
833
- // Fraction: a bare trailing dot is fine, but when fraction digits
834
- // are present the run must START with a digit, as the integer and
835
- // exponent runs already require. The previous `\.[0-9]?(...)` made
836
- // the leading digit optional, so a separator could open the run
837
- // and `1._5` parsed as 1.5 while `1_5.` style boundary-separator
838
- // forms fell to text — separators are legal only BETWEEN digits.
839
- // (?: keeps the capture count: tsrc is read from m[9] below.)
840
- '(\\.(?:[0-9]([0-9_]*[0-9])?)?)?',
841
- '([eE][-+]?[0-9]+([0-9_]*[0-9])?)?',
842
+ // A base-prefixed run (0x…, 0o…, 0b…) is a COMPLETE integer: no fraction
843
+ // and no exponent may attach to it. Only the decimal alternative carries
844
+ // that tail.
845
+ //
846
+ // Both groups used to sit outside the alternation, so they attached to
847
+ // base-prefixed runs too. `0xFF.5` then produced msrc `0xFF.5`, which
848
+ // coerces to NaN, so the matcher declined the whole span and the lenient
849
+ // text matcher took `0xFF` as #TX — while Go, whose base-prefix branch has
850
+ // no tail at all, read #NR("0xFF") and left `.5` to following matchers.
851
+ //
852
+ // The follow character decided whether that was visible: `0xFF.a` agreed
853
+ // by accident, because `.a` cannot open a fraction, so the regex
854
+ // backtracked to `0xFF` and `.` served as the ender. Any test probing only
855
+ // `0xFF.x` or `0xFF.5x` passes against the broken code — see the parity
856
+ // fixtures, which deliberately carry both a diverging and an agreeing
857
+ // follow character for each of 0x/0o/0b.
858
+ //
859
+ // Fraction digits, when present, must START with a digit, as the integer
860
+ // and exponent runs already require: an earlier `\.[0-9]?(...)` let a
861
+ // separator open the run, so `1._5` parsed as 1.5 — separators are legal
862
+ // only BETWEEN digits.
863
+ //
864
+ // Every inner group is now non-capturing, so the number contributes
865
+ // exactly ONE capture (msrc) and the ender's first group is m[2] rather
866
+ // than m[9]. That retires "count parens in numberEnder!" as a hazard.
867
+ // The marker letter is case-insensitive, as it is in Go's matchNumber
868
+ // (src[sI+1] == 'x' || src[sI+1] == 'X', and likewise o/O and b/B) and as
869
+ // JS `Number()` already is — +"0XFF" is 255, so the coercion below needed
870
+ // no change. TS accepted only the lowercase marker, so `0XFF` lexed as
871
+ // #TX here and #NR there.
872
+ //
873
+ // Widening TS to match Go, rather than narrowing Go to match TS: Go is the
874
+ // reference port, and narrowing would break any Go consumer relying on
875
+ // 0XFF being 255. It is also the internally consistent direction — hex
876
+ // DIGITS are already case-insensitive in both ports (0xAB == 0xab), so
877
+ // only the marker was asymmetric.
878
+ let baseAlts = [
879
+ mcfg.hex ? '[xX][0-9a-fA-F_]+' : null,
880
+ mcfg.oct ? '[oO][0-7_]+' : null,
881
+ mcfg.bin ? '[bB][01_]+' : null,
842
882
  ]
843
- .join('')
844
- .replace(/_/g, mcfg.sep ? (0, utility_1.escre)(mcfg.sepChar) : ''), ')', ...cfg.rePart.ender);
883
+ .filter((s) => null != s)
884
+ .join('|');
885
+ let decimalRe = '\\.?[0-9]+(?:[0-9_]*[0-9])?' +
886
+ '(?:\\.(?:[0-9](?:[0-9_]*[0-9])?)?)?' +
887
+ '(?:[eE][-+]?[0-9]+(?:[0-9_]*[0-9])?)?';
888
+ let ender = (0, utility_1.regexp)('y', ('([-+]?' +
889
+ // With every base form disabled there is no prefix branch at all,
890
+ // rather than a degenerate `0(?:)` that matches a bare `0`.
891
+ ('' === baseAlts
892
+ ? decimalRe
893
+ : '(?:0(?:' + baseAlts + ')|' + decimalRe + ')')).replace(/_/g, mcfg.sep ? (0, utility_1.escre)(mcfg.sepChar) : ''), ')', ...cfg.rePart.ender);
845
894
  let numberSep = mcfg.sep
846
895
  ? (0, utility_1.regexp)('g', (0, utility_1.escre)(mcfg.sepChar))
847
896
  : undefined;
@@ -854,7 +903,11 @@ let makeNumberMatcher = (cfg, _opts) => {
854
903
  let m = ender.exec(lex.src);
855
904
  if (m) {
856
905
  let msrc = m[1];
857
- let tsrc = m[9]; // NOTE: count parens in numberEnder!
906
+ // m[2], not m[9]: the number contributes exactly one capture (msrc),
907
+ // so the ender's first group follows it directly. Every inner group in
908
+ // the number pattern is non-capturing precisely so this index cannot
909
+ // drift again.
910
+ let tsrc = m[2];
858
911
  let out = undefined;
859
912
  let included = true;
860
913
  if (null != msrc &&
@@ -1245,6 +1298,106 @@ class Lex {
1245
1298
  }
1246
1299
  return this.fwd;
1247
1300
  }
1301
+ // Negotiated lexing (cfg.lex.relex): re-cut the source span of an
1302
+ // already-lexed token, constrained to the tins the requesting
1303
+ // alternate wants. Returns the recut token — the cursor then sits
1304
+ // after it and any pending lookahead is discarded — or undefined,
1305
+ // with all lexer state restored.
1306
+ //
1307
+ // Why this exists: one character can be claimable by several
1308
+ // matchers ('"' by an escape class and by a fixed quote; '\n' by a
1309
+ // whitespace class and by a fixed literal). The first fetch commits
1310
+ // to one identity by matcher order, and the pushback buffer makes
1311
+ // that identity sticky across rule boundaries — so an alternate
1312
+ // wanting the other, equally valid, identity fails. Scannerless
1313
+ // notations (GBNF) hit this constantly; the parser knows which tins
1314
+ // it wants, so it is allowed to renegotiate the cut.
1315
+ relex(from, want, rule) {
1316
+ if (null == from || from.len <= 0 || from.sI < 0) {
1317
+ return undefined;
1318
+ }
1319
+ const pnt = this.pnt;
1320
+ const sI = pnt.sI;
1321
+ const rI = pnt.rI;
1322
+ const cI = pnt.cI;
1323
+ const queue = pnt.token;
1324
+ const end = pnt.end;
1325
+ pnt.sI = from.sI;
1326
+ pnt.rI = from.rI;
1327
+ pnt.cI = from.cI;
1328
+ pnt.token = [];
1329
+ pnt.end = undefined;
1330
+ this.want = want;
1331
+ let tkn = undefined;
1332
+ try {
1333
+ tkn = this.next(rule);
1334
+ }
1335
+ finally {
1336
+ this.want = null;
1337
+ }
1338
+ if (null == tkn || !want.includes(tkn.tin)) {
1339
+ pnt.sI = sI;
1340
+ pnt.rI = rI;
1341
+ pnt.cI = cI;
1342
+ pnt.token = queue;
1343
+ pnt.end = end;
1344
+ return undefined;
1345
+ }
1346
+ // Commit. The cursor now sits after the recut token; queued
1347
+ // lookahead derived from the old cut is stale and stays dropped.
1348
+ // Preserve any attached ignored token (it precedes the span and is
1349
+ // unaffected by the recut).
1350
+ if (null != from.ignored) {
1351
+ tkn.ignored = from.ignored;
1352
+ }
1353
+ // Record where the point was, so the caller can undo this commit if
1354
+ // the alternate that asked for it goes on to fail. See `unrelex`.
1355
+ const undo = this.relexUndo;
1356
+ undo.sI = sI;
1357
+ undo.rI = rI;
1358
+ undo.cI = cI;
1359
+ undo.token = queue;
1360
+ undo.end = end;
1361
+ return tkn;
1362
+ }
1363
+ // Undo a committed recut: put the point back where `relex` found it.
1364
+ // The caller passes its own copy of the snapshot rather than reading
1365
+ // `relexUndo` directly, because that field is overwritten by any
1366
+ // further recut and the undo must reach back to the FIRST one.
1367
+ unrelex(sI, rI, cI, token, end) {
1368
+ const pnt = this.pnt;
1369
+ pnt.sI = sI;
1370
+ pnt.rI = rI;
1371
+ pnt.cI = cI;
1372
+ pnt.token = token;
1373
+ pnt.end = end;
1374
+ }
1375
+ // Run one matcher under a `want` constraint, keeping its token only
1376
+ // when the tin is wanted and restoring the point otherwise. Used for
1377
+ // custom matchers during negotiated lexing, where the produced tin is
1378
+ // not knowable in advance. A matcher is free to move the cursor and
1379
+ // queue tokens, so the restore covers the same fields `relex` saves.
1380
+ speculate(mat, rule, tI) {
1381
+ const pnt = this.pnt;
1382
+ const sI = pnt.sI;
1383
+ const rI = pnt.rI;
1384
+ const cI = pnt.cI;
1385
+ const qN = pnt.token.length;
1386
+ const end = pnt.end;
1387
+ if (undefined === BUILTIN_MATCHER[mat.matcher]) {
1388
+ this.refwd();
1389
+ }
1390
+ const tkn = mat(this, rule, tI);
1391
+ if (null != tkn && this.want.includes(tkn.tin)) {
1392
+ return tkn;
1393
+ }
1394
+ pnt.sI = sI;
1395
+ pnt.rI = rI;
1396
+ pnt.cI = cI;
1397
+ pnt.token.length = qN;
1398
+ pnt.end = end;
1399
+ return undefined;
1400
+ }
1248
1401
  constructor(ctx) {
1249
1402
  this.src = types_1.EMPTY; // Full source text being lexed.
1250
1403
  this.ctx = {}; // Parse context (config, logging, subscribers).
@@ -1252,6 +1405,22 @@ class Lex {
1252
1405
  this.pnt = makePoint(-1); // Current scan position.
1253
1406
  this.fwd = types_1.EMPTY; // Source from pnt.sI onward (the unconsumed remainder).
1254
1407
  this.fwdSI = -1; // pnt.sI the current fwd slice was taken at (memo key).
1408
+ // Negotiated-lexing constraint (cfg.lex.relex). When non-null, only
1409
+ // matchers that can produce one of these tins run, and tcol gating is
1410
+ // bypassed — the requesting alternate's own token list is a sharper
1411
+ // gate than the rule-level union. Set only inside relex().
1412
+ this.want = null;
1413
+ // Where the point stood immediately before the last recut `relex`
1414
+ // COMMITTED. One reusable record: the parser copies out of it at the
1415
+ // moment of the commit (see parse_alts), because a later recut
1416
+ // overwrites it.
1417
+ this.relexUndo = {
1418
+ sI: -1,
1419
+ rI: -1,
1420
+ cI: -1,
1421
+ token: [],
1422
+ end: undefined,
1423
+ };
1255
1424
  this.ctx = ctx;
1256
1425
  this.src = ctx.src();
1257
1426
  this.cfg = ctx.cfg;
@@ -1300,6 +1469,38 @@ class Lex {
1300
1469
  : dispatch[cc < 256 ? cc : 256];
1301
1470
  try {
1302
1471
  for (let mat of mats) {
1472
+ // Negotiated lexing: a single-token builtin whose tin is not
1473
+ // wanted cannot serve the request; skip it. match/fixed filter
1474
+ // internally, per candidate.
1475
+ if (null != this.want) {
1476
+ const nm = mat.matcher;
1477
+ if ('match' !== nm && 'fixed' !== nm) {
1478
+ const t = this.cfg.t;
1479
+ const btin = 'space' === nm ? t.SP :
1480
+ 'line' === nm ? t.LN :
1481
+ 'string' === nm ? t.ST :
1482
+ 'comment' === nm ? t.CM :
1483
+ 'number' === nm ? t.NR :
1484
+ 'text' === nm ? t.TX : -1;
1485
+ if (-1 === btin) {
1486
+ // A custom `lex.match` matcher. Its token identity is
1487
+ // opaque — the only way to learn whether it can serve
1488
+ // the request is to run it — so run it speculatively and
1489
+ // put the cursor back when what it produced is not
1490
+ // wanted. Skipping it outright would deny custom tokens
1491
+ // the renegotiation that match and fixed tokens get.
1492
+ const cand = this.speculate(mat, rule, tI);
1493
+ if (undefined === cand)
1494
+ continue;
1495
+ tkn = cand;
1496
+ match = mat;
1497
+ break;
1498
+ }
1499
+ if (!this.want.includes(btin)) {
1500
+ continue;
1501
+ }
1502
+ }
1503
+ }
1303
1504
  if (undefined === BUILTIN_MATCHER[mat.matcher]) {
1304
1505
  this.refwd();
1305
1506
  }