parser

package
v0.2.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Digits    = "0123456789"
	HexDigits = "0123456789abcdefABCDEF"
)
View Source
const ADD = 57379
View Source
const ADD_EQ = 57392
View Source
const AND = 57402
View Source
const BOOL = 57375
View Source
const BREAK = 57367
View Source
const COLON = 57371
View Source
const COMMA = 57347
View Source
const COMMENT = 57348
View Source
const CONTINUE = 57368
View Source
const DIV = 57380
View Source
const DIV_EQ = 57394
View Source
const DOT = 57349
View Source
const ELIF = 57407
View Source
const ELSE = 57408
View Source
const EOF = 57350
View Source
const EOL = 57370
View Source
const EQ = 57389
View Source
const EQEQ = 57390
View Source
const ERROR = 57351
View Source
const FALSE = 57400
View Source
const FLOAT = 57374
View Source
const FOR = 57364
View Source
const GT = 57382
View Source
const GTE = 57381
View Source
const ID = 57352
View Source
const IDENTIFIER = 57401
View Source
const IF = 57406
View Source
const IN = 57365
View Source
const INT = 57373
View Source
const LEFT_BRACE = 57356
View Source
const LEFT_BRACKET = 57355
View Source
const LEFT_PAREN = 57354
View Source
const LIST = 57376
View Source
const LT = 57384
View Source
const LTE = 57385
View Source
const MAP = 57377
View Source
const MOD = 57386
View Source
const MOD_EQ = 57396
View Source
const MUL = 57387
View Source
const MULTILINE_STRING = 57363
View Source
const MUL_EQ = 57395
View Source
const NEQ = 57388
View Source
const NIL = 57404
View Source
const NOT = 57383
View Source
const NULL = 57405
View Source
const NUMBER = 57353
View Source
const OR = 57403
View Source
const QUOTED_STRING = 57362
View Source
const RETURN = 57369
View Source
const RIGHT_BRACE = 57357
View Source
const RIGHT_BRACKET = 57359
View Source
const RIGHT_PAREN = 57358
View Source
const SEMICOLON = 57346
View Source
const SPACE = 57360
View Source
const START_STMTS = 57411
View Source
const STR = 57372
View Source
const STRING = 57361
View Source
const SUB = 57391
View Source
const SUB_EQ = 57393
View Source
const TRUE = 57399
View Source
const UMINUS = 57413
View Source
const WHILE = 57366

Variables

View Source
var (
	ItemTypeStr = map[ItemType]string{
		LEFT_PAREN:    "(",
		RIGHT_PAREN:   ")",
		LEFT_BRACKET:  "[",
		RIGHT_BRACKET: "]",
		LEFT_BRACE:    "{",
		RIGHT_BRACE:   "}",
		COMMA:         ",",

		EQ:     "=",
		ADD_EQ: "+=",
		SUB_EQ: "-=",
		MUL_EQ: "*=",
		DIV_EQ: "/=",
		MOD_EQ: "%=",

		SEMICOLON: ";",
		DOT:       ".",
		SPACE:     "<space>",
		COLON:     ":",

		EQEQ: "==",
		NEQ:  "!=",
		LTE:  "<=",
		LT:   "<",
		GTE:  ">=",
		GT:   ">",

		NOT: "!",
		SUB: "-",
		ADD: "+",
		MUL: "*",
		MOD: "%",
		DIV: "/",

		AND: "&&",
		OR:  "||",
	}

	AstOp = func(op ItemType) ast.Op {
		return ast.Op(ItemTypeStr[op])
	}
)
View Source
var ErrSyntax = errors.New("invalid syntax")

ErrSyntax indicates that a value does not have the right syntax for the target type.

Functions

func InitLog

func InitLog(logger logger.Logger)

func ParsePipeline

func ParsePipeline(name, input string) (res ast.Stmts, err error)

func Unquote

func Unquote(s string) (t string, err error)

Unquote interprets s as a single-quoted, double-quoted, or backquoted Prometheus query language string literal, returning the string value that s quotes.

NOTE: This function as well as the necessary helper functions below (unquoteChar, contains, unhex) and associated tests have been adapted from the corresponding functions in the "strconv" package of the Go standard library to work for Prometheus-style strings. Go's special-casing for single quotes was removed and single quoted strings are now treated the same as double quoted ones.

func UnquoteMultiline

func UnquoteMultiline(s string) (t string, err error)

Types

type Item

type Item struct {
	Typ ItemType
	Pos token.Pos
	Val string
}

func (*Item) PositionRange

func (i *Item) PositionRange() *PositionRange

func (Item) String

func (i Item) String() string

type ItemType

type ItemType int

func (ItemType) IsKeyword

func (i ItemType) IsKeyword() bool

func (ItemType) IsOperator

func (i ItemType) IsOperator() bool

func (ItemType) String

func (i ItemType) String() string

type Lexer

type Lexer struct {
	// contains filtered or unexported fields
}

Lexer holds the state of the scanner.

func Lex

func Lex(input string) *Lexer

func (*Lexer) NextItem

func (l *Lexer) NextItem(itemp *Item)

type ParseError

type ParseError struct {
	Pos   *PositionRange
	Err   error
	Query string
}

func (*ParseError) Error

func (e *ParseError) Error() string

type ParseErrors

type ParseErrors []ParseError

func (ParseErrors) Error

func (errs ParseErrors) Error() string

Error impl Error() interface.

type PositionRange

type PositionRange struct {
	Start, End token.Pos
}

func (PositionRange) String

func (pos PositionRange) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL