parser

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StripCR

func StripCR(b []byte, comment bool) []byte

StripCR removes carriage return characters.

Types

type Error

type Error struct {
	Pos ast.SourceFilePos
	Msg string
}

Error represents a parser error.

func (Error) Error

func (e Error) Error() string

type ErrorList

type ErrorList []*Error

ErrorList is a collection of parser errors.

func (*ErrorList) Add

func (p *ErrorList) Add(pos ast.SourceFilePos, msg string)

Add adds a new parser error to the collection.

func (ErrorList) Err

func (p ErrorList) Err() error

Err returns an error.

func (ErrorList) Error

func (p ErrorList) Error() string

func (ErrorList) Len

func (p ErrorList) Len() int

Len returns the number of elements in the collection.

func (ErrorList) Less

func (p ErrorList) Less(i, j int) bool

func (ErrorList) Sort

func (p ErrorList) Sort()

Sort sorts the collection.

func (ErrorList) Swap

func (p ErrorList) Swap(i, j int)

type Parser

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

Parser parses the Kavun source files.

func NewParser

func NewParser(file *ast.SourceFile, src []byte, trace io.Writer) *Parser

NewParser creates a Parser.

func (*Parser) ParseFile

func (p *Parser) ParseFile() (file *ast.File, err error)

ParseFile parses the source and returns an AST file unit.

type ScanMode

type ScanMode int

ScanMode represents a scanner mode.

const (
	ScanComments ScanMode = 1 << iota
	DoNotInsertSemis
)

List of scanner modes.

type Scanner

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

Scanner reads the Kavun source text.

func NewScanner

func NewScanner(file *ast.SourceFile, src []byte, errorHandler ScannerErrorHandler, mode ScanMode) *Scanner

NewScanner creates a Scanner.

func (*Scanner) Backup

func (s *Scanner) Backup() ScannerBackup

Backup returns a backup of the scanner state.

func (*Scanner) ErrorCount

func (s *Scanner) ErrorCount() int

ErrorCount returns the number of errors.

func (*Scanner) Restore

func (s *Scanner) Restore(b ScannerBackup)

Restore restores the scanner state from a backup.

func (*Scanner) Scan

func (s *Scanner) Scan() (tok token.Token, literal string, pos core.Pos)

Scan returns a token, token literal and its position.

type ScannerBackup

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

ScannerBackup represents a backup of the scanner state.

type ScannerErrorHandler

type ScannerErrorHandler func(pos ast.SourceFilePos, msg string)

ScannerErrorHandler is an error handler for the scanner.

Jump to

Keyboard shortcuts

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