Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasLessPrecedence ¶
HasLessPrecedence checks if a current token has lower precedence than the next. There is a specific ordering in the iota (lower numbers = higher precedence) indicating whether the operator has more precedence or not.
func IsTerminal ¶
IsTerminal checks wether a specific token is a terminal token meaning it can't be matched in the grammar.
Types ¶
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer is a lexer that will parse an input string into tokens for consumption by a grammar parser.
type TokType ¶
type TokType int
TokType is an enum of token types that can be parsed by the lexer. Order matters here for non terminals with a lower number meaning a higher precedence.
const ( // terminal characters TErr TokType = iota TLiteral TQuoted TRegexp // precedence of operators. Order matters here. This might need to be abstracted // to a grammar specific precedence but for now it is fine here. TEqual TGreater TLess TColon TPlus TMinus TTilde TCarrot TNot TAnd TOr TRParen TLParen // operators that do not have a set precedence because we specifically handle them // due to ambiguities in the grammar TLCurly TRCurly TTO TLSquare TRSquare // start and end operators TEOF TStart )
types of tokens that can be parsed
Click to show internal directories.
Click to hide internal directories.