gobpp

package
v0.0.0-...-e689c96 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package gobpp converts Go source code into B++ source code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(fset *token.FileSet, filename string, f *ast.File) (string, error)

Convert converts a parsed Go source code file and returns B++ source code

Types

type Function

type Function func(args []ast.Expr) error

Function defines the signature for a function parser

type Program

type Program struct {
	*strings.Builder

	Fset     *token.FileSet
	Funcs    map[string]Function
	FuncName string
}

Program defines the program source code and some program data

func (*Program) AddBlock

func (p *Program) AddBlock(args []ast.Stmt) error

AddBlock adds a block of statements to a B++ program, add a boolean parameter to the end of the call to remove the "\n" from the end of the code generated

func (*Program) AddDecl

func (p *Program) AddDecl(decl ast.Decl) error

AddDecl adds a Go declaration to the program's source code

func (*Program) AddExpr

func (p *Program) AddExpr(expr ast.Expr) error

AddExpr adds an expression to the program's source code

func (*Program) AddFile

func (p *Program) AddFile(f *ast.File) error

AddFile adds an *ast.File to the program's source code

func (*Program) AddStmt

func (p *Program) AddStmt(stmt ast.Stmt) error

AddStmt adds a statement to the program's source code

func (*Program) End

func (p *Program) End()

End cleans up a program and adds running code

func (*Program) Init

func (p *Program) Init()

Init initializes a program

func (*Program) NodePos

func (p *Program) NodePos(node ast.Node) string

NodePos gets the position of a ast.Node and converts that to a string with the same method as Pos

func (*Program) Pos

func (p *Program) Pos(pos token.Pos) string

Pos uses the Fset to convert a token.Pos to a string

Jump to

Keyboard shortcuts

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