Skip to content

Commit 23cd9b6

Browse files
Added support for GAP (CAS) (#3054)
1 parent 8d0b74b commit 23cd9b6

15 files changed

+502
-2
lines changed

components.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,10 @@
446446
"require": "clike",
447447
"owner": "LiarOnce"
448448
},
449+
"gap": {
450+
"title": "GAP (CAS)",
451+
"owner": "RunDevelopment"
452+
},
449453
"gcode": {
450454
"title": "G-code",
451455
"owner": "RunDevelopment"

components/prism-gap.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// https://www.gap-system.org/Manuals/doc/ref/chap4.html
2+
// https://www.gap-system.org/Manuals/doc/ref/chap27.html
3+
4+
Prism.languages.gap = {
5+
'shell': {
6+
pattern: /^gap>[\s\S]*?(?=^gap>|$(?![\s\S]))/m,
7+
greedy: true,
8+
inside: {
9+
'gap': {
10+
pattern: /^(gap>).+(?:(?:\r(?:\n|(?!\n))|\n)>.*)*/,
11+
lookbehind: true,
12+
inside: null // see below
13+
},
14+
'punctuation': /^gap>/
15+
}
16+
},
17+
18+
'comment': {
19+
pattern: /#.*/,
20+
greedy: true
21+
},
22+
'string': {
23+
pattern: /(^|[^\\'"])(?:'(?:[^\r\n\\']|\\.){1,10}'|"(?:[^\r\n\\"]|\\.)*"(?!")|"""[\s\S]*?""")/,
24+
lookbehind: true,
25+
greedy: true,
26+
inside: {
27+
'continuation': {
28+
pattern: /([\r\n])>/,
29+
lookbehind: true,
30+
alias: 'punctuation'
31+
}
32+
}
33+
},
34+
35+
'keyword': /\b(?:Assert|Info|IsBound|QUIT|TryNextMethod|Unbind|and|atomic|break|continue|do|elif|else|end|fi|for|function|if|in|local|mod|not|od|or|quit|readonly|readwrite|rec|repeat|return|then|until|while)\b/,
36+
'boolean': /\b(?:false|true)\b/,
37+
38+
'function': /\b[a-z_]\w*(?=\s*\()/i,
39+
40+
'number': {
41+
pattern: /(^|[^\w.]|\.\.)(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?(?:_[a-z]?)?(?=$|[^\w.]|\.\.)/,
42+
lookbehind: true
43+
},
44+
45+
'continuation': {
46+
pattern: /([\r\n])>/,
47+
lookbehind: true,
48+
alias: 'punctuation'
49+
},
50+
'operator': /->|[-+*/^~=!]|<>|[<>]=?|:=|\.\./,
51+
'punctuation': /[()[\]{},;.:]/
52+
};
53+
54+
Prism.languages.gap.shell.inside.gap.inside = Prism.languages.gap;

components/prism-gap.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/prism-gap.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<h2>Full example</h2>
2+
<pre><code># Source: https://www.gap-system.org/Manuals/doc/ref/chap4.html#X815F71EA7BC0EB6F
3+
gap> fib := function ( n )
4+
> local f1, f2, f3, i;
5+
> f1 := 1; f2 := 1;
6+
> for i in [3..n] do
7+
> f3 := f1 + f2;
8+
> f1 := f2;
9+
> f2 := f3;
10+
> od;
11+
> return f2;
12+
> end;;
13+
gap> List( [1..10], fib );
14+
[ 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 ]
15+
</code></pre>

plugins/show-language/prism-show-language.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
"ftl": "FreeMarker Template Language",
8888
"gml": "GameMaker Language",
8989
"gamemakerlanguage": "GameMaker Language",
90+
"gap": "GAP (CAS)",
9091
"gcode": "G-code",
9192
"gdscript": "GDScript",
9293
"gedcom": "GEDCOM",

plugins/show-language/prism-show-language.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
false
2+
true
3+
4+
----------------------------------------------------
5+
6+
[
7+
["boolean", "false"],
8+
["boolean", "true"]
9+
]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# comment
2+
3+
----------------------------------------------------
4+
5+
[
6+
["comment", "# comment"]
7+
]
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
Assert;
2+
Info;
3+
IsBound;
4+
QUIT;
5+
TryNextMethod;
6+
Unbind;
7+
and;
8+
atomic;
9+
break;
10+
continue;
11+
do;
12+
elif;
13+
else;
14+
end;
15+
fi;
16+
for;
17+
function;
18+
if;
19+
in;
20+
local;
21+
mod;
22+
not;
23+
od;
24+
or;
25+
quit;
26+
readonly;
27+
readwrite;
28+
rec;
29+
repeat;
30+
return;
31+
then;
32+
until;
33+
while;
34+
35+
----------------------------------------------------
36+
37+
[
38+
["keyword", "Assert"], ["punctuation", ";"],
39+
["keyword", "Info"], ["punctuation", ";"],
40+
["keyword", "IsBound"], ["punctuation", ";"],
41+
["keyword", "QUIT"], ["punctuation", ";"],
42+
["keyword", "TryNextMethod"], ["punctuation", ";"],
43+
["keyword", "Unbind"], ["punctuation", ";"],
44+
["keyword", "and"], ["punctuation", ";"],
45+
["keyword", "atomic"], ["punctuation", ";"],
46+
["keyword", "break"], ["punctuation", ";"],
47+
["keyword", "continue"], ["punctuation", ";"],
48+
["keyword", "do"], ["punctuation", ";"],
49+
["keyword", "elif"], ["punctuation", ";"],
50+
["keyword", "else"], ["punctuation", ";"],
51+
["keyword", "end"], ["punctuation", ";"],
52+
["keyword", "fi"], ["punctuation", ";"],
53+
["keyword", "for"], ["punctuation", ";"],
54+
["keyword", "function"], ["punctuation", ";"],
55+
["keyword", "if"], ["punctuation", ";"],
56+
["keyword", "in"], ["punctuation", ";"],
57+
["keyword", "local"], ["punctuation", ";"],
58+
["keyword", "mod"], ["punctuation", ";"],
59+
["keyword", "not"], ["punctuation", ";"],
60+
["keyword", "od"], ["punctuation", ";"],
61+
["keyword", "or"], ["punctuation", ";"],
62+
["keyword", "quit"], ["punctuation", ";"],
63+
["keyword", "readonly"], ["punctuation", ";"],
64+
["keyword", "readwrite"], ["punctuation", ";"],
65+
["keyword", "rec"], ["punctuation", ";"],
66+
["keyword", "repeat"], ["punctuation", ";"],
67+
["keyword", "return"], ["punctuation", ";"],
68+
["keyword", "then"], ["punctuation", ";"],
69+
["keyword", "until"], ["punctuation", ";"],
70+
["keyword", "while"], ["punctuation", ";"]
71+
]
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
0
2+
123134523423423412345132123123432744839127384723987497
3+
+123123
4+
-245435
5+
6+
66/123
7+
66/-123
8+
9+
3.14
10+
6.62606896e-34
11+
.1
12+
.1e1
13+
-.999
14+
1._
15+
1._l
16+
17+
[1..100]
18+
19+
----------------------------------------------------
20+
21+
[
22+
["number", "0"],
23+
["number", "123134523423423412345132123123432744839127384723987497"],
24+
["operator", "+"], ["number", "123123"],
25+
["operator", "-"], ["number", "245435"],
26+
27+
["number", "66"], ["operator", "/"], ["number", "123"],
28+
["number", "66"], ["operator", "/"], ["operator", "-"], ["number", "123"],
29+
30+
["number", "3.14"],
31+
["number", "6.62606896e-34"],
32+
["number", ".1"],
33+
["number", ".1e1"],
34+
["operator", "-"], ["number", ".999"],
35+
["number", "1._"],
36+
["number", "1._l"],
37+
38+
["punctuation", "["],
39+
["number", "1"],
40+
["operator", ".."],
41+
["number", "100"],
42+
["punctuation", "]"]
43+
]
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
+ - * / ^ ~
2+
= <> < > <= >=
3+
:= .. ->
4+
5+
!. ![ !{
6+
7+
----------------------------------------------------
8+
9+
[
10+
["operator", "+"],
11+
["operator", "-"],
12+
["operator", "*"],
13+
["operator", "/"],
14+
["operator", "^"],
15+
["operator", "~"],
16+
17+
["operator", "="],
18+
["operator", "<>"],
19+
["operator", "<"],
20+
["operator", ">"],
21+
["operator", "<="],
22+
["operator", ">="],
23+
24+
["operator", ":="],
25+
["operator", ".."],
26+
["operator", "->"],
27+
28+
["operator", "!"],
29+
["punctuation", "."],
30+
["operator", "!"],
31+
["punctuation", "["],
32+
["operator", "!"],
33+
["punctuation", "{"]
34+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
( ) [ ] { }
2+
, ; . :
3+
4+
----------------------------------------------------
5+
6+
[
7+
["punctuation", "("],
8+
["punctuation", ")"],
9+
["punctuation", "["],
10+
["punctuation", "]"],
11+
["punctuation", "{"],
12+
["punctuation", "}"],
13+
14+
["punctuation", ","],
15+
["punctuation", ";"],
16+
["punctuation", "."],
17+
["punctuation", ":"]
18+
]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy