@xdbml/parse 0.3.0 → 0.3.1

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/parser.d.ts CHANGED
@@ -219,6 +219,8 @@ export declare class Parser {
219
219
  /** True if the token looks like the start of a TypeExpression. */
220
220
  private tokenStartsType;
221
221
  private parseTupleElements;
222
+ /** Lookahead for a tuple position marker `[ <number> ]` (vs. a settings block). */
223
+ private positionMarkerAhead;
222
224
  private parseMapType;
223
225
  private parseSetType;
224
226
  /**
package/dist/parser.js CHANGED
@@ -1049,7 +1049,11 @@ export class Parser {
1049
1049
  this.expect(TokenKind.RBracket, "Expected ']' after position");
1050
1050
  const nameTok = this.expect(TokenKind.Identifier, 'Expected tuple element name');
1051
1051
  const type = this.parseTypeExpression();
1052
- const settings = this.maybeSettingsBlock();
1052
+ // Optional per-element settings. A following `[` only opens a settings
1053
+ // block if it is NOT the next element's `[N]` position marker; otherwise
1054
+ // maybeSettingsBlock would greedily consume it and fail on the number
1055
+ // (grammar: tupleElement's settingsBlock is optional).
1056
+ const settings = this.positionMarkerAhead() ? [] : this.maybeSettingsBlock();
1053
1057
  out.push({
1054
1058
  kind: 'TupleElement',
1055
1059
  position: parseInt(numTok.text, 10),
@@ -1058,11 +1062,19 @@ export class Parser {
1058
1062
  settings,
1059
1063
  span: this.spanFrom(start),
1060
1064
  });
1061
- if (!this.match(TokenKind.Comma))
1062
- break;
1065
+ // Elements may be separated by a comma OR by whitespace/newline alone
1066
+ // (grammar: `tupleElement (COMMA? tupleElement)+`). Consume an optional
1067
+ // separator; the loop condition resumes on the next `[N]`.
1068
+ this.match(TokenKind.Comma);
1063
1069
  }
1064
1070
  return out;
1065
1071
  }
1072
+ /** Lookahead for a tuple position marker `[ <number> ]` (vs. a settings block). */
1073
+ positionMarkerAhead() {
1074
+ return this.check(TokenKind.LBracket)
1075
+ && this.peek(1).kind === TokenKind.NumberLiteral
1076
+ && this.peek(2).kind === TokenKind.RBracket;
1077
+ }
1066
1078
  parseMapType() {
1067
1079
  const start = this.peek().start;
1068
1080
  const kwTok = this.advance();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xdbml/parse",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Parser for xDBML (eXtended Database Markup Language), a strict superset of DBML 3.13.6: tokenizer, parser, module resolver, and name resolver.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Hackolade",