errors

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package errors defines the typed parser error used throughout the luascript front-end. Lua 5.4 has a small, focused set of failure modes, so the categories here are intentionally narrow.

Index

Constants

View Source
const (

	// EndOfFileError represents a normal EOF reached while expecting more input.
	EndOfFileError
	// UnexpectedTokenError means a token did not match what the grammar expected.
	UnexpectedTokenError
	// UnexpectedEndError means an `end` keyword appeared with nothing to close
	// (used by the REPL to detect "still typing" vs. "real syntax error").
	UnexpectedEndError
	// InvalidAssignmentError means the LHS of an `=` is not a valid var.
	InvalidAssignmentError
	// SyntaxError is the catch-all for grammatical mistakes.
	SyntaxError
)

Enums for different kinds of syntax errors.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Message string
	ErrType int
}

Error represents a parser failure with a human-readable message and a machine-readable category.

func InitError

func InitError(msg string, errType int) *Error

InitError builds an Error from a message and category.

func NewTypeParsingError

func NewTypeParsingError(tokenLiteral, targetType string, line int) *Error

NewTypeParsingError reports a literal that could not be converted to its declared numeric type (e.g. an integer literal too large for int64).

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface, returning the message verbatim. Having this here lets callers return *Error directly as an `error` while preserving the typed-introspection helpers (IsEOF etc.) for the REPL.

func (*Error) IsEOF

func (e *Error) IsEOF() bool

IsEOF reports whether the error is an end-of-file marker.

func (*Error) IsUnexpectedEmptyLine

func (e *Error) IsUnexpectedEmptyLine(stmtCount int) bool

IsUnexpectedEmptyLine reports whether the error is an unmatched `end` arising from REPL input with no preceding statements.

func (*Error) IsUnexpectedEnd

func (e *Error) IsUnexpectedEnd() bool

IsUnexpectedEnd reports whether the error is an unmatched `end`.

func (*Error) IsUnexpectedToken

func (e *Error) IsUnexpectedToken() bool

IsUnexpectedToken reports whether the error is the generic "unexpected token" category.

Jump to

Keyboard shortcuts

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