errtoken

package
v0.38.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package errtoken contains standard diagnostics involving tokens, usually emitted by the lexer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ImpureString

type ImpureString struct {
	Token token.Token
	Where taxa.Place
}

ImpureString diagnoses a string literal that probably should not contain escapes or concatenation.

func (ImpureString) Diagnose

func (e ImpureString) Diagnose(d *report.Diagnostic)

Diagnose implements report.Diagnose.

type InvalidEscape

type InvalidEscape struct {
	Span source.Span // The span of the offending escape within a literal.
}

InvalidEscape diagnoses an invalid escape sequence within a string literal.

func (InvalidEscape) Diagnose

func (e InvalidEscape) Diagnose(d *report.Diagnostic)

Diagnose implements report.Diagnose.

type InvalidNumber

type InvalidNumber struct {
	Token token.Token // The offending number token.
}

errInvalidNumber diagnoses a numeric literal with invalid syntax.

func (InvalidNumber) Diagnose

func (e InvalidNumber) Diagnose(d *report.Diagnostic)

Diagnose implements report.Diagnose.

type Unexpected

type Unexpected struct {
	// The unexpected thing (may be a token or AST node).
	What source.Spanner

	// The context we're in. Should be format-able with %v.
	Where taxa.Place
	// Useful when where is an "after" position: if non-nil, this will be
	// highlighted as "previous where.Object is here"
	Prev source.Spanner

	// What we wanted vs. what we got. Got can be used to customize what gets
	// shown, but if it's not set, we call describe(what) to get a user-visible
	// description.
	Want taxa.Set
	// If set and want is empty, the snippet will repeat the "unexpected foo"
	// text under the snippet.
	RepeatUnexpected bool
	Got              any

	// If nonempty, inserting this text will be suggested at the given offset.
	Insert        string
	InsertAt      int
	InsertJustify just.Kind
	Stream        *token.Stream
}

Unexpected is a low-level parser error for when we hit a token we don't know how to handle.

func UnexpectedEOF

func UnexpectedEOF(c *token.Cursor, where taxa.Place) Unexpected

UnexpectedEOF is a helper for constructing EOF diagnostics that need to provide *no* suggestions. This is used in places where any suggestion we could provide would be nonsensical.

func (Unexpected) Diagnose

func (e Unexpected) Diagnose(d *report.Diagnostic)

type Unmatched

type Unmatched struct {
	Span    source.Span // The offending delimiter.
	Keyword keyword.Keyword

	// If present, this indicates that we did match with another brace delimiter, but it
	// was of the wrong kind
	Mismatch source.Span

	// If present, this is a brace delimiter we think we *should* have matched.
	ShouldMatch source.Span
}

Unmatched diagnoses a delimiter for which we found one half of a matched delimiter but not the other.

func (Unmatched) Diagnose

func (e Unmatched) Diagnose(d *report.Diagnostic)

Diagnose implements report.Diagnose.

Jump to

Keyboard shortcuts

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