lexer

package
v0.0.0-...-f836197 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2025 License: EPL-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STATE_CODE   = 0
	STATE_STRING = 1
)
View Source
const (
	ILLEGAL = "ILLEGAL"
	EOF     = "EOF"

	// Identifiers + Literals
	IDENT  = "IDENT"  // add, foobar, x, y
	INT    = "INT"    // 1343456
	FLOAT  = "FLOAT"  // 123.45
	STRING = "STRING" // "foobar"

	// Operators
	ASSIGN   = "="
	PLUS     = "+"
	MINUS    = "-"
	BANG     = "!"
	ASTERISK = "*"
	SLASH    = "/"

	LT     = "<"
	GT     = ">"
	EQ     = "=="
	NOT_EQ = "!="
	LTE    = "<="
	GTE    = ">="

	// Bitwise Operators
	AND    = "&"
	OR     = "|"
	XOR    = "^"
	TILDE  = "~" // Bitwise NOT
	LSHIFT = "<<"
	RSHIFT = ">>"

	// Delimiters
	COMMA     = ","
	SEMICOLON = ";"
	COLON     = ":"
	DOT       = "."

	LPAREN   = "("
	RPAREN   = ")"
	LBRACE   = "{"
	RBRACE   = "}"
	LBRACKET = "["
	RBRACKET = "]"

	// Interpolation
	INTERP_START = "#{"

	// Keywords
	FUNGSI     = "FUNGSI"
	JIKA       = "JIKA"
	ATAU_JIKA  = "ATAU_JIKA"
	LAINNYA    = "LAINNYA"
	KEMBALIKAN = "KEMBALIKAN"
	BENAR      = "BENAR"
	SALAH      = "SALAH"
	KOSONG     = "KOSONG"
	AKHIR      = "AKHIR"
	SELAMA     = "SELAMA"
	DAN        = "DAN"
	ATAU       = "ATAU"
	AMBIL      = "AMBIL"
	DARI       = "DARI"
	BERHENTI   = "BERHENTI"
	LANJUT     = "LANJUT"
	STRUKTUR   = "STRUKTUR"
	COMMENT    = "COMMENT"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Lexer

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

func New

func New(input string) *Lexer

func (*Lexer) Input

func (l *Lexer) Input() string

func (*Lexer) NextToken

func (l *Lexer) NextToken() Token

type Token

type Token struct {
	Type            TokenType
	Literal         string
	Line            int
	Column          int
	HasLeadingSpace bool
}

type TokenType

type TokenType string

func LookupIdent

func LookupIdent(ident string) TokenType

LookupIdent checks if an identifier is a keyword (case-insensitive)

Jump to

Keyboard shortcuts

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