CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/codemirror/mode/ada.ts
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import * as CodeMirror from "codemirror";
7
8
// Little first step for Ada
9
10
// This is redundant with the regexp's below, but we need this to do completions
11
// before the terms are ever used.
12
export const completions: string[] = "abort|else|new|return|abs|elsif|not|reverse|abstract|end|null|accept|entry|select|access|exception|of|separate|aliased|exit|or|some|all|others|subtype|and|for|out|synchronized|array|function|overriding|at|tagged|generic|package|task|begin|goto|pragma|terminate|body|private|then|if|procedure|type|case|in|protected|constant|interface|until|is|raise|use|declare|range|delay|limited|record|when|delta|loop|rem|while|digits|renames|with|do|mod|requeue|xor".split(
13
"|"
14
);
15
completions.sort();
16
17
(CodeMirror as any).defineSimpleMode("ada", {
18
start: [
19
{ regex: /"(?:[^\\]|\\.)*?(?:"|$)/, token: "string" },
20
{ regex: /--.*/, token: "comment" },
21
{ regex: /[-+\/*=<>!:]+/, token: "operator" },
22
{
23
regex: /\b(abort|else|new|return|abs|elsif|not|reverse|abstract|end|null|accept|entry|select|access|exception|of|separate|aliased|exit|or|some|all|others|subtype|and|for|out|synchronized|array|function|overriding|at|tagged|generic|package|task|begin|goto|pragma|terminate|body|private|then|if|procedure|type|case|in|protected|constant|interface|until|is|raise|use|declare|range|delay|limited|record|when|delta|loop|rem|while|digits|renames|with|do|mod|requeue|xor)\b/,
24
token: "atom",
25
},
26
{
27
regex: /0x[a-f\d]+|[-+]?(?:\.\d+|\d+\.?\d*)(?:e[-+]?\d+)?/i,
28
token: "number",
29
},
30
{ regex: /(if|elseif|case|when|begin|while|loop)/, indent: true },
31
{ regex: /(end)/, dedent: true },
32
{
33
regex: /\b([A-Za-z_0-9]+)\b/,
34
token: "variable-3",
35
},
36
{ regex: /b?"/, token: "string", next: "string" },
37
],
38
string: [
39
{ regex: /"/, token: "string", next: "start" },
40
{ regex: /(?:[^\\"]|\\(?:.|$))*/, token: "string" },
41
],
42
meta: {
43
dontIndentStates: ["comment"],
44
lineComment: "--",
45
},
46
});
47
48