Changeset View
Changeset View
Standalone View
Standalone View
src/lexer/PhutilPHPFragmentLexer.php
| Show First 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | return array( | ||||
| array('(?i:'.implode('|', $constants).')\\b', 'kc'), | array('(?i:'.implode('|', $constants).')\\b', 'kc'), | ||||
| array('\\$+'.$identifier_pattern, 'nv'), | array('\\$+'.$identifier_pattern, 'nv'), | ||||
| // Match "f(" as a function and "C::" as a class. These won't work | // Match "f(" as a function and "C::" as a class. These won't work | ||||
| // if you put a comment between the symbol and the operator, but | // if you put a comment between the symbol and the operator, but | ||||
| // that's a bizarre usage. | // that's a bizarre usage. | ||||
| array($identifier_ns_pattern.'(?=\s*[\\(])', 'nf'), | array($identifier_ns_pattern.'(?=\s*[\\(])', 'nf'), | ||||
| array($identifier_ns_pattern.'(?=\s*::)', 'nc', 'context_attr', | array( | ||||
| $identifier_ns_pattern.'(?=\s*::)', | |||||
| 'nc', | |||||
| 'context_attr', | |||||
| array( | array( | ||||
| 'context' => 'push', | 'context' => 'push', | ||||
| ), | ), | ||||
| ), | ), | ||||
| array($identifier_ns_pattern, 'no'), | array($identifier_ns_pattern, 'no'), | ||||
| array('(\\d+\\.\\d*|\\d*\\.\\d+)([eE][+-]?[0-9]+)?', 'mf'), | array('(\\d+\\.\\d*|\\d*\\.\\d+)([eE][+-]?[0-9]+)?', 'mf'), | ||||
| array('\\d+[eE][+-]?[0-9]+', 'mf'), | array('\\d+[eE][+-]?[0-9]+', 'mf'), | ||||
| array('0[0-7]+', 'mo'), | array('0[0-7]+', 'mo'), | ||||
| array('0[xX][a-fA-F0-9]+', 'mh'), | array('0[xX][a-fA-F0-9]+', 'mh'), | ||||
| array('0[bB][0-1]+', 'm'), | array('0[bB][0-1]+', 'm'), | ||||
| array('\d+', 'mi'), | array('\d+', 'mi'), | ||||
| array("'", 's1', 'string1'), | array("'", 's1', 'string1'), | ||||
| array('`', 'sb', 'stringb'), | array('`', 'sb', 'stringb'), | ||||
| array('"', 's2', 'string2'), | array('"', 's2', 'string2'), | ||||
| array('.', null), | array('.', null), | ||||
| )), | )), | ||||
| // We've just matched a class name, with a "::" lookahead. The name of | // We've just matched a class name, with a "::" lookahead. The name of | ||||
| // the class is on the top of the context stack. We want to try to match | // the class is on the top of the context stack. We want to try to match | ||||
| // the attribute or method (e.g., "X::C" or "X::f()"). | // the attribute or method (e.g., "X::C" or "X::f()"). | ||||
| 'context_attr' => array_merge($nonsemantic_rules, array( | 'context_attr' => array_merge($nonsemantic_rules, array( | ||||
| array('::', 'o'), | array('::', 'o'), | ||||
| array($identifier_pattern.'(?=\s*[\\(])', 'nf', '!pop', | array( | ||||
| $identifier_pattern.'(?=\s*[\\(])', | |||||
| 'nf', | |||||
| '!pop', | |||||
| array( | array( | ||||
| 'context' => 'pop', | 'context' => 'pop', | ||||
| ), | ), | ||||
| ), | ), | ||||
| array($identifier_pattern, 'na', '!pop', | array( | ||||
| $identifier_pattern, | |||||
| 'na', | |||||
| '!pop', | |||||
| array( | array( | ||||
| 'context' => 'pop', | 'context' => 'pop', | ||||
| ), | ), | ||||
| ), | ), | ||||
| array('', null, '!pop', | array( | ||||
| '', | |||||
| null, | |||||
| '!pop', | |||||
| array( | array( | ||||
| 'context' => 'discard', | 'context' => 'discard', | ||||
| ), | ), | ||||
| ), | ), | ||||
| )), | )), | ||||
| // After '->' or '::', a symbol is an attribute name. Note that we end | // After '->' or '::', a symbol is an attribute name. Note that we end | ||||
| // up in 'context_attr' instead of here in some cases. | // up in 'context_attr' instead of here in some cases. | ||||
| ▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines | |||||