3 class XmlLanguage extends HyperLanguage {
4 public function __construct() {
7 parent::VERSION => '0.3',
8 parent::AUTHOR => array(
9 parent::NAME => 'Konrad Rudolph',
10 parent::WEBSITE => 'madrat.net',
11 parent::EMAIL => 'konrad_rudolph@madrat.net'
15 $this->setExtensions(array('xml', 'xsl', 'xslt', 'xsd', 'manifest'));
17 $inline = array('entity');
18 $common = array('tagname', 'attribute', 'value' => array('double', 'single'));
20 $this->addStates(array(
21 'init' => array_merge(array('comment', 'cdata', 'tag'), $inline),
22 'tag' => array_merge(array('preprocessor', 'meta'), $common),
23 'preprocessor' => $common,
25 'value double' => $inline,
26 'value single' => $inline,
29 $this->addRules(array(
30 'comment' => '/<!--.*?-->/s',
31 'cdata' => '/<!\[CDATA\[.*?\]\]>/',
32 'tag' => new Rule('/</', '/>/'),
33 'tagname' => '#(?:(?<=<)|(?<=</)|(?<=<\?)|(?<=<!))[a-z0-9:-]+#i',
34 'attribute' => '/[a-z0-9:-]+/i',
35 'preprocessor' => new Rule('/\?/'),
36 'meta' => new Rule('/!/'),
38 'double' => new Rule('/"/', '/"/'),
39 'single' => new Rule("/'/", "/'/")
41 'entity' => '/&.*?;/',
44 $this->addMappings(array(
45 'attribute' => 'keyword type',
47 'value double' => 'string',
48 'value single' => 'string',
49 'entity' => 'escaped',
50 'tagname' => 'keyword'