lexer

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

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(source string) *Lexer

func (*Lexer) ParseSource

func (l *Lexer) ParseSource() ([]Token, error)

type LexerError

type LexerError struct {
	Message string
	Line    int
}

func (LexerError) Error

func (l LexerError) Error() string

type Token

type Token struct {
	Type    TokenType
	Literal string
	Line    int
}

type TokenType

type TokenType string
const (
	TK_KEYWORD TokenType = "KEYWORD"
	TK_IDENT   TokenType = "IDENTIFIER"

	TK_INTEGER      TokenType = "INTEGER"
	TK_FLOAT        TokenType = "FLOAT"
	TK_CHAR_LITERAL TokenType = "CHAR"

	TK_LPAREN TokenType = "("
	TK_RPAREN TokenType = ")"
	TK_LBRACE TokenType = "{"
	TK_RBRACE TokenType = "}"

	TK_SEMICOLON TokenType = ";"

	TK_EQUAL TokenType = "="
	TK_DASH  TokenType = "-"
	TK_PLUS  TokenType = "+"
	TK_STAR  TokenType = "*"
	TK_SLASH TokenType = "/"

	TK_PLUS_EQUAL   TokenType = "+="
	TK_MINUS_EQUAL  TokenType = "-="
	TK_TIMES_EQUAL  TokenType = "*="
	TK_DIVIDE_EQUAL TokenType = "/="

	TK_EOF TokenType = "EOF"
)

Jump to

Keyboard shortcuts

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