Documentation ¶
Overview ¶
compile and execute GSC requests
Index ¶
- Constants
- func CompareAny(v1, v2 any) (int, error)
- func Eval(name string, content string) (result any, err error)
- func EvalFile(fname string) (result any, err error)
- func EvalFileWithParams(fname string, params map[string]any) (result any, err error)
- func EvalWithParams(name string, content string, params map[string]any) (result any, err error)
- func GetParamsList(compiledRequest Node) []string
- func ParseLitteral(content string) (any, error)
- func TokenAsString(t int) string
- type Interpreter
- type Lexer
- type Node
- type NodeMap
- type NodeWithBody
- type Nodes
Constants ¶
const ( // Colors ColRED = csi + "31m" ColGREEN = csi + "32m" ColYELLOW = csi + "33m" ColBLUE = csi + "34m" ColMAGENTA = csi + "35m" ColCYAN = csi + "36m" // Graphics parameters Bold = csi + "1m" Italic = csi + "3m" Underline = csi + "4m" Blink = csi + "5m" Reverse = csi + "7m" Strike = csi + "9m" Dim = csi + "2m" // Cursor save/restore CursorSave = csi + "s" CursorRestore = csi + "u" // Clear creen ClearScreen = csi + "2J" ClearScreenFromCursor = csi + "0J" ClearScreenBeforeCursor = csi + "1J" // Clear line ClearLine = csi + "2K" ClearLineFromCursor = csi + "0K" ClearLineBeforeCursor = csi + "1K" // Reset all settings AnsiRESET = csi + "0m" )
const ABS = 57384
const AND = 57386
const AS = 57363
const ASSERT = 57418
const ASSIGN = 57350
const AT = 57409
const ATTR = 57406
const BLUE = 57433
const BOOL = 57346
const CLICK = 57352
const CLOSE = 57402
const COLON = 57404
const COMMA = 57360
const CONTAINS = 57396
const CYAN = 57434
const DISTINCT = 57408
const DIV = 57382
const DOLLAR = 57427
const DOT = 57375
const DOTDOT = 57410
const ELSE = 57417
const EQ = 57390
const FAIL = 57419
const FILE_SEPARATOR = 57414
const FIND = 57397
const FOR = 57361
const FORMAT = 57421
const FROM = 57364
const GO = 57423
const GREEN = 57431
const GSC = 57425
const GT = 57394
const GTE = 57395
const IDENTIFIER = 57349
const IF = 57415
const IN = 57354
const INPUT = 57353
const JOIN = 57400
const JSON = 57424
const LAST = 57429
const LBRACE = 57373
const LBRACKET = 57371
const LEFT = 57356
const LEN = 57376
const LIMIT = 57368
const LPAREN = 57369
const LT = 57392
const LTE = 57393
const MAGENTA = 57435
const MIDDLE = 57358
const MINUS = 57378
const MINUSMINUS = 57380
const MOD = 57383
const MULTI = 57381
const NAND = 57389
const NEQ = 57391
const NIL = 57428
const NL = 57426
const NORMAL = 57436
const NOT = 57385
const NOW = 57412
const NUMBER = 57347
const OF = 57407
const OR = 57387
const PAGE = 57401
const PAGES = 57403
const PATH = 57398
const PLUS = 57377
const PLUSPLUS = 57379
const PRINT = 57420
const QUESTION = 57411
const RANGE = 57438
const RAW = 57422
const RBRACE = 57374
const RBRACKET = 57372
const RED = 57430
const RETURN = 57359
const RIGHT = 57357
const RPAREN = 57370
const SELECT = 57362
const SEMICOLON = 57351
const SLOW = 57355
const STEP = 57366
const STRING = 57348
const TEXT = 57405
const THEN = 57416
const TO = 57365
const VERSION = 57413
const WHERE = 57367
const WITH = 57399
const XOR = 57388
const XPATH = 57437
const YELLOW = 57432
Variables ¶
This section is empty.
Functions ¶
func CompareAny ¶ added in v0.4.9
CompareAny takes two interface{} values and tries to compare them. It returns -1 if v1 < v2, 0 if v1 == v2, and 1 if v1 > v2. If the types are different or not comparable, it returns an error.
func Eval ¶ added in v0.4.9
Compile a request, create a defalt interpreter, and evaluate the request.
func EvalFileWithParams ¶ added in v0.4.9
Eval from file with parameter map
func EvalWithParams ¶ added in v0.4.9
Same a Eval, but with parameters map
func GetParamsList ¶ added in v0.4.14
Extracts the (sorted) list of parameters a compiled requests expects.
func ParseLitteral ¶ added in v0.4.9
ParseLitteral parse a gsc litteral with a small subset of the gsc syntax. Only accepts nil, bool, ints, strings, [] and {}.
func TokenAsString ¶
Prints a token defined by its constant value as a string.
Types ¶
type Interpreter ¶ added in v0.4.9
type Interpreter struct {
// contains filtered or unexported fields
}
Interpreter maintains context for running a compiled request.
func NewInterpreter ¶ added in v0.4.9
func NewInterpreter(ctx context.Context) *Interpreter
Start a new interpreter in default setting.
func (*Interpreter) DumpVars ¶ added in v0.4.9
func (it *Interpreter) DumpVars(w io.Writer, title string)
Write all known variables to the given writer, including input parameters. Sorted for test stability.
func (*Interpreter) Eval ¶ added in v0.4.9
func (it *Interpreter) Eval(node Node) (any, error)
Evaluate a compiled request.
func (*Interpreter) SetAsyncMode ¶ added in v0.4.9
func (it *Interpreter) SetAsyncMode(ch chan<- any) *Interpreter
Set asynchroneous mode. Results will be sent to channel for each loop. If channel is nil, sets to synchroneous mode.
func (*Interpreter) SetSyncMode ¶ added in v0.4.9
func (it *Interpreter) SetSyncMode() *Interpreter
Set synchroneous mode. Results will be aggregated and sent at the end. This is the default mode.
func (*Interpreter) With ¶ added in v0.4.9
func (it *Interpreter) With(params map[string]any) *Interpreter
Set input parameters for the request to interprete.
type Node ¶ added in v0.4.9
type Node interface {
// contains filtered or unexported methods
}
Node for the abstract syntax tree.
type NodeWithBody ¶ added in v0.4.9
type NodeWithBody interface { Node // contains filtered or unexported methods }
Node with a body (eg : loop statement)