unified-query
Version:
Composable search input with autocompletion and a rich query-language parser for the Unified Data System
27 lines (26 loc) • 725 B
JavaScript
/**
* `@todo` is a parameter-less flag (alias for “@completed false”).
* • If *no* tokens follow → parsed = true (flag enabled).
* • Any token present → semantic error.
*/
export function analyzeTodo(seg) {
const errors = [];
if (seg.tokens.length) {
for (const tok of seg.tokens) {
errors.push({
message: `invalid token "${tok.raw}" for @todo (no arguments allowed)`,
token: tok.raw,
from: tok.from,
to: tok.to,
});
}
}
seg.errors.push(...errors);
return {
keyword: 'todo',
parsed: undefined,
from: seg.from,
to: seg.to,
raw: seg.raw,
};
}