import
[web.mtrack] / inc / hyperlight / perl.php
1 <?php # vim:ts=2:sw=2:et:
2 /* For licensing and copyright terms, see the file named LICENSE */
3
4 class PerlLanguage extends HyperLanguage {
5   public function __construct() {
6     $this->setInfo(array(
7           parent::NAME => 'Perl',
8           ));
9     $this->setExtensions(array('pl'));
10     $this->setCaseInsensitive(false);
11     $this->addStates(array(
12           'init' => array(
13             'string',
14             'number',
15             'char',
16             'ticked',
17             'variable',
18             'comment',
19             'keyword' => array('', 'operator'),
20             'identifier'
21             ),
22           'variable' => array('identifier'),
23           )
24     );
25
26     $this->addRules(array(
27           'string' => Rule::C_DOUBLEQUOTESTRING,
28           'char' => Rule::C_SINGLEQUOTESTRING,
29           'ticked' => "/\`(?:\\\`|.)*\`/sU",
30           'number' => Rule::C_NUMBER,
31           'comment' => '/#.*/',
32           'keyword' => array(
33             array(
34               'use', 'my', 'our', 'open', 'close', 'tie',
35               'exists', 'keys', 'values', 'chomp',
36               'last', 'next', 'print', 'unless',
37               'and', 'or', 'not', 'defined', 'undef',
38               'push', 'unshift', 'shift', 'pop',
39               'system', 'exec', 'goto', 'uc', 'lc',
40               'length', 'split',
41               'sort', 'grep', 'map', 'die', 'eval',
42               'require', 'bless', 'sub', 'package',
43               'eq', 'ne', 'le', 'lt', 'ge', 'gt',
44               'else', 'for', 'foreach', 'then',
45               'if', 'in', 'case', 'esac', 'while',
46               'end', 'do', 'return', 'elsif', 'exit'
47               ),
48             'operator' => '/&&|\|\||<<|>>|\.=|==|=~|!~|[=;&|!<>\[\].]/',
49             ),
50           'identifier' => Rule::C_IDENTIFIER,
51           'variable' => new Rule('/(@\$|%\$|&\$|@|%|&|\$)/', '//'),
52           ));
53         $this->addMappings(array(
54             'char' => 'string',
55             'variable' => 'tag',
56             'ticked' => 'string',
57         ));
58
59   }
60 }