Source File
token.go
Belonging Package
github.com/pancsta/gochickpeas/gql/internal/parser
// Token kinds and the parse error type for the hand-written GQL lexer.package parserimport// TokKind discriminates a token.type TokKind uint8const (// TokEOF terminates the stream.TokEOF TokKind = iota// TokIdent is an identifier or (case-insensitive) keyword; Text keeps// the original spelling.TokIdent// TokInt is an integer literal.TokInt// TokFloat is a float literal (digits '.' digits).TokFloat// TokStr is a quoted string; Text is the content, no escape processing.TokStr// TokParam is $name; Text is the name (not reserved-word checked).TokParam// Punctuation and operators.TokLParen // (TokRParen // )TokLBracket // [TokRBracket // ]TokLBrace // {TokRBrace // }TokComma // ,TokDot // .TokDotDot // ..TokQuestionTokPercentTokColon // :TokPipe // |TokAmp // &TokBang // !TokEq // =TokNeq // <>TokLt // <TokLte // <=TokGt // >TokGte // >=TokPlus // +TokMinus // -TokStar // *TokSlash // /)// Token is one lexed token; Pos is the byte offset in the input.type Token struct {Kind TokKindText stringPos int}// Error is a parse error with the byte offset it was detected at. The root// gql package wraps it with the ErrParse sentinel (this package cannot// import gql -- that would be an import cycle).type Error struct {Pos intMsg string}// Error formats the message with its position.func ( *Error) () string { return fmt.Sprintf("at offset %d: %s", .Pos, .Msg) }// errf builds a positioned parse error.func errf( int, string, ...any) *Error {return &Error{Pos: , Msg: fmt.Sprintf(, ...)}}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |