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.
Index ¶
Constants ¶
const ADD_ASSIGN = 57396
const AFTER = 57352
const AND = 57394
const AS = 57353
const ASSIGN = 57397
const BITAND = 57390
const BITOR = 57392
const BUCKETS = 57363
const BUILTIN = 57364
const BY = 57354
const CAPREF = 57367
const CAPREF_NAMED = 57368
const COMMA = 57407
const CONCAT = 57398
const CONST = 57355
const COUNTER = 57347
const DEC = 57375
const DECO = 57370
const DEF = 57357
const DEL = 57358
const DIV = 57376
const DURATIONLITERAL = 57373
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 = 57388
const FLOATLITERAL = 57372
const GAUGE = 57348
const GE = 57387
const GT = 57385
const HIDDEN = 57356
const HISTOGRAM = 57351
const ID = 57369
const INC = 57374
const INTLITERAL = 57371
const INVALID = 57346
const LCURLY = 57401
const LE = 57386
const LPAREN = 57403
const LSQUARE = 57405
const LT = 57384
const MATCH = 57399
const MINUS = 57379
const MOD = 57377
const MUL = 57378
const NE = 57389
const NEXT = 57359
const NL = 57408
const NOT = 57393
const NOT_MATCH = 57400
const OR = 57395
const OTHERWISE = 57360
const PLUS = 57380
const POW = 57381
const RCURLY = 57402
const REGEX = 57365
const RPAREN = 57404
const RSQUARE = 57406
const SHL = 57382
const SHR = 57383
const STOP = 57362
const STRING = 57366
const TEXT = 57350
const TIMER = 57349
const XOR = 57391
Variables ¶
This section is empty.
Functions ¶
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.