-
Notifications
You must be signed in to change notification settings - Fork 0
/
perl.js
164 lines (163 loc) · 5.06 KB
/
perl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
module.exports = function(hljs) {
var PERL_KEYWORDS = 'getpwent getservent quotemeta msgrcv scalar kill dbmclose undef lc ' +
'ma syswrite tr send umask sysopen shmwrite vec qx utime local oct semctl localtime ' +
'readpipe do return format read sprintf dbmopen pop getpgrp not getpwnam rewinddir qq' +
'fileno qw endprotoent wait sethostent bless s|0 opendir continue each sleep endgrent ' +
'shutdown dump chomp connect getsockname die socketpair close flock exists index shmget' +
'sub for endpwent redo lstat msgctl setpgrp abs exit select print ref gethostbyaddr ' +
'unshift fcntl syscall goto getnetbyaddr join gmtime symlink semget splice x|0 ' +
'getpeername recv log setsockopt cos last reverse gethostbyname getgrnam study formline ' +
'endhostent times chop length gethostent getnetent pack getprotoent getservbyname rand ' +
'mkdir pos chmod y|0 substr endnetent printf next open msgsnd readdir use unlink ' +
'getsockopt getpriority rindex wantarray hex system getservbyport endservent int chr ' +
'untie rmdir prototype tell listen fork shmread ucfirst setprotoent else sysseek link ' +
'getgrgid shmctl waitpid unpack getnetbyname reset chdir grep split require caller ' +
'lcfirst until warn while values shift telldir getpwuid my getprotobynumber delete and ' +
'sort uc defined srand accept package seekdir getprotobyname semop our rename seek if q|0 ' +
'chroot sysread setpwent no crypt getc chown sqrt write setnetent setpriority foreach ' +
'tie sin msgget map stat getlogin unless elsif truncate exec keys glob tied closedir' +
'ioctl socket readlink eval xor readline binmode setservent eof ord bind alarm pipe ' +
'atan2 getgrent exp time push setgrent gt lt or ne m|0 break given say state when';
var SUBST = {
className: 'subst',
begin: '[$@]\\{', end: '\\}',
keywords: PERL_KEYWORDS,
relevance: 10
};
var VAR1 = {
className: 'variable',
begin: '\\$\\d'
};
var VAR2 = {
className: 'variable',
begin: '[\\$\\%\\@\\*](\\^\\w\\b|#\\w+(\\:\\:\\w+)*|[^\\s\\w{]|{\\w+}|\\w+(\\:\\:\\w*)*)'
};
var STRING_CONTAINS = [hljs.BACKSLASH_ESCAPE, SUBST, VAR1, VAR2];
var METHOD = {
begin: '->',
contains: [
{begin: hljs.IDENT_RE},
{begin: '{', end: '}'}
]
};
var COMMENT = {
className: 'comment',
begin: '^(__END__|__DATA__)', end: '\\n$',
relevance: 5
}
var PERL_DEFAULT_CONTAINS = [
VAR1, VAR2,
hljs.HASH_COMMENT_MODE,
COMMENT,
{
className: 'comment',
begin: '^\\=\\w', end: '\\=cut', endsWithParent: true
},
METHOD,
{
className: 'string',
begin: 'q[qwxr]?\\s*\\(', end: '\\)',
contains: STRING_CONTAINS,
relevance: 5
},
{
className: 'string',
begin: 'q[qwxr]?\\s*\\[', end: '\\]',
contains: STRING_CONTAINS,
relevance: 5
},
{
className: 'string',
begin: 'q[qwxr]?\\s*\\{', end: '\\}',
contains: STRING_CONTAINS,
relevance: 5
},
{
className: 'string',
begin: 'q[qwxr]?\\s*\\|', end: '\\|',
contains: STRING_CONTAINS,
relevance: 5
},
{
className: 'string',
begin: 'q[qwxr]?\\s*\\<', end: '\\>',
contains: STRING_CONTAINS,
relevance: 5
},
{
className: 'string',
begin: 'qw\\s+q', end: 'q',
contains: STRING_CONTAINS,
relevance: 5
},
{
className: 'string',
begin: '\'', end: '\'',
contains: [hljs.BACKSLASH_ESCAPE],
relevance: 0
},
{
className: 'string',
begin: '"', end: '"',
contains: STRING_CONTAINS,
relevance: 0
},
{
className: 'string',
begin: '`', end: '`',
contains: [hljs.BACKSLASH_ESCAPE]
},
{
className: 'string',
begin: '{\\w+}',
relevance: 0
},
{
className: 'string',
begin: '\-?\\w+\\s*\\=\\>',
relevance: 0
},
{
className: 'number',
begin: '(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b',
relevance: 0
},
{ // regexp container
begin: '(' + hljs.RE_STARTERS_RE + '|\\b(split|return|print|reverse|grep)\\b)\\s*',
keywords: 'split return print reverse grep',
relevance: 0,
contains: [
hljs.HASH_COMMENT_MODE,
COMMENT,
{
className: 'regexp',
begin: '(s|tr|y)/(\\\\.|[^/])*/(\\\\.|[^/])*/[a-z]*',
relevance: 10
},
{
className: 'regexp',
begin: '(m|qr)?/', end: '/[a-z]*',
contains: [hljs.BACKSLASH_ESCAPE],
relevance: 0 // allows empty "//" which is a common comment delimiter in other languages
}
]
},
{
className: 'sub',
beginWithKeyword: true, end: '(\\s*\\(.*?\\))?[;{]',
keywords: 'sub',
relevance: 5
},
{
className: 'operator',
begin: '-\\w\\b',
relevance: 0
}
];
SUBST.contains = PERL_DEFAULT_CONTAINS;
METHOD.contains[1].contains = PERL_DEFAULT_CONTAINS;
return {
keywords: PERL_KEYWORDS,
contains: PERL_DEFAULT_CONTAINS
};
};