Documentation ¶
Overview ¶
Package ast implements Thrift AST and parser.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Const ¶
type Const struct { Type *Type `parser:" 'const' @@ "` Name string `parser:" @Ident "` Value *Value `parser:" '=' @@ "` }
Const represents the Thrift const.
type Definition ¶
type Definition struct { Const *Const `parser:" @@ " json:",omitempty"` Typedef *Typedef `parser:" | @@ " json:",omitempty"` Enum *Enum `parser:" | @@ " json:",omitempty"` Struct *Struct `parser:" | @@ " json:",omitempty"` Service *Service `parser:" | @@ " json:",omitempty"` }
Definition represents the Thrift definition.
type Enum ¶
type Enum struct { Name string `parser:" 'enum' @Ident "` Constants []*EnumConstant `parser:" '{' @@* '}' " json:",omitempty"` }
Enum represents the Thrift enum.
type EnumConstant ¶
type EnumConstant struct { Name string `parser:" @Ident "` Value *int `parser:" ( '=' @Int )? " json:",omitempty"` }
EnumConstant represents the constant of the Thrift enum.
type Field ¶
type Field struct { ID int `parser:" @Int ':' "` Optional bool `parser:" ( 'required' | @'optional' )? " json:",omitempty"` Type *Type `parser:" @@ "` Name string `parser:" @Ident "` }
Field represents the field of the Thrift struct.
type File ¶
type File struct { Headers []*Header `parser:" ( @@* " json:",omitempty"` Definitions []*Definition `parser:" @@* )? " json:",omitempty"` }
File represents the Thrift file.
func ParseBytes ¶
ParseBytes parses the Thrift file from []byte.
func ParseString ¶
ParseString parses the Thrift file from string.
func (File) GetDefinition ¶
func (f File) GetDefinition(name string) *Definition
GetDefinition returns the definition which matches the given name.
func (File) GetNamespace ¶
GetNamespace returns the namespace which matches the given language.
type Header ¶
type Header struct { Include *Include `parser:" @@ " json:",omitempty"` Namespace *Namespace `parser:" | @@ " json:",omitempty"` }
Header represents the Thrift header.
type Include ¶
type Include struct {
Path string `parser:" 'include' @String "`
}
Include represents the Thrift include.
type Method ¶
type Method struct { Oneway bool `parser:" @'oneway'? " json:",omitempty"` Void bool `parser:" ( @'void' " json:",omitempty"` Type *Type `parser:" | @@ ) " json:",omitempty"` Name string `parser:" @Ident "` Arguments []*Field `parser:" '(' @@* ')' " json:",omitempty"` Throws []*Field `parser:" ( 'throws' '(' @@* ')' )? " json:",omitempty"` }
Method represents the method of the Thrift service.
type Namespace ¶
type Namespace struct { Language string `parser:" 'namespace' @( Ident | '*' ) "` Name string `parser:" @Ident "` }
Namespace represents the Thrift namespace.
type Service ¶
type Service struct { Name string `parser:" 'service' @Ident "` Extends *string `parser:" ( 'extends' @Ident )? " json:",omitempty"` Methods []*Method `parser:" '{' @@* '}' " json:",omitempty"` }
Service represents the Thrift service.
type Struct ¶
type Struct struct { Type string `parser:" @( 'struct' | 'union' | 'exception' ) "` Name string `parser:" @Ident "` Fields []*Field `parser:" '{' @@* '}' " json:",omitempty"` }
Struct represents the Thrift struct.
type Type ¶
type Type struct { Name string `parser:" @Ident "` Arguments []*Type `parser:" ( '<' @@ ( ',' @@ )* '>' )? " json:",omitempty"` }
Type represents the Thrift type.
type Value ¶
type Value struct { Int *float64 `parser:" @( ( '+' | '-' )? Int ( '.' Int? )? ) " json:",omitempty"` String *string `parser:" | @String " json:",omitempty"` List []*Value `parser:" | '[' ( @@ ','? )* ']' " json:",omitempty"` Map []*MapItem `parser:" | '{' @@* '}' " json:",omitempty"` Reference string `parser:" | @Ident " json:",omitempty"` }
Value represents the Thrift value.