4 // - Fill the scaffold below!
5 // - More keywords? What about functions?
6 // - String interpolation and escaping.
7 // - Usual stuff for doc comments
9 // - More complex nested variable names.
11 class PhpLanguage extends HyperLanguage {
12 public function __construct() {
14 parent::NAME => 'PHP',
15 parent::VERSION => '0.3',
16 parent::AUTHOR => array(
17 parent::NAME => 'Konrad Rudolph',
18 parent::WEBSITE => 'madrat.net',
19 parent::EMAIL => 'konrad_rudolph@madrat.net'
23 $this->setExtensions(array('php', 'php3', 'php4', 'php5', 'inc'));
25 $this->addPostProcessing('html', HyperLanguage::fromName('xml'));
27 $this->addStates(array(
28 'init' => array('php', 'html'),
30 'comment', 'string', 'char', 'number',
31 'keyword' => array('', 'type', 'literal', 'operator', 'builtin'),
32 'identifier', 'variable'),
33 'variable' => array('identifier'),
37 $this->addRules(array(
38 'php' => new Rule('/<\?php/', '/\?>/'),
39 'html' => new Rule('/(?=.)/', '/(?=<\?php)/'),
40 'comment' => ",#[^\n]*\n|//.*?\n|/\*.*?\*/,s",
41 'string' => Rule::C_DOUBLEQUOTESTRING,
42 'char' => Rule::C_SINGLEQUOTESTRING,
43 'number' => Rule::C_NUMBER,
44 'identifier' => Rule::C_IDENTIFIER,
45 'variable' => new Rule('/\$/', '//'),
47 array('break', 'case', 'class', 'const', 'continue', 'declare', 'default', 'do', 'else', 'elseif', 'enddeclare', 'endfor', 'endforeach', 'endif', 'endswitch', 'endwhile', 'extends', 'for', 'foreach', 'function', 'global', 'if', 'return', 'static', 'switch', 'use', 'var', 'while', 'final', 'interface', 'implements', 'public', 'private', 'protected', 'abstract', 'try', 'catch', 'throw', 'final', 'namespace'),
48 'type' => array('exception', 'int'),
49 'literal' => array('false', 'null', 'true', 'this'),
50 'operator' => array('and', 'as', 'or', 'xor', 'new', 'instanceof', 'clone'),
51 'builtin' => array('array', 'die', 'echo', 'empty', 'eval', 'exit', 'include', 'include_once', 'isset', 'list', 'print', 'require', 'require_once', 'unset')
55 $this->addMappings(array(
58 'html' => 'preprocessor',