protected function addPattern($pattern, $ruleName, $childRuleName = null) {
        if (!isset($this->patterns[$ruleName])) {
            $this->patterns[$ruleName] = new LexerPattern($ruleName);
        }
        $this->patterns[$ruleName]->addPattern($pattern, $childRuleName);

        return $this;
    }