Documentation ¶
Index ¶
- Variables
- func DumpDom(b *bytes.Buffer, dom interface{}, lvl int)
- func NewContext() *bpl.Context
- func SetDumpCode(dumpCode string)
- func SetDumper(w io.Writer, flags ...int)
- type Compiler
- type Ruler
- func (p Ruler) Match(in *bufio.Reader, ctx *bpl.Context) (v interface{}, err error)
- func (p Ruler) MatchBuffer(b []byte) (v interface{}, err error)
- func (p Ruler) MatchStream(r io.Reader) (v interface{}, err error)
- func (p Ruler) SafeMatch(in *bufio.Reader, ctx *bpl.Context) (v interface{}, err error)
Constants ¶
This section is empty.
Variables ¶
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 )
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.
var ( // ErrNoDoc is returned when `doc` is undefined. ErrNoDoc = errors.New("no doc") )
Functions ¶
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.
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 ¶
Fntable returns the qlang compiler's function table. It is required by tpl.Interpreter engine.
type Ruler ¶
A Ruler is a matching unit.
func NewFromFile ¶
NewFromFile compiles bpl source file and returns the corresponding matching unit.
func NewFromString ¶
NewFromString compiles bpl source code and returns the corresponding matching unit.
func (Ruler) MatchBuffer ¶
MatchBuffer matches input buffer `b`, and returns matching result.
func (Ruler) MatchStream ¶
MatchStream matches input stream `r`, and returns matching result.