Versions in this module Expand all Collapse all v1 v1.9.2 May 17, 2020 Changes in this version + func Lit2Token(lit string) (tok uint) + func Token2Lit(tok uint) (s string) v1.9.1 May 17, 2020 Changes in this version + func TokenLen(tok uint) int type Token + func (p *Token) End() token.Pos v1.3.1 May 16, 2020 Changes in this version + const ADD + const ADD_ASSIGN + const AND + const AND_ASSIGN + const AND_NOT + const AND_NOT_ASSIGN + const ARROW + const ASSIGN + const AT + const CHAR + const COLON + const COMMA + const COMMENT + const DEC + const DEFINE + const ELLIPSIS + const EOF + const EQ + const FLOAT + const GE + const GT + const IDENT + const ILLEGAL + const IMAG + const INC + const INT + const LAND + const LBRACE + const LBRACK + const LE + const LOR + const LPAREN + const LT + const MUL + const MUL_ASSIGN + const NE + const NOT + const OR + const OR_ASSIGN + const PERIOD + const QUESTION + const QUO + const QUO_ASSIGN + const RBRACE + const RBRACK + const REM + const REM_ASSIGN + const RPAREN + const SEMICOLON + const SHL + const SHL_ASSIGN + const SHR + const SHR_ASSIGN + const STRING + const SUB + const SUB_ASSIGN + const TILDE + const USER_TOKEN_BEGIN + const XOR + const XOR_ASSIGN + var ErrNoDoc = errors.New("no doc") + var ErrNoGrammar = errors.New("no grammar") + var ErrVarAssigned = errors.New("variable is already assigned") + var ErrVarNotAssigned = errors.New("variable is not assigned") + func Code(g Grammar, t Tokener) string + func FileLine(doc []Token, t Tokener) (string, int) + func List(a, b Grammar) *grList + func List0(a, b Grammar) *grList + func Repeat1(g Grammar) *grRepeat1 + func Source(doc []Token, t Tokener) (text []byte) + type AutoKwScanner struct + func (p *AutoKwScanner) Init(file *token.File, src []byte, err ScanErrorHandler, mode ScanMode) + func (p *AutoKwScanner) Ltot(lit string) (tok uint) + func (p *AutoKwScanner) Scan() (t Token) + func (p *AutoKwScanner) Ttol(tok uint) (lit string) + type CompileRet struct + Grammars map[string]Grammar + Vars map[string]*GrVar + func (p CompileRet) EvalSub(name string, src interface{}) error + type Compiler struct + Grammar []byte + Init func() + Marker func(g Grammar, mark string) Grammar + ScanMode ScanMode + Scanner Tokener + func (p *Compiler) Cl() (ret CompileRet, err error) + type Context interface + Tokener func() Tokener + type GrNamed struct + func Named(name string, g Grammar) *GrNamed + func (p *GrNamed) Assign(name string, g Grammar) + func (p *GrNamed) Len() int + func (p *GrNamed) Marshal(b []byte, t Tokener, lvlParent int) []byte + func (p *GrNamed) Match(src []Token, ctx Context) (n int, err error) + type GrVar struct + Elem Grammar + Name string + func Var(name string) *GrVar + func (p *GrVar) Assign(g Grammar) error + func (p *GrVar) Len() int + func (p *GrVar) Marshal(b []byte, t Tokener, lvlParent int) []byte + func (p *GrVar) Match(src []Token, ctx Context) (n int, err error) + type Grammar interface + Len func() int + Marshal func(b []byte, t Tokener, lvlParent int) []byte + Match func(src []Token, ctx Context) (n int, err error) + var GrEOF Grammar = grEOF{} + var GrTrue Grammar = grTrue{} + func Action(g Grammar, act func(tokens []Token, g Grammar)) Grammar + func And(gs ...Grammar) Grammar + func Clone(gs []Grammar) []Grammar + func Gr(tok uint) Grammar + func Not(g Grammar) Grammar + func Or(gs ...Grammar) Grammar + func Peek(g Grammar) Grammar + func Repeat0(g Grammar) Grammar + func Repeat01(g Grammar) Grammar + func Transaction(g Grammar, begin func() interface{}, end func(trans interface{}, err error)) Grammar + type MatchError struct + Ctx Context + Err error + Grammar Grammar + IdxErr int + Src []Token + func (p *MatchError) Error() string + type Matcher struct + Grammar Grammar + Init func() + ScanMode ScanMode + Scanner Tokener + func (p *Matcher) Code() string + func (p *Matcher) Eval(src string) (err error) + func (p *Matcher) Match(src []byte, fname string) (next []Token, err error) + func (p *Matcher) MatchExactly(src []byte, fname string) (err error) + func (p *Matcher) Tokener() Tokener + func (p *Matcher) Tokenize(src []byte, fname string) (tokens []Token, err error) + type ScanErrorHandler func(pos token.Position, msg string) + type ScanMode uint + const InsertSemis + const ScanComments + type Scanner struct + ErrorCount int + func (p *Scanner) Ltot(lit string) (tok uint) + func (p *Scanner) Ttol(tok uint) (s string) + func (s *Scanner) Init(file *token.File, src []byte, err ScanErrorHandler, mode ScanMode) + func (s *Scanner) Scan() (t Token) + func (s *Scanner) Source() TokenSource + type Token struct + Kind uint + Literal string + Pos token.Pos + type TokenSource struct + File *token.File + Src []byte + type Tokener interface + Init func(file *token.File, src []byte, err ScanErrorHandler, mode ScanMode) + Ltot func(lit string) (tok uint) + Scan func() (t Token) + Source func() (src TokenSource) + Ttol func(tok uint) (lit string) + type TokenizeError struct + Msg string + Pos token.Position + func (p *TokenizeError) Error() string