compile

package
v0.0.0-...-040724e Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2019 License: BSD-3-Clause, GPL-2.0, BSD-3-Clause, + 1 more Imports: 21 Imported by: 1

Documentation

Overview

Package compile declares the functions required to translate an Antha AST into a go source file

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fprint

func Fprint(output io.Writer, fset *token.FileSet, node interface{}) error

Fprint "pretty-prints" an AST node to output. It calls Config.Fprint with default settings.

Types

type Antha

type Antha struct {
	SourceSHA256 []byte
	// contains filtered or unexported fields
}

Antha is a preprocessing pass from antha file to go file

func NewAntha

func NewAntha(root *AnthaRoot) *Antha

NewAntha creates a new antha pass

func (*Antha) Generate

func (p *Antha) Generate(fileSet *token.FileSet, file *ast.File) (*AnthaFiles, error)

Generate returns files with slash names to complete antha to go transformation

func (*Antha) Transform

func (p *Antha) Transform(fileSet *token.FileSet, src *ast.File) (err error)

Transform rewrites AST to go standard primitives

type AnthaFile

type AnthaFile struct {
	// Name is a slash-delimited filename
	Name string
	Data []byte
}

An AnthaFile is a file generated by the Antha translation process

func (*AnthaFile) NewReader

func (f *AnthaFile) NewReader() io.ReadCloser

NewReader returns a new reader for this file

type AnthaFiles

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

AnthaFiles is a collection of AnthaFiles

func NewAnthaFiles

func NewAnthaFiles() *AnthaFiles

NewAnthaFiles returns a new collection of AnthaFiles

func (*AnthaFiles) Files

func (f *AnthaFiles) Files() []*AnthaFile

Files returns the files in the collection

type AnthaRoot

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

An AnthaRoot collects data from multiple Antha passes

func NewAnthaRoot

func NewAnthaRoot(basePackage string) *AnthaRoot

NewAnthaRoot creates a new AnthaRoot

func (*AnthaRoot) Generate

func (r *AnthaRoot) Generate() (*AnthaFiles, error)

Generate generates additional files not stric

type CommentedNode

type CommentedNode struct {
	Node     interface{} // *ast.File, or ast.Expr, ast.Decl, ast.Spec, or ast.Stmt
	Comments []*ast.CommentGroup
}

A CommentedNode bundles an AST node and corresponding comments. It may be provided as argument to any of the Fprint functions.

type Config

type Config struct {
	Mode     Mode // default: 0
	Tabwidth int  // default: 8
	Indent   int  // default: 0 (all code is indented at least by this much)
}

A Config node controls the output of Fprint.

func (*Config) Fprint

func (cfg *Config) Fprint(output io.Writer, fset *token.FileSet, node interface{}) (map[int]int, error)

Fprint "pretty-prints" an AST node to output for a given configuration cfg. Position information is interpreted relative to the file set fset. The node type must be *ast.File, *CommentedNode, []ast.Decl, []ast.Stmt, or assignment-compatible to ast.Expr, ast.Decl, ast.Spec, or ast.Stmt.

type Field

type Field struct {
	Name string
	Type ast.Expr // Fully qualified go type name
	Doc  string
	Tag  string
}

A Field is a field of a message

type Message

type Message struct {
	Name   string
	Doc    string
	Fields []*Field
	Kind   token.Token // One of token.{DATA, PARAMETERS, OUTPUTS, INPUTS, MESSAGE}
}

A Message is an input or an output or user defined type

type Mode

type Mode uint

A Mode value is a set of flags (or 0). They control printing.

const (
	RawFormat Mode = 1 << iota // do not use a tabwriter; if set, UseSpaces is ignored
	TabIndent                  // use tabs for indentation independent of UseSpaces
	UseSpaces                  // use spaces instead of tabs for alignment
	SourcePos                  // emit //line comments to preserve original source positions
)

Valid modes

Jump to

Keyboard shortcuts

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