Reference

The functions and structures for using the Gentee programming language in Golang projects are described here.

Types

type Custom

The Custom type is used for additional configuration of the compiler and virtual machine. It is passed when the Customize function is called.

  • Embedded []EmbedItem - an array of additional functions for the standard library.

type EmbedItem

The EmbedItem type describes the function to be embedded in the standard library. It is used in the Custom type.

  • Prototype string - a description of the function in the Gentee language. For example, myfunc(str,int) int.

  • Object interface{} - the corresponding golang function.

type Settings

The Settings type is used to specify additional parameters when starting the bytecode in the Run method.

  • CmdLine []string - an array of command line parameters.

  • Input []byte - predefined standard input (stdin). Can be used, for example, in the function ReadString.

  • Cycle uint64 - maximum number of iterations in the loop. By default, it is 1600000000.

  • Depth uint32 - maximum nesting of executable blocks. Limits the recursion depth. By default, it is equal to 1000.

Functions and methods

Customize(custom *Custom) error

The Customize function is used for additional settings of the compiler and virtual machine. It should be called before all the functions. The function returns the error value.

New() *Gentee

The New function creates a workspace for compiling source code.

(g *Gentee) Compile(input, path string) (*Exec, int, error)

The Compile function compiles the script passed to input. You can specify the path to the script in the path parameter. The function returns a bytecode structure, module number and error value.

(g *Gentee) CompileAndRun(filename string) (interface{}, error)

The CompileAndRun function compiles the script from the filename file and executes it. The function returns the result of the script and the error value.

(g *Gentee) CompileFile(filename string) (*Exec, int, error)

The CompileFile function compiles the script from the filename file. The function returns a bytecode structure, module number, and error value.

(exec *Exec) Run(settings Settings) (interface{}, error)

The Run function executes bytecode from the exec structure. You can specify additional settings in the settings parameter. The function returns the result of the script and the error value.

Version() string

The Version function returns the current version number of the language.