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 = 57394
const AFTER = 57351
const AND = 57392
const AS = 57352
const ASSIGN = 57395
const BITAND = 57388
const BITOR = 57390
const BUILTIN = 57362
const BY = 57353
const CAPREF = 57365
const CAPREF_NAMED = 57366
const COMMA = 57405
const CONCAT = 57396
const CONST = 57354
const COUNTER = 57347
const DEC = 57373
const DECO = 57368
const DEF = 57356
const DEL = 57357
const DIV = 57374
const DURATIONLITERAL = 57371
const ELSE = 57360
const EOF = 0
EOF is a marker for end of file. It has the same value as the goyacc internal Kind `$end`.
const EQ = 57386
const FLOATLITERAL = 57370
const GAUGE = 57348
const GE = 57385
const GT = 57383
const HIDDEN = 57355
const ID = 57367
const INC = 57372
const INTLITERAL = 57369
const INVALID = 57346
const LCURLY = 57399
const LE = 57384
const LPAREN = 57401
const LSQUARE = 57403
const LT = 57382
const MATCH = 57397
const MINUS = 57377
const MOD = 57375
const MUL = 57376
const NE = 57387
const NEXT = 57358
const NL = 57406
const NOT = 57391
const NOT_MATCH = 57398
const OR = 57393
const OTHERWISE = 57359
const PLUS = 57378
const POW = 57379
const RCURLY = 57400
const REGEX = 57363
const RPAREN = 57402
const RSQUARE = 57404
const SHL = 57380
const SHR = 57381
const STOP = 57361
const STRING = 57364
const TEXT = 57350
const TIMER = 57349
const XOR = 57389
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.