parser

package
v0.0.0-...-bf59245 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const ENUM = 57350
View Source
const ERROR = 57346
View Source
const FORMAT = 57351
View Source
const IDENT = 57347
View Source
const PRIM = 57352
View Source
const RESERVED = 57353
View Source
const STR = 57348
View Source
const STRUCT = 57354
View Source
const SUM = 57355
View Source
const TAG = 57349

Variables

This section is empty.

Functions

func Format

func Format(buf *bytes.Buffer, ast interface{})

Format converts an IR tree to a human-readable representation.

func ToString

func ToString(ast interface{}) string

ToString converts an IR tree to a human-readable representation, using Format.

Types

type Def

type Def struct {
	Kind  DefKind
	Name  TypeNameOccur
	Items []DefItem
}

Def represents either an enumeration, a primitive type, a struct, or a sum.

func Parse

func Parse(filename string, src io.Reader) ([]Def, error)

Parse parses definitions from an io.Reader.

type DefItem

type DefItem struct {
	Name    ItemNameOccur
	IsSlice bool
	Type    TypeNameOccur
	Tag     TagOccur
}

DefItem represents either an enumeration constant, a struct field, a sum alternative, or a reserved tag. Enumeration constants have a name. Struct fields have a name and a type. Sum alternatives have a type. Reserved tags have neither a name nor a type.

func (DefItem) IsReserved

func (i DefItem) IsReserved() bool

IsReserved returns true if the item is a tag reservation.

type DefKind

type DefKind int

DefKind determines the type of a definition.

const (
	EnumDef DefKind = iota
	PrimDef
	StructDef
	SumDef
)

DefKind values.

type ItemName

type ItemName string

ItemName represents the name of an enumeration constant or a struct field.

type ItemNameOccur

type ItemNameOccur struct {
	Name ItemName
	Pos  Pos
}

ItemNameOccur represents an occurrence of an ItemName in the input.

type Pos

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

Pos represents a position in the input.

func (Pos) String

func (pos Pos) String() string

type PosError

type PosError struct {
	Pos Pos
	Err error
}

PosError wraps an error that occurred at a specific position in the input.

func (PosError) Error

func (e PosError) Error() string

type Tag

type Tag int32

Tag represents a protobuf tag number.

type TagOccur

type TagOccur struct {
	Tag Tag
	Pos Pos
}

TagOccur represents an occurrence of a Tag in the input.

type TypeName

type TypeName string

TypeName represents the name of a type (primitive or not).

type TypeNameOccur

type TypeNameOccur struct {
	Name TypeName
	Pos  Pos
}

TypeNameOccur represents an occurrence of a TypeName in the input.

Jump to

Keyboard shortcuts

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