private function wantSymbol(string $name, bool $isHidden = false, bool $isInline = false): Symbol
    {
        if ($isInline) {
            if (!isset($this->inline[$name]) && isset($this->symbols[$name])) {
                throw new GrammarException(
                    "Inline '$name' conflicts with token <$name> defined previously"
                );
            }
            if (isset($this->defines[$name])) {
                throw new GrammarException("Inline '$name' conflicts with DEFINE");
            }

            $this->inline[$name] = $name;
            $isHidden = true;
        } else {
            if (isset($this->inline[$name])) {
                throw new GrammarException(
                    "Token <$name> conflicts with inline '$name' defined previously"
                );
            }
            if (isset($this->defines[$name])) {
                throw new GrammarException("Token <$name> conflicts with DEFINE");
            }
        }

        return $this->symbols[$name][$isHidden]
            ?? ($this->symbols[$name][$isHidden] = new Symbol($name, true, $isHidden));
    }
private function wantSymbol(string $name, bool $isHidden = false, bool $isInline = false): Symbol
    {
        if ($isInline) {
            if (!isset($this->inline[$name]) && isset($this->symbols[$name])) {
                throw new GrammarException(
                    "Inline '$name' conflicts with token <$name> defined previously"
                );
            }
            if (isset($this->defines[$name])) {
                throw new GrammarException("Inline '$name' conflicts with DEFINE");
            }

            $this->inline[$name] = $name;
            $isHidden = true;
        } else {
            if (isset($this->inline[$name])) {
                throw new GrammarException(
                    "Token <$name> conflicts with inline '$name' defined previously"
                );
            }
            if (isset($this->defines[$name])) {
                throw new GrammarException("Token <$name> conflicts with DEFINE");
            }
        }

        return $this->symbols[$name][$isHidden]
            ?? ($this->symbols[$name][$isHidden] = new Symbol($name, true, $isHidden));
    }
private function wantSymbol ( string $ name , bool $ isHidden = false , bool $ isInline = false ) : Symbol { if ( $ isInline ) { if ( ! isset ( $ this -> inline [ $ name ] ) && isset ( $ this -> symbols [ $ name ] ) ) { throw new GrammarException ( "Inline '$name' conflicts with token <$name> defined previously" ) ; } if ( isset ( $ this -> defines [ $ name ] ) ) { throw new GrammarException ( "Inline '$name' conflicts with DEFINE" ) ; } $ this -> inline [ $ name ] = $ name ; $ isHidden = true ; } else { if ( isset ( $ this -> inline [ $ name ] ) ) { throw new GrammarException ( "Token <$name> conflicts with inline '$name' defined previously" ) ; } if ( isset ( $ this -> defines [ $ name ] ) ) { throw new GrammarException ( "Token <$name> conflicts with DEFINE" ) ; } } return $ this -> symbols [ $ name ] [ $ isHidden ] ?? ( $ this -> symbols [ $ name ] [ $ isHidden ] = new Symbol ( $ name , true , $ isHidden ) ) ; }
Register a Symbol
@param string $name Symbol name
@param bool $isHidden Whether the hidden symbol is needed
@param bool $isInline Whether the symbol is inline string
@return Symbol
@throws GrammarException
Register a Symbol