File: perl.jsf

package info (click to toggle)
joe 4.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,308 kB
  • sloc: ansic: 51,623; sh: 4,358; makefile: 149; csh: 26
file content (487 lines) | stat: -rw-r--r-- 7,797 bytes parent folder | download | duplicates (3)
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
# JOE syntax highlight file for Perl

# Define colors

=Idle
=Ident
=Comment
=Pod		+Preproc
=Variable	+DefinedIdent # TODO: Make this work.
=Constant
=Number		+Constant
=String		+Constant
=StringEscape	+Escape
=StringVariable	+StringEscape
=Regex		+String
=RegexEscape	+StringEscape
=Type
=Keyword
=Statement	+Keyword
=Loop		+Statement
=Conditional	+Statement
=Structure	+Statement
=Bad

:begin Idle
	*		begin noeat call=.perl()

#
# Perl as a subroutine for Mason
#

.subr perl

# Detect pod

:idle Idle
	*		idle1		noeat
.ifdef mason_line
	"\n"		idle return
.else
	"\n"		idle
.endif
	"="		pod_start

# allow keywords

:idle1 Idle
	*		idle1
	"#"		line_comment_i	recolor=-1
	"\n"		idle noeat
	"0"		first_digit	recolor=-1
	"1-9"		decimal	recolor=-1
	"."		maybe_float
	"\""		string		recolor=-1
	"'"		char		recolor=-1
	"`"		backtick	recolor=-1
	"<"		maybe_inc
	"$"		not_string	buffer recolor=-1
.ifdef mason_block
	"&%"		perl_maybe_done	buffer
	"-@\i"		ident		buffer recolor=-1
.else
	"/"		regex		recolor=-1
	"-\i@%&"	ident		buffer recolor=-1
.endif

:perl_maybe_done Idle
	*		ident noeat
	">"		idle1	recolor=-2 return

# prevent keywords

:rest Idle
	*		rest
	"({;~"		idle1
	"#"		line_comment	recolor=-1
	"\n"		idle noeat
	"0"		first_digit	recolor=-1
	"1-9"		decimal	recolor=-1
	"."		maybe_float
	"\""		string		recolor=-1
	"'"		char		recolor=-1
	"`"		backtick	recolor=-1
	"$"		not_string	buffer recolor=-1
	"<"		maybe_inc
.ifdef mason_block
	"&%"		perl_maybe_done buffer recolor=-1
	"\i@"		maybe_string	buffer
.else
	"\i@%&"		maybe_string	buffer
.endif

:pod_start Idle
	*		pod_start
	"\n"		pod_block

:pod_block Pod
	*		pod_block
	"="		pod_ident	buffer

:pod_ident Pod
	*		pod_block	noeat strings
	"=cut"		rest
done
	"\c"		pod_ident

:maybe_inc Idle
	*		rest		noeat
.ifdef mason_block
	"/"		perl_maybe_done_2
.endif
	"<"		maybe_inc1

:perl_maybe_done_2 Idle
	*		perl_idle	noeat
	"a-z"		perl_maybe_done_2
	">"		idle


:maybe_inc1 Idle
	*		rest		noeat
	" 	"	maybe_inc1
	"'\""		quoted_inc_start	save_c recolor=-1
	"\i"		inc		buffer noeat

:quoted_inc_start Variable
	*		quoted_inc	buffer

:quoted_inc Variable
	*		quoted_inc
	&		skipline	save_s

:inc Variable
	*		skipline	save_s noeat
	"\c"		inc

# Should be treated as a normal line here...

:skipline Idle
	*		skipline
	"\n"		next_line

:todelim String string
	*		todelim
	"\n"		next_line	strings
	"&"		founddelim
done

# eat \n so it's not in string.
:next_line String string
	*		todelim		buffer
	"\n"		next_line

:founddelim Variable
	*		idle		noeat

:regex Regex
	*		regex
	"\\"		regex_quote	recolor=-1
	"/"		rest

:regex_quote RegexEscape
	*		regex

:not_string Idle
	*		rest noeat
	"\i"		ident
	"\"'`#"		rest

:line_comment Comment comment
	*		line_comment
	"BFHNTX"	line_comment	noeat call=comment_todo.comment_todo()
	"\n"		rest

:line_comment_i Comment comment
	*		line_comment_i
	"BFHNTX"	line_comment_i	noeat call=comment_todo.comment_todo()
	"\n"		idle noeat

:end_of_file_comment Comment comment
	"BFHNTX"	end_of_file_comment	noeat call=comment_todo.comment_todo()
	*		end_of_file_comment

:first_digit Number
	*		rest	noeat
	"x"		hex
	"b"		binary
	"."		float
	"eE"		epart
	"0-7"		octal
	"89"		bad_number	recolor=-1

:bad_number Bad
	*		rest	noeat
	"0-9"		bad_number

:octal Number
	*		rest	noeat
	"0-7_"		octal
	"89"		bad_number	recolor=-1

:binary Number
	*		rest	noeat
	"01_"		binary
	"2-9"		bad_number	recolor=-1

:hex Number
	*		rest	noeat
	"0-9A-Fa-f_"	hex

:decimal Number
	*		rest	noeat
	"0-9_"		decimal
	"eE"		epart
	"."		float

:maybe_float Number
	*		rest	recolor=-2	noeat
	"0-9"		float		recolor=-2

:float Number
	*		rest	noeat
	"eE"		epart
	"0-9_"		float

:epart Number
	*		rest	noeat
	"0-9+\-"	enum

:enum Number
	*		rest	noeat
	"0-9_"		enum

:string	String string
	*		string
	"\""		rest
	"\\"		string_escape	recolor=-1
	"$@"		string_subst	recolor=-1

:string_subst StringVariable string
	*		string	noeat recolor=-1
	"\c"		string_subst

:string_escape StringEscape string
	*		string
	"x"		string_hex1
	"c"		string_ctrl
	"N"		string_named
	"0-7"		string_octal2
	"\n"		string		recolor=-2

:string_named StringEscape string
	*		string
	"{"		string_named_rest

:string_named_rest StringEscape string
	*		string_named_rest
	"}"		string

:string_ctrl StringEscape string
	*		string

:string_hex1 StringEscape string
	*		string		noeat
	"{"		string_unicode
	"0-9a-fA-F"	string_hex2

:string_unicode StringEscape string
	*		string_unicode
	"}"		string

:string_hex2 StringEscape string
	*		string		noeat
	"0-9a-fA-F"	string

:string_octal2 StringEscape string
	*		string		noeat
	"0-7"		string_octal3

:string_octal3 StringEscape string
	*		string		noeat
	"0-7"		string

:char String string
	*		char
	"\n"		idle noeat
	"'"		rest
	"\\"		char_escape	recolor=-1

:char_escape	StringEscape string
	*		char		recolor=-2
	"\\'"		char

:backtick	String string
	*		backtick
	"`"		rest
	"\\"		backtick_escape	recolor=-1
	"$@"		backtick_subst recolor=-1

:backtick_subst StringVariable string
	*		backtick	noeat recolor=-1
	"\c"		backtick_subst

:backtick_escape StringEscape string
	*		backtick
	"x"		backtick_hex1
	"c"		backtick_ctrl
	"N"		backtick_named
	"0-7"		backtick_octal2
	"\n"		backtick		recolor=-2

:backtick_named StringEscape string
	*		backtick
	"{"		backtick_named_rest

:backtick_named_rest StringEscape string
	*		backtick_named_rest
	"}"		backtick

:backtick_ctrl StringEscape string
	*		backtick

:backtick_hex1 StringEscape string
	*		backtick		noeat
	"{"		backtick_unicode
	"0-9a-fA-F"	backtick_hex2

:backtick_unicode StringEscape string
	*		backtick_unicode
	"}"		backtick

:backtick_hex2 StringEscape string
	*		backtick		noeat
	"0-9a-fA-F"	backtick

:backtick_octal2 StringEscape string
	*		backtick		noeat
	"0-7"		backtick_octal3

:backtick_octal3 StringEscape string
	*		backtick		noeat
	"0-7"		backtick

# TODO: Tease out the variable logic from this so that we can highlight
# variables separate from other identifiers.

:ident Ident
	*		rest		noeat strings
	"BEGIN"		kw
	"END"		kw
	"if"		cond
	"unless"	cond
	"while"		loop
	"until"		loop
	"foreach"	loop
	"sub"		struct
	"my"		kw
	"do"		loop
	"if"		cond
	"else"		cond
	"elsif"		cond
	"for"		loop
	"continue"	loop
	"last"		loop
	"print"		stmt
	"reset"		kw
	"die"		stmt
	"goto"		stmt
	"require"	stmt
	"use"		kw
	"eval"		kw
	"redo"		kw
	"next"		loop
	"warn"		stmt
	"return"	stmt
	"printf"	stmt
	"close"		stmt
	"package"	kw
	"m"		match
	"qr"		match
	"qq"		match
	"qx"		match
	"qw"		match
	"q"		match
	"s"		subst
	"tr"		subst
	"y"		subst
	"__END__"	end_of_file_comment
	"__DATA__"	end_of_file_comment
done
	"\c"		ident

:maybe_string Idle
	*		rest		noeat strings
	"qr"		match
	"qq"		match
	"qx"		match
	"qw"		match
	"q"		match
done
	"\c"		maybe_string

:type Type
	*		rest	noeat

:kw Keyword
	*		rest	noeat

:cond Conditional
	*		rest	noeat

:loop Loop
	*		rest	noeat

:struct Structure
	*		rest	noeat

:stmt Statement
	*		rest	noeat

:match Idle
	*		inmatch		save_c recolor=-1
	" 	"	match

:inmatch Regex
	*		inmatch
	%		inmatch		call=.inmatch()
	&		rest
	"\\"		inmatch_quote	recolor=-1

:inmatch_quote RegexEscape
	*		inmatch

:subst Idle
	*		insubst		save_c recolor=-1
	"<([{`"		delim_insubst	save_c recolor=-1
	" 	"	subst

:insubst Regex
	*		insubst
	&		inrepl
	"\\"		insubst_quote	recolor=-1

:insubst_quote RegexEscape
	*		insubst

:inrepl Regex
	*		inrepl
	&		rest
	"\\"		inrepl_quote

:inrepl_quote RegexEscape
	*		inrepl

:delim_insubst Regex
	*		delim_insubst
	&		delim_repl
	"\\"		delim_quote

:delim_quote RegexEscape
	*		delim_insubst

:delim_repl Regex
	*		repl		save_c recolor=-1
	" 	"	delim_repl

:repl Regex
	*		repl
	&		rest
	"\\"		repl_quote

:repl_quote RegexEscape
	*		repl

.end

.subr inmatch

:inmatch Regex
	*		inmatch
	%		inmatch		call=.inmatch()
	&		inmatch		return
	"\\"		inmatch_quote	recolor=-1

:inmatch_quote RegexEscape
	*		inmatch
.end