external specialize syntax

I am completely new to code mirror. I have the following three files.

When I type in jack in the editor I get Uncaught ReferenceError:CoolItem is not defined

I know it has to do with return statement in tokens.js
However I am completely lost as to what is to be returned here – how is the token declared in grammar file inside braces of external specializer passed to the function in token.js

In grammar file

@external specialize {Identifier} SpecializeIdent from “./tokens” {
CoolItem
}

in tokens.js

const SpecializeIdent = {
SpecializeIdent: function(name) {
name = name.toLowerCase();

    let specials = ["jack", "jim"];

    if (specials.includes(name)) {
        return CoolItem
    }

    return -1
}

}

in index.ts

export const MyLanguage = LRLanguage.define({

parser: parser.configure({
    props: [
        indentNodeProp.add({
            Application: delimitedIndent({closing: ")", align: false})
        }),
        foldNodeProp.add({
            Application: foldInside
        }),
        styleTags({
            Identifier: t.variableName,
            Boolean: t.bool,
            String: t.string,
            LineComment: t.lineComment,
            CoolItem:t.typeName,
            "( )": t.paren
        }),
    ],

}),
languageData: {
    commentTokens: {line: ";"}
}

})

export function MyLang() {
return new LanguageSupport(MyLanguage)
}

in editor.js

const myHighlightStyle = HighlightStyle.define([
{tag: tags.typeName, color: “#fc6”},
{tag: tags.comment, color: “#f5d”, fontStyle: “italic”}
])

let editor = new EditorView({
extensions: [basicSetup, MyLang(),syntaxHighlighting(myHighlightStyle)],
parent: document.querySelector(“#editor”)
})

lezer-generator will emit two files when you run it on your grammar, one holding the parse table and one with constants for all the node ids. You’ll need to import CoolItem from the latter file to be able to use it in your external specializer.

Thank you very much
clear instructions under building grammar somehow didn’t click before

in linter

   
    syntaxTree(view.state).cursor().iterate(node => {

if the node name is CoolItem - how do you get the value associated with the token for example “jack”