yal

package
v0.0.0-...-5065da5 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Exprs map[string]func(Node) ast.Expr
View Source
var Stmts map[string]func(Node) ast.Stmt

Functions

func ADD

func ADD(node Node) ast.Expr

ADD returns expression for addition.

(  a b)

func ARRAY

func ARRAY(node Node) ast.Expr

ARRAY returns composite literal expression for array. First node represents element type. Second node represents array size.

(array type n a b)

func ASSIGN

func ASSIGN(node Node) ast.Stmt

ASSIGN returns "=" statement. Accepts multiple arguments.

(= a b c d)

Becomes:

a, c = b, d

func Buffer

func Buffer(file *ast.File) (*bytes.Buffer, error)

func DEFINE

func DEFINE(node Node) ast.Stmt

DEFINE returns ":=" statement. Accepts multiple arguments.

(:= a b c d)

Becomes:

a, c := b, d

func EQL

func EQL(node Node) ast.Expr

EQL returns expression for equality.

(== a b)

func GEQ

func GEQ(node Node) ast.Expr

GEQ returns "greater than or equal" expression.

(>= a b)

func GTR

func GTR(node Node) ast.Expr

GTR returns "greater than" expression.

(> a b)

func IF

func IF(node Node) ast.Stmt

IF returns "if" statement.

(if a b)

Becomes:

if a {
  b
}

func LAND

func LAND(node Node) ast.Expr

LAND returns "and" expression.

(&& a b)

func LEQ

func LEQ(node Node) ast.Expr

LEQ returns "less than or equal" expression.

(<= a b)

func LOR

func LOR(node Node) ast.Expr

LOR returns "or" expression.

(<= a b)

func LSS

func LSS(node Node) ast.Expr

LSS returns "less than" expression.

(< a b)

func MAP

func MAP(node Node) ast.Expr

MAP generates anonymous function which applies function `f` to each element in slice `a` and returns new slice. Function `f` should have one argument and return value with same type.

(map type type f a)

func MUL

func MUL(node Node) ast.Expr

MUL returns expression for multiplication.

(* a b)

func NEQ

func NEQ(node Node) ast.Expr

NEQ returns expression for inequality.

(!= a b)

func QUO

func QUO(node Node) ast.Expr

QUO returns expression for division.

(/ a b)

func REM

func REM(node Node) ast.Expr

REM returns expression for remainder.

(% a b)

func RETURN

func RETURN(node Node) ast.Stmt

RETURN returns "return" statement. Accepts multiple arguments.

(return a b c)

Becomes:

return a, b, c

func SLICE

func SLICE(node Node) ast.Expr

SLICE returns composite literal expression for slice. First node represents element type.

(slice type a b)

func SUB

func SUB(node Node) ast.Expr

SUB returns expression for subtraction.

(- a b)

func SWITCH

func SWITCH(node Node) ast.Stmt

SWITCH returns "switch" statement. Accepts multiple arguments.

(switch a b c)

Becomes:

switch a {
  case b: c
}

func VAR

func VAR(node Node) ast.Stmt

VAR returns "var" statement.

(var a b)

Becomes:

var a b

Types

type Node

type Node struct {
	Atom  string
	Nodes []Node
}

func (Node) Expr

func (node Node) Expr() ast.Expr

func (Node) Field

func (node Node) Field() *ast.Field

func (Node) FieldList

func (node Node) FieldList() *ast.FieldList

func (Node) File

func (node Node) File() *ast.File

func (Node) Func

func (node Node) Func() ast.Decl

func (Node) Ident

func (node Node) Ident() *ast.Ident

func (Node) Import

func (node Node) Import() *ast.ImportSpec

func (Node) Imports

func (node Node) Imports() *ast.GenDecl

func (Node) Return

func (node Node) Return() ast.Stmt

func (Node) Stmt

func (node Node) Stmt() ast.Stmt

type Parser

type Parser interface {
	Parse(tokens []string) Node
}

type Tokenizer

type Tokenizer interface {
	Tokenize(src []byte) []string
}

type Yal

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

func New

func New(t Tokenizer, p Parser) *Yal

func (*Yal) Run

func (y *Yal) Run(src []byte) *ast.File

Jump to

Keyboard shortcuts

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