File: make-macaulay2-js.m2

package info (click to toggle)
macaulay2-jupyter-kernel 0.6.7~beta-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 3,492 kB
  • sloc: python: 21,611; javascript: 51; makefile: 9
file content (19 lines) | stat: -rw-r--r-- 929 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
load "/usr/share/Macaulay2/make-M2-symbols.m2"

symbolsForCodeMirror = template -> (
    output := replace("@M2KEYWORDS@", demark("|", KEYWORDS), template);
    output = replace("@M2DATATYPES@", demark("|", DATATYPES), output);
    output = replace("@M2FUNCTIONS@", demark("|", FUNCTIONS), output);
    output)

-- copied from make-M2-symbols.m2, since it's local to that file
generateGrammar := (grammarFile, grammarFunction) -> (
    template := currentFileDirectory | grammarFile | ".in";
    if fileExists template then (
        stdio << "-- Generating " << grammarFile << endl;
        directory := replace("/[^/].*$", "", grammarFile);
        if not isDirectory directory then makeDirectory directory;
        grammarFile << grammarFunction get(template) << close)
    else stderr << "Skipping generation of " << grammarFile << " as it does not exist." << endl;)

generateGrammar("./macaulay2.js", symbolsForCodeMirror);