pseudo

package module
v0.0.0-...-36fd41a Latest Latest
Warning

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

Go to latest
Published: May 1, 2019 License: MPL-2.0 Imports: 14 Imported by: 3

README

pseudo CircleCI

Pseudo aims to be a 'pseudo' language. Its primary purpose is simplify and unitize development operations.

Language

Types

The following core types are supported:

  • number
  • float
  • string
  • list
  • map
Functions

There are a few builtin functions with the ability to register custom functions. A complete set of functions can be found in the functions.go file.

Syntax

A code block is any data wrapped in ${...}. This may be a variable, function or any other supported operation

Escape sequence

A code block within ${...} can be escaped by prepending a $ to it like so $${...}

Development
Test
make test
Build
make pseudo
Run
./pseudo -h

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadVariableBytes

func LoadVariableBytes(contentType string, b []byte) (scope.Variables, error)

LoadVariableBytes loads an index from the given bytes.

func LoadVariables

func LoadVariables(uri *url.URL, opts ...IndexOptions) (scope.Variables, error)

LoadVariables loads an index from the URL. It reads the data, parses and indexes the data structure

func ReadDirFiles

func ReadDirFiles(dirpath string) (map[string][]byte, error)

ReadDirFiles reads all files in a given directory returning a map of filename to its contents

Types

type IndexOptions

type IndexOptions struct {
	// Content type of context data
	ContentType string
}

IndexOptions are index loader options

type Script

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

Script is an evaluatable script

func NewScript

func NewScript(filename string) (*Script, error)

NewScript loads a script from the given file returning an error on failure

func NewScriptBytes

func NewScriptBytes(b []byte) *Script

NewScriptBytes this simply removes the shabang line if one is specified

func (*Script) Contents

func (scr *Script) Contents() string

Contents returns the script contents as a string

func (*Script) Vars

func (scr *Script) Vars() []string

Vars returns a list of variables needed to be passed in to the 'script'. Functions are skipped over, as such currently it does not return variables referenced by functions.

type VM

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

VM is used to parse and eval a given script

func NewVM

func NewVM() *VM

NewVM inits a new VM with core functions

func (*VM) Eval

func (vm *VM) Eval() (*hil.EvaluationResult, error)

Eval evaluates a parsed script. Parse must be called before a call to Eval can be made

func (*VM) FuncNames

func (vm *VM) FuncNames() []string

FuncNames returns a list of function names in scope for this vm instance

func (*VM) Parse

func (vm *VM) Parse(script string) (err error)

Parse parses an input script and creates the ast root node

func (*VM) ParseEval

func (vm *VM) ParseEval(script string, vars scope.Variables) (result *hil.EvaluationResult, err error)

ParseEval is a helper function to set variables, parse the script and evaluate it

func (*VM) RegisterFunc

func (vm *VM) RegisterFunc(name string, f ast.Function) error

RegisterFunc registers a function to the vm

func (*VM) SetVars

func (vm *VM) SetVars(vars map[string]ast.Variable)

SetVars sets the variables that are in scope for this vm instance

func (*VM) VarNames

func (vm *VM) VarNames() []string

VarNames returns a list of vars scoped for this vm instance

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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