I am new in codemirror/lezer.
I am trying to write a new language.
In syntax.grammer file:
@external specialize {identifier} fields from "./tokens" {
Metric[@name=Metric],
Dimension[@name=Dimension]
}
In tokens.ts
const metrics = ["quantity", "cost" ];
const dimensions = ["name", "date"]
export function fields(name:string) {
name = name.toLowerCase();
if (metrics.includes(name)){
return Metric;
}
if (dimensions.includes(name)){
return Dimension;
}
return -1;
}
My question is: how to send to language module metrics and dimensions variables at runtime, especially access metrics and dimensions from tokens.ts file (metrics and dimensions depend on context).
My main script main.js is outside of language module: