source: node_modules/refractor/lang/parigp.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1.6 KB
Line 
1'use strict'
2
3module.exports = parigp
4parigp.displayName = 'parigp'
5parigp.aliases = []
6function parigp(Prism) {
7 Prism.languages.parigp = {
8 comment: /\/\*[\s\S]*?\*\/|\\\\.*/,
9 string: {
10 pattern: /"(?:[^"\\\r\n]|\\.)*"/,
11 greedy: true
12 },
13 // PARI/GP does not care about white spaces at all
14 // so let's process the keywords to build an appropriate regexp
15 // (e.g. "b *r *e *a *k", etc.)
16 keyword: (function () {
17 var keywords = [
18 'breakpoint',
19 'break',
20 'dbg_down',
21 'dbg_err',
22 'dbg_up',
23 'dbg_x',
24 'forcomposite',
25 'fordiv',
26 'forell',
27 'forpart',
28 'forprime',
29 'forstep',
30 'forsubgroup',
31 'forvec',
32 'for',
33 'iferr',
34 'if',
35 'local',
36 'my',
37 'next',
38 'return',
39 'until',
40 'while'
41 ]
42 keywords = keywords
43 .map(function (keyword) {
44 return keyword.split('').join(' *')
45 })
46 .join('|')
47 return RegExp('\\b(?:' + keywords + ')\\b')
48 })(),
49 function: /\b\w(?:[\w ]*\w)?(?= *\()/,
50 number: {
51 // The lookbehind and the negative lookahead prevent from breaking the .. operator
52 pattern:
53 /((?:\. *\. *)?)(?:\b\d(?: *\d)*(?: *(?!\. *\.)\.(?: *\d)*)?|\. *\d(?: *\d)*)(?: *e *(?:[+-] *)?\d(?: *\d)*)?/i,
54 lookbehind: true
55 },
56 operator:
57 /\. *\.|[*\/!](?: *=)?|%(?: *=|(?: *#)?(?: *')*)?|\+(?: *[+=])?|-(?: *[-=>])?|<(?: *>|(?: *<)?(?: *=)?)?|>(?: *>)?(?: *=)?|=(?: *=){0,2}|\\(?: *\/)?(?: *=)?|&(?: *&)?|\| *\||['#~^]/,
58 punctuation: /[\[\]{}().,:;|]/
59 }
60}
Note: See TracBrowser for help on using the repository browser.