listener

package
v0.8.17 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package listener adds semantic error handling to a standard antlr.DiagnosticListener and conforms to the go error handling infrastructure

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Diagnostic

type Diagnostic struct {
	Type    string
	Path    string
	Line    int
	Column  int
	Message string
}

Diagnostic represents a locatable error in an FSE spec

func (Diagnostic) String

func (d Diagnostic) String() string

type Listener

type Listener struct {
	Path string
	*antlr.DiagnosticErrorListener
	Diagnostics []Diagnostic
}

Listener records and logs syntax errors produced by the antlr4 parser

func New

func New(path string) *Listener

New creates a new Listener

func (*Listener) Error

func (el *Listener) Error() string

Error makes Listener itself an error

func (*Listener) ErrorCount

func (el *Listener) ErrorCount() int

ErrorCount counts the number of Diagnostic messages

func (*Listener) SemErr

func (el *Listener) SemErr(
	offendingToken antlr.Token,
	msg string,
)

SemErr logs a semantic error

func (*Listener) SemanticError

func (el *Listener) SemanticError(
	line, column int,
	msg string,
)

SemanticError logs a semantic error

func (*Listener) SyntaxError

func (el *Listener) SyntaxError(
	recognizer antlr.Recognizer,
	offendingSymbol interface{},
	line, column int,
	msg string,
	e antlr.RecognitionException,
)

SyntaxError implements an interface method of antlr.DiagnosticListener

Jump to

Keyboard shortcuts

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