Documentation ¶
Overview ¶
*
- The lexer for parsing fet template
Index ¶
- Constants
- Variables
- func IsBaseNumberByte(bt byte, base NumberBase) bool
- func IsBinaryByte(bt byte) bool
- func IsBinaryOrParenOpToken(token IToken) bool
- func IsBytesInBytesList(bts []byte, btsList [][]byte) bool
- func IsDecimalByte(bt byte) bool
- func IsEqualOpToken(token IToken) bool
- func IsHexByte(bt byte) bool
- func IsOctalByte(bt byte) bool
- func IsOpToken(token IToken, op *Operator) bool
- func IsPipeOpToken(token IToken) bool
- func IsSpaceByte(bt byte) bool
- func IsSpaceToken(token IToken) bool
- type ArrayField
- type ArrayInState
- type ArrayItem
- type ArrayLiteral
- type AstNode
- type DoubleQuoteStringToken
- type ExpOpts
- type Expression
- func (exp *Expression) Add(bt byte, _ *Expression) (IToken, error)
- func (exp *Expression) End() error
- func (exp *Expression) Eof() error
- func (exp *Expression) IsEmpty() bool
- func (exp *Expression) IsKeyword(bts []byte) bool
- func (exp *Expression) Parse(str string) (IToken, error)
- func (exp *Expression) RawBytes() []byte
- func (exp *Expression) Token() IToken
- func (exp *Expression) Type() TokenType
- type FunctionCall
- type IToken
- type IdentifierToken
- type Integer
- type NumberBase
- type NumberToken
- type ObjectProperty
- type Operator
- type OperatorToken
- type PipeFunction
- type SingleQuoteStringToken
- type SpaceToken
- type StringVariable
- type TokenType
Constants ¶
View Source
const ( BYTE_UNDERSCORE byte = '_' BYTE_SPACE byte = ' ' BYTE_EOF byte = 0 )
Variables ¶
View Source
var KEYWORDS = [][]byte{ []byte("true"), []byte("false"), []byte("null"), }
Functions ¶
func IsBaseNumberByte ¶
func IsBaseNumberByte(bt byte, base NumberBase) bool
func IsBinaryByte ¶
func IsBinaryOrParenOpToken ¶
func IsEqualOpToken ¶
func IsOctalByte ¶
func IsPipeOpToken ¶
func IsSpaceToken ¶
Types ¶
type ArrayField ¶
type ArrayField struct { IsEnd bool Array IToken Field *IdentifierToken ComputedField *Expression }
* * Array Field * e.g $a.b $a["b"]
func (*ArrayField) Add ¶
func (arr *ArrayField) Add(bt byte, exp *Expression) (IToken, error)
func (*ArrayField) End ¶
func (arr *ArrayField) End() error
func (*ArrayField) RawBytes ¶
func (arr *ArrayField) RawBytes() []byte
func (*ArrayField) Type ¶
func (arr *ArrayField) Type() TokenType
type ArrayInState ¶
type ArrayInState uint8
const ( MaybeArrayKey ArrayInState = iota InArrayValue )
type ArrayLiteral ¶
type ArrayLiteral struct { IsEnd bool HasKey bool State ArrayInState Index int CurExp *Expression Items []ArrayItem Raw []byte }
func (*ArrayLiteral) Add ¶
func (arr *ArrayLiteral) Add(bt byte, exp *Expression) (IToken, error)
func (*ArrayLiteral) End ¶
func (arr *ArrayLiteral) End() error
func (*ArrayLiteral) RawBytes ¶
func (arr *ArrayLiteral) RawBytes() []byte
func (*ArrayLiteral) Type ¶
func (arr *ArrayLiteral) Type() TokenType
type DoubleQuoteStringToken ¶
type DoubleQuoteStringToken struct { InTranslate bool IsEnd bool CurRawLen int CurVar *Expression CurRaw []byte RawString [][]byte VarString []StringVariable }
func (*DoubleQuoteStringToken) Add ¶
func (ds *DoubleQuoteStringToken) Add(bt byte, exp *Expression) (IToken, error)
func (*DoubleQuoteStringToken) End ¶
func (ds *DoubleQuoteStringToken) End() error
func (*DoubleQuoteStringToken) RawBytes ¶
func (ds *DoubleQuoteStringToken) RawBytes() []byte
func (*DoubleQuoteStringToken) Type ¶
func (ds *DoubleQuoteStringToken) Type() TokenType
type Expression ¶
type Expression struct { LazyPipe bool PrevToken IToken CurToken IToken Options *ExpOpts OpStack []*OperatorToken Output []IToken }
func New ¶
func New(args ...*ExpOpts) *Expression
func (*Expression) Add ¶
func (exp *Expression) Add(bt byte, _ *Expression) (IToken, error)
func (*Expression) End ¶
func (exp *Expression) End() error
func (*Expression) IsEmpty ¶
func (exp *Expression) IsEmpty() bool
func (*Expression) IsKeyword ¶
func (exp *Expression) IsKeyword(bts []byte) bool
func (*Expression) Parse ¶
func (exp *Expression) Parse(str string) (IToken, error)
* * Parse string to AST
func (*Expression) RawBytes ¶
func (exp *Expression) RawBytes() []byte
func (*Expression) Token ¶
func (exp *Expression) Token() IToken
func (*Expression) Type ¶
func (exp *Expression) Type() TokenType
type FunctionCall ¶
type FunctionCall struct { IsEnd bool Name IToken Args []IToken CurArg *Expression Raw []byte }
*
- Function Call
- e.g => abc(), abc(1+2, "def")
func (*FunctionCall) Add ¶
func (fn *FunctionCall) Add(bt byte, exp *Expression) (IToken, error)
func (*FunctionCall) End ¶
func (fn *FunctionCall) End() error
func (*FunctionCall) RawBytes ¶
func (fn *FunctionCall) RawBytes() []byte
func (*FunctionCall) Type ¶
func (fn *FunctionCall) Type() TokenType
type IToken ¶
type IToken interface { Add(bt byte, exp *Expression) (IToken, error) Type() TokenType End() error RawBytes() []byte }
func AddUnkownTokenByte ¶
func AddUnkownTokenByte(bt byte, exp *Expression) (IToken, error)
type IdentifierToken ¶
*
- Identifier token, e.g $a abc a123
func (*IdentifierToken) Add ¶
func (id *IdentifierToken) Add(bt byte, exp *Expression) (IToken, error)
func (*IdentifierToken) End ¶
func (id *IdentifierToken) End() error
func (*IdentifierToken) RawBytes ¶
func (id *IdentifierToken) RawBytes() []byte
func (*IdentifierToken) Type ¶
func (id *IdentifierToken) Type() TokenType
type NumberBase ¶
type NumberBase uint8
const ( HexBase NumberBase = 16 OctalBase NumberBase = 8 BinaryBase NumberBase = 2 DecimalBase NumberBase = 10 )
type NumberToken ¶
type NumberToken struct { BeginWithZero bool Base NumberBase Integer Integer Decimal *Integer Exponent *Integer }
func Number ¶
func Number() *NumberToken
*
- method => Number()
- creates an instance of a number token
- keep the base as 10 instead of the default 0.
func (*NumberToken) Add ¶
func (num *NumberToken) Add(bt byte, exp *Expression) (IToken, error)
func (*NumberToken) RawBytes ¶
func (num *NumberToken) RawBytes() []byte
func (*NumberToken) Type ¶
func (num *NumberToken) Type() TokenType
type ObjectProperty ¶
type ObjectProperty struct { Object IToken Property *IdentifierToken Raw []byte }
* Object Property
func (*ObjectProperty) Add ¶
func (obj *ObjectProperty) Add(bt byte, exp *Expression) (IToken, error)
func (*ObjectProperty) End ¶
func (obj *ObjectProperty) End() error
func (*ObjectProperty) RawBytes ¶
func (obj *ObjectProperty) RawBytes() []byte
func (*ObjectProperty) Type ¶
func (obj *ObjectProperty) Type() TokenType
type OperatorToken ¶
func (*OperatorToken) Add ¶
func (token *OperatorToken) Add(bt byte, exp *Expression) (IToken, error)
func (*OperatorToken) End ¶
func (token *OperatorToken) End() error
func (*OperatorToken) RawBytes ¶
func (token *OperatorToken) RawBytes() []byte
func (*OperatorToken) Type ¶
func (token *OperatorToken) Type() TokenType
type PipeFunction ¶
type PipeFunction struct { IsEnd bool CurArg *Expression Name *IdentifierToken Args []IToken Raw []byte }
* * Pipe Function
func (*PipeFunction) Add ¶
func (pipe *PipeFunction) Add(bt byte, exp *Expression) (IToken, error)
func (*PipeFunction) End ¶
func (pipe *PipeFunction) End() error
func (*PipeFunction) RawBytes ¶
func (pipe *PipeFunction) RawBytes() []byte
func (*PipeFunction) Type ¶
func (pipe *PipeFunction) Type() TokenType
type SingleQuoteStringToken ¶
*
- string token
- SingleQuote: 'abc'
- DoubleQuote: "abc`$a`"
Single Quote String
func (*SingleQuoteStringToken) Add ¶
func (ss *SingleQuoteStringToken) Add(bt byte, exp *Expression) (IToken, error)
func (*SingleQuoteStringToken) End ¶
func (ss *SingleQuoteStringToken) End() error
func (*SingleQuoteStringToken) RawBytes ¶
func (ss *SingleQuoteStringToken) RawBytes() []byte
func (*SingleQuoteStringToken) Type ¶
func (ss *SingleQuoteStringToken) Type() TokenType
type SpaceToken ¶
type SpaceToken struct {
Raw []byte
}
*
- [Space Token] struct
func (*SpaceToken) Add ¶
func (sp *SpaceToken) Add(bt byte, exp *Expression) (IToken, error)
func (*SpaceToken) End ¶
func (sp *SpaceToken) End() error
func (*SpaceToken) RawBytes ¶
func (sp *SpaceToken) RawBytes() []byte
func (*SpaceToken) Type ¶
func (sp *SpaceToken) Type() TokenType
type StringVariable ¶
type StringVariable struct { Index int Var *Expression }
Click to show internal directories.
Click to hide internal directories.