Documentation ¶
Overview ¶
Package parser implements the parse phase of the mtail program compilation. The parser itself is defined in parser.y, and goyacc generates the program code and token definitions. The parser fetches tokens from the lexer, which scans the input converting the program source into a token stream. The driver code wraps the generated parser and marshals the ast and errors back to the caller.
Two pretty-printers are used for debugging: the unparser, which converts an ast back into program text, and an approximation of an s-expression printer, which tries to model in indented text the structure of the ast.
#nosec G104 generated code, errors reported do not make sense
Index ¶
Constants ¶
const ADD_ASSIGN = 57397
const AFTER = 57352
const AND = 57395
const AS = 57353
const ASSIGN = 57398
const BITAND = 57391
const BITOR = 57393
const BUCKETS = 57363
const BUILTIN = 57365
const BY = 57354
const CAPREF = 57368
const CAPREF_NAMED = 57369
const COMMA = 57407
const CONST = 57355
const COUNTER = 57347
const DEC = 57376
const DECO = 57371
const DEF = 57357
const DEL = 57358
const DIV = 57377
const DURATIONLITERAL = 57374
const ELSE = 57361
const EOF = 0
EOF is a marker for end of file. It has the same value as the goyacc internal Kind `$end`.
const EQ = 57389
const FLOATLITERAL = 57373
const GAUGE = 57348
const GE = 57388
const GT = 57386
const HIDDEN = 57356
const HISTOGRAM = 57351
const ID = 57370
const INC = 57375
const INTLITERAL = 57372
const INVALID = 57346
const LCURLY = 57401
const LE = 57387
const LIMIT = 57364
const LPAREN = 57403
const LSQUARE = 57405
const LT = 57385
const MATCH = 57399
const MINUS = 57380
const MOD = 57378
const MUL = 57379
const NE = 57390
const NEXT = 57359
const NL = 57408
const NOT = 57394
const NOT_MATCH = 57400
const OR = 57396
const OTHERWISE = 57360
const PLUS = 57381
const POW = 57382
const RCURLY = 57402
const REGEX = 57366
const RPAREN = 57404
const RSQUARE = 57406
const SHL = 57383
const SHR = 57384
const STOP = 57362
const STRING = 57367
const TEXT = 57350
const TIMER = 57349
const XOR = 57392
Variables ¶
This section is empty.
Functions ¶
func Dictionary ¶
func Dictionary() (r []string)
Dictionary returns a list of all keywords and builtins of the language.
Types ¶
type Lexer ¶
type Lexer struct { InRegex bool // Context aware flag from parser to say we're in a regex // contains filtered or unexported fields }
A lexer holds the state of the scanner.
type Sexp ¶
type Sexp struct { EmitTypes bool // contains filtered or unexported fields }
Sexp is for converting program syntax trees into typed s-expression for printing.
func (*Sexp) Dump ¶
Dump begins the dumping of the syntax tree, returning the s-expression as a single string.
func (*Sexp) VisitAfter ¶
VisitAfter implements the astNode Visitor interface.
type Token ¶
Token describes a lexed Token from the input, containing its type, the original text of the Token, and its position in the input.
type Unparser ¶
type Unparser struct {
// contains filtered or unexported fields
}
Unparser is for converting program syntax trees back to program text.
func (*Unparser) Unparse ¶
Unparse begins the unparsing of the syntax tree, returning the program text as a single string.
func (*Unparser) VisitAfter ¶
VisitAfter implements the ast.Visitor interface.