bpl

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: May 31, 2022 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Ldefault is default flag for `Dumper`.
	Ldefault = log.Llevel

	// Llong is long log mode for `Dumper`.
	Llong = log.Llevel | log.LstdFlags

	// Dumper is used for dumping log informations.
	Dumper = log.New(os.Stdout, "", Ldefault)

	// SetCaseType controls to set `_type` into matching result or not.
	SetCaseType = true
)
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.

View Source
var (
	// ErrNoDoc is returned when `doc` is undefined.
	ErrNoDoc = errors.New("no doc")
)

Functions

func DumpDom

func DumpDom(b *bytes.Buffer, dom interface{}, lvl int)

DumpDom dumps a dom tree.

func NewContext

func NewContext() *bpl.Context

NewContext returns a new matching Context.

func SetDumpCode

func SetDumpCode(dumpCode string)

SetDumpCode sets dump code mode:

	"1" - dump code with rem instruction.
	"2" - dump code without rem instruction.
 else - don't dump code.

func SetDumper

func SetDumper(w io.Writer, flags ...int)

SetDumper sets the dumper instance for dumping log informations.

Types

type Compiler

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

A Compiler compiles bpl source code to matching units.

func (*Compiler) CallFn

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

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

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) Grammar

func (p *Compiler) Grammar() string

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

func (*Compiler) Ret

func (p *Compiler) Ret() (r Ruler, err error)

Ret returns compiling result.

func (*Compiler) Stack

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

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

type Ruler

type Ruler struct {
	Impl bpl.Ruler
}

A Ruler is a matching unit.

func New

func New(code []byte, fname string) (r Ruler, err error)

New compiles bpl source code and returns the corresponding matching unit.

func NewFromFile

func NewFromFile(fname string) (r Ruler, err error)

NewFromFile compiles bpl source file and returns the corresponding matching unit.

func NewFromString

func NewFromString(code string, fname string) (r Ruler, err error)

NewFromString compiles bpl source code and returns the corresponding matching unit.

func (Ruler) Match

func (p Ruler) Match(in *bufio.Reader, ctx *bpl.Context) (v interface{}, err error)

Match matches input stream `in`, and returns matching result.

func (Ruler) MatchBuffer

func (p Ruler) MatchBuffer(b []byte) (v interface{}, err error)

MatchBuffer matches input buffer `b`, and returns matching result.

func (Ruler) MatchStream

func (p Ruler) MatchStream(r io.Reader) (v interface{}, err error)

MatchStream matches input stream `r`, and returns matching result.

func (Ruler) SafeMatch

func (p Ruler) SafeMatch(in *bufio.Reader, ctx *bpl.Context) (v interface{}, err error)

SafeMatch matches input stream `in`, and returns matching result.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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