Documentation ¶
Index ¶
Constants ¶
View Source
const ( ExprMode = Mode(iota) StringMode TemplateMode )
View Source
const ( TokBad = TokenKind(-2 + iota) TokEOF TokLiteral // literal character sequence (e.g. characters in string, template text outside expr) TokTmplExprOpen TokExprOpen TokTmplExprClose TokExprClose TokWhitespace TokFieldSep TokIdxOpen TokIdxClose TokIdent TokNumber TokStrOpen TokStrClose )
View Source
const EOF = rune(-1)
Variables ¶
This section is empty.
Functions ¶
func RecoverSyntaxError ¶
func RecoverSyntaxError(to *error)
RecoverSyntaxError intercepts any SyntaxError panic and stores in *to, with no effect on other panics. Example:
func Example() (err error) { defer RecoverSyntaxError(&err) // ... code that may panic with SyntaxError here ... }
Types ¶
type Lex ¶
type Lex struct {
// contains filtered or unexported fields
}
func (*Lex) Adv ¶
func (l *Lex) Adv()
Adv moves to lex the next Token. Subsequent calls to Peek return this Token.
func (*Lex) AdvMode ¶
AdvMode is as Adv, but first switches lex to a new lexer mode. It is equivalent to, but more efficient than, calling Adv then SetMode.
func (*Lex) Peek ¶
Peek returns the next Token. Subsequent calls will return the sake Token until a call to Adv, SetMode, or AdvMode.
func (*Lex) SetMode ¶
SetMode re-lexes the characters underlying the current Token in a new lexer mode, likely changing the lexed Token. Subsequent calls to Peek return this Token.
func (*Lex) SyntaxError ¶
func (l *Lex) SyntaxError(msg string) SyntaxError
type SyntaxError ¶
type SyntaxError struct { Pos int // byte position RPos int // rune (character) position Msg string }
func (SyntaxError) Error ¶
func (s SyntaxError) Error() string
Click to show internal directories.
Click to hide internal directories.