-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #802 from Golmote/prism-parigp
Add support for PARI/GP
- Loading branch information
Showing
12 changed files
with
408 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Prism.languages.parigp = { | ||
'comment': /\/\*[\s\S]*?\*\/|\\\\.*/, | ||
'string': /"(?:[^"\\]|\\.)*"/, | ||
// PARI/GP does not care about white spaces at all | ||
// so let's process the keywords to build an appropriate regexp | ||
// (e.g. "b *r *e *a *k", etc.) | ||
'keyword': (function () { | ||
var keywords = [ | ||
'breakpoint', 'break', 'dbg_down', 'dbg_err', 'dbg_up', 'dbg_x', | ||
'forcomposite', 'fordiv', 'forell', 'forpart', 'forprime', | ||
'forstep', 'forsubgroup', 'forvec', 'for', 'iferr', 'if', | ||
'local', 'my', 'next', 'return', 'until', 'while' | ||
]; | ||
keywords = keywords.map(function (keyword) { | ||
return keyword.split('').join(' *'); | ||
}).join('|'); | ||
return RegExp('\\b(?:' + keywords + ')\\b'); | ||
}()), | ||
'function': /\w[\w ]*?(?= *\()/, | ||
'number': { | ||
// The lookbehind and the negative lookahead prevent from breaking the .. operator | ||
pattern: /((?:\. *\. *)?)(?:\d(?: *\d)*(?: *(?!\. *\.)\.(?: *\d)*)?|\. *\d(?: *\d)*)(?: *e *[+-]? *\d(?: *\d)*)?/i, | ||
lookbehind: true | ||
}, | ||
'operator': /\. *\.|[*\/!](?: *=)?|%(?: *=|(?: *#)?(?: *')*)?|\+(?: *[+=])?|-(?: *[-=>])?|<(?:(?: *<)?(?: *=)?| *>)?|>(?: *>)?(?: *=)?|=(?: *=){0,2}|\\(?: *\/)?(?: *=)?|&(?: *&)?|\| *\||['#~^]/, | ||
'punctuation': /[\[\]{}().,:;|]/ | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<h1>PARI/GP</h1> | ||
<p>To use this language, use the class "language-parigp".</p> | ||
|
||
<h2>Comments</h2> | ||
<pre><code>\\ Single line comment | ||
/* Multi line | ||
comment */</code></pre> | ||
|
||
<h2>Strings</h2> | ||
<pre><code>"" | ||
"Foo \"bar\" baz"</code></pre> | ||
|
||
<h2>Numbers</h2> | ||
<pre><code>0. | ||
42 | ||
3 . 14 15 9 | ||
5.2 E +12 | ||
.89</code></pre> | ||
|
||
<h2>Ignored whitespaces</h2> | ||
<pre><code>p r i n t ("hello") | ||
if err(1/i, E, print (E)) | ||
a + = b \ / c</code></pre> | ||
|
||
<h2>Known failures</h2> | ||
<p>There are certain edge cases where Prism will fail. | ||
There are always such cases in every regex-based syntax highlighter. | ||
However, Prism dares to be open and honest about them. | ||
If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug. | ||
</p> | ||
|
||
<h3>Comment-like substrings</h3> | ||
<pre><code>"foo /* baz */" "foo \\ baz"</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/**/ | ||
/* foo | ||
bar */ | ||
\\ | ||
\\ foobar | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", "/**/"], | ||
["comment", "/* foo\r\nbar */"], | ||
["comment", "\\\\"], | ||
["comment", "\\\\ foobar"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for comments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
foo() | ||
f o o b a r ( ) | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["function", "foo"], ["punctuation", "("], ["punctuation", ")"], | ||
["function", "f o o b a r"], ["punctuation", "("], ["punctuation", ")"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for functions. Also checks that whitespaces are ignored. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
break | ||
breakpoint | ||
dbg_down | ||
dbg_err | ||
dbg_up | ||
dbg_x | ||
for | ||
forcomposite | ||
fordiv | ||
forell | ||
forpart | ||
forprime | ||
forstep | ||
forsubgroup | ||
forvec | ||
if | ||
iferr | ||
local | ||
my | ||
next | ||
return | ||
until | ||
while | ||
|
||
br e ak | ||
break point | ||
d b g_down | ||
dbg_e r r | ||
dbg _ up | ||
db g _x | ||
f o r | ||
for composite | ||
for div | ||
for ell | ||
for part | ||
for prime | ||
for step | ||
for subgroup | ||
for vec | ||
i f | ||
if err | ||
l o c a l | ||
m y | ||
ne xt | ||
re tu rn | ||
u nti l | ||
whi le | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", "break"], | ||
["keyword", "breakpoint"], | ||
["keyword", "dbg_down"], | ||
["keyword", "dbg_err"], | ||
["keyword", "dbg_up"], | ||
["keyword", "dbg_x"], | ||
["keyword", "for"], | ||
["keyword", "forcomposite"], | ||
["keyword", "fordiv"], | ||
["keyword", "forell"], | ||
["keyword", "forpart"], | ||
["keyword", "forprime"], | ||
["keyword", "forstep"], | ||
["keyword", "forsubgroup"], | ||
["keyword", "forvec"], | ||
["keyword", "if"], | ||
["keyword", "iferr"], | ||
["keyword", "local"], | ||
["keyword", "my"], | ||
["keyword", "next"], | ||
["keyword", "return"], | ||
["keyword", "until"], | ||
["keyword", "while"], | ||
|
||
["keyword", "br e ak"], | ||
["keyword", "break point"], | ||
["keyword", "d b g_down"], | ||
["keyword", "dbg_e r r"], | ||
["keyword", "dbg _ up"], | ||
["keyword", "db g _x"], | ||
["keyword", "f o r"], | ||
["keyword", "for composite"], | ||
["keyword", "for div"], | ||
["keyword", "for ell"], | ||
["keyword", "for part"], | ||
["keyword", "for prime"], | ||
["keyword", "for step"], | ||
["keyword", "for subgroup"], | ||
["keyword", "for vec"], | ||
["keyword", "i f"], | ||
["keyword", "if err"], | ||
["keyword", "l o c a l"], | ||
["keyword", "m y"], | ||
["keyword", "ne xt"], | ||
["keyword", "re tu rn"], | ||
["keyword", "u nti l"], | ||
["keyword", "whi le"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for all keywords. Also checks that whitespaces are ignored. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
0 | ||
42 | ||
1 2 3 4 5 | ||
4. | ||
4 . | ||
.5 | ||
. 5 | ||
3.14159 | ||
3 . 14 15 9 | ||
3E8 | ||
3 E 8 | ||
2.0e-7 | ||
2 . 0 e - 7 | ||
.28e+12 | ||
. 2 8 e + 1 2 | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["number", "0"], | ||
["number", "42"], | ||
["number", "1 2 3 4 5"], | ||
["number", "4."], | ||
["number", "4 ."], | ||
["number", ".5"], | ||
["number", ". 5"], | ||
["number", "3.14159"], | ||
["number", "3 . 14 15 9"], | ||
["number", "3E8"], | ||
["number", "3 E 8"], | ||
["number", "2.0e-7"], | ||
["number", "2 . 0 e - 7"], | ||
["number", ".28e+12"], | ||
["number", ". 2 8 e + 1 2"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for numbers. Also checks that whitespaces are ignored. |
Oops, something went wrong.