Documentation
¶
Overview ¶
Package parser provides the lexer and parser for the English programming language.
Package parser – human-readable error messages and hint strings.
Every message that can be shown to a programmer when their code contains a syntax error lives here. Edit this file to improve wording, add extra examples, or translate the text – no other file needs to change.
Convention
- msg* constants are the primary error description ("what went wrong").
- hint* constants give corrective guidance ("how to fix it").
- msgFmt* / hintFmt* constants are fmt.Sprintf format strings whose %s / %q placeholders are filled in by the call site using runtime token values.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Lexer ¶
Lexer is a type alias for the shared tokeniser.Lexer so that all existing callers (cmd, vm, lsp, transpiler …) continue to work without change while both the parser and the highlight package share a single tokenisation implementation.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser transforms tokens into an AST
type SyntaxError ¶
type SyntaxError struct {
Msg string // human-readable description of what went wrong
Line int // 1-based source line (0 = unknown)
Col int // 1-based source column (0 = unknown)
Hint string // optional guidance for the programmer
}
SyntaxError is a structured parse-time error. It satisfies the stacktraces.SyntaxError interface so the renderer can display it with a dedicated "Syntax Error" header, line/column information, and an optional user-friendly hint.
func (*SyntaxError) Error ¶
func (e *SyntaxError) Error() string
Error implements the standard error interface.
func (*SyntaxError) SyntaxCol ¶
func (e *SyntaxError) SyntaxCol() int
SyntaxCol implements stacktraces.SyntaxError.
func (*SyntaxError) SyntaxHint ¶
func (e *SyntaxError) SyntaxHint() string
SyntaxHint implements stacktraces.SyntaxError.
func (*SyntaxError) SyntaxLine ¶
func (e *SyntaxError) SyntaxLine() int
SyntaxLine implements stacktraces.SyntaxError.
func (*SyntaxError) SyntaxMessage ¶
func (e *SyntaxError) SyntaxMessage() string
SyntaxMessage implements stacktraces.SyntaxError.