Commits

Jharrod LaFon committed f95cea3 Merge

Correctly match valid identifiers in PHP that include unicode characters

  • Participants
  • Parent commits 345b151, fa6da9b

Comments (0)

Files changed (2)

pygments/lexers/web.py

             (r'/\*\*/', Comment.Multiline),
             (r'/\*\*.*?\*/', String.Doc),
             (r'/\*.*?\*/', Comment.Multiline),
-            (r'(->|::)(\s*)([a-zA-Z_][a-zA-Z0-9_]*)',
+            (r'(->|::)(\s*)([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)',
              bygroups(Operator, Text, Name.Attribute)),
             (r'[~!%^&*+=|:.<>/?@-]+', Operator),
             (r'[\[\]{}();,]+', Punctuation),
             (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_]*)',
+            (r'(const)(\s+)([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)',
               bygroups(Keyword, Text, Name.Constant)),
             (r'(and|E_PARSE|old_function|E_ERROR|or|as|E_WARNING|parent|'
              r'eval|PHP_OS|break|exit|case|extends|PHP_VERSION|cfunction|'
              r'catch|throw|this|use|namespace|trait|yield|'
              r'finally)\b', Keyword),
             (r'(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),
-            (r'[\\a-zA-Z_][\\a-zA-Z0-9_]*', Name.Other),
+            (r'\$\{\$+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\}', Name.Variable),
+            (r'\$+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*', Name.Variable),
+            (r'[\\a-zA-Z_\x7f-\xff][\\a-zA-Z0-9_\x7f-\xff]*', Name.Other),
             (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
             (r'\d+[eE][+-]?[0-9]+', Number.Float),
             (r'0[0-7]+', Number.Oct),
             (r'"', String.Double, 'string'),
         ],
         'classname': [
-            (r'[a-zA-Z_][\\a-zA-Z0-9_]*', Name.Class, '#pop')
+            (r'[a-zA-Z_\x7f-\xff][\\a-zA-Z0-9_\x7f-\xff]*', Name.Class, '#pop')
         ],
         'functionname': [
-            (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Function, '#pop')
+            (r'[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*', Name.Function, '#pop')
         ],
         'string': [
             (r'"', String.Double, '#pop'),
             (r'[^{$"\\]+', String.Double),
             (r'\\([nrt\"$\\]|[0-7]{1,3}|x[0-9A-Fa-f]{1,2})', String.Escape),
+<<<<<<< local
             (r'\$[a-zA-Z_][a-zA-Z0-9_]*(\[\S+?\]|->[a-zA-Z_][a-zA-Z0-9_]*)?',
+=======
+            (r'\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(\[\S+\]|->[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)?',
+>>>>>>> other
              String.Interpol),
             (r'(\{\$\{)(.*?)(\}\})',
              bygroups(String.Interpol, using(this, _startinline=True),

tests/examplefiles/test.php

 <?php
 
+$disapproval_ಠ_ಠ_of_php = 'unicode var';
+
 $test = function($a) { $lambda = 1; }
 
 /**
 // Load the parent archive class
 require_once(ROOT_PATH.'/classes/archive.class.php');
 
-class Zip\Zipp {
+class Zip\Zippಠ_ಠ_ {
 
 }