plugins/geshi/geshi/perl.php
changeset 2 9e3258dfae15
parent 0 441963e5b07a
child 3 f3e2bbbd2155
equal deleted inserted replaced
1:c715631f809a 2:9e3258dfae15
     2 /*************************************************************************************
     2 /*************************************************************************************
     3  * perl.php
     3  * perl.php
     4  * --------
     4  * --------
     5  * Author: Andreas Gohr (andi@splitbrain.org), Ben Keen (ben.keen@gmail.com)
     5  * Author: Andreas Gohr (andi@splitbrain.org), Ben Keen (ben.keen@gmail.com)
     6  * Copyright: (c) 2004 Andreas Gohr, Ben Keen (http://www.benjaminkeen.org/), Nigel McNie (http://qbnz.com/highlighter/)
     6  * Copyright: (c) 2004 Andreas Gohr, Ben Keen (http://www.benjaminkeen.org/), Nigel McNie (http://qbnz.com/highlighter/)
     7  * Release Version: 1.0.7.20
     7  * Release Version: 1.0.8.2
     8  * Date Started: 2004/08/20
     8  * Date Started: 2004/08/20
     9  *
     9  *
    10  * Perl language file for GeSHi.
    10  * Perl language file for GeSHi.
    11  *
    11  *
    12  * CHANGES
    12  * CHANGES
    13  * -------
    13  * -------
       
    14  * 2008/06/22 (1.0.8)
       
    15  *   -  Added support for system calls in backticks (Corley Kinnane)
       
    16  * 2008/05/23 (1.0.7.22)
       
    17  *   -  Added description of extra language features (SF#1970248)
       
    18  *   -  Added comment_regexp for predefined variables
       
    19  * 2008/02/15 (1.003)
       
    20  *   -  Fixed SF#1891630 with placebo patch
    14  * 2006/01/05 (1.0.2)
    21  * 2006/01/05 (1.0.2)
    15  *   -  Used hardescape feature for ' strings (Cliff Stanford)
    22  *   -  Used hardescape feature for ' strings (Cliff Stanford)
    16  * 2004/11/27 (1.0.1)
    23  * 2004/11/27 (1.0.1)
    17  *   -  Added support for multiple object splitters
    24  *   -  Added support for multiple object splitters
    18  * 2004/08/20 (1.0.0)
    25  * 2004/08/20 (1.0.0)
    42  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    49  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    43  *
    50  *
    44  ************************************************************************************/
    51  ************************************************************************************/
    45 
    52 
    46 $language_data = array (
    53 $language_data = array (
    47 	'LANG_NAME' => 'Perl',
    54     'LANG_NAME' => 'Perl',
    48 	'COMMENT_SINGLE' => array(1 => '#'),
    55     'COMMENT_SINGLE' => array(1 => '#'),
    49 	'COMMENT_MULTI' => array( '=pod' => '=cut'),
    56     'COMMENT_MULTI' => array(
    50 	'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
    57         '=back' => '=cut',
    51 	'QUOTEMARKS' => array('"'),
    58         '=head' => '=cut',
    52 	'HARDQUOTE' => array("'", "'"),		    // An optional 2-element array defining the beginning and end of a hard-quoted string
    59         '=item' => '=cut',
    53 	'HARDESCAPE' => array('\\\'', "\\\\"),	    // Things that must still be escaped inside a hard-quoted string
    60         '=over' => '=cut',
    54 						    // If HARDQUOTE is defined, HARDESCAPE must be defined
    61         '=begin' => '=cut',
    55 						    // This will not work unless the first character of each element is either in the
    62         '=end' => '=cut',
    56 						    // QUOTEMARKS array or is the ESCAPE_CHAR
    63         '=for' => '=cut',
    57 	'ESCAPE_CHAR' => '\\',
    64         '=encoding' => '=cut',
    58 	'KEYWORDS' => array(
    65         '=pod' => '=cut'
    59 		1 => array(
    66         ),
    60 			'case', 'do', 'else', 'elsif', 'for', 'if', 'then', 'until', 'while', 'foreach', 'my',
    67     'COMMENT_REGEXP' => array(
    61 			'or', 'and', 'unless', 'next', 'last', 'redo', 'not', 'our',
    68         //Regular expressions
    62 			'reset', 'continue','and', 'cmp', 'ne'
    69         2 => "/(?<=[\\s^])(s|tr|y)\\/(?:\\\\.|(?!\n)[^\\/\\\\])+\\/(?:\\\\.|(?!\n)[^\\/\\\\])*\\/[msixpogcde]*(?=[\\s$\\.\\;])|(?<=[\\s^(=])(m|q[qrwx]?)?\\/(?:\\\\.|(?!\n)[^\\/\\\\])+\\/[msixpogc]*(?=[\\s$\\.\\,\\;\\)])/iU",
    63 			),
    70         //Regular expression match variables
    64 		2 => array(
    71         3 => '/\$\d+/',
    65 			'use', 'sub', 'new', '__END__', '__DATA__', '__DIE__', '__WARN__', 'BEGIN',
    72         //Heredoc
    66 			'STDIN', 'STDOUT', 'STDERR'
    73         4 => '/<<\s*?([\'"]?)([a-zA-Z0-9]+)\1;[^\n]*?\\n.*\\n\\2(?![a-zA-Z0-9])/siU',
    67 			),
    74         //Predefined variables
    68 		3 => array(
    75         5 => '/\$(\^[a-zA-Z]?|[\$`\'&_\.,+\-~:\\\\\/"\|%=\?!@<>\(\)\[\]])|@_/',
    69 			'abs', 'accept', 'alarm', 'atan2', 'bind', 'binmode', 'bless',
    76         ),
    70 			'caller', 'chdir', 'chmod', 'chomp', 'chop', 'chown', 'chr',
    77     'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
    71 			'chroot', 'close', 'closedir', 'connect', 'continue', 'cos',
    78     'QUOTEMARKS' => array('"','`'),
    72 			'crypt', 'dbmclose', 'dbmopen', 'defined', 'delete', 'die',
    79     'HARDQUOTE' => array("'", "'"),            // An optional 2-element array defining the beginning and end of a hard-quoted string
    73 			'dump', 'each', 'endgrent', 'endhostent', 'endnetent', 'endprotoent',
    80     'HARDESCAPE' => array('\\\'',),
    74 			'endpwent', 'endservent', 'eof', 'eval', 'exec', 'exists', 'exit',
    81         // Things that must still be escaped inside a hard-quoted string
    75 			'exp', 'fcntl', 'fileno', 'flock', 'fork', 'format', 'formline',
    82         // If HARDQUOTE is defined, HARDESCAPE must be defined
    76 			'getc', 'getgrent', 'getgrgid', 'getgrnam', 'gethostbyaddr',
    83         // This will not work unless the first character of each element is either in the
    77 			'gethostbyname', 'gethostent', 'getlogin', 'getnetbyaddr', 'getnetbyname',
    84         // QUOTEMARKS array or is the ESCAPE_CHAR
    78 			'getnetent', 'getpeername', 'getpgrp', 'getppid', 'getpriority',
    85     'ESCAPE_CHAR' => '\\',
    79 			'getprotobyname', 'getprotobynumber', 'getprotoent', 'getpwent',
    86     'KEYWORDS' => array(
    80 			'getpwnam', 'getpwuid', 'getservbyname', 'getservbyport', 'getservent',
    87         1 => array(
    81 			'getsockname', 'getsockopt', 'glob', 'gmtime', 'goto', 'grep',
    88             'case', 'do', 'else', 'elsif', 'for', 'if', 'then', 'until', 'while', 'foreach', 'my',
    82 			'hex', 'import', 'index', 'int', 'ioctl', 'join', 'keys', 'kill',
    89             'or', 'and', 'unless', 'next', 'last', 'redo', 'not', 'our',
    83 			'last', 'lc', 'lcfirst', 'length', 'link', 'listen', 'local',
    90             'reset', 'continue', 'cmp', 'ne'
    84 			'localtime', 'log', 'lstat', 'm', 'map', 'mkdir', 'msgctl', 'msgget',
    91             ),
    85 			'msgrcv', 'msgsnd', 'my', 'next', 'no', 'oct', 'open', 'opendir',
    92         2 => array(
    86 			'ord', 'our', 'pack', 'package', 'pipe', 'pop', 'pos', 'print',
    93             'use', 'sub', 'new', '__END__', '__DATA__', '__DIE__', '__WARN__', 'BEGIN',
    87 			'printf', 'prototype', 'push', 'qq', 'qr', 'quotemeta', 'qw',
    94             'STDIN', 'STDOUT', 'STDERR'
    88 			'qx', 'q', 'rand', 'read', 'readdir', 'readline', 'readlink', 'readpipe',
    95             ),
    89 			'recv', 'redo', 'ref', 'rename', 'require', 'return',
    96         3 => array(
    90 			'reverse', 'rewinddir', 'rindex', 'rmdir', 's', 'scalar', 'seek',
    97             'abs', 'accept', 'alarm', 'atan2', 'bind', 'binmode', 'bless',
    91 			'seekdir', 'select', 'semctl', 'semget', 'semop', 'send', 'setgrent',
    98             'caller', 'chdir', 'chmod', 'chomp', 'chop', 'chown', 'chr',
    92 			'sethostent', 'setnetent', 'setpgrp', 'setpriority', 'setprotoent',
    99             'chroot', 'close', 'closedir', 'connect', 'cos',
    93 			'setpwent', 'setservent', 'setsockopt', 'shift', 'shmctl', 'shmget',
   100             'crypt', 'dbmclose', 'dbmopen', 'defined', 'delete', 'die',
    94 			'shmread', 'shmwrite', 'shutdown', 'sin', 'sleep', 'socket', 'socketpair',
   101             'dump', 'each', 'endgrent', 'endhostent', 'endnetent', 'endprotoent',
    95 			'sort', 'splice', 'split', 'sprintf', 'sqrt', 'srand', 'stat',
   102             'endpwent', 'endservent', 'eof', 'eval', 'exec', 'exists', 'exit',
    96 			'study', 'substr', 'symlink', 'syscall', 'sysopen', 'sysread',
   103             'exp', 'fcntl', 'fileno', 'flock', 'fork', 'format', 'formline',
    97 			'sysseek', 'system', 'syswrite', 'tell', 'telldir', 'tie', 'tied',
   104             'getc', 'getgrent', 'getgrgid', 'getgrnam', 'gethostbyaddr',
    98 			'time', 'times', 'tr', 'truncate', 'uc', 'ucfirst', 'umask', 'undef',
   105             'gethostbyname', 'gethostent', 'getlogin', 'getnetbyaddr', 'getnetbyname',
    99 			'unlink', 'unpack', 'unshift', 'untie', 'utime', 'values',
   106             'getnetent', 'getpeername', 'getpgrp', 'getppid', 'getpriority',
   100 			'vec', 'wait', 'waitpid', 'wantarray', 'warn', 'write', 'y'
   107             'getprotobyname', 'getprotobynumber', 'getprotoent', 'getpwent',
   101 			)
   108             'getpwnam', 'getpwuid', 'getservbyname', 'getservbyport', 'getservent',
   102 		),
   109             'getsockname', 'getsockopt', 'glob', 'gmtime', 'goto', 'grep',
   103 	'SYMBOLS' => array(
   110             'hex', 'import', 'index', 'int', 'ioctl', 'join', 'keys', 'kill',
   104 		'(', ')', '[', ']', '!', '@', '%', '&', '*', '|', '/', '<', '>'
   111             'lc', 'lcfirst', 'length', 'link', 'listen', 'local',
   105 		),
   112             'localtime', 'log', 'lstat', 'm', 'map', 'mkdir', 'msgctl', 'msgget',
   106 	'CASE_SENSITIVE' => array(
   113             'msgrcv', 'msgsnd', 'no', 'oct', 'open', 'opendir',
   107 		GESHI_COMMENTS => true,
   114             'ord', 'pack', 'package', 'pipe', 'pop', 'pos', 'print',
   108 		1 => true,
   115             'printf', 'prototype', 'push', 'qq', 'qr', 'quotemeta', 'qw',
   109 		2 => true,
   116             'qx', 'q', 'rand', 'read', 'readdir', 'readline', 'readlink', 'readpipe',
   110 		3 => true,
   117             'recv', 'ref', 'rename', 'require', 'return',
   111 		),
   118             'reverse', 'rewinddir', 'rindex', 'rmdir', 's', 'scalar', 'seek',
   112 	'STYLES' => array(
   119             'seekdir', 'select', 'semctl', 'semget', 'semop', 'send', 'setgrent',
   113 		'KEYWORDS' => array(
   120             'sethostent', 'setnetent', 'setpgrp', 'setpriority', 'setprotoent',
   114 			1 => 'color: #b1b100;',
   121             'setpwent', 'setservent', 'setsockopt', 'shift', 'shmctl', 'shmget',
   115 			2 => 'color: #000000; font-weight: bold;',
   122             'shmread', 'shmwrite', 'shutdown', 'sin', 'sleep', 'socket', 'socketpair',
   116 			3 => 'color: #000066;'
   123             'sort', 'splice', 'split', 'sprintf', 'sqrt', 'srand', 'stat',
   117 			),
   124             'study', 'substr', 'symlink', 'syscall', 'sysopen', 'sysread',
   118 		'COMMENTS' => array(
   125             'sysseek', 'system', 'syswrite', 'tell', 'telldir', 'tie', 'tied',
   119 			1 => 'color: #808080; font-style: italic;',
   126             'time', 'times', 'tr', 'truncate', 'uc', 'ucfirst', 'umask', 'undef',
   120 			'MULTI' => 'color: #808080; font-style: italic;'
   127             'unlink', 'unpack', 'unshift', 'untie', 'utime', 'values',
   121 			),
   128             'vec', 'wait', 'waitpid', 'wantarray', 'warn', 'write', 'y'
   122 		'ESCAPE_CHAR' => array(
   129             )
   123 			0 => 'color: #000099; font-weight: bold;'
   130         ),
   124 			),
   131     'SYMBOLS' => array(
   125 		'BRACKETS' => array(
   132         '<', '>', '=',
   126 			0 => 'color: #66cc66;'
   133         '!', '@', '~', '&', '|',
   127 			),
   134         '+','-', '*', '/', '%',
   128 		'STRINGS' => array(
   135         ',', ';', '?', ':'
   129 			0 => 'color: #ff0000;'
   136         ),
   130 			),
   137     'CASE_SENSITIVE' => array(
   131 		'NUMBERS' => array(
   138         GESHI_COMMENTS => false,
   132 			0 => 'color: #cc66cc;'
   139         1 => true,
   133 			),
   140         2 => true,
   134 		'METHODS' => array(
   141         3 => true,
   135 			1 => 'color: #006600;',
   142         ),
   136 			2 => 'color: #006600;'
   143     'STYLES' => array(
   137 			),
   144         'KEYWORDS' => array(
   138 		'SYMBOLS' => array(
   145             1 => 'color: #b1b100;',
   139 			0 => 'color: #66cc66;'
   146             2 => 'color: #000000; font-weight: bold;',
   140 			),
   147             3 => 'color: #000066;'
   141 		'REGEXPS' => array(
   148             ),
   142 			0 => 'color: #0000ff;',
   149         'COMMENTS' => array(
   143 			4 => 'color: #009999;',
   150             1 => 'color: #666666; font-style: italic;',
   144 			),
   151             2 => 'color: #009966; font-style: italic;',
   145 		'SCRIPT' => array(
   152             3 => 'color: #0000ff;',
   146 			)
   153             4 => 'color: #cc0000; font-style: italic;',
   147 		),
   154             5 => 'color: #0000ff;',
   148 	'URLS' => array(
   155             'MULTI' => 'color: #666666; font-style: italic;'
   149 		3 => 'http://perldoc.perl.org/functions/{FNAME}.html'
   156             ),
   150 		),
   157         'ESCAPE_CHAR' => array(
   151 	'OOLANG' => true,
   158             0 => 'color: #000099; font-weight: bold;',
   152 	'OBJECT_SPLITTERS' => array(
   159             'HARD' => 'color: #000099; font-weight: bold;'
   153 		1 => '-&gt;',
   160             ),
   154 		2 => '::'
   161         'BRACKETS' => array(
   155 		),
   162             0 => 'color: #009900;'
   156 	'REGEXPS' => array(
   163             ),
   157 		0 => '[\\$%@]+[a-zA-Z_][a-zA-Z0-9_]*',
   164         'STRINGS' => array(
   158 		4 => '&lt;[a-zA-Z_][a-zA-Z0-9_]*&gt;',
   165             0 => 'color: #ff0000;',
   159 		),
   166             'HARD' => 'color: #ff0000;'
   160 	'STRICT_MODE_APPLIES' => GESHI_NEVER,
   167             ),
   161 	'SCRIPT_DELIMITERS' => array(
   168         'NUMBERS' => array(
   162 		),
   169             0 => 'color: #cc66cc;'
   163 	'HIGHLIGHT_STRICT_BLOCK' => array(
   170             ),
   164 		)
   171         'METHODS' => array(
       
   172             1 => 'color: #006600;',
       
   173             2 => 'color: #006600;'
       
   174             ),
       
   175         'SYMBOLS' => array(
       
   176             0 => 'color: #339933;'
       
   177             ),
       
   178         'REGEXPS' => array(
       
   179             0 => 'color: #0000ff;',
       
   180             4 => 'color: #009999;',
       
   181             ),
       
   182         'SCRIPT' => array(
       
   183             )
       
   184         ),
       
   185     'URLS' => array(
       
   186         1 => '',
       
   187         2 => '',
       
   188         3 => 'http://perldoc.perl.org/functions/{FNAMEL}.html'
       
   189         ),
       
   190     'OOLANG' => true,
       
   191     'OBJECT_SPLITTERS' => array(
       
   192         1 => '-&gt;',
       
   193         2 => '::'
       
   194         ),
       
   195     'REGEXPS' => array(
       
   196         //Variable
       
   197         0 => '[\\$%@]+[a-zA-Z_][a-zA-Z0-9_]*',
       
   198         //File Descriptor
       
   199         4 => '&lt;[a-zA-Z_][a-zA-Z0-9_]*&gt;',
       
   200         ),
       
   201     'STRICT_MODE_APPLIES' => GESHI_NEVER,
       
   202     'SCRIPT_DELIMITERS' => array(
       
   203         ),
       
   204     'HIGHLIGHT_STRICT_BLOCK' => array(
       
   205         ),
       
   206     'PARSER_CONTROL' => array(
       
   207         'COMMENTS' => array(
       
   208             'DISALLOWED_BEFORE' => '$'
       
   209         )
       
   210     )
   165 );
   211 );
   166 
   212 
   167 ?>
   213 ?>