token

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2021 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LowestPrec  = 0 // non-operators
	UnaryPrec   = 7
	HighestPrec = 8
)

Variables

This section is empty.

Functions

func IsIdentifier

func IsIdentifier(name string) bool

func IsKeyword

func IsKeyword(name string) bool

Types

type File

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

func NewFile

func NewFile(name string, size int) *File

func (*File) AddLine

func (f *File) AddLine(offset int)

func (*File) LineCount

func (f *File) LineCount() int

func (*File) Name

func (f *File) Name() string

func (*File) Position

func (f *File) Position(offset int) (pos Position)

func (*File) ValidateOffset

func (f *File) ValidateOffset(offset int) int

type Position

type Position struct {
	Filename string
	Offset   int
	Line     int
	Column   int
}

func (Position) String

func (pos Position) String() string

type Token

type Token int
const (
	ILLEGAL Token = iota
	EOF
	// type specific
	COMMENT

	// order of the below token is important to has the same order as
	// TINTEGER, TFLOAT ...etc
	INTEGER // 125
	FLOAT   // 1.23
	BOOLEAN // true, false
	STRING  // 'text', "text", `text`, text
	ARRAY   // {1:2, 3:2}
	MAP     // [1, 2, 3]
	// none order needed
	IDENT      // name, variable
	STRING_ITP // sample $A text

	ADD            // +
	SUB            // -
	MUL            // *
	QUO            // /
	REM            // %
	ADD_ASSIGN     // +=
	SUB_ASSIGN     // -=
	MUL_ASSIGN     // *=
	QUO_ASSIGN     // /=
	REM_ASSIGN     // %=
	INC            // ++
	DEC            // --
	AND            // &
	LAND           // &&
	OR             // |
	LOR            // ||
	XOR            // ^
	SHL            // <<
	SHR            // >>
	AND_NOT        // &^
	AND_ASSIGN     // &=
	OR_ASSIGN      // |=
	AND_NOT_ASSIGN // &^=
	ASSIGN         // =
	LAMBDA         // =>
	NOT            // !
	EQL            // ==
	NEQ            // !=
	LSS            // <
	LEQ            // <=
	GTR            // >
	GEQ            // >=
	READ_FROM      // <
	WRITE_TO       // >
	APPEND_TO      // >>
	AT             // @
	HASH           // #
	VAR            // $
	QES            // ?
	DQS            // ??

	LBRACK // [
	LBRACE // {
	RBRACK // ]
	RBRACE // }
	LPAREN // (
	RPAREN // )
	COMMA  // ,
	COLON  // :
	LF     // \n,\r,\r\n: linefeed

	FOR
	IS
	IF
	ELSE
	RETURN
	IN
	EXIT
	RANGE
	SIZEOF
	BREAK
	CONTINUE
	INCLUDE
	DELETE

	TINTEGER
	TFLOAT
	TBOOLEAN
	TSTRING
	TARRAY
	TMAP
	TOBJECT
)

func Lookup

func Lookup(ident string, tok Token) Token

func (Token) IsComparison

func (tok Token) IsComparison() bool

func (Token) IsKeyword

func (tok Token) IsKeyword() bool

func (Token) IsLiteral

func (tok Token) IsLiteral() bool

func (Token) IsLogicOperator

func (tok Token) IsLogicOperator() bool

func (Token) IsOperator

func (tok Token) IsOperator() bool

func (Token) Kind

func (tok Token) Kind() reflect.Kind

func (Token) Precedence

func (op Token) Precedence() int

func (Token) String

func (t Token) String() string

func (Token) Type

func (tok Token) Type() int

Jump to

Keyboard shortcuts

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