Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

CodeMirror 6 Language Support for Scanspec

Provides syntax highlighting, code folding, and autocompletion for the Scanspec language in CodeMirror 6.

Features

  • Syntax highlighting for keywords, types, operators, strings, numbers, comments, and variables
  • Code folding for if/end and for/end blocks
  • Autocompletion for keywords, types, built-in functions (len, toInt64), and all module functions (math.*, graphs.*, strings.*, numbers.*, arrays.*, matrices.*, regexp.*) with parameter hints

Setup

Install dependencies and build the Lezer grammar:

npm install
npm run build

This compiles scanspec.grammar into scanspec.grammar.js, which is imported by scanspec.js.

Usage

import { scanspec } from "./scanspec.js"
import { EditorView, basicSetup } from "codemirror"

new EditorView({
  extensions: [basicSetup, scanspec()],
  parent: document.getElementById("editor"),
})

File Structure

  • scanspec.grammar — Lezer grammar source defining the Scanspec syntax
  • scanspec.js — Language definition, highlighting rules, and autocompletion
  • scanspec.grammar.js — Compiled parser (generated by npm run build, not checked in)
  • scanspec.grammar.terms.js — Compiled token terms (generated by npm run build, not checked in)

Updating

When new modules or functions are added to Scanspec, update the moduleFunctions array in scanspec.js to include them in autocompletion.

If the Scanspec grammar changes (new statement types, operators, etc.), update scanspec.grammar and rebuild.