parser

package
v3.0.0-rc30+incompatible Latest Latest
Warning

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

Go to latest
Published: May 14, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

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

View Source
const ADD_ASSIGN = 57396
View Source
const AFTER = 57352
View Source
const AND = 57394
View Source
const AS = 57353
View Source
const ASSIGN = 57397
View Source
const BITAND = 57390
View Source
const BITOR = 57392
View Source
const BUCKETS = 57363
View Source
const BUILTIN = 57364
View Source
const BY = 57354
View Source
const CAPREF = 57367
View Source
const CAPREF_NAMED = 57368
View Source
const COMMA = 57407
View Source
const CONCAT = 57398
View Source
const CONST = 57355
View Source
const COUNTER = 57347
View Source
const DEC = 57375
View Source
const DECO = 57370
View Source
const DEF = 57357
View Source
const DEL = 57358
View Source
const DIV = 57376
View Source
const DURATIONLITERAL = 57373
View Source
const ELSE = 57361
View Source
const EOF = 0

EOF is a marker for end of file. It has the same value as the goyacc internal Kind `$end`.

View Source
const EQ = 57388
View Source
const FLOATLITERAL = 57372
View Source
const GAUGE = 57348
View Source
const GE = 57387
View Source
const GT = 57385
View Source
const HIDDEN = 57356
View Source
const HISTOGRAM = 57351
View Source
const ID = 57369
View Source
const INC = 57374
View Source
const INTLITERAL = 57371
View Source
const INVALID = 57346
View Source
const LCURLY = 57401
View Source
const LE = 57386
View Source
const LPAREN = 57403
View Source
const LSQUARE = 57405
View Source
const LT = 57384
View Source
const MATCH = 57399
View Source
const MINUS = 57379
View Source
const MOD = 57377
View Source
const MUL = 57378
View Source
const NE = 57389
View Source
const NEXT = 57359
View Source
const NL = 57408
View Source
const NOT = 57393
View Source
const NOT_MATCH = 57400
View Source
const OR = 57395
View Source
const OTHERWISE = 57360
View Source
const PLUS = 57380
View Source
const POW = 57381
View Source
const RCURLY = 57402
View Source
const REGEX = 57365
View Source
const RPAREN = 57404
View Source
const RSQUARE = 57406
View Source
const SHL = 57382
View Source
const SHR = 57383
View Source
const STOP = 57362
View Source
const STRING = 57366
View Source
const TEXT = 57350
View Source
const TIMER = 57349
View Source
const XOR = 57391

Variables

This section is empty.

Functions

func Parse

func Parse(name string, input io.Reader) (ast.Node, error)

Parse reads the program named name from the input, and if successful returns an ast.Node for the root of the AST, otherwise parser errors.

Types

type Kind

type Kind int

Kind enumerates the types of lexical tokens in a mtail program.

func (Kind) String

func (k Kind) String() string

String returns a readable name of the token Kind.

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.

func NewLexer

func NewLexer(name string, input io.Reader) *Lexer

NewLexer creates a new scanner type that reads the input provided.

func (*Lexer) NextToken

func (l *Lexer) NextToken() Token

NextToken returns the next token in the input. When no token is available to be returned it executes the next action in the state machine.

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

func (s *Sexp) Dump(n ast.Node) string

Dump begins the dumping of the syntax tree, returning the s-expression as a single string

func (*Sexp) VisitAfter

func (s *Sexp) VisitAfter(node ast.Node) ast.Node

VisitAfter implements the astNode Visitor interface.

func (*Sexp) VisitBefore

func (s *Sexp) VisitBefore(n ast.Node) (ast.Visitor, ast.Node)

VisitBefore implements the astNode Visitor interface.

type Token

type Token struct {
	Kind     Kind
	Spelling string
	Pos      position.Position
}

Token describes a lexed Token from the input, containing its type, the original text of the Token, and its position in the input.

func (Token) String

func (t Token) String() string

String returns a printable form of a Token.

type Unparser

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

Unparser is for converting program syntax trees back to program text.

func (*Unparser) Unparse

func (u *Unparser) Unparse(n ast.Node) string

Unparse begins the unparsing of the syntax tree, returning the program text as a single string.

func (*Unparser) VisitAfter

func (u *Unparser) VisitAfter(n ast.Node) ast.Node

VisitAfter implements the ast.Visitor interface.

func (*Unparser) VisitBefore

func (u *Unparser) VisitBefore(n ast.Node) (ast.Visitor, ast.Node)

VisitBefore implements the ast.Visitor interface.

Jump to

Keyboard shortcuts

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