errors

package
v4.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: MIT Imports: 2 Imported by: 22

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InternalCommunicationProtocol

type InternalCommunicationProtocol struct {
	Type   InternalCommunicationProtocolTypes
	RValue *shared.RuntimeValue
}

type InternalCommunicationProtocolTypes

type InternalCommunicationProtocolTypes int

--- InternalCommunicationProtocol ---

const (
	ICP_Return InternalCommunicationProtocolTypes = iota
	ICP_Continue
	ICP_Break
)

type LexerError

type LexerError struct {
	Character rune     // The problematic character
	Pos       Position // Position (Line/Col) of the character
	Message   string   // Optional: for specific messages like "unclosed comment"
}

--- LexerError ---

func NewLexerError

func NewLexerError(char rune, pos Position) *LexerError

NewLexerError creates a new LexerError for an unexpected character (Message will be empty).

func NewLexerErrorf

func NewLexerErrorf(pos Position, charForContext rune, format string, args ...interface{}) *LexerError

NewLexerErrorf creates a new LexerError with a custom message. 'charForContext' can be the opening delimiter (e.g., '/' for unclosed comment) or 0 if not relevant. The Message field will be populated by the formatted string.

func (*LexerError) Error

func (e *LexerError) Error() string

type ParserError

type ParserError struct {
	Token   string   // The literal of the unexpected token
	Start   Position // Start position of the token
	End     Position // End position of the token
	Message string   // Optional: More specific message about why it's an error
}

--- ParserError --- Often, ParserError is very similar to SyntaxError.

func NewParserError

func NewParserError(tokenLiteral string, start, end Position) *ParserError

NewParserError creates a new ParserError for an unexpected token.

func NewParserErrorf

func NewParserErrorf(start, end Position, format string, args ...interface{}) *ParserError

NewParserErrorf creates a new ParserError with a custom formatted message.

func (*ParserError) Error

func (e *ParserError) Error() string

type Position

type Position struct {
	Line int // 1-based line number
	Col  int // 1-based column number
}

type RuntimeError

type RuntimeError struct {
	Message                       string
	InternalCommunicationProtocol *InternalCommunicationProtocol
}

--- RuntimeError ---

func (*RuntimeError) Error

func (e *RuntimeError) Error() string

type SyntaxError

type SyntaxError struct {
	Expected string   // What was expected
	Got      string   // What was actually found (e.g., token literal or type)
	Start    Position // Start position of the problematic syntax
	End      Position // End position of the problematic syntax
	Message  string   // Optional additional message
}

--- SyntaxError ---

func NewSyntaxError

func NewSyntaxError(expected string, gotLiteral string, start, end Position) *SyntaxError

NewSyntaxError creates a new SyntaxError. 'gotLiteral' is often the token.Literal that caused the error. 'start' and 'end' define the span of the problematic token/syntax.

func NewSyntaxErrorf

func NewSyntaxErrorf(start, end Position, format string, args ...interface{}) *SyntaxError

NewSyntaxErrorf creates a new SyntaxError with a custom message.

func (*SyntaxError) Error

func (e *SyntaxError) Error() string

Jump to

Keyboard shortcuts

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