Blame view

bower_components/prism/components/prism-perl.js 3.83 KB
73bcce88   luigser   COMPONENTS
1
2
3
4
  Prism.languages.perl = {
  	'comment': [
  		{
  			// POD
eb240478   Luigi Serra   public room cards...
5
  			pattern: /(^\s*)=\w+[\s\S]*?=cut.*/m,
73bcce88   luigser   COMPONENTS
6
7
8
  			lookbehind: true
  		},
  		{
eb240478   Luigi Serra   public room cards...
9
  			pattern: /(^|[^\\$])#.*/,
73bcce88   luigser   COMPONENTS
10
11
12
13
14
15
  			lookbehind: true
  		}
  	],
  	// TODO Could be nice to handle Heredoc too.
  	'string': [
  		// q/.../
eb240478   Luigi Serra   public room cards...
16
  		/\b(?:q|qq|qx|qw)\s*([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1/,
73bcce88   luigser   COMPONENTS
17
18
  	
  		// q a...a
eb240478   Luigi Serra   public room cards...
19
  		/\b(?:q|qq|qx|qw)\s+([a-zA-Z0-9])(?:[^\\]|\\[\s\S])*?\1/,
73bcce88   luigser   COMPONENTS
20
21
  	
  		// q(...)
eb240478   Luigi Serra   public room cards...
22
  		/\b(?:q|qq|qx|qw)\s*\((?:[^()\\]|\\[\s\S])*\)/,
73bcce88   luigser   COMPONENTS
23
24
  	
  		// q{...}
eb240478   Luigi Serra   public room cards...
25
  		/\b(?:q|qq|qx|qw)\s*\{(?:[^{}\\]|\\[\s\S])*\}/,
73bcce88   luigser   COMPONENTS
26
27
  	
  		// q[...]
eb240478   Luigi Serra   public room cards...
28
  		/\b(?:q|qq|qx|qw)\s*\[(?:[^[\]\\]|\\[\s\S])*\]/,
73bcce88   luigser   COMPONENTS
29
30
  	
  		// q<...>
eb240478   Luigi Serra   public room cards...
31
  		/\b(?:q|qq|qx|qw)\s*<(?:[^<>\\]|\\[\s\S])*>/,
73bcce88   luigser   COMPONENTS
32
  
eb240478   Luigi Serra   public room cards...
33
34
35
36
37
38
  		// "...", `...`
  		/("|`)(?:[^\\]|\\[\s\S])*?\1/,
  
  		// '...'
  		// FIXME Multi-line single-quoted strings are not supported as they would break variables containing '
  		/'(?:[^'\\\r\n]|\\.)*'/
73bcce88   luigser   COMPONENTS
39
40
41
  	],
  	'regex': [
  		// m/.../
eb240478   Luigi Serra   public room cards...
42
  		/\b(?:m|qr)\s*([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1[msixpodualngc]*/,
73bcce88   luigser   COMPONENTS
43
44
  	
  		// m a...a
eb240478   Luigi Serra   public room cards...
45
  		/\b(?:m|qr)\s+([a-zA-Z0-9])(?:[^\\]|\\.)*?\1[msixpodualngc]*/,
73bcce88   luigser   COMPONENTS
46
47
  	
  		// m(...)
eb240478   Luigi Serra   public room cards...
48
  		/\b(?:m|qr)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngc]*/,
73bcce88   luigser   COMPONENTS
49
50
  	
  		// m{...}
eb240478   Luigi Serra   public room cards...
51
  		/\b(?:m|qr)\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngc]*/,
73bcce88   luigser   COMPONENTS
52
53
  	
  		// m[...]
eb240478   Luigi Serra   public room cards...
54
  		/\b(?:m|qr)\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngc]*/,
73bcce88   luigser   COMPONENTS
55
56
  	
  		// m<...>
eb240478   Luigi Serra   public room cards...
57
58
59
60
  		/\b(?:m|qr)\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngc]*/,
  
  		// The lookbehinds prevent -s from breaking
  		// FIXME We don't handle change of separator like s(...)[...]
73bcce88   luigser   COMPONENTS
61
  		// s/.../.../
eb240478   Luigi Serra   public room cards...
62
63
64
65
  		{
  			pattern: /(^|[^-]\b)(?:s|tr|y)\s*([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\2(?:[^\\]|\\[\s\S])*?\2[msixpodualngcer]*/,
  			lookbehind: true
  		},
73bcce88   luigser   COMPONENTS
66
67
  	
  		// s a...a...a
eb240478   Luigi Serra   public room cards...
68
69
70
71
  		{
  			pattern: /(^|[^-]\b)(?:s|tr|y)\s+([a-zA-Z0-9])(?:[^\\]|\\[\s\S])*?\2(?:[^\\]|\\[\s\S])*?\2[msixpodualngcer]*/,
  			lookbehind: true
  		},
73bcce88   luigser   COMPONENTS
72
73
  	
  		// s(...)(...)
eb240478   Luigi Serra   public room cards...
74
75
76
77
  		{
  			pattern: /(^|[^-]\b)(?:s|tr|y)\s*\((?:[^()\\]|\\[\s\S])*\)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngcer]*/,
  			lookbehind: true
  		},
73bcce88   luigser   COMPONENTS
78
79
  	
  		// s{...}{...}
eb240478   Luigi Serra   public room cards...
80
81
82
83
  		{
  			pattern: /(^|[^-]\b)(?:s|tr|y)\s*\{(?:[^{}\\]|\\[\s\S])*\}\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngcer]*/,
  			lookbehind: true
  		},
73bcce88   luigser   COMPONENTS
84
85
  	
  		// s[...][...]
eb240478   Luigi Serra   public room cards...
86
87
88
89
  		{
  			pattern: /(^|[^-]\b)(?:s|tr|y)\s*\[(?:[^[\]\\]|\\[\s\S])*\]\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngcer]*/,
  			lookbehind: true
  		},
73bcce88   luigser   COMPONENTS
90
91
  	
  		// s<...><...>
eb240478   Luigi Serra   public room cards...
92
93
94
95
  		{
  			pattern: /(^|[^-]\b)(?:s|tr|y)\s*<(?:[^<>\\]|\\[\s\S])*>\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngcer]*/,
  			lookbehind: true
  		},
73bcce88   luigser   COMPONENTS
96
97
  	
  		// /.../
eb240478   Luigi Serra   public room cards...
98
99
100
101
  		// The look-ahead tries to prevent two divisions on
  		// the same line from being highlighted as regex.
  		// This does not support multi-line regex.
  		/\/(?:[^\/\\\r\n]|\\.)*\/[msixpodualngc]*(?=\s*(?:$|[\r\n,.;})&|\-+*~<>!?^]|(lt|gt|le|ge|eq|ne|cmp|not|and|or|xor|x)\b))/
73bcce88   luigser   COMPONENTS
102
103
104
105
106
  	],
  
  	// FIXME Not sure about the handling of ::, ', and #
  	'variable': [
  		// ${^POSTMATCH}
eb240478   Luigi Serra   public room cards...
107
  		/[&*$@%]\{\^[A-Z]+\}/,
73bcce88   luigser   COMPONENTS
108
  		// $^V
eb240478   Luigi Serra   public room cards...
109
  		/[&*$@%]\^[A-Z_]/,
73bcce88   luigser   COMPONENTS
110
  		// ${...}
eb240478   Luigi Serra   public room cards...
111
  		/[&*$@%]#?(?=\{)/,
73bcce88   luigser   COMPONENTS
112
  		// $foo
eb240478   Luigi Serra   public room cards...
113
  		/[&*$@%]#?((::)*'?(?!\d)[\w$]+)+(::)*/i,
73bcce88   luigser   COMPONENTS
114
  		// $1
eb240478   Luigi Serra   public room cards...
115
  		/[&*$@%]\d+/,
73bcce88   luigser   COMPONENTS
116
  		// $_, @_, %!
eb240478   Luigi Serra   public room cards...
117
118
  		// The negative lookahead prevents from breaking the %= operator
  		/(?!%=)[$@%][!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~]/
73bcce88   luigser   COMPONENTS
119
120
121
  	],
  	'filehandle': {
  		// <>, <FOO>, _
eb240478   Luigi Serra   public room cards...
122
  		pattern: /<(?![<=])\S*>|\b_\b/,
73bcce88   luigser   COMPONENTS
123
124
125
126
127
128
129
130
131
132
133
134
135
136
  		alias: 'symbol'
  	},
  	'vstring': {
  		// v1.2, 1.2.3
  		pattern: /v\d+(\.\d+)*|\d+(\.\d+){2,}/,
  		alias: 'string'
  	},
  	'function': {
  		pattern: /sub [a-z0-9_]+/i,
  		inside: {
  			keyword: /sub/
  		}
  	},
  	'keyword': /\b(any|break|continue|default|delete|die|do|else|elsif|eval|for|foreach|given|goto|if|last|local|my|next|our|package|print|redo|require|say|state|sub|switch|undef|unless|until|use|when|while)\b/,
eb240478   Luigi Serra   public room cards...
137
138
  	'number': /\b-?(0x[\dA-Fa-f](_?[\dA-Fa-f])*|0b[01](_?[01])*|(\d(_?\d)*)?\.?\d(_?\d)*([Ee][+-]?\d+)?)\b/,
  	'operator': /-[rwxoRWXOezsfdlpSbctugkTBMAC]\b|\+[+=]?|-[-=>]?|\*\*?=?|\/\/?=?|=[=~>]?|~[~=]?|\|\|?=?|&&?=?|<(?:=>?|<=?)?|>>?=?|![~=]?|[%^]=?|\.(?:=|\.\.?)?|[\\?]|\bx(?:=|\b)|\b(lt|gt|le|ge|eq|ne|cmp|not|and|or|xor)\b/,
73bcce88   luigser   COMPONENTS
139
140
  	'punctuation': /[{}[\];(),:]/
  };