syntax

package
v3.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package syntax defines the the MRO pipeline declaration language.

This includes the grammar and AST definition, as well as the parsers, preprocessors, and formatters for it.

Index

Constants

View Source
const (
	KindArray  ExpKind = "array"
	KindMap            = "map"
	KindFloat          = "float"
	KindInt            = "int"
	KindString         = "string"
	KindBool           = "bool"
	KindNull           = "null"
	KindSelf           = "self" // reference
	KindCall           = "call" // reference
)
View Source
const (
	INDENT  string = "    "
	NEWLINE string = "\n"
)
View Source
const AS = 57375
View Source
const BOOL = 57394
View Source
const CALL = 57365
View Source
const COLON = 57350
View Source
const COMMA = 57351
View Source
const COMMENT = 57347
View Source
const COMPILED = 57388
View Source
const DEFAULT = 57398
View Source
const DISABLED = 57371
View Source
const DOT = 57383
View Source
const EQUALS = 57352
View Source
const EXEC = 57387
View Source
const FALSE = 57396
View Source
const FILETYPE = 57362
View Source
const FLOAT = 57392
View Source
const GO = 57385
View Source
const ID = 57379
View Source
const IN = 57372
View Source
const INT = 57390
View Source
const INVALID = 57348
View Source
const LBRACE = 57357
View Source
const LBRACKET = 57353
View Source
const LITSTRING = 57380
View Source
const LOCAL = 57368
View Source
const LPAREN = 57355
View Source
const MAP = 57389
View Source
const MEM_GB = 57377
View Source
const NULL = 57397
View Source
const NUM_FLOAT = 57381
View Source
const NUM_INT = 57382
View Source
const OUT = 57373
View Source
const PATH = 57393
View Source
const PIPELINE = 57364
View Source
const PREFLIGHT = 57369
View Source
const PREPROCESS_DIRECTIVE = 57399
View Source
const PY = 57384
View Source
const RBRACE = 57358
View Source
const RBRACKET = 57354
View Source
const RETURN = 57360
View Source
const RPAREN = 57356
View Source
const SELF = 57361
View Source
const SEMICOLON = 57349
View Source
const SH = 57386
View Source
const SKIP = 57346
View Source
const SPECIAL = 57378
View Source
const SPLIT = 57366
View Source
const SRC = 57374
View Source
const STAGE = 57363
View Source
const STRING = 57391
View Source
const SWEEP = 57359
View Source
const THREADS = 57376
View Source
const TRUE = 57395
View Source
const USING = 57367
View Source
const VOLATILE = 57370

Variables

This section is empty.

Functions

func DefiningFile

func DefiningFile(node AstNodable) string

Gets the name of the file that defines the node.

func Format

func Format(src, filename string) (string, error)

func FormatFile

func FormatFile(filename string) (string, error)

Exported API

func JsonDumpAsts

func JsonDumpAsts(asts []*Ast) string

func SearchPipestanceParams

func SearchPipestanceParams(pipestance *Ast, what string) interface{}

func SetEnforcementLevel

func SetEnforcementLevel(level LanguageEnforceLevel)

Set the global language enforcement level.

Types

type Ast

type Ast struct {
	UserTypes     []*UserType
	UserTypeTable map[string]*UserType
	TypeTable     map[string]Type
	Stages        []*Stage
	Pipelines     []*Pipeline
	Callables     *Callables
	Call          *CallStm
	Errors        []error
	// contains filtered or unexported fields
}

func Compile

func Compile(fpath string, mroPaths []string, checkSrcPath bool) (string, []string, *Ast, error)

Compile an MRO file in cwd or mroPaths.

func NewAst

func NewAst(decs []Dec, call *CallStm) *Ast

func ParseSource

func ParseSource(src string, srcPath string, incPaths []string, checkSrc bool) (string, []string, *Ast, error)

Parser interface, called by runtime.

type AstError

type AstError struct {
	Node *AstNode
	Msg  string
	// contains filtered or unexported fields
}

AstError

func (*AstError) Error

func (self *AstError) Error() string

type AstNodable

type AstNodable interface {
	// contains filtered or unexported methods
}

type AstNode

type AstNode struct {
	Loc          int
	Fname        string
	IncludeStack []string
	Comments     []string
}

func NewAstNode

func NewAstNode(loc int, locmap []FileLoc) AstNode

type BindStm

type BindStm struct {
	Node  AstNode
	Id    string
	Exp   Exp
	Sweep bool
	Tname string
}

type BindStms

type BindStms struct {
	Node  AstNode
	List  []*BindStm `json:"-"`
	Table map[string]*BindStm
}

type BuiltinType

type BuiltinType struct {
	Id string
}

func (*BuiltinType) GetId

func (s *BuiltinType) GetId() string

type CallStm

type CallStm struct {
	Node      AstNode
	Modifiers *Modifiers
	Id        string
	DecId     string
	Bindings  *BindStms
}

type Callable

type Callable interface {
	AstNodable
	GetId() string
	GetInParams() *Params
	GetOutParams() *Params
	Type() string
	// contains filtered or unexported methods
}

type Callables

type Callables struct {
	List  []Callable `json:"-"`
	Table map[string]Callable
}

type Dec

type Dec interface {
	AstNodable
	// contains filtered or unexported methods
}

type ErrorList

type ErrorList []error

func (ErrorList) Error

func (self ErrorList) Error() string

func (ErrorList) If

func (self ErrorList) If() error

Collapse the error list down, and remove any nil errors. Returns nil if the list is empty.

type Exp

type Exp interface {
	AstNodable

	ToInterface() interface{}
	// contains filtered or unexported methods
}

type ExpKind

type ExpKind string

type FileLoc

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

Preprocessor

type InParam

type InParam struct {
	Node     AstNode
	Tname    string
	ArrayDim int
	Id       string
	Help     string
	Isfile   bool
}

func (*InParam) GetArrayDim

func (s *InParam) GetArrayDim() int

func (*InParam) GetHelp

func (s *InParam) GetHelp() string

func (*InParam) GetId

func (s *InParam) GetId() string

func (*InParam) GetOutName

func (s *InParam) GetOutName() string

func (*InParam) GetTname

func (s *InParam) GetTname() string

func (*InParam) IsFile

func (s *InParam) IsFile() bool

type LanguageEnforceLevel

type LanguageEnforceLevel int

Specifies how strictly new language features should be.

The intent is that when the compiler or runtime become more strict about some existing semantics, in a way which may break older pipelines, the level of backwards compatibility for the compiler and runtime is specified according to these levels. Such backwards compatibility measures should be considered temporary measures - pipelines affected by this flag are depending on deprecated functionality.

const (
	// Enforcement of new constraints is disabled.
	EnforceDisable LanguageEnforceLevel = iota

	// Violation of new constraints is logged as a warning.
	EnforceLog

	// Violation of new constraints triggers an alarm in pipelines.  The
	// result of this is that in addition to logging the warning as it
	// occurs, the alarm will be printed with the pipeline's final outputs.
	EnforceAlarm

	// Backwards compatibility is turned off.  Violation of constraints will
	// cause pipelines to fail.
	EnforceError
)

func GetEnforcementLevel

func GetEnforcementLevel() LanguageEnforceLevel

Get the current language enforcement level.

func ParseEnforcementLevel

func ParseEnforcementLevel(level string) LanguageEnforceLevel

Convert from a string representation.

func (LanguageEnforceLevel) MarshalText

func (self LanguageEnforceLevel) MarshalText() (text []byte, err error)

func (LanguageEnforceLevel) String

func (self LanguageEnforceLevel) String() string

func (*LanguageEnforceLevel) UnmarshalText

func (self *LanguageEnforceLevel) UnmarshalText(text []byte) error

type Modifiers

type Modifiers struct {
	Local     bool
	Preflight bool
	Volatile  bool
	Bindings  *BindStms
}

type OutParam

type OutParam struct {
	Node     AstNode
	Tname    string
	ArrayDim int
	Id       string
	Help     string
	OutName  string
	Isfile   bool
}

func (*OutParam) GetArrayDim

func (s *OutParam) GetArrayDim() int

func (*OutParam) GetHelp

func (s *OutParam) GetHelp() string

func (*OutParam) GetId

func (s *OutParam) GetId() string

func (*OutParam) GetOutName

func (s *OutParam) GetOutName() string

func (*OutParam) GetTname

func (s *OutParam) GetTname() string

func (*OutParam) IsFile

func (s *OutParam) IsFile() bool

type Param

type Param interface {
	AstNodable

	GetTname() string
	GetArrayDim() int
	GetId() string
	GetHelp() string
	GetOutName() string
	IsFile() bool
	// contains filtered or unexported methods
}

type Params

type Params struct {
	List  []Param
	Table map[string]Param
}

type ParseError

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

ParseError

func (*ParseError) Error

func (self *ParseError) Error() string

type Pipeline

type Pipeline struct {
	Node      AstNode
	Id        string
	InParams  *Params
	OutParams *Params
	Calls     []*CallStm
	Callables *Callables `json:"-"`
	Ret       *ReturnStm
}

func (*Pipeline) GetId

func (s *Pipeline) GetId() string

func (*Pipeline) GetInParams

func (s *Pipeline) GetInParams() *Params

func (*Pipeline) GetOutParams

func (s *Pipeline) GetOutParams() *Params

func (*Pipeline) Type

func (s *Pipeline) Type() string

type PreprocessError

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

PreprocessError

func (*PreprocessError) Error

func (self *PreprocessError) Error() string

type RefExp

type RefExp struct {
	Node     AstNode
	Kind     ExpKind
	Id       string
	OutputId string
}

func (*RefExp) ToInterface

func (self *RefExp) ToInterface() interface{}

type Resources

type Resources struct {
	Node        AstNode
	ThreadNode  *AstNode
	MemNode     *AstNode
	SpecialNode *AstNode

	Threads int
	MemGB   int
	Special string
}

type ReturnStm

type ReturnStm struct {
	Node     AstNode
	Bindings *BindStms
}

type SrcParam

type SrcParam struct {
	Node AstNode
	Lang StageLanguage
	Path string
	Args []string
}

type Stage

type Stage struct {
	Node      AstNode
	Id        string
	InParams  *Params
	OutParams *Params
	Src       *SrcParam
	ChunkIns  *Params
	ChunkOuts *Params
	Split     bool
	Resources *Resources
}

func (*Stage) GetId

func (s *Stage) GetId() string

func (*Stage) GetInParams

func (s *Stage) GetInParams() *Params

func (*Stage) GetOutParams

func (s *Stage) GetOutParams() *Params

func (*Stage) Type

func (s *Stage) Type() string

type StageCodeType

type StageCodeType int
const (
	UnknownStageLang StageCodeType = iota
	PythonStage
	ExecStage
	CompiledStage
)

func (StageCodeType) MarshalJSON

func (self StageCodeType) MarshalJSON() ([]byte, error)

func (StageCodeType) String

func (self StageCodeType) String() string

func (*StageCodeType) UnmarshalJSON

func (self *StageCodeType) UnmarshalJSON(b []byte) error

type StageLanguage

type StageLanguage string

func (StageLanguage) Parse

func (lang StageLanguage) Parse() (StageCodeType, error)

type Type

type Type interface {
	GetId() string
}

type UserType

type UserType struct {
	Node AstNode
	Id   string
}

func (*UserType) GetId

func (s *UserType) GetId() string

type ValExp

type ValExp struct {
	Node  AstNode
	Kind  ExpKind
	Value interface{}
}

func (*ValExp) ToInterface

func (valExp *ValExp) ToInterface() interface{}

Jump to

Keyboard shortcuts

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