internal

package
v0.0.0-...-fa0b8d5 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

func Compile()

func Run

func Run(source string)

func RunFile

func RunFile(input string, output string)

func RunRepl

func RunRepl()

Types

type Scanner

type Scanner struct {
	Source  string // The consumed line
	Tokens  []Token
	Start   uint16 // Start of each token
	Current uint16 // Current char position in the line
	Line    uint16
}

func NewScanner

func NewScanner(source string) *Scanner

func (*Scanner) ScanToken

func (s *Scanner) ScanToken()

func (*Scanner) ScanTokens

func (s *Scanner) ScanTokens() []Token

type Token

type Token struct {
	TokenType TokenType
	Word      string // individual word
	Value     any    // individual word
	Line      uint16
}

func NewToken

func NewToken(tokenType TokenType, word string, value string, line uint16) Token

func (Token) String

func (t Token) String() string

type TokenType

type TokenType byte
const (
	// Single-character tokens
	LEFT_PAREN TokenType = iota
	RIGHT_PAREN
	LEFT_BRACE
	RIGHT_BRACE
	COMMA
	DOT
	MINUS
	PLUS
	SEMICOLON
	SLASH
	STAR

	// One or two character tokens
	BANG
	BANG_EQUAL
	EQUAL
	EQUAL_EQUAL
	GREATER
	GREATER_EQUAL
	LESS
	LESS_EQUAL

	// Literals
	BOOL
	IDENTIFIER
	NUMBER
	STRING

	// Keywords/Identifiers
	AND
	CLASS
	CONST
	ELSE
	EXTENDS
	FALSE
	FOR
	FUNC
	IF
	LET
	NULL
	OR
	PRINT
	RETURN
	THIS
	TRUE

	EOF
)

func GetIdentifier

func GetIdentifier(text string) TokenType

type TokenValue

type TokenValue interface {
	string | float64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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