Match

| content | content |

@param string                    $ruleNameName
@param \ViKon\Parser\Lexer\Lexer $lexer

@return $this
197976
public function embedInto($ruleNameName, Lexer $lexer) {
        parent::embedInto($ruleNameName, $lexer);
        // Match table row
        $lexer->addSimplePattern('\n\|?(?:[^|\n]+\|)+(?:[^|\n]+\|?)', $this->name);

        return $this;
    }
348366
protected function lexName(): NameNode
    {
        $token = $this->expect(TokenKindEnum::NAME);

        return new NameNode($token->getValue(), $this->createLocation($token));
    }
832542
public function withRule(Rule $rule): RulesCollection
    {
        $rules = array_merge($this->rules, [$rule]);

        return new RulesCollection($rules);
    }
326331
public static function rule($ruleName, $arguments): RuleInterface
    {
        $ruleName = ucfirst($ruleName) . 'Rule';

        foreach (static::$rulesNamespaces as $ruleNamespace) {
            $ruleClass = $ruleNamespace . $ruleName;
            if (class_exists($ruleClass)) {
                return new $ruleClass(...$arguments);
            }
        }

        throw new ComponentException("Class for validator `$ruleName` not found");
    }
243758
def visitLexerAltList(self, ctx: jsgParser.LexerAltListContext):
        
        altlist = ctx.lexerAlt()
        self.visit(altlist[0])
        for alt in altlist[1:]:
            self._rulePattern += '|'
            self.visit(alt)
818259
public function match($attribute, $rule, $value, $dnFlag = false)
    {
        return new MatchingRule($attribute, $rule, $value, $dnFlag);
    }
515496
public function add_rule($name, $value, $rules){
        $this->fieldsState[$name] = array(
			'name'			=> $name,
			'value'			=> $value,
			'rules'			=> explode('|', $rules),
                        'valid'                 => TRUE,
                        'message'               => NULL
        );
    }
596485
private function findMatchingTransliterator(string $rule, string $locale): \Transliterator
	{
		$candidates = [
			'Latin-'.$rule,
			$rule,
		];

		if ($locale) {
			array_unshift(
				$candidates,
				$locale.'-'.$rule,
				\Locale::getPrimaryLanguage($locale).'-'.$rule
			);
		}

		$errorLevel = ini_set('intl.error_level', '0');
		$useExceptions = ini_set('intl.use_exceptions', '0');

		try {
			foreach ($candidates as $candidate) {
				$candidate = $this->fixTransliteratorRule($candidate);
				if ($transliterator = \Transliterator::create($candidate)) {
					return $transliterator;
				}
				if ($transliterator = \Transliterator::createFromRules($candidate)) {
					return $transliterator;
				}
			}
		} finally {
			ini_set('intl.error_level', $errorLevel);
			ini_set('intl.use_exceptions', $useExceptions);
		}

		throw new \InvalidArgumentException(
			sprintf('No Transliterator transform rule found for "%s" with locale "%s".', $rule, $locale)
		);
	}
976053
public function init(Parser $parser, Lexer $lexer) {
        $parser->setStartRule($this->startRule);

        foreach ($this->rules as $rule) {
            $parser->addRule($rule);
        }

        $parser->setLexer($lexer);
        $lexer->setParser($parser);

        return $this;
    }
838315
public function alias(string $name, $rules, ?string $error = null): self
    {
        $this->definitions[$name] = function () use ($rules, $error) {
            return $this->parser->parse($rules)->setError($error);
        };
        return $this;
    }
1202631
private function match($token)
    {
        if (!$this->lexer->isNextToken($token)) {
            throw SyntaxException::expectedToken(
                $this->lexer->getLiteral($token),
                null,
                $this->lexer
            );
        }

        return $this->lexer->moveNext();
    }
347964
private function ignoreObjectBlock(Lexer $lexer) : int
    {
        do {
            $code = $lexer->lex();

            // recursively ignore nested objects
            if (self::JSON_OBJECT_START === $code) {
                $this->ignoreObjectBlock($lexer);
            }
        } while (self::JSON_OBJECT_END !== $code);

        return $lexer->lex();
    }
1092650
private function getTransliterator(string $rule, string $locale): \Transliterator
	{
		$key = $rule.'|'.$locale;

		if (!isset($this->transliterators[$key])) {
			$this->transliterators[$key] = $this->findMatchingTransliterator($rule, $locale);
		}

		return $this->transliterators[$key];
	}
376165
protected function addRule(array $rules, $name, array $abbreviations) {
        if (array_get($rules, $name) === null) {
            $rules[$name] = [];
        }

        $patterns = $this->createPatternsForStrings($abbreviations);

        foreach ($patterns as $pattern) {
            $rules[$name][] = $pattern;
        }

        return $rules;
    }
1247451
public function addLexerRule($rulename, $rule)
	{
		$this->rules[$rulename] = [];
		$this->rules[$rulename][] = $rule; 
	}
339824
def validate_rules(lexer)
      if lexer.state_re.empty?
        complain("No rules of the form rule(name, pattern) are defined")
      end

      lexer.state_info.each do |state_name, state_type|
        if !lexer.state_re.key?(state_name.to_sym)
          complain("No rules defined for state '#{state_name}'")
        end
      end
    end
216388
private function handleJsonRoot(Lexer $lexer) : void
    {
        do {
            $code = $lexer->lex();

            if (self::JSON_OBJECT_START === $code) {
                $code = $this->handleJsonDivision($lexer);
            }
        } while (self::JSON_EOF !== $code);
    }