driver

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2017 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDecodingRequest  = errors.NewKind("error decoding request")
	ErrEncodingResponse = errors.NewKind("error encoding response")
)

Functions

func FillLineColFromOffset

func FillLineColFromOffset(data []byte, n *uast.Node) error

FillLineColFromOffset gets the original source code and its parsed form as *Node and fills every Line and Column field using its Offset.

func FillOffsetFromLineCol

func FillOffsetFromLineCol(data []byte, n *uast.Node) error

FillOffsetFromLineCol gets the original source code and its parsed form as *Node and fills every Offset field using its Line and Column.

Types

type Client

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

Client is a client to communicate with a driver.

func NewClient

func NewClient(in io.WriteCloser, out io.Reader) *Client

func (*Client) Close

func (c *Client) Close() error

func (*Client) Parse

type Driver

type Driver struct {
	// Version of the driver.
	Version string
	// Build identifier.
	Build string
	// ParserBuilder creates a Parser.
	ParserBuilder ParserBuilder
	// Annotate contains an *ann.Rule to convert AST to UAST.
	Annotate *ann.Rule
	// In is the input of the driver. Defaults to os.Stdin.
	In io.Reader
	// Out is the output of the driver. Defaults to os.Stdout.
	Out io.Writer
	// Err is the error output of the driver. Defaults to os.Stderr.
	Err io.Writer
}

Driver implements a driver.

func (*Driver) Exec

func (d *Driver) Exec()

Exec runs the driver with the given command line arguments. Note that this method contains calls to os.Exit.

func (*Driver) Run

func (d *Driver) Run(args []string) error

type Parser

type Parser interface {
	io.Closer
	protocol.Parser
}

type ParserBuilder

type ParserBuilder func(ParserOptions) (Parser, error)

ParserBuilder is a function that given ParserOptions creates a Parser.

type ParserOptions

type ParserOptions struct {
	NativeBin string `long:"native-bin" description:"alternative path for the native binary" default:"/opt/driver/bin/native"`
}

type Server

type Server struct {
	Parser

	In  io.Reader
	Out io.Writer
	// contains filtered or unexported fields
}

func (*Server) Start

func (s *Server) Start() error

func (*Server) Wait

func (s *Server) Wait() error

type TransformationParser

type TransformationParser struct {
	// Parser to delegate parsing.
	Parser
	// Transformation function to apply to resulting *uast.Node. The first
	// argument is the original source code from the request. Any
	// transformation to *uast.Node should be performed in-place. If error
	// is returned, it will be propagated to the Parse call.
	Transformation func([]byte, *uast.Node) error
}

TransformationParser wraps another Parser and applies a transformation to its results.

func (*TransformationParser) Parse

Parse calls the wrapped Parser and applies the transformation to its result.

Jump to

Keyboard shortcuts

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