Reads a punctuation token from the source file.

@param int   $code
@param int   $line
@param int   $column
@param Token $prev
@return Token
@throws SyntaxErrorException
187558
protected function lexPunctuation(int $code, int $line, int $column, Token $prev): ?Token
    {
        if (!isset(self::$codeTokenKindMap[$code])) {
            throw $this->createSyntaxErrorException();
        }

        return new Token(self::$codeTokenKindMap[$code], $this->position, $this->position + 1, $line, $column, $prev);
    }
1206158
protected function logInconvertibleError(
        string $line,
        \esperecyan\dictionary_php\exception\SyntaxException $exception = null
    ) {
        $this->logger->error(
            // TRANSLATORS: %s は例外メッセージ。空文字列の場合もある。
            sprintf(_('以下の行は汎用辞書のお題に変換できません: %s'), $exception ? $exception->getMessage() : '')
                . "\n> " . str_replace("\n", "\n> ", $line),
            $exception ? ['exception' => $exception] : []
        );
    }
127412
protected function lexString(int $line, int $column, Token $prev): Token
    {
        $start      = $this->position;
        $chunkStart = ++$this->position; // skip the quote
        $value      = '';

        while ($this->position < $this->bodyLength) {
            $code = $this->readCharCode($this->position);

            if (isLineTerminator($code)) {
                break;
            }

            // Closing Quote (")
            if (34 === $code) {
                $value .= sliceString($this->body, $chunkStart, $this->position);
                return new Token(TokenKindEnum::STRING, $start, $this->position + 1, $line, $column, $prev, $value);
            }

            if (isSourceCharacter($code)) {
                throw $this->createSyntaxErrorException(
                    \sprintf('Invalid character within String: %s.', printCharCode($code))
                );
            }

            ++$this->position;

            if (92 === $code) {
                // \
                $value .= sliceString($this->body, $chunkStart, $this->position - 1);

                $code = $this->readCharCode($this->position);

                switch ($code) {
                    case 34: // "
                        $value .= '"';
                        break;
                    case 47: // /
                        $value .= '/';
                        break;
                    case 92: // \
                        $value .= '\\';
                        break;
                    case 98: // b
                        $value .= '\b';
                        break;
                    case 102: // f
                        $value .= '\f';
                        break;
                    case 110: // n
                        $value .= '\n';
                        break;
                    case 114: // r
                        $value .= '\r';
                        break;
                    case 116: // t
                        $value .= '\t';
                        break;
                    case 117: // u
                        $unicodeString = sliceString($this->body, $this->position + 1, $this->position + 5);

                        if (!\preg_match('/[0-9A-Fa-f]{4}/', $unicodeString)) {
                            throw $this->createSyntaxErrorException(
                                \sprintf('Invalid character escape sequence: \\u%s.', $unicodeString)
                            );
                        }

                        $value .= '\\u' . $unicodeString;

                        $this->position += 4;

                        break;
                    default:
                        throw $this->createSyntaxErrorException(
                            \sprintf('Invalid character escape sequence: \\%s.', \chr($code))
                        );
                }

                ++$this->position;

                $chunkStart = $this->position;
            }
        }

        throw $this->createSyntaxErrorException('Unterminated string.');
    }
1015650
protected function lexSpread(int $line, int $column, Token $prev): Token
    {
        return new Token(TokenKindEnum::SPREAD, $this->position, $this->position + 3, $line, $column, $prev);
    }
17012
public static function IncludeException($code, $string, $file, $line, $context)
	{
		// check for repressed errors
		if (error_reporting() == 0) return;
		
		$tmp1 = explode(")",$string);
		$tmp2 = explode("(",$tmp1[0]);
		$mfile = isset($tmp2[1]) ? $tmp2[1] : "";
		
		$msg = "Error $code: " .  ($mfile ? "Unable to include file: '" . $mfile . "'" : $string);
		
		throw new IncludeException($msg,$code);
	}
1301542
public function preOutputNoLineFeed($code)
    {
        $this->lastLine = $code;
        $this->code = str_repeat("\t", $this->level).$code.$this->code;
    }
671769
function check(semiToken, expected) {
            const prevToken = sourceCode.getTokenBefore(semiToken);
            const nextToken = sourceCode.getTokenAfter(semiToken);
            const prevIsSameLine = !prevToken || astUtils.isTokenOnSameLine(prevToken, semiToken);
            const nextIsSameLine = !nextToken || astUtils.isTokenOnSameLine(semiToken, nextToken);

            if ((expected === "last" && !prevIsSameLine) || (expected === "first" && !nextIsSameLine)) {
                context.report({
                    loc: semiToken.loc,
                    message: "Expected this semicolon to be at {{pos}}.",
                    data: {
                        pos: (expected === "last")
                            ? "the end of the previous line"
                            : "the beginning of the next line"
                    },
                    fix(fixer) {
                        if (prevToken && nextToken && sourceCode.commentsExistBetween(prevToken, nextToken)) {
                            return null;
                        }

                        const start = prevToken ? prevToken.range[1] : semiToken.range[0];
                        const end = nextToken ? nextToken.range[0] : semiToken.range[1];
                        const text = (expected === "last") ? ";\n" : "\n;";

                        return fixer.replaceTextRange([start, end], text);
                    }
                });
            }
        }
113490
public function errorHandler($code, $message, $file, $line)
    {
        $this->debug->setShowBackTrace(false);
        $this->debug->onUncaughtException(new \ErrorException($message, $code, 0, $file, $line));
    }
778209
protected function getPregErrorText($code = null)
    {
        $code = $code ?: preg_last_error();

        if (!isset(self::$pregErrors[$code])) {
            $code = PREG_NO_ERROR;
        }

        return self::$pregErrors[$code];
    }
354032
protected function getLineFormatted($line, $key, $last_frame_count)
    {
        // If this is the first thing we're writing, just return the line
        if ($last_frame_count == 0) {
            return $line;
        }

        $content = '';

        // If this is the first line of the frame,
        // move the cursor up the total number of previous lines from the previous frame
        if ($key == 0) {
            $content .= $this->util->cursor->up($last_frame_count);
        }

        $content .= $this->util->cursor->startOfCurrentLine();
        $content .= $this->util->cursor->deleteCurrentLine();
        $content .= $line;

        return $content;
    }
635927
private void parseLine(State state, String line) {
        // XXX The regex does not work if the first token is blank, and I
        // don't understand why. Workaround: if it's blank, add a space,
        // and remember I added a space.
        boolean firstEmpty = false;
        if (line.startsWith(state.currentSeparator)) {
            line = " " + line;
            firstEmpty = true;
        }
        
        // Match using the parser
        state.mLineTokens.reset(line);
        int nColumn = 0;
        while (state.mLineTokens.find()) {
            // Does this line have more columns than expected?
            if (nColumn == state.nColumns) {
                state.columnMismatch = true;
                return;
            }
            
            String token;
            if (state.mLineTokens.start(2) >= 0) {
                // The token was unquoted. Check if it could be a number.
                token = state.mLineTokens.group(2);
                if (firstEmpty) {
                    token = "";
                    firstEmpty = false;
                }
                if (!isTokenNumberParsable(state, token)) {
                    state.columnNumberParsable.set(nColumn, false);
                }
            } else {
                // If quoted, always use string
                token = state.mQuote.reset(state.mLineTokens.group(1)).replaceAll("\"");
                state.columnNumberParsable.set(nColumn, false);
            }
            state.columnTokens.get(nColumn).add(token);
            nColumn++;
        }
        // Does this line have fewer columns than expected?
        if (nColumn != state.nColumns) {
            state.columnMismatch = true;
        }
    }
799164
function HandleError($code, $line, $col, $byte_index = 0)
    {
        $sample_size = 80;
        $sample_start = $byte_index - ($sample_size / 2);
        if ($sample_start < 0) {
          $sample_start = 0;
        }
        
        trigger_error('XML Parsing Error at '.$line.':'.$col. (($byte_index != 0)?' (byte index: '.$byte_index.')':''). '. Error '.$code.': '.xml_error_string($code). ' check sample which starts at position '.$sample_start.': html encoded: '.htmlentities(substr($this->xml, $sample_start, $sample_size)). ' (hex: '.bin2hex(substr($this->xml, $sample_start, $sample_size)).', raw: '.(substr($this->xml, $sample_start, $sample_size)).')');
    }
490644
public function tokenize($code)
    {
        $code = trim((string) $code);
        if (empty($code)) {
            throw new \InvalidArgumentException('Cannot tokenize empty string.');
        }

        $this->code = $code;
        $this->tokens = array();

        $tokenArray = explode(' ', $this->code);

        if (!is_array($tokenArray) || empty($tokenArray)) {
            throw new \InvalidArgumentException(
                sprintf('Cannot tokenize string: %s, please use " "(empty space for delimeter betwwen tokens)', $this->code)
            );
        }

        foreach ($tokenArray as $t) {
            if (array_key_exists($t, static::$operatorsMap)) {
                $token = new Operator(
                        $t,
                        static::$operatorsMap[$t]['priority'],
                        static::$operatorsMap[$t]['associativity']
                );
            } elseif (is_numeric($t)) {
                $token = new Token((float) $t, Token::T_OPERAND);
            }elseif('(' === $t) {
                $token = new Token($t, Token::T_LEFT_BRACKET);
            }elseif(')' === $t) {
                $token = new Token($t, Token::T_RIGHT_BRACKET);
            }elseif('' === $t) {
                continue;
            }else {
                throw new \InvalidArgumentException(sprintf('Syntax error: unknown token "%s"', $t));
            }

            $this->tokens[] = $token;
        }

        return $this->tokens;
    }
588342
public function handleFatalError($code, $description, $file = null, $line = null)
    {
        $exception = new FatalErrorException($description, $code, $file, $line);

        return $this->handle($exception);
    }
637280
function translate ($code)
    {
        if (preg_match_all("/<\?_\(\"(.*)\"\)\?>/siU", $code, $matches, PREG_SET_ORDER)) {
            foreach ($matches as $match) {
                if (isset($match[1])) {
                    $code = str_replace($match[0], gettext(stripslashes($match[1])), $code);
                }
            }
        }
        return $code;
    }
857197
private function parseAnnotation($line) {
		// Let's get the annotation text
		preg_match("/^[@]([a-zA-Z][a-zA-Z0-9]*)(.*)/", $line, $values);
		
		$annotationClass = isset($values[1])?$values[1]:null;
		$annotationParams = trim(isset($values[2])?$values[2]:null);
		
		$this->annotationsArrayAsString[$annotationClass][] = $annotationParams;		
	}
1224883
public function error($msg, Token $token = null, $code = 0)
    {
        $error = new ParserException(
            Translator::gettext($msg),
            $token,
            $code
        );
        parent::error($error);
    }