diff options
author | Georg Brandl <georg@python.org> | 2010-03-01 16:01:44 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-03-01 16:01:44 +0100 |
commit | 44d58cd0b187f94f9359db163841a24d108a2cf5 (patch) | |
tree | 18c1cc1afff31a01571cdbc77290a8b79820ea0a | |
parent | 26a6c4153733225bf484a7da5c3c11956b716889 (diff) | |
download | pygments-44d58cd0b187f94f9359db163841a24d108a2cf5.tar.gz |
Added support for PHP 5.3 namespaces in the PHP lexer.
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | pygments/lexers/web.py | 9 | ||||
-rw-r--r-- | tests/examplefiles/test.php | 9 |
4 files changed, 16 insertions, 5 deletions
@@ -26,6 +26,7 @@ Other contributors, listed alphabetically, are: * Laurent Gautier -- R/S lexer * Krzysiek Goj -- Scala lexer * Matt Good -- Genshi, Cheetah lexers +* Patrick Gotthardt -- PHP namespaces support * Olivier Guibe -- Asymptote lexer * Matthew Harrison -- SVG formatter * Steven Hazel -- Tcl lexer @@ -22,6 +22,8 @@ Version 1.3 - Enhanced reStructuredText highlighting. +- Added support for PHP 5.3 namespaces in the PHP lexer. + - Fixed a bug in `do_insertions()` used for multi-lexer languages. - Fixed a Ruby regex highlighting bug (#476). diff --git a/pygments/lexers/web.py b/pygments/lexers/web.py index 1d265dbd..ec0b27be 100644 --- a/pygments/lexers/web.py +++ b/pygments/lexers/web.py @@ -715,7 +715,7 @@ class PhpLexer(RegexLexer): ], 'php': [ (r'\?>', Comment.Preproc, '#pop'), - (r'<<<([a-zA-Z_][a-zA-Z0-9_]*)\n.*?\n\1\;?\n', String), + (r'<<<(\'?)([a-zA-Z_][a-zA-Z0-9_]*)\1\n.*?\n\2\;?\n', String), (r'\s+', Text), (r'#.*?\n', Comment.Single), (r'//.*?\n', Comment.Single), @@ -729,6 +729,7 @@ class PhpLexer(RegexLexer): (r'[~!%^&*+=|:.<>/?@-]+', Operator), (r'[\[\]{}();,]+', Punctuation), (r'(class)(\s+)', bygroups(Keyword, Text), 'classname'), + (r'(function)(\s*)(?=\()', bygroups(Keyword, Text)), (r'(function)(\s+)(&?)(\s*)', bygroups(Keyword, Text, Operator, Text), 'functionname'), (r'(const)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)', @@ -742,11 +743,11 @@ class PhpLexer(RegexLexer): r'endif|list|__LINE__|endswitch|new|__sleep|endwhile|not|' r'array|__wakeup|E_ALL|NULL|final|php_user_filter|interface|' r'implements|public|private|protected|abstract|clone|try|' - r'catch|throw|this)\b', Keyword), + r'catch|throw|this|use|namespace)\b', Keyword), ('(true|false|null)\b', Keyword.Constant), (r'\$\{\$+[a-zA-Z_][a-zA-Z0-9_]*\}', Name.Variable), (r'\$+[a-zA-Z_][a-zA-Z0-9_]*', Name.Variable), - ('[a-zA-Z_][a-zA-Z0-9_]*', Name.Other), + (r'[\\a-zA-Z_][\\a-zA-Z0-9_]*', Name.Other), (r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|" r"0[xX][0-9a-fA-F]+[Ll]?", Number), (r"'([^'\\]*(?:\\.[^'\\]*)*)'", String.Single), @@ -754,7 +755,7 @@ class PhpLexer(RegexLexer): (r'"', String.Double, 'string'), ], 'classname': [ - (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop') + (r'[a-zA-Z_][\\a-zA-Z0-9_]*', Name.Class, '#pop') ], 'functionname': [ (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Function, '#pop') diff --git a/tests/examplefiles/test.php b/tests/examplefiles/test.php index 90de7472..97e21f73 100644 --- a/tests/examplefiles/test.php +++ b/tests/examplefiles/test.php @@ -1,4 +1,7 @@ <?php + +$test = function($a) { $lambda = 1; } + /** * Zip class file * @@ -12,7 +15,11 @@ if(!defined('UNLOCK') || !UNLOCK) // Load the parent archive class require_once(ROOT_PATH.'/classes/archive.class.php'); - + +class Zip\Zipp { + +} + /** * Zip class * |