token

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Keywords = map[string]Kind{
	"const": Const,
	"let":   Let,
	"if":    If,
	"else":  Else,

	"return": Return,

	"true":  Boolean,
	"false": Boolean,
	"null":  Null,
}

Functions

This section is empty.

Types

type Kind

type Kind uint16
const (
	Illegal Kind = iota
	EOF
	Comment

	// --- Dữ liệu (Literals) ---
	Identifier // work, db, cleanup
	Number     // 123, 0.5
	String     // "02:00", 'logs'
	Template   // `Hello ${name}`
	Boolean    // true, false
	Null

	// --- Truy cập & Chaining ---
	Assign   // =
	Dot      // .
	Spread   // ...
	FatArrow // =>

	// --- Dấu ngoặc ---
	LeftParen    // (
	RightParen   // )
	LeftBrace    // {
	RightBrace   // }
	LeftBracket  // [
	RightBracket // ]

	// --- Ngắt câu & Phân tách ---
	Comma     // ,
	Semicolon // ;
	Colon     // :

	// --- Logic & So sánh ---
	LogicalAnd     // &&
	LogicalOr      // ||
	NullCoalescing // ??
	LogicalNot     // !
	Equal          // ==
	NotEqual       // !=

	Greater      // >
	GreaterEqual //>=
	Less         // <
	LessEqual    //<=

	// --- Số học ---
	Plus  // +
	Minus // -
	Star  // *
	Slash // /

	// --- Từ khóa ---
	Const
	Let
	If
	Else
	Return
)

func LookupIdentifier

func LookupIdentifier(ident string) Kind

func (Kind) IsOperator

func (k Kind) IsOperator() bool

func (Kind) Precedence

func (k Kind) Precedence() int

func (Kind) String

func (k Kind) String() string

String trả về chuỗi đại diện cho Kind (Hữu ích cho Debug/Error Reporting)

type Token

type Token struct {
	Value    value.Value
	Position int32
	Length   int16
	Kind     Kind
}

func (Token) String

func (t Token) String() string

String trả về nội dung text của Token (giúp hiển thị khi in AST)

Jump to

Keyboard shortcuts

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