Lines Matching full:pattern

3  * Processes pattern strings and checks that the code conforms to the pattern.
22 * Processes pattern strings and checks that the code conforms to the pattern.
107 foreach ($patterns as $pattern) {
108 $parsedPattern = $this->_parse($pattern);
110 // Find a token position in the pattern that we can use
118 'pattern' => $parsedPattern,
119 'pattern_code' => $pattern,
135 * Returns the token types that the specified pattern is checking for.
141 * // should occur in the pattern.
145 * @param array $pattern The parsed pattern to find the acquire the token
150 private function _getPatternTokenTypes($pattern) argument
153 foreach ($pattern as $pos => $patternInfo) {
167 * Returns the position in the pattern that this test should register as
168 * a listener for the pattern.
170 * @param array $pattern The pattern to acquire the listener for.
172 * @return int The position in the pattern that this test should register
177 private function _getListenerTokenPos($pattern) argument
179 $tokenTypes = $this->_getPatternTokenTypes($pattern);
231 // Loop over each pattern that is listening to the current token type
234 // If processPattern returns false, then the pattern that we are
238 // The pattern didn't match.
241 // The pattern matched, but there were no errors.
261 * Processes the pattern and verifies the code at $stackPtr.
263 * @param array $patternInfo Information about the pattern used
266 * pattern.
280 $pattern = $patternInfo['pattern'];
298 if ($pattern[$i]['type'] === 'token') {
299 if ($pattern[$i]['token'] === T_WHITESPACE) {
308 if ($tokens[$stackPtr]['content'] !== $pattern[$i]['value']) {
314 // previous important token in the pattern. If it is not,
315 // then the pattern cannot be for this piece of code.
324 || $tokens[$prev]['code'] !== $pattern[$i]['token']
338 if (isset($pattern[($i - 1)]) === true
339 && $pattern[($i - 1)]['type'] === 'skip'
346 } else if ($pattern[$i]['type'] === 'skip') {
348 if ($pattern[$i]['to'] === 'parenthesis_closer') {
364 // using the wrong pattern.
378 } else if ($pattern[$i]['type'] === 'string') {
380 } else if ($pattern[$i]['type'] === 'newline') {
427 if ($hasError === false && $pattern[($i - 1)]['type'] !== 'newline') {
440 $patternLen = count($pattern);
447 if ($pattern[$i]['type'] === 'token') {
448 if ($pattern[$i]['token'] === T_WHITESPACE) {
468 if (isset($pattern[($i + 1)]) === false) {
469 // This is the last token in the pattern, so just compare
500 if (isset($pattern[($i + 1)]) === true
501 && $pattern[($i + 1)]['type'] === 'skip'
506 if (strpos($tokenContent, $pattern[$i]['value']) !== 0) {
510 if ($tokenContent !== $pattern[$i]['value']) {
516 // next important token in the pattern. If it is not, then
517 // the pattern cannot be for this piece of code.
526 || $tokens[$next]['code'] !== $pattern[$i]['token']
528 // The next important token did not match the pattern.
540 // our pattern. This means the pattern is not for us.
551 // our pattern. This means the pattern is not for us.
579 // newlines without the pattern specifying them, so
591 if (isset($pattern[($i + 1)]) === true
592 && $pattern[($i + 1)]['type'] === 'skip'
599 } else if ($pattern[$i]['type'] === 'skip') {
600 if ($pattern[$i]['to'] === 'unknown') {
602 $pattern[($i + 1)]['token'],
608 // be using the wrong pattern.
622 || isset($tokens[$next][$pattern[$i]['to']]) === false
625 // be using the wrong pattern.
630 if ($pattern[$i]['to'] === 'parenthesis_closer') {
637 $stackPtr = ($tokens[$next][$pattern[$i]['to']] + 1);
639 } else if ($pattern[$i]['type'] === 'string') {
650 } else if ($pattern[$i]['type'] === 'newline') {
721 * @param string $patternCode The expected pattern code.
753 * an arbitrary validation that cannot be performed using a pattern, with
754 * other pattern tests.
786 * Parses a pattern string into an array of pattern steps.
788 * @param string $pattern The pattern to parse.
790 * @return array The parsed pattern array.
794 private function _parse($pattern) argument
797 $length = strlen($pattern);
806 if (substr($pattern, $i, 3) === '...') {
807 // It's a skip pattern. The skip pattern requires the
810 $specialPattern = $this->_createSkipPattern($pattern, ($i - 1));
818 } else if (substr($pattern, $i, 3) === 'abc') {
823 } else if (substr($pattern, $i, 3) === 'EOL') {
833 // Get the string from the end of the last skip pattern, if any,
834 // to the end of the pattern string.
835 $str = substr($pattern, $oldFirstToken);
837 // Get the string from the end of the last special pattern,
838 // if any, to the start of this special pattern.
842 // This happens if you have something like: EOL... in your pattern.
845 $str = substr($pattern, $oldFirstToken, $lastToken);
862 // Add the skip pattern *after* we have processed
863 // all the tokens from the end of the last skip pattern
864 // to the start of this skip pattern.
876 * Creates a skip pattern.
878 * @param string $pattern The pattern being parsed.
879 * @param string $from The token content that the skip pattern starts from.
881 * @return array The pattern step.
885 private function _createSkipPattern($pattern, $from) argument
892 switch ($pattern[$start]) {
930 * Creates a token pattern.
932 * @param string $str The tokens string that the pattern should match.
934 * @return array The pattern step.