parser

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoTargetLanguage = errors.New("no target source language was set")
)

Functions

This section is empty.

Types

type Option

type Option func(p *Options)

Option is a more atomic to configure the different Options rather than passing the entire Options struct.

func Go

func Go(ctx context.Context) Option

Go returns the options.Option to run the parser targeting golang source code

func Include

func Include(dirs ...string) Option

Include configure the parser to parse the given included directories SourceFile and SourceContent will override this, if present.

func Logger

func Logger(logger *logging.Logger) Option

Logger configure the parser's logger

func Recursive

func Recursive(recursive bool) Option

func Strict

func Strict(strict bool) Option

type Options

type Options struct {
	// TargetLanguage is the language targeted by the parser, i.e: go.
	TargetLanguage language.Target

	// IncludedDirs is the array containing all the directories that will be parsed by the parser.
	// SourceFile and SourceContent will override this, if present.
	// Option: func Include(dirs ...string) Option
	IncludedDirs []string

	// Logger is the parser's logger
	// Option: func Logger(logger *logging.Logger) Option
	Logger *logging.Logger

	// Strict set the parser to error hard on errors rather than keep processing
	Strict bool

	// Recursive set the parser to recursively parser the target directories
	Recursive bool
}

Options is a struct contains all the configurations available for the parser

type Parser

type Parser struct {
	// Opts contains the different options available to the parser.
	// These are applied by the parser constructor during initialization
	Opts *Options
}

Parser parses source files containing the sloth definitions

func New

func New(opts ...Option) *Parser

New creates a new instance of the parser. See options.Option for more info on the available configuration.

func (*Parser) AnnotateAllErrors

func (p *Parser) AnnotateAllErrors(ctx context.Context, wrapErrors, annotateOnlyTodos bool) error

AnnotateErrors parses the data source for error declarations using the given parser configurations and returns them.

func (*Parser) AnnotateSourceErrors

func (p *Parser) AnnotateSourceErrors(ctx context.Context, filename string, wrapErrors, annotateOnlyTodos bool) error

AnnotateErrors parses the data source for error declarations using the given parser configurations and returns them.

func (*Parser) ParseAllSources

func (p *Parser) ParseAllSources(ctx context.Context) ([]*api.Manifest, error)

ParseAllSources parses the data source for the target annotations using the given parser configurations and returns a parsed specification.

func (*Parser) ParseSource

func (p *Parser) ParseSource(ctx context.Context, content io.Reader) (*api.Manifest, error)

ParseSource parses the data source for the target annotations using the given parser configurations and returns a parsed specification.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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