errors

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Type     ErrorType      `json:"type"`
	Message  string         `json:"message"`
	Position lexer.Position `json:"position"`
	Source   string         `json:"source,omitempty"`
}

Error 表示解析错误

func NewLexicalError

func NewLexicalError(message string, pos lexer.Position) *Error

NewLexicalError 创建词法错误

func NewSemanticError

func NewSemanticError(message string, pos lexer.Position) *Error

NewSemanticError 创建语义错误

func NewSyntaxError

func NewSyntaxError(message string, pos lexer.Position) *Error

NewSyntaxError 创建语法错误

func (*Error) Error

func (e *Error) Error() string

Error 实现 error 接口

func (*Error) PrintFormatted

func (e *Error) PrintFormatted() string

PrintFormatted 格式化打印错误(带源代码上下文)

func (*Error) String

func (e *Error) String() string

String 返回错误的字符串表示

func (*Error) WithSource

func (e *Error) WithSource(source string) *Error

WithSource 添加源代码上下文

type ErrorList

type ErrorList []*Error

ErrorList 错误列表

func (*ErrorList) Add

func (el *ErrorList) Add(err *Error)

Add 添加错误

func (*ErrorList) AddLexicalError

func (el *ErrorList) AddLexicalError(message string, pos lexer.Position)

AddLexicalError 添加词法错误

func (*ErrorList) AddSemanticError

func (el *ErrorList) AddSemanticError(message string, pos lexer.Position)

AddSemanticError 添加语义错误

func (*ErrorList) AddSyntaxError

func (el *ErrorList) AddSyntaxError(message string, pos lexer.Position)

AddSyntaxError 添加语法错误

func (ErrorList) Count

func (el ErrorList) Count() int

Count 返回错误数量

func (ErrorList) Error

func (el ErrorList) Error() string

Error 实现 error 接口

func (ErrorList) FilterByType

func (el ErrorList) FilterByType(errorType ErrorType) ErrorList

FilterByType 按类型过滤错误

func (ErrorList) GetLexicalErrors

func (el ErrorList) GetLexicalErrors() ErrorList

GetLexicalErrors 获取词法错误

func (ErrorList) GetSemanticErrors

func (el ErrorList) GetSemanticErrors() ErrorList

GetSemanticErrors 获取语义错误

func (ErrorList) GetSyntaxErrors

func (el ErrorList) GetSyntaxErrors() ErrorList

GetSyntaxErrors 获取语法错误

func (ErrorList) HasErrors

func (el ErrorList) HasErrors() bool

HasErrors 检查是否有错误

func (ErrorList) String

func (el ErrorList) String() string

String 返回所有错误的字符串表示

type ErrorReporter

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

ErrorReporter 错误报告器

func NewErrorReporter

func NewErrorReporter(source string) *ErrorReporter

NewErrorReporter 创建新的错误报告器

func (*ErrorReporter) Clear

func (er *ErrorReporter) Clear()

Clear 清除所有错误

func (*ErrorReporter) GetErrorCount

func (er *ErrorReporter) GetErrorCount() int

GetErrorCount 获取错误数量

func (*ErrorReporter) GetErrors

func (er *ErrorReporter) GetErrors() ErrorList

GetErrors 获取所有错误

func (*ErrorReporter) HasErrors

func (er *ErrorReporter) HasErrors() bool

HasErrors 检查是否有错误

func (*ErrorReporter) Report

func (er *ErrorReporter) Report(err *Error)

Report 报告错误

func (*ErrorReporter) ReportLexicalError

func (er *ErrorReporter) ReportLexicalError(message string, pos lexer.Position)

ReportLexicalError 报告词法错误

func (*ErrorReporter) ReportSemanticError

func (er *ErrorReporter) ReportSemanticError(message string, pos lexer.Position)

ReportSemanticError 报告语义错误

func (*ErrorReporter) ReportSyntaxError

func (er *ErrorReporter) ReportSyntaxError(message string, pos lexer.Position)

ReportSyntaxError 报告语法错误

type ErrorType

type ErrorType int

ErrorType 错误类型

const (
	SyntaxError ErrorType = iota
	LexicalError
	SemanticError
)

Jump to

Keyboard shortcuts

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