@intlify/message-compiler 9.13.0 → 10.0.0-alpha.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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * message-compiler v9.13.0
2
+ * message-compiler v10.0.0-alpha.1
3
3
  * (c) 2024 kazuya kawaguchi
4
4
  * Released under the MIT License.
5
5
  */
@@ -23,23 +23,6 @@ function createLocation(start, end, source) {
23
23
  return loc;
24
24
  }
25
25
 
26
- const CompileWarnCodes = {
27
- USE_MODULO_SYNTAX: 1,
28
- __EXTEND_POINT__: 2
29
- };
30
- /** @internal */
31
- const warnMessages = {
32
- [CompileWarnCodes.USE_MODULO_SYNTAX]: `Use modulo before '{{0}}'.`
33
- };
34
- function createCompileWarn(code, loc, ...args) {
35
- const msg = code;
36
- const message = { message: String(msg), code };
37
- if (loc) {
38
- message.location = loc;
39
- }
40
- return message;
41
- }
42
-
43
26
  const CompileErrorCodes = {
44
27
  // tokenizer error codes
45
28
  EXPECTED_TOKEN: 1,
@@ -163,7 +146,6 @@ function createScanner(str) {
163
146
  }
164
147
  function skipToPeek() {
165
148
  const target = _index + _peekOffset;
166
- // eslint-disable-next-line no-unmodified-loop-condition
167
149
  while (target !== _index) {
168
150
  next();
169
151
  }
@@ -197,11 +179,11 @@ function createTokenizer(source, options = {}) {
197
179
  const _initLoc = currentPosition();
198
180
  const _initOffset = currentOffset();
199
181
  const _context = {
200
- currentType: 14 /* TokenTypes.EOF */,
182
+ currentType: 13 /* TokenTypes.EOF */,
201
183
  offset: _initOffset,
202
184
  startLoc: _initLoc,
203
185
  endLoc: _initLoc,
204
- lastType: 14 /* TokenTypes.EOF */,
186
+ lastType: 13 /* TokenTypes.EOF */,
205
187
  lastOffset: _initOffset,
206
188
  lastStartLoc: _initLoc,
207
189
  lastEndLoc: _initLoc,
@@ -236,7 +218,7 @@ function createTokenizer(source, options = {}) {
236
218
  }
237
219
  return token;
238
220
  }
239
- const getEndToken = (context) => getToken(context, 14 /* TokenTypes.EOF */);
221
+ const getEndToken = (context) => getToken(context, 13 /* TokenTypes.EOF */);
240
222
  function eat(scnr, ch) {
241
223
  if (scnr.currentChar() === ch) {
242
224
  scnr.next();
@@ -310,7 +292,7 @@ function createTokenizer(source, options = {}) {
310
292
  }
311
293
  function isLinkedDotStart(scnr, context) {
312
294
  const { currentType } = context;
313
- if (currentType !== 8 /* TokenTypes.LinkedAlias */) {
295
+ if (currentType !== 7 /* TokenTypes.LinkedAlias */) {
314
296
  return false;
315
297
  }
316
298
  peekSpaces(scnr);
@@ -320,7 +302,7 @@ function createTokenizer(source, options = {}) {
320
302
  }
321
303
  function isLinkedModifierStart(scnr, context) {
322
304
  const { currentType } = context;
323
- if (currentType !== 9 /* TokenTypes.LinkedDot */) {
305
+ if (currentType !== 8 /* TokenTypes.LinkedDot */) {
324
306
  return false;
325
307
  }
326
308
  peekSpaces(scnr);
@@ -330,8 +312,8 @@ function createTokenizer(source, options = {}) {
330
312
  }
331
313
  function isLinkedDelimiterStart(scnr, context) {
332
314
  const { currentType } = context;
333
- if (!(currentType === 8 /* TokenTypes.LinkedAlias */ ||
334
- currentType === 12 /* TokenTypes.LinkedModifier */)) {
315
+ if (!(currentType === 7 /* TokenTypes.LinkedAlias */ ||
316
+ currentType === 11 /* TokenTypes.LinkedModifier */)) {
335
317
  return false;
336
318
  }
337
319
  peekSpaces(scnr);
@@ -341,7 +323,7 @@ function createTokenizer(source, options = {}) {
341
323
  }
342
324
  function isLinkedReferStart(scnr, context) {
343
325
  const { currentType } = context;
344
- if (currentType !== 10 /* TokenTypes.LinkedDelimiter */) {
326
+ if (currentType !== 9 /* TokenTypes.LinkedDelimiter */) {
345
327
  return false;
346
328
  }
347
329
  const fn = () => {
@@ -350,7 +332,6 @@ function createTokenizer(source, options = {}) {
350
332
  return isIdentifierStart(scnr.peek());
351
333
  }
352
334
  else if (ch === "@" /* TokenChars.LinkedAlias */ ||
353
- ch === "%" /* TokenChars.Modulo */ ||
354
335
  ch === "|" /* TokenChars.Pipe */ ||
355
336
  ch === ":" /* TokenChars.LinkedDelimiter */ ||
356
337
  ch === "." /* TokenChars.LinkedDot */ ||
@@ -364,7 +345,7 @@ function createTokenizer(source, options = {}) {
364
345
  }
365
346
  else {
366
347
  // other characters
367
- return isIdentifierStart(ch);
348
+ return isTextStart(scnr, false);
368
349
  }
369
350
  };
370
351
  const ret = fn();
@@ -377,41 +358,25 @@ function createTokenizer(source, options = {}) {
377
358
  scnr.resetPeek();
378
359
  return ret;
379
360
  }
380
- function detectModuloStart(scnr) {
381
- const spaces = peekSpaces(scnr);
382
- const ret = scnr.currentPeek() === "%" /* TokenChars.Modulo */ &&
383
- scnr.peek() === "{" /* TokenChars.BraceLeft */;
384
- scnr.resetPeek();
385
- return {
386
- isModulo: ret,
387
- hasSpace: spaces.length > 0
388
- };
389
- }
390
361
  function isTextStart(scnr, reset = true) {
391
- const fn = (hasSpace = false, prev = '', detectModulo = false) => {
362
+ const fn = (hasSpace = false, prev = '') => {
392
363
  const ch = scnr.currentPeek();
393
364
  if (ch === "{" /* TokenChars.BraceLeft */) {
394
- return prev === "%" /* TokenChars.Modulo */ ? false : hasSpace;
365
+ return hasSpace;
395
366
  }
396
367
  else if (ch === "@" /* TokenChars.LinkedAlias */ || !ch) {
397
- return prev === "%" /* TokenChars.Modulo */ ? true : hasSpace;
398
- }
399
- else if (ch === "%" /* TokenChars.Modulo */) {
400
- scnr.peek();
401
- return fn(hasSpace, "%" /* TokenChars.Modulo */, true);
368
+ return hasSpace;
402
369
  }
403
370
  else if (ch === "|" /* TokenChars.Pipe */) {
404
- return prev === "%" /* TokenChars.Modulo */ || detectModulo
405
- ? true
406
- : !(prev === CHAR_SP || prev === CHAR_LF);
371
+ return !(prev === CHAR_SP || prev === CHAR_LF);
407
372
  }
408
373
  else if (ch === CHAR_SP) {
409
374
  scnr.peek();
410
- return fn(true, CHAR_SP, detectModulo);
375
+ return fn(true, CHAR_SP);
411
376
  }
412
377
  else if (ch === CHAR_LF) {
413
378
  scnr.peek();
414
- return fn(true, CHAR_LF, detectModulo);
379
+ return fn(true, CHAR_LF);
415
380
  }
416
381
  else {
417
382
  return true;
@@ -481,18 +446,8 @@ function createTokenizer(source, options = {}) {
481
446
  }
482
447
  return num;
483
448
  }
484
- function readModulo(scnr) {
485
- skipSpaces(scnr);
486
- const ch = scnr.currentChar();
487
- if (ch !== "%" /* TokenChars.Modulo */) {
488
- emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch);
489
- }
490
- scnr.next();
491
- return "%" /* TokenChars.Modulo */;
492
- }
493
449
  function readText(scnr) {
494
450
  let buf = '';
495
- // eslint-disable-next-line no-constant-condition
496
451
  while (true) {
497
452
  const ch = scnr.currentChar();
498
453
  if (ch === "{" /* TokenChars.BraceLeft */ ||
@@ -502,15 +457,6 @@ function createTokenizer(source, options = {}) {
502
457
  !ch) {
503
458
  break;
504
459
  }
505
- else if (ch === "%" /* TokenChars.Modulo */) {
506
- if (isTextStart(scnr)) {
507
- buf += ch;
508
- scnr.next();
509
- }
510
- else {
511
- break;
512
- }
513
- }
514
460
  else if (ch === CHAR_SP || ch === CHAR_LF) {
515
461
  if (isTextStart(scnr)) {
516
462
  buf += ch;
@@ -643,10 +589,9 @@ function createTokenizer(source, options = {}) {
643
589
  return name;
644
590
  }
645
591
  function readLinkedRefer(scnr) {
646
- const fn = (detect = false, buf) => {
592
+ const fn = (buf) => {
647
593
  const ch = scnr.currentChar();
648
594
  if (ch === "{" /* TokenChars.BraceLeft */ ||
649
- ch === "%" /* TokenChars.Modulo */ ||
650
595
  ch === "@" /* TokenChars.LinkedAlias */ ||
651
596
  ch === "|" /* TokenChars.Pipe */ ||
652
597
  ch === "(" /* TokenChars.ParenLeft */ ||
@@ -660,15 +605,15 @@ function createTokenizer(source, options = {}) {
660
605
  else if (ch === CHAR_LF || ch === DOT) {
661
606
  buf += ch;
662
607
  scnr.next();
663
- return fn(detect, buf);
608
+ return fn(buf);
664
609
  }
665
610
  else {
666
611
  buf += ch;
667
612
  scnr.next();
668
- return fn(true, buf);
613
+ return fn(buf);
669
614
  }
670
615
  };
671
- return fn(false, '');
616
+ return fn('');
672
617
  }
673
618
  function readPlural(scnr) {
674
619
  skipSpaces(scnr);
@@ -725,31 +670,31 @@ function createTokenizer(source, options = {}) {
725
670
  return token;
726
671
  }
727
672
  if (context.braceNest > 0 &&
728
- (context.currentType === 5 /* TokenTypes.Named */ ||
729
- context.currentType === 6 /* TokenTypes.List */ ||
730
- context.currentType === 7 /* TokenTypes.Literal */)) {
673
+ (context.currentType === 4 /* TokenTypes.Named */ ||
674
+ context.currentType === 5 /* TokenTypes.List */ ||
675
+ context.currentType === 6 /* TokenTypes.Literal */)) {
731
676
  emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0);
732
677
  context.braceNest = 0;
733
678
  return readToken(scnr, context);
734
679
  }
735
680
  if ((validNamedIdentifier = isNamedIdentifierStart(scnr, context))) {
736
- token = getToken(context, 5 /* TokenTypes.Named */, readNamedIdentifier(scnr));
681
+ token = getToken(context, 4 /* TokenTypes.Named */, readNamedIdentifier(scnr));
737
682
  skipSpaces(scnr);
738
683
  return token;
739
684
  }
740
685
  if ((validListIdentifier = isListIdentifierStart(scnr, context))) {
741
- token = getToken(context, 6 /* TokenTypes.List */, readListIdentifier(scnr));
686
+ token = getToken(context, 5 /* TokenTypes.List */, readListIdentifier(scnr));
742
687
  skipSpaces(scnr);
743
688
  return token;
744
689
  }
745
690
  if ((validLiteral = isLiteralStart(scnr, context))) {
746
- token = getToken(context, 7 /* TokenTypes.Literal */, readLiteral(scnr));
691
+ token = getToken(context, 6 /* TokenTypes.Literal */, readLiteral(scnr));
747
692
  skipSpaces(scnr);
748
693
  return token;
749
694
  }
750
695
  if (!validNamedIdentifier && !validListIdentifier && !validLiteral) {
751
696
  // TODO: we should be re-designed invalid cases, when we will extend message syntax near the future ...
752
- token = getToken(context, 13 /* TokenTypes.InvalidPlace */, readInvalidIdentifier(scnr));
697
+ token = getToken(context, 12 /* TokenTypes.InvalidPlace */, readInvalidIdentifier(scnr));
753
698
  emitError(CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER, currentPosition(), 0, token.value);
754
699
  skipSpaces(scnr);
755
700
  return token;
@@ -764,27 +709,27 @@ function createTokenizer(source, options = {}) {
764
709
  const { currentType } = context;
765
710
  let token = null;
766
711
  const ch = scnr.currentChar();
767
- if ((currentType === 8 /* TokenTypes.LinkedAlias */ ||
768
- currentType === 9 /* TokenTypes.LinkedDot */ ||
769
- currentType === 12 /* TokenTypes.LinkedModifier */ ||
770
- currentType === 10 /* TokenTypes.LinkedDelimiter */) &&
712
+ if ((currentType === 7 /* TokenTypes.LinkedAlias */ ||
713
+ currentType === 8 /* TokenTypes.LinkedDot */ ||
714
+ currentType === 11 /* TokenTypes.LinkedModifier */ ||
715
+ currentType === 9 /* TokenTypes.LinkedDelimiter */) &&
771
716
  (ch === CHAR_LF || ch === CHAR_SP)) {
772
717
  emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0);
773
718
  }
774
719
  switch (ch) {
775
720
  case "@" /* TokenChars.LinkedAlias */:
776
721
  scnr.next();
777
- token = getToken(context, 8 /* TokenTypes.LinkedAlias */, "@" /* TokenChars.LinkedAlias */);
722
+ token = getToken(context, 7 /* TokenTypes.LinkedAlias */, "@" /* TokenChars.LinkedAlias */);
778
723
  context.inLinked = true;
779
724
  return token;
780
725
  case "." /* TokenChars.LinkedDot */:
781
726
  skipSpaces(scnr);
782
727
  scnr.next();
783
- return getToken(context, 9 /* TokenTypes.LinkedDot */, "." /* TokenChars.LinkedDot */);
728
+ return getToken(context, 8 /* TokenTypes.LinkedDot */, "." /* TokenChars.LinkedDot */);
784
729
  case ":" /* TokenChars.LinkedDelimiter */:
785
730
  skipSpaces(scnr);
786
731
  scnr.next();
787
- return getToken(context, 10 /* TokenTypes.LinkedDelimiter */, ":" /* TokenChars.LinkedDelimiter */);
732
+ return getToken(context, 9 /* TokenTypes.LinkedDelimiter */, ":" /* TokenChars.LinkedDelimiter */);
788
733
  default:
789
734
  if (isPluralStart(scnr)) {
790
735
  token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr));
@@ -800,7 +745,7 @@ function createTokenizer(source, options = {}) {
800
745
  }
801
746
  if (isLinkedModifierStart(scnr, context)) {
802
747
  skipSpaces(scnr);
803
- return getToken(context, 12 /* TokenTypes.LinkedModifier */, readLinkedModifier(scnr));
748
+ return getToken(context, 11 /* TokenTypes.LinkedModifier */, readLinkedModifier(scnr));
804
749
  }
805
750
  if (isLinkedReferStart(scnr, context)) {
806
751
  skipSpaces(scnr);
@@ -809,10 +754,10 @@ function createTokenizer(source, options = {}) {
809
754
  return readTokenInPlaceholder(scnr, context) || token;
810
755
  }
811
756
  else {
812
- return getToken(context, 11 /* TokenTypes.LinkedKey */, readLinkedRefer(scnr));
757
+ return getToken(context, 10 /* TokenTypes.LinkedKey */, readLinkedRefer(scnr));
813
758
  }
814
759
  }
815
- if (currentType === 8 /* TokenTypes.LinkedAlias */) {
760
+ if (currentType === 7 /* TokenTypes.LinkedAlias */) {
816
761
  emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0);
817
762
  }
818
763
  context.braceNest = 0;
@@ -822,7 +767,7 @@ function createTokenizer(source, options = {}) {
822
767
  }
823
768
  // TODO: We need refactoring of token parsing ...
824
769
  function readToken(scnr, context) {
825
- let token = { type: 14 /* TokenTypes.EOF */ };
770
+ let token = { type: 13 /* TokenTypes.EOF */ };
826
771
  if (context.braceNest > 0) {
827
772
  return readTokenInPlaceholder(scnr, context) || getEndToken(context);
828
773
  }
@@ -847,12 +792,6 @@ function createTokenizer(source, options = {}) {
847
792
  context.inLinked = false;
848
793
  return token;
849
794
  }
850
- const { isModulo, hasSpace } = detectModuloStart(scnr);
851
- if (isModulo) {
852
- return hasSpace
853
- ? getToken(context, 0 /* TokenTypes.Text */, readText(scnr))
854
- : getToken(context, 4 /* TokenTypes.Modulo */, readModulo(scnr));
855
- }
856
795
  if (isTextStart(scnr)) {
857
796
  return getToken(context, 0 /* TokenTypes.Text */, readText(scnr));
858
797
  }
@@ -870,7 +809,7 @@ function createTokenizer(source, options = {}) {
870
809
  _context.offset = currentOffset();
871
810
  _context.startLoc = currentPosition();
872
811
  if (_scnr.currentChar() === EOF) {
873
- return getToken(_context, 14 /* TokenTypes.EOF */);
812
+ return getToken(_context, 13 /* TokenTypes.EOF */);
874
813
  }
875
814
  return readToken(_scnr, _context);
876
815
  }
@@ -906,7 +845,7 @@ function fromEscapeSequence(match, codePoint4, codePoint6) {
906
845
  }
907
846
  function createParser(options = {}) {
908
847
  const location = options.location !== false;
909
- const { onError, onWarn } = options;
848
+ const { onError } = options;
910
849
  function emitError(tokenzer, code, start, offset, ...args) {
911
850
  const end = tokenzer.currentPosition();
912
851
  end.offset += offset;
@@ -920,15 +859,6 @@ function createParser(options = {}) {
920
859
  onError(err);
921
860
  }
922
861
  }
923
- function emitWarn(tokenzer, code, start, offset, ...args) {
924
- const end = tokenzer.currentPosition();
925
- end.offset += offset;
926
- end.column += offset;
927
- if (onWarn) {
928
- const loc = location ? createLocation(start, end) : null;
929
- onWarn(createCompileWarn(code, loc, args));
930
- }
931
- }
932
862
  function startNode(type, offset, loc) {
933
863
  const node = { type };
934
864
  if (location) {
@@ -965,14 +895,11 @@ function createParser(options = {}) {
965
895
  endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
966
896
  return node;
967
897
  }
968
- function parseNamed(tokenizer, key, modulo) {
898
+ function parseNamed(tokenizer, key) {
969
899
  const context = tokenizer.context();
970
900
  const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc
971
901
  const node = startNode(4 /* NodeTypes.Named */, offset, loc);
972
902
  node.key = key;
973
- if (modulo === true) {
974
- node.modulo = true;
975
- }
976
903
  tokenizer.nextToken(); // skip brach right
977
904
  endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
978
905
  return node;
@@ -991,7 +918,7 @@ function createParser(options = {}) {
991
918
  const context = tokenizer.context();
992
919
  const { lastOffset: offset, lastStartLoc: loc } = context; // get linked dot loc
993
920
  const node = startNode(8 /* NodeTypes.LinkedModifier */, offset, loc);
994
- if (token.type !== 12 /* TokenTypes.LinkedModifier */) {
921
+ if (token.type !== 11 /* TokenTypes.LinkedModifier */) {
995
922
  // empty modifier
996
923
  emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER, context.lastStartLoc, 0);
997
924
  node.value = '';
@@ -1022,13 +949,13 @@ function createParser(options = {}) {
1022
949
  const context = tokenizer.context();
1023
950
  const linkedNode = startNode(6 /* NodeTypes.Linked */, context.offset, context.startLoc);
1024
951
  let token = tokenizer.nextToken();
1025
- if (token.type === 9 /* TokenTypes.LinkedDot */) {
952
+ if (token.type === 8 /* TokenTypes.LinkedDot */) {
1026
953
  const parsed = parseLinkedModifier(tokenizer);
1027
954
  linkedNode.modifier = parsed.node;
1028
955
  token = parsed.nextConsumeToken || tokenizer.nextToken();
1029
956
  }
1030
957
  // asset check token
1031
- if (token.type !== 10 /* TokenTypes.LinkedDelimiter */) {
958
+ if (token.type !== 9 /* TokenTypes.LinkedDelimiter */) {
1032
959
  emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
1033
960
  }
1034
961
  token = tokenizer.nextToken();
@@ -1037,25 +964,25 @@ function createParser(options = {}) {
1037
964
  token = tokenizer.nextToken();
1038
965
  }
1039
966
  switch (token.type) {
1040
- case 11 /* TokenTypes.LinkedKey */:
967
+ case 10 /* TokenTypes.LinkedKey */:
1041
968
  if (token.value == null) {
1042
969
  emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
1043
970
  }
1044
971
  linkedNode.key = parseLinkedKey(tokenizer, token.value || '');
1045
972
  break;
1046
- case 5 /* TokenTypes.Named */:
973
+ case 4 /* TokenTypes.Named */:
1047
974
  if (token.value == null) {
1048
975
  emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
1049
976
  }
1050
977
  linkedNode.key = parseNamed(tokenizer, token.value || '');
1051
978
  break;
1052
- case 6 /* TokenTypes.List */:
979
+ case 5 /* TokenTypes.List */:
1053
980
  if (token.value == null) {
1054
981
  emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
1055
982
  }
1056
983
  linkedNode.key = parseList(tokenizer, token.value || '');
1057
984
  break;
1058
- case 7 /* TokenTypes.Literal */:
985
+ case 6 /* TokenTypes.Literal */:
1059
986
  if (token.value == null) {
1060
987
  emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
1061
988
  }
@@ -1092,7 +1019,6 @@ function createParser(options = {}) {
1092
1019
  const node = startNode(2 /* NodeTypes.Message */, startOffset, startLoc);
1093
1020
  node.items = [];
1094
1021
  let nextToken = null;
1095
- let modulo = null;
1096
1022
  do {
1097
1023
  const token = nextToken || tokenizer.nextToken();
1098
1024
  nextToken = null;
@@ -1103,39 +1029,32 @@ function createParser(options = {}) {
1103
1029
  }
1104
1030
  node.items.push(parseText(tokenizer, token.value || ''));
1105
1031
  break;
1106
- case 6 /* TokenTypes.List */:
1032
+ case 5 /* TokenTypes.List */:
1107
1033
  if (token.value == null) {
1108
1034
  emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
1109
1035
  }
1110
1036
  node.items.push(parseList(tokenizer, token.value || ''));
1111
1037
  break;
1112
- case 4 /* TokenTypes.Modulo */:
1113
- modulo = true;
1114
- break;
1115
- case 5 /* TokenTypes.Named */:
1038
+ case 4 /* TokenTypes.Named */:
1116
1039
  if (token.value == null) {
1117
1040
  emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
1118
1041
  }
1119
- node.items.push(parseNamed(tokenizer, token.value || '', !!modulo));
1120
- if (modulo) {
1121
- emitWarn(tokenizer, CompileWarnCodes.USE_MODULO_SYNTAX, context.lastStartLoc, 0, getTokenCaption(token));
1122
- modulo = null;
1123
- }
1042
+ node.items.push(parseNamed(tokenizer, token.value || ''));
1124
1043
  break;
1125
- case 7 /* TokenTypes.Literal */:
1044
+ case 6 /* TokenTypes.Literal */:
1126
1045
  if (token.value == null) {
1127
1046
  emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
1128
1047
  }
1129
1048
  node.items.push(parseLiteral(tokenizer, token.value || ''));
1130
1049
  break;
1131
- case 8 /* TokenTypes.LinkedAlias */: {
1050
+ case 7 /* TokenTypes.LinkedAlias */: {
1132
1051
  const parsed = parseLinked(tokenizer);
1133
1052
  node.items.push(parsed.node);
1134
1053
  nextToken = parsed.nextConsumeToken || null;
1135
1054
  break;
1136
1055
  }
1137
1056
  }
1138
- } while (context.currentType !== 14 /* TokenTypes.EOF */ &&
1057
+ } while (context.currentType !== 13 /* TokenTypes.EOF */ &&
1139
1058
  context.currentType !== 1 /* TokenTypes.Pipe */);
1140
1059
  // adjust message node loc
1141
1060
  const endOffset = context.currentType === 1 /* TokenTypes.Pipe */
@@ -1159,7 +1078,7 @@ function createParser(options = {}) {
1159
1078
  hasEmptyMessage = msg.items.length === 0;
1160
1079
  }
1161
1080
  node.cases.push(msg);
1162
- } while (context.currentType !== 14 /* TokenTypes.EOF */);
1081
+ } while (context.currentType !== 13 /* TokenTypes.EOF */);
1163
1082
  if (hasEmptyMessage) {
1164
1083
  emitError(tokenizer, CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL, loc, 0);
1165
1084
  }
@@ -1170,7 +1089,7 @@ function createParser(options = {}) {
1170
1089
  const context = tokenizer.context();
1171
1090
  const { offset, startLoc } = context;
1172
1091
  const msgNode = parseMessage(tokenizer);
1173
- if (context.currentType === 14 /* TokenTypes.EOF */) {
1092
+ if (context.currentType === 13 /* TokenTypes.EOF */) {
1174
1093
  return msgNode;
1175
1094
  }
1176
1095
  else {
@@ -1189,7 +1108,7 @@ function createParser(options = {}) {
1189
1108
  node.cacheKey = options.onCacheKey(source);
1190
1109
  }
1191
1110
  // assert whether achieved to EOF
1192
- if (context.currentType !== 14 /* TokenTypes.EOF */) {
1111
+ if (context.currentType !== 13 /* TokenTypes.EOF */) {
1193
1112
  emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, source[context.offset] || '');
1194
1113
  }
1195
1114
  endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
@@ -1198,7 +1117,7 @@ function createParser(options = {}) {
1198
1117
  return { parse };
1199
1118
  }
1200
1119
  function getTokenCaption(token) {
1201
- if (token.type === 14 /* TokenTypes.EOF */) {
1120
+ if (token.type === 13 /* TokenTypes.EOF */) {
1202
1121
  return 'EOF';
1203
1122
  }
1204
1123
  const name = (token.value || '').replace(/\r?\n/gu, '\\n');
@@ -1544,8 +1463,7 @@ function generateNode(generator, node) {
1544
1463
  }
1545
1464
  }
1546
1465
  // generate code from AST
1547
- const generate = (ast, options = {} // eslint-disable-line
1548
- ) => {
1466
+ const generate = (ast, options = {}) => {
1549
1467
  const mode = shared.isString(options.mode) ? options.mode : 'normal';
1550
1468
  const filename = shared.isString(options.filename)
1551
1469
  ? options.filename
@@ -1642,16 +1560,13 @@ function baseCompile(source, options = {}) {
1642
1560
  }
1643
1561
 
1644
1562
  exports.CompileErrorCodes = CompileErrorCodes;
1645
- exports.CompileWarnCodes = CompileWarnCodes;
1646
1563
  exports.ERROR_DOMAIN = ERROR_DOMAIN;
1647
1564
  exports.LOCATION_STUB = LOCATION_STUB;
1648
1565
  exports.baseCompile = baseCompile;
1649
1566
  exports.createCompileError = createCompileError;
1650
- exports.createCompileWarn = createCompileWarn;
1651
1567
  exports.createLocation = createLocation;
1652
1568
  exports.createParser = createParser;
1653
1569
  exports.createPosition = createPosition;
1654
1570
  exports.defaultOnError = defaultOnError;
1655
1571
  exports.detectHtmlTag = detectHtmlTag;
1656
1572
  exports.errorMessages = errorMessages;
1657
- exports.warnMessages = warnMessages;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlify/message-compiler",
3
- "version": "9.13.0",
3
+ "version": "10.0.0-alpha.1",
4
4
  "description": "@intlify/message-compiler",
5
5
  "keywords": [
6
6
  "compiler",
@@ -34,7 +34,7 @@
34
34
  "types": "dist/message-compiler.d.ts",
35
35
  "dependencies": {
36
36
  "source-map-js": "^1.0.2",
37
- "@intlify/shared": "9.13.0"
37
+ "@intlify/shared": "10.0.0-alpha.1"
38
38
  },
39
39
  "engines": {
40
40
  "node": ">= 16"