parser

package
v0.0.0-...-1dd1f65 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package parser contains logic for parsing Herd-style observations.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoImpl occurs if the parser's impl is nil.
	ErrNoImpl = errors.New("parser not supplied with valid implementation")
	// ErrBadState occurs if the parser somehow gets into an unknown state.
	ErrBadState = errors.New("unknown state")
	// ErrBadTransition occurs if the parser somehow performs a bad transition.
	ErrBadTransition = errors.New("invalid state transition")

	// ErrBadStateCount occurs if the number of states is invalid.
	ErrBadStateCount = errors.New("bad state count")
	// ErrInputEmpty occurs if the input to the parser runs out before anything is parsed.
	ErrInputEmpty = errors.New("input was empty")
	// ErrNoTest occurs if the input to the parser runs out before the start of a test is parsed.
	ErrNoTest = errors.New("input ended before reaching test")
	// ErrNoStates occurs if the input to the parser runs out before any states are parsed.
	ErrNoStates = errors.New("input ended with no state block")
	// ErrNotEnoughStates occurs if the input to the parser runs out midway through the expected number of states.
	ErrNotEnoughStates = errors.New("input ended while expecting more states")
	// ErrNoSummary occurs if the input to the parser runs out before the summary is parsed.
	ErrNoSummary = errors.New("input ended while expecting summary")

	// ErrBadTestType occurs if the test-type line is badly formed.
	ErrBadTestType = errors.New("malformed test-type line")
	// ErrBadSummary occurs if the summary line is badly formed.
	ErrBadSummary = errors.New("malformed summary line")
	// ErrBadStateLine occurs if the state line is badly formed.
	// It may be used by BackendImpl implementations.
	ErrBadStateLine = errors.New("malformed state line")
)

Functions

func Parse

func Parse(i Impl, r io.Reader, o *obs.Obs) error

Parse parses an observation from r into o using i.

Types

type Impl

type Impl interface {
	// ParseStateCount parses a potential state-count line whose raw fields are fields.
	// If the line is a state count, it returns (k, true, nil) where k is the state count;
	// if the line is to be skipped, it returns (_, false, nil); else, an error.
	ParseStateCount(fields []string) (k uint64, ok bool, err error)

	// ParseStateLine parses the state line whose raw fields are fields.
	ParseStateLine(tt TestType, fields []string) (*StateLine, error)

	// ParsePreTestLine extracts any flags implied by the pre-'Test' line whose raw fields are fields.
	//
	// Most implementations can safely pull this to (0, nil).
	// An example of an exception is Rmem, where the presence of the phrase 'PARTIAL RESULTS' before the 'Test' line
	// implies the 'partial' flag.
	ParsePreTestLine(fields []string) (obs.Flag, error)
}

Impl describes the parser functionality that differs between Herdtools-style backends.

type StateLine

type StateLine struct {
	// State is the state parsed, less the valuation.
	State obs.State
	// Rest is the remaining fields of the state line, which should be of the form 'x=y;'.
	Rest []string
}

StateLine is the struct that an implementation of the Herdtools parser must return when parsing a state line.

type TestType

type TestType int

TestType is the type of test we're parsing.

const (
	// None states that we haven't parsed a test type yet.
	None TestType = iota
	// Allowed is the 'allowed' test type.
	Allowed
	// Required is the 'required' test type.
	Required
)

func (TestType) Flags

func (t TestType) Flags() obs.Flag

Flags returns any observation flags that correspond to this test type.

Jump to

Keyboard shortcuts

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