2024 日本 PHP 研討會

Parle\Lexer 類別

(PECL parle >= 0.5.1)

簡介

單狀態詞法分析器類別。詞彙可以動態定義。如果特定的詞法分析器實例打算與 Parle\Parser 一起使用,則需要從那裡取得權杖 ID。否則,可以提供任意權杖 ID。如果不需要多個狀態,這個詞法分析器可以比 Parle\RLexer 提供一定的效能優勢。請注意,Parle\RParser 與此詞法分析器不相容。

類別概要

class Parle\Lexer {
/* 常數 */
const int ICASE = 1;
const int DOT_NOT_LF = 2;
const int DOT_NOT_CRLF = 4;
const int SKIP_WS = 8;
const int MATCH_ZERO_LEN = 16;
/* 屬性 */
public bool $bol = false;
public int $flags = 0;
public int $state = 0;
public int $marker = 0;
public int $cursor = 0;
/* 方法 */
public advance(): void
public build(): void
public callout(int $id, callable $callback): void
public consume(string $data): void
公開 dump(): void
公開 insertMacro(字串 $name, 字串 $regex): void
公開 push(字串 $regex, 整數 $id): void
公開 reset(整數 $pos): void
}

屬性

bol

輸入開頭旗標。

flags

Lexer 旗標。

state

目前 Lexer 狀態,唯讀。

marker

最新 token 比對的位置,唯讀。

cursor

目前輸入位元偏移量,唯讀。

目錄

新增註釋

使用者貢獻的註釋

此頁面沒有使用者貢獻的註釋。
To Top