1# perl.ssh --- Sheet definitions for Perl files
2# Copyright (c) 1988-1993 Miguel Santana
3# Copyright (c) 1995-2000 Akim Demaille, Miguel Santana, Denis Girou
4#
5
6#
7# This file is part of a2ps.
8#
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation; either version 2, or (at your option)
12# any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program; see the file COPYING.  If not, write to
21# the Free Software Foundation, 59 Temple Place - Suite 330,
22# Boston, MA 02111-1307, USA.
23
24## TODO
25# Finer grained sub, require etc. handling (regexps?)
26# Make the difference between a proto and a def
27# Generic s/// handling?
28
29style Perl is
30
31written by "Denis Girou <Denis.Girou@idris.fr>"
32version is 2.11
33requires a2ps version 4.13
34
35documentation is
36   "As most interpreted languages, Perl is very free on its syntax, what"
37   "leads to significant problems for a pretty printer.  Please, be kind"
38   "with our try.  Any improvement is most welcome."
39end documentation
40
41first alphabet is
42   "$@ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_"
43second alphabet is
44   "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_"
45case sensitive
46
47keywords in Keyword_strong are
48    if, BEGIN, CORE, END, __FILE__, __LINE__, abs, accept, alarm, and,
49    atan, atan2, bind, binmode, bless, caller, chdir, chmod, chop,
50    chown, chr, chroot, close, closedir, cmp, connect, continue, cos,
51    crypt, dbmclose, dbmopen, defined, delete, die, do, dump, each,
52    else, elsif, endgrent, endhostent, endnetent, endprotoent,
53    endpwent, endservent, eof, eq, eval, exec, exit, exp, fcntl,
54    fileno, flock, for, foreach, fork, formline, ge, getc, getgrent,
55    getgrgid, getgrnam, gethostbyaddr, gethostbyname, gethostent,
56    getlogin, getnetbyaddr, getnetbyname, getnetent, getpeername,
57    getpgrp, getppid, getpriority, getprotobyname, getprotobynumber,
58    getprotoent, getpwent, getpwnam, getpwuid, getservbyname,
59    getservbyport, getservent, getsockname, getsockopt, glob, gmtime,
60    goto, grep, gt, hex, index, int, ioctl, join, keys, kill, last,
61    lc, lcfirst, le, length, link, listen, local, localtime, log,
62    lstat, lt, mkdir, msgctl, msgget, msgrcv, msgsnd, my, ne, next,
63    not, oct, open, opendir, or, ord, pack, package, pipe, pop, print,
64    printf, push, q, qq, quotemeta, qw, rand, read, readdir, readline,
65    readlink, readpipe, recv, redo, ref, rename, require, reset,
66    return, reverse, rewinddir, rindex, rmdir, seek, seekdir, select,
67    semctl, semget, semop, send, setgrent, sethostent, setnetent,
68    setpgrp, setpriority, setprotoent, setpwent, setservent,
69    setsockopt, shift, shmctl, shmget, shmread, shmwrite, shutdown,
70    sin, sleep, socket, socketpair, sort, split, sprintf, sqrt, srand,
71    stat, study, sub, substr, symlink, syscall, sysread, system,
72    syswrite, tell, telldir, time, times, truncate, uc, ucfirst,
73    umask, undef, unless, unlink, unpack, unshift, until, use, utime,
74    values, vec, wait, waitpid, wantarray, warn, while, write, x, xor
75end keywords
76
77# Since regex cannot be spread upon several lines, they are
78# handled thanks to operators, not sequences.
79operators are
80    # I'd be damned.  $' is not starting a string :(
81    "$'" Plain,
82    # and $# does not start a comment.
83    "$#" Plain,
84    # There can be quoted characters in the test.
85    /\\\\./ Plain,
86
87    # Functions calls
88    /(&[[:alnum:]_]+)/ Label,
89
90    # Regular expressions: chars not (`/' and '\') or `\.' between `/'.
91    /\/([^\\\/]|\\\\.)*\// Plain,
92
93    # Matching:
94    # One regexp with a single char as delimiter
95    (/(m)/			# 1. The command: `m'
96     /([[:punct:]])/		# 2. The delimiter
97     /(/             		# 3. The regexp
98     /(.|\\\\.)*/
99     /)/
100     /\\2/			# Closer
101     \1 Keyword_strong, \2 Plain, \3 Plain, \2 Plain),
102
103
104    # Substitution and transliteration:
105    # two regexps with a single char as delimiter
106    (/(s|tr)/			# 1. The command: `tr' or `s'
107     /(([[:punct:]])/		# 2. The delimiter
108     /(/			# 3. The *two* regexps
109     /(.|\\\\.)*/		#   First regexp
110     /\\3/			#   Separator
111     /(.|\\\\.)*/		#   Second Regexp
112     /)/			#
113     /\\3)/			# Closer
114     \1 Keyword_strong, \2 Plain),
115
116    # Substitution and transliteration:
117    # two regexps with ()() as delimiter
118    (/(s|tr)/			# The command: `tr' or `s'
119     /(\\(/			# The delimiter
120     /([^)]|\\\\.)*/		# First part
121     /\\)[^(]*\\(/		# The separation
122     /([^)]|\\\\.)*/		# Second part
123     /\\))/			# Closer
124     \1 Keyword_strong, \2 Plain),
125
126    # Substitution and transliteration:
127    # two regexps with {}{} as delimiter
128    (/(s|tr)/			# The command: `tr' or `s'
129     /(\\{/			# The delimiter
130     /([^}]|\\\\.)*/		# First part
131     /\\}[^{]*\\{/		# The separation
132     /([^}]|\\\\.)*/		# Second part
133     /\\})/			# Closer
134     \1 Keyword_strong, \2 Plain),
135
136    # Substitution and transliteration:
137    # two regexps with [][] as delimiter
138    (/(s|tr)/			# The command: `tr' or `s'
139     /(\\[/			# The delimiter
140     /([^]]|\\\\.)*/		# First part
141     /\\][^[]*\\[/		# The separation
142     /([^]]|\\\\.)*/		# Second part
143     /\\])/			# Closer
144     \1 Keyword_strong, \2 Plain)
145end operators
146
147sequences are
148    # Strings
149    C-string,
150    "'" Plain String "'" Plain
151       exceptions are
152	/\\\\./
153       end exceptions,
154    "`" Plain String "`" Plain
155       exceptions are
156	/\\\\./
157       end exceptions,
158
159    # A few << Constructs seen in html2ps and help2man
160    "<<EOC" Plain /^EOC/,
161    "<<EOD" Plain /^EOD/,
162    "<<EOT" Plain /^EOT/,
163    "<<'EOR'" Plain /^EOR/,
164
165    # Comments
166    "#"            Comment,
167    /^=/           Comment_strong        /^=cut/,
168
169    # Some declarations
170    (/(sub|require|use)/	# \1. the keyword
171     /([[:blank:]]+)/		# \2. blanks
172     \1 Keyword_strong, \2 Plain) (Label_strong  + Index1)
173	closers are
174	  /$/ Plain,
175	  /[ ;{]/ Plain
176	end closers
177end sequences
178
179# Trying to support Some regexp from here
180sequences are
181  # Regular expressions: m{}, m(), and m[]
182  ("m(" "m" Keyword_strong, "(") Plain ")"
183     exceptions are
184       /\\\\./
185     end exceptions,
186  ("m{" "m" Keyword_strong, "{") Plain "}"
187     exceptions are
188       /\\\\./
189     end exceptions,
190  ("m[" "m" Keyword_strong, "[") Plain "]"
191     exceptions are
192       /\\\\./
193     end exceptions
194end sequences
195
196end style
197