Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLexSpec ¶
func NewLexSpec(spec *spec.LexicalSpec) *lexSpec
Types ¶
type LexSpec ¶
type LexSpec interface { InitialMode() ModeID Pop(mode ModeID, modeKind ModeKindID) bool Push(mode ModeID, modeKind ModeKindID) (ModeID, bool) ModeName(mode ModeID) string InitialState(mode ModeID) StateID NextState(mode ModeID, state StateID, v int) (StateID, bool) Accept(mode ModeID, state StateID) (ModeKindID, bool) KindIDAndName(mode ModeID, modeKind ModeKindID) (KindID, string) }
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
type LexerOption ¶
func DisableModeTransition ¶
func DisableModeTransition() LexerOption
DisableModeTransition disables the active mode transition. Thus, even if the lexical specification has the push and pop operations, the lexer doesn't perform these operations. When the lexical specification has multiple modes, and this option is enabled, you need to call the Lexer.Push and Lexer.Pop methods to perform the mode transition. You can use the Lexer.Mode method to know the current lex mode.
type Token ¶
type Token struct { // ModeID is an ID of a lex mode. ModeID ModeID // KindID is an ID of a kind. This is unique among all modes. KindID KindID // ModeKindID is an ID of a lexical kind. This is unique only within a mode. // Note that you need to use KindID field if you want to identify a kind across all modes. ModeKindID ModeKindID // Row is a row number where a lexeme appears. Row int // Col is a column number where a lexeme appears. // Note that Col is counted in code points, not bytes. Col int // Lexeme is a byte sequence matched a pattern of a lexical specification. Lexeme []byte // When this field is true, it means the token is the EOF token. EOF bool // When this field is true, it means the token is an error token. Invalid bool }
Token representes a token.
Click to show internal directories.
Click to hide internal directories.