lexer

package
v0.0.0-...-cad1e12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TokenEOF        = iota         // EOF
	TokenVararg                    // ...
	TokenSepSemi                   // ;
	TokenSepComma                  // ,
	TokenSepDot                    // .
	TokenSepColon                  // :
	TokenSepLabel                  // ::
	TokenSepLparen                 // (
	TokenSepRparen                 // )
	TokenSepLBrack                 // [
	TokenSepRBrack                 // ]
	TokenSepLcurly                 // {
	TokenSepRcurly                 // }
	TokenOpAssign                  // =
	TokenOpMinus                   // -(unm or sub)
	TokenOpWave                    // ~(not or bxor)
	TokenOpAdd                     // +
	TokenOpMul                     // *
	TokenOpDiv                     // /
	TokenOpIDiv                    // //
	TokenOpMod                     // %
	TokenOpPow                     // ^
	TokenOpBand                    // &
	TokenOpBor                     // |
	TokenOpShr                     // >>
	TokenOpShl                     // <<
	TokenOpConcat                  // ..
	TokenOpLt                      // <
	TokenOpLe                      // <=
	TokenOpGt                      // >
	TokenOpGe                      // >=
	TokenOpEq                      // ==
	TokenOpNe                      // ~=
	TokenOpLen                     // #
	TokenOpAnd                     // and
	TokenOpOr                      // or
	TokenOpNot                     // not
	TokenKwBreak                   // break
	TokenKwDo                      // do
	TokenKwElse                    // else
	TokenKwElseif                  // elseif
	TokenKwEnd                     // end
	TokenKwFalse                   // false
	TokenKwFor                     // for
	TokenKwFunction                // function
	TokenKwGoto                    // goto
	TokenKwIf                      // if
	TokenKwIn                      // in
	TokenKwLocal                   // local
	TokenKwNil                     // nil
	TokenKwRepeat                  // repeat
	TokenKwReturn                  // return
	TokenKwThen                    // then
	TokenKwTrue                    // true
	TokenKwUntil                   // until
	TokenKwWhile                   // while
	TokenIdentifier                // identifier
	TokenNumber                    // number literal
	TokenString                    // string literal
	TokenOpUnm      = TokenOpMinus // unary minus
	TokenOpSub      = TokenOpMinus // binary minus
	TokenOpBnot     = TokenOpWave  // not
	TokenOpBxor     = TokenOpWave  // xor
)

token kind

Variables

This section is empty.

Functions

func KindToString

func KindToString(kind int) string

KindToString coverts kind int to string

Types

type Lexer

type Lexer struct {
	// contains filtered or unexported fields
}

Lexer lua lexer

func NewLexer

func NewLexer(chunk, chunkName string) *Lexer

NewLexer new lua lexer

func (*Lexer) AssertNextTokenKind

func (lex *Lexer) AssertNextTokenKind(k int) (line int, token string)

AssertNextTokenKind extracts the token of the specified type

func (*Lexer) Line

func (lex *Lexer) Line() int

Line return current line of lexer

func (*Lexer) LookAhead

func (lex *Lexer) LookAhead() int

LookAhead caches next token and returns the of next token

func (*Lexer) NextToken

func (lex *Lexer) NextToken() (line, kind int, token string)

NextToken returns next token

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL