@metweave/parser 0.1.0 → 0.1.2

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/index.cjs CHANGED
@@ -1007,7 +1007,7 @@ function parse(raw, options) {
1007
1007
  i += 1;
1008
1008
  let period;
1009
1009
  const periodTok = peek();
1010
- if (kindText !== "NOSIG" && periodTok !== void 0 && /^(AT|FM|TL)\d{4}$/.test(periodTok.text)) {
1010
+ if (kindText !== "NOSIG" && periodTok !== void 0 && (/^(?:AT|FM|TL)\d{4}$/.test(periodTok.text) || /^\d{4}\/\d{4}$/.test(periodTok.text))) {
1011
1011
  period = {
1012
1012
  text: periodTok.text,
1013
1013
  span: spanOf(periodTok)
@@ -1028,7 +1028,7 @@ function parse(raw, options) {
1028
1028
  continue;
1029
1029
  }
1030
1030
  if (text.length === 6 && (text.charCodeAt(0) === 65 || text.charCodeAt(0) === 84 || text.charCodeAt(0) === 70) || text.startsWith("BECMG") || text.startsWith("TEMPO")) {
1031
- const fused = /^(BECMG|TEMPO)(AT|TL|FM)\d{4}$/.exec(text);
1031
+ const fused = /^(BECMG|TEMPO)((?:AT|TL|FM)\d{4}|\d{4}\/\d{4})$/.exec(text);
1032
1032
  if (fused !== null) {
1033
1033
  const indicator = fused[1] ?? "";
1034
1034
  const collected = [t];
@@ -1076,12 +1076,36 @@ function parse(raw, options) {
1076
1076
  warnings.push({
1077
1077
  code: "invalid-format",
1078
1078
  severity: "warning",
1079
- message: `趋势时段词缺指示组(${text}——§15.14.3 时段词须随 BECMG/TEMPO 出现)——按磨损趋势段收下,指示组类型不可辨`,
1079
+ message: `趋势时段词缺指示组(${text}——§15.14.3 时段词须随 BECMG/TEMPO 出现)——按指示组缺失的趋势段收下,指示组类型不可辨`,
1080
1080
  span: spanOf(t)
1081
1081
  });
1082
1082
  continue;
1083
1083
  }
1084
1084
  }
1085
+ if (text.length === 9 && text.charCodeAt(4) === 47 && /^\d{4}\/\d{4}$/.test(text)) {
1086
+ const collected = [t];
1087
+ i += 1;
1088
+ collectTrendTokens(collected);
1089
+ trendCloseWarning();
1090
+ const bareElements = structureTrendElements(collected, 1);
1091
+ trends.push({
1092
+ kind: "unspecified",
1093
+ period: {
1094
+ text,
1095
+ span: spanOf(t)
1096
+ },
1097
+ ...bareElements !== void 0 ? { elements: bareElements } : {},
1098
+ raw: collected.map((c) => c.text).join(" "),
1099
+ span: joinSpan(collected)
1100
+ });
1101
+ warnings.push({
1102
+ code: "invalid-format",
1103
+ severity: "warning",
1104
+ message: `趋势时段词缺指示组(${text}——ICAO Annex 3 模板趋势时段须随 BECMG/TEMPO 出现)——按指示组缺失的趋势段收下,指示组类型不可辨`,
1105
+ span: spanOf(t)
1106
+ });
1107
+ continue;
1108
+ }
1085
1109
  if (text === "CAVOK") {
1086
1110
  cavok = true;
1087
1111
  cavokSpan = spanOf(t);