Documentation ¶
Index ¶
Constants ¶
View Source
const ( LEXER_ERROR_UNEXPECTED_EOF string = "Unexpected end of file" LEXER_ERROR_UNEXPECTED_RUNE string = "Unexpected character" LEXER_ERROR_UNEXPECTED_NEWLINE string = "Unexpected newline" LEXER_ERROR_MISSING_RIGHT_BRACE string = "Missing closing section brace" LEXER_ERROR_MISSING_NEWLINE_BEFORE_LEFT_BRACE string = "Missing newline before start of section" LEXER_ERROR_MISSING_NEWLINE_BEFORE_EOF string = "Missing newline before end of file" LEXER_ERROR_MISSING_RIGHT_PARENTHESIS string = "Missing closing parenthesis" LEXER_ERROR_START_OF_TOKEN_AFTER_EOF string = "Start of current token is after EOF" LEXER_ERROR_POSITION_AFTER_EOF string = "Lexer position is after EOF" LEXER_ERROR_NIL_LEXING_FUNCTION string = "Cannot call nil lexing function" )
View Source
const ( RUNE_EOF rune = 0 RUNE_ERROR rune = utf8.RuneError RUNE_LEFT_PARENTHESIS rune = '(' RUNE_RIGHT_PARENTHESIS rune = ')' RUNE_LEFT_BRACKET rune = '[' RUNE_RIGHT_BRACKET rune = ']' RUNE_LEFT_BRACE rune = '{' RUNE_RIGHT_BRACE rune = '}' RUNE_COLUMN rune = ':' RUNE_NEWLINE rune = '\n' )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
func NewLexer ¶
func NewLexer(input string, lexingFunc LexingFunction) *Lexer
NewLexer creates a new lexer
func (*Lexer) Errorf ¶
func (lexer *Lexer) Errorf(format string, args ...interface{}) LexingFunction
Errorf pushes an error token in the token channel. Errorf is a lexing function.
func (*Lexer) MoveAfterRune ¶
MoveAfterRune moves position just after next rune
func (*Lexer) PeekRune ¶
PeekRune returns the next rune in input. Returns EOF if OEF is reached. Returns ERROR if error occured while reading next rune.
func (*Lexer) SkipWhitespace ¶
func (lexer *Lexer) SkipWhitespace()
SkipWhitespace moves position to the next non-whitespaces rune. Non-whitespace runes are all runes for which utf8.IsSpace returns false. If EOF is reached, pushes an EOF
type Token ¶
type Token struct { Type TokenType Value string Start TokenPosition End TokenPosition }
Token
type TokenPosition ¶
func (*TokenPosition) String ¶
func (tokenPosition *TokenPosition) String() string
Click to show internal directories.
Click to hide internal directories.