Documentation
¶
Index ¶
- func PrintError(err error, dest io.Writer)
- type Array
- type AssignTarget
- type BufferedInputFile
- type ErrorGroup
- type Evaluator
- func EvalProgram(progSrc string, files []InputFile, rootSelectors []string, stdout io.Writer, ...) (*Evaluator, error)
- func EvalProgramContext(progSrc string, files []InputFile, rootSelectors []string, stdout io.Writer, ...) (*Evaluator, error)
- func NewEmptyEvaluator(stdout io.Writer) Evaluator
- func NewEvaluator(prog Program, stdout io.Writer) Evaluator
- func (e *Evaluator) EvalExpr(expr Expr) (Value, error)
- func (e *Evaluator) EvalStatement(stmt Statement) error
- func (e *Evaluator) GetPrettyRootJson() (string, error)
- func (e *Evaluator) GetUglyRootJson() (string, error)
- func (e *Evaluator) RunInBeginFileContext(files []InputFile, rootSelectors []string, fn func() error) error
- func (e *Evaluator) RunProgram(prog Program, files []InputFile, rootSelectors []string) error
- type Expr
- type ExprArray
- type ExprAssign
- type ExprBinary
- type ExprCall
- type ExprFunction
- type ExprIdentifier
- type ExprLiteral
- type ExprMatch
- type ExprObject
- type ExprRange
- type ExprTernary
- type ExprUnary
- type FnWithContext
- type InputFile
- type JsonError
- type LValue
- type Lexer
- type MatchCase
- type Node
- type Object
- type ObjectKeyValue
- type Parser
- type PathSeg
- type Precedence
- type Program
- type Rule
- type RuleKind
- type RuntimeError
- type Statement
- type StatementBlock
- type StatementBreak
- type StatementContinue
- type StatementExit
- type StatementExpr
- type StatementFor
- type StatementForIn
- type StatementIf
- type StatementLet
- type StatementNext
- type StatementPrint
- type StatementReturn
- type StatementWhile
- type StreamingInputFile
- type SyntaxError
- type Token
- type TokenTag
- type Value
- type ValueTag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrintError ¶
Types ¶
type AssignTarget ¶
type BufferedInputFile ¶
type BufferedInputFile struct {
// contains filtered or unexported fields
}
func (*BufferedInputFile) Name ¶
func (f *BufferedInputFile) Name() string
func (*BufferedInputFile) NewReader ¶
func (f *BufferedInputFile) NewReader() io.Reader
type ErrorGroup ¶
type ErrorGroup struct {
Errors []error
}
func (ErrorGroup) Error ¶
func (err ErrorGroup) Error() string
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
func EvalProgram ¶
func EvalProgramContext ¶
func NewEmptyEvaluator ¶
func (*Evaluator) EvalStatement ¶
func (*Evaluator) GetPrettyRootJson ¶
func (*Evaluator) GetUglyRootJson ¶
func (*Evaluator) RunInBeginFileContext ¶
type ExprAssign ¶
type ExprAssign struct {
Target AssignTarget
Value Expr
OpToken Token
}
func (*ExprAssign) String ¶
func (expr *ExprAssign) String() string
func (*ExprAssign) Token ¶
func (expr *ExprAssign) Token() Token
type ExprBinary ¶
func (*ExprBinary) String ¶
func (expr *ExprBinary) String() string
func (*ExprBinary) Token ¶
func (expr *ExprBinary) Token() Token
type ExprFunction ¶
type ExprFunction struct {
Ident string
Args []string
Body Statement
// contains filtered or unexported fields
}
func (*ExprFunction) String ¶
func (expr *ExprFunction) String() string
func (*ExprFunction) Token ¶
func (expr *ExprFunction) Token() Token
type ExprIdentifier ¶
type ExprIdentifier struct {
Ident string
// contains filtered or unexported fields
}
func (*ExprIdentifier) String ¶
func (expr *ExprIdentifier) String() string
func (*ExprIdentifier) Token ¶
func (expr *ExprIdentifier) Token() Token
type ExprLiteral ¶
type ExprLiteral struct {
Literal string
// contains filtered or unexported fields
}
func (*ExprLiteral) String ¶
func (expr *ExprLiteral) String() string
func (*ExprLiteral) Token ¶
func (expr *ExprLiteral) Token() Token
type ExprObject ¶
type ExprObject struct {
Items []ObjectKeyValue
// contains filtered or unexported fields
}
func (*ExprObject) String ¶
func (expr *ExprObject) String() string
func (*ExprObject) Token ¶
func (expr *ExprObject) Token() Token
type ExprTernary ¶
func (*ExprTernary) String ¶
func (expr *ExprTernary) String() string
func (*ExprTernary) Token ¶
func (expr *ExprTernary) Token() Token
type ExprUnary ¶
type ExprUnary struct {
Expr Expr
OpToken Token
Target AssignTarget // ++ and -- only
Postfix bool
}
type FnWithContext ¶
type FnWithContext struct {
Expr *ExprFunction
Scope *scope
}
type InputFile ¶
func NewBufferedInputFile ¶
type ObjectKeyValue ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) ParseExpression ¶
func (*Parser) ParseStatement ¶
type Precedence ¶
type Precedence uint8
const ( PrecNone Precedence = iota PrecAssign PrecTernary PrecLogical PrecComparison PrecAddition PrecMultiplication PrecPower PrecPostfix PrecUnary PrecCall PrecGroup )
type Program ¶
type Program struct {
Rules []Rule
Functions []ExprFunction
}
type RuntimeError ¶
func (RuntimeError) Error ¶
func (err RuntimeError) Error() string
type StatementBlock ¶
type StatementBlock struct {
Body []Statement
// contains filtered or unexported fields
}
func (*StatementBlock) Token ¶
func (stmt *StatementBlock) Token() Token
type StatementBreak ¶
type StatementBreak struct {
// contains filtered or unexported fields
}
func (*StatementBreak) Token ¶
func (stmt *StatementBreak) Token() Token
type StatementContinue ¶
type StatementContinue struct {
// contains filtered or unexported fields
}
func (*StatementContinue) Token ¶
func (stmt *StatementContinue) Token() Token
type StatementExit ¶
type StatementExit struct {
// contains filtered or unexported fields
}
func (*StatementExit) Token ¶
func (stmt *StatementExit) Token() Token
type StatementExpr ¶
type StatementExpr struct {
Expr Expr
}
func (*StatementExpr) Token ¶
func (stmt *StatementExpr) Token() Token
type StatementFor ¶
type StatementFor struct {
PreExpr Expr
Expr Expr
PostExpr Expr
Body Statement
// contains filtered or unexported fields
}
func (*StatementFor) Token ¶
func (stmt *StatementFor) Token() Token
type StatementForIn ¶
type StatementForIn struct {
Ident *ExprIdentifier
IndexIdent *ExprIdentifier
Iterable Expr
Body Statement
}
func (*StatementForIn) Token ¶
func (stmt *StatementForIn) Token() Token
type StatementIf ¶
func (*StatementIf) Token ¶
func (stmt *StatementIf) Token() Token
type StatementLet ¶
type StatementLet struct {
Ident *ExprIdentifier
Value Expr
}
func (*StatementLet) Token ¶
func (stmt *StatementLet) Token() Token
type StatementNext ¶
type StatementNext struct {
// contains filtered or unexported fields
}
func (*StatementNext) Token ¶
func (stmt *StatementNext) Token() Token
type StatementPrint ¶
type StatementPrint struct {
Args []Expr
// contains filtered or unexported fields
}
func (*StatementPrint) Token ¶
func (stmt *StatementPrint) Token() Token
type StatementReturn ¶
type StatementReturn struct {
Expr Expr
}
func (*StatementReturn) Token ¶
func (stmt *StatementReturn) Token() Token
type StatementWhile ¶
func (*StatementWhile) Token ¶
func (stmt *StatementWhile) Token() Token
type StreamingInputFile ¶
type StreamingInputFile struct {
// contains filtered or unexported fields
}
func (*StreamingInputFile) Name ¶
func (f *StreamingInputFile) Name() string
func (*StreamingInputFile) NewReader ¶
func (f *StreamingInputFile) NewReader() io.Reader
type SyntaxError ¶
func (SyntaxError) Error ¶
func (err SyntaxError) Error() string
type TokenTag ¶
type TokenTag uint8
const ( EOF TokenTag = iota Error Ident Str Regex Num Begin End BeginFile EndFile Print Function Return If Else For While In Match Break Continue Next Newline Exit Null Is Let True // true False // false LCurly // { RCurly // } LSquare // [ RSquare // ] LParen // ( RParen // ) LessThan // < GreaterThan // > Dollar // $ Comma // , Dot // . Equal // = EqualEqual // == BangEqual // != LessEqual // <= GreaterEqual // >= Colon // : SemiColon // ; Plus // + Minus // - Multiply // * Power // ** Divide // / PlusEqual // += MinusEqual // -= MultiplyEqual // *= DivideEqual // /= Tilde // ~ BangTilde // !~ AmpAmp // && PipePipe // || Arrow // => Bang // ! PlusPlus // ++ MinusMinus // -- Percent // % Question // ? )
type Value ¶
type Value struct {
Tag ValueTag
Str *string
Num *float64
Bool *bool
Array *Array
Obj *Object
NativeFn func(*Evaluator, []*Value, *Value) (*Value, error)
Fn FnWithContext
Regexp *regexp.Regexp
Proto *Value
Binding *Value
}
func (*Value) MarshalJSON ¶
func (*Value) PrettyString ¶
convert a value to prettified string
Click to show internal directories.
Click to hide internal directories.