Documentation ¶
Overview ¶
Package ast defines the AST data structures used by gotoc.
Index ¶
- Variables
- func Walk(v Visitor, n Node)
- func WalkFile(v Visitor, f *File)
- type Comment
- type Enum
- type EnumValue
- type Extension
- type Field
- type FieldType
- type File
- type FileOrMessage
- type FileOrNode
- type FileSet
- type Message
- type MessageOrExtension
- type MessageOrField
- type Method
- type Node
- type NodeSort
- type Oneof
- type Position
- type Reserved
- type Service
- type Visitor
Constants ¶
This section is empty.
Variables ¶
var FieldTypeMap = map[FieldType]string{ Double: "double", Float: "float", Int64: "int64", Uint64: "uint64", Int32: "int32", Fixed64: "fixed64", Fixed32: "fixed32", Bool: "bool", String: "string", Bytes: "bytes", Uint32: "uint32", Sfixed32: "sfixed32", Sfixed64: "sfixed64", Sint32: "sint32", Sint64: "sint64", }
Functions ¶
Types ¶
type Comment ¶
Comment represents a comment.
func InlineComment ¶
InlineComment returns the comment on the same line as a node, or nil if there's no inline comment. The returned comment is guaranteed to be a single line.
func LeadingComment ¶
LeadingComment returns the comment that immediately precedes a node, or nil if there's no such comment.
type Enum ¶
type Enum struct { Position Position // position of "enum" token Name string Values []*EnumValue Up FileOrMessage // either *File or *Message }
type Extension ¶
type Extension struct { Position Position // position of the "extend" token Extendee string // the thing being extended ExtendeeType *Message // set during resolution Fields []*Field Up FileOrMessage // either *File or *Message or ... }
Extension represents an extension definition.
type Field ¶
type Field struct { Position Position // position of "required"/"optional"/"repeated"/type // TypeName is the raw name parsed from the input. // Type is set during resolution; it will be a FieldType, *Message or *Enum. TypeName string Type interface{} // For a map field, the TypeName/Type fields are the value type, // and KeyTypeName/KeyType will be set. KeyTypeName string KeyType FieldType // At most one of {required,repeated} is set. Required bool Repeated bool Name string Tag int HasDefault bool Default string // e.g. "foo", 7, true HasPacked bool Packed bool HasDeprecated bool Deprecated bool Options [][2]string // slice of key/value pairs Oneof *Oneof Up MessageOrExtension // either *Message or *Extension }
Field represents a field in a message.
type FieldType ¶
type FieldType int8
const ( Double FieldType Float Int64 Uint64 Int32 Fixed64 Fixed32 Bool String Bytes Uint32 Sfixed32 Sfixed64 Sint32 Sint64 )
type File ¶
type File struct { Name string // filename Syntax string // "proto2" or "proto3" Package []string Options [][2]string // slice of key/value pairs Imports []string PublicImports []int // list of indexes in the Imports slice Messages []*Message // top-level messages Enums []*Enum // top-level enums Services []*Service // services Extensions []*Extension // top-level extensions Comments []*Comment // all the comments for this file, sorted by position }
File represents a single proto file.
type FileOrMessage ¶
type FileOrMessage interface { FileOrNode // contains filtered or unexported methods }
type FileOrNode ¶
type FileOrNode interface {
// contains filtered or unexported methods
}
type Message ¶
type Message struct { Position Position // position of the "message" token Name string Group bool Fields []*Field Extensions []*Extension Oneofs []*Oneof ReservedFields []Reserved Options [][2]string Messages []*Message // includes groups Enums []*Enum ExtensionRanges [][2]int // extension ranges (inclusive at both ends) Up FileOrMessage // either *File or *Message }
Message represents a proto message.
type MessageOrExtension ¶
type MessageOrExtension interface { FileOrNode // contains filtered or unexported methods }
type MessageOrField ¶
type MessageOrField interface { FileOrNode // contains filtered or unexported methods }
type Method ¶
type Method struct { Position Position // position of the "rpc" token Name string // InTypeName/OutTypeName are the raw names parsed from the input. // InType/OutType is set during resolution; it will be a *Message. InTypeName, OutTypeName string InType, OutType interface{} // TODO: support streaming methods Options [][2]string // slice of key/value pairs Up *Service }
Method represents an RPC method.
type Node ¶
type Node interface { FileOrNode Pos() Position File() *File }
Node is implemented by concrete types that represent things appearing in a proto file.
type Position ¶
Position describes a source position in an input file. It is only valid if the line number is positive.