qlang

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: GPL-2.0, MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// FindEntry specifies the policy how qlang searches library file.
	FindEntry = findEntry

	// ReadFile specifies the policy how qlang reads source file.
	ReadFile = ioutil.ReadFile
)
View Source
var DumpCode int

DumpCode is mode how to dump code. 1 means to dump code with `rem` instruction; 2 means to dump clean code; 0 means don't dump code.

Functions

This section is empty.

Types

type Compiler

type Compiler struct {
	Opts *ipt.Options
	// contains filtered or unexported fields
}

A Compiler represents a qlang compiler.

func New

func New() *Compiler

New returns a qlang compiler instance.

func (*Compiler) CallFn

func (p *Compiler) CallFn(fn interface{})

CallFn generates a function call instruction. It is required by tpl.Interpreter engine.

func (*Compiler) Cl

func (p *Compiler) Cl(codeText []byte, fname string) int

Cl compiles a qlang source code.

func (*Compiler) Code

func (p *Compiler) Code() *exec.Code

Code returns the generated code.

func (*Compiler) Compile

func (p *Compiler) Compile(fname string) int

Compile compiles a qlang source file.

func (*Compiler) Done

func (p *Compiler) Done()

Done completes all exit functions generated by `Cl`.

func (*Compiler) Fntable

func (p *Compiler) Fntable() map[string]interface{}

Fntable returns the qlang compiler's function table. It is required by tpl.Interpreter engine.

func (*Compiler) GlobalSymbols

func (p *Compiler) GlobalSymbols() map[string]int

GlobalSymbols returns the global symbol table.

func (*Compiler) Grammar

func (p *Compiler) Grammar() string

Grammar returns the qlang compiler's grammar. It is required by tpl.Interpreter engine.

func (*Compiler) InjectMethods

func (p *Compiler) InjectMethods(cls *exec.Class, code []byte) (err error)

InjectMethods injects some methods into a class.

func (*Compiler) SetLibs

func (p *Compiler) SetLibs(libs string)

SetLibs sets searching paths when qlang searchs a library (ie. import a module).

func (*Compiler) Stack

func (p *Compiler) Stack() interpreter.Stack

Stack returns nil (no stack). It is required by tpl.Interpreter engine.

func (*Compiler) Vars

func (p *Compiler) Vars() map[string]interface{}

Vars returns compiling time variables, eg. __file__, __dir__, etc.

type FindEntryError

type FindEntryError struct {
	Name string
	Err  error
}

An FindEntryError represents a FindEntry error.

func (*FindEntryError) Error

func (e *FindEntryError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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