Files
NapCatQQ/.pnpm-store/v3/files/ac/47452deadf7e26d897f2df7f7131418ff6ab026bf6e6e9f554c7362b34bfd00ecb61f71f3f0d4cb2c7a2c5a468c3cc4bb6f7c3c5c1bf86d2d5bf29f971aeb6
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

31 lines
816 B
Plaintext

import { Spec } from '../../primitives.js';
import { Tokenizer } from './index.js';
/**
* Splits the `@prefix` from remaining `Spec.lines[].token.description` into the `tag` token,
* and populates `spec.tag`
*/
export default function tagTokenizer(): Tokenizer {
return (spec: Spec): Spec => {
const { tokens } = spec.source[0];
const match = tokens.description.match(/\s*(@(\S+))(\s*)/);
if (match === null) {
spec.problems.push({
code: 'spec:tag:prefix',
message: 'tag should start with "@" symbol',
line: spec.source[0].number,
critical: true,
});
return spec;
}
tokens.tag = match[1];
tokens.postTag = match[3];
tokens.description = tokens.description.slice(match[0].length);
spec.tag = match[2];
return spec;
};
}