Documentation ¶
Index ¶
- Constants
- func SplitComponents(n string) (pkgName, messageName string)
- type AnnotationCollection
- type AnnotationValue
- type Array
- type Element
- type Field
- type File
- type FileSet
- type Import
- type ImportFileNotFoundError
- type Map
- type Message
- type Method
- type MixedPackagesError
- type Offset
- type OneOfField
- type Package
- type ParseError
- type Position
- type Primitive
- type PrimitiveType
- type Scanner
- type Service
- type SourceFileNotFoundError
- type SourceIsDirectoryError
- type SyntaxError
- type Token
- type Type
- type TypeType
- type Unresolved
Constants ¶
const ( // RepeatedAnnotation contains a constant representing the name of // @repeated annotations. RepeatedAnnotation = "repeated" // OptionalAnnotation contains a constant representing the name of // @optional annotations. OptionalAnnotation = "optional" // DeprecatedAnnotation contains a constant representing the name of // @deprecated annotations. (RFU) DeprecatedAnnotation = "deprecated" )
Variables ¶
This section is empty.
Functions ¶
func SplitComponents ¶
SplitComponents splits a given name into a package and message name. In case the provided name does not include a package, pkgName is returned as an empty string.
Types ¶
type AnnotationCollection ¶
type AnnotationCollection []AnnotationValue
AnnotationCollection represents a list of Annotation values.
func (AnnotationCollection) FindByName ¶
func (a AnnotationCollection) FindByName(name string) (*AnnotationValue, bool)
FindByName takes a name and returns an Annotation value, and a boolean indicating whether the current AnnotationCollection contains the provided name.
type AnnotationValue ¶
AnnotationValue represents a single @annotation value present in a source file.
type Element ¶
type Element int
Element represents a single Token element kind in a source file
const ( InvalidElement Element = iota Identifier // [a-z][0-9a-z_] OpenCurly // { CloseCurly // } OpenParen // ( CloseParen // ) OpenAngled // < CloseAngled // > Comma // , Dot // . LineBreak // \n Equal // = Number // 0-9+ Arrow // -> Semi // ; Comment // Anything from # onwards Annotation // Anything from @ until next space StringElement // Anything between " EOF )
type Field ¶
type Field struct { Offset Offset Name string Comments []string Annotations AnnotationCollection Type Type Index int }
Field represents a Message's field
type File ¶
type File struct { // Tree contains a list of Package, Import, Message, and Service objects // representing structures defined in a source file. Tree []any // Package represents the package name defined by the source file. Package string // DeclaredMessages contains the names of all messages declared by the // source file. DeclaredMessages []string // DeclaredService contains the names of all services declared by the // source file. DeclaredServices []string // ImportedFiles contains a list of paths provided to `import` directives. ImportedFiles []string // contains filtered or unexported fields }
File represents a single YARP source file.
func (File) MessageByName ¶
MessageByName takes a name and returns a Message, along with a boolean indicating whether the provided message exists in the current File.
type FileSet ¶
type FileSet struct { Messages []*Message Services []*Service // contains filtered or unexported fields }
FileSet represents structures provided by a set of source files.
func (*FileSet) FindMessage ¶
FindMessage takes a message name (e.g. SomethingRequest) or FQN (e.g. package.SomethingRequest) and returns a Message along with a boolean indicating whether the provided name could be resolved to a message.
func (FileSet) FromSamePackage ¶
FromSamePackage takes a name and returns whether it is declared by the package declared in the loaded source files.
type ImportFileNotFoundError ¶
type ImportFileNotFoundError struct{ Source, Path string }
ImportFileNotFoundError indicates that a file imported by a given source could not be found.
func (ImportFileNotFoundError) Error ¶
func (i ImportFileNotFoundError) Error() string
type Map ¶
type Map struct { Key PrimitiveType Value Type }
type Message ¶
type Message struct { Offset Offset Name string Comments []string Annotations AnnotationCollection Fields []any }
Message represents a single `message` declared in a source file.
type Method ¶
type Method struct { Offset Offset Name string Comments []string Annotations AnnotationCollection ArgumentType string ReturnType string ReturnStreaming bool }
Method represents a Service's method
type MixedPackagesError ¶
type MixedPackagesError struct{ Path, Package1, Package2 string }
MixedPackagesError indicates that source files provides different packages. Only a single package can be compiled at a time.
func (MixedPackagesError) Error ¶
func (m MixedPackagesError) Error() string
type Offset ¶
Offset represents the offset in which a given structure appears in the source file. It includes Position for both the point in which it starts, and the point in which it ends.
type OneOfField ¶
type OneOfField struct { Offset Offset Comments []string Annotations AnnotationCollection Index int Items []any }
OneOfField represents an oneof field present in a Message
type ParseError ¶
ParseError indicates that one or more productions from the scanner does not define a valid IDL file.
func (ParseError) Error ¶
func (p ParseError) Error() string
type Primitive ¶
type Primitive struct {
Kind PrimitiveType
}
type PrimitiveType ¶
type PrimitiveType int
PrimitiveType represents a single type recognized by YARP
const ( Invalid PrimitiveType = iota Uint8 Uint16 Uint32 Uint64 Int8 Int16 Int32 Int64 Float32 Float64 Struct OneOf Bool String )
func (PrimitiveType) String ¶
func (i PrimitiveType) String() string
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner implements mechanisms responsible for reading an IDL file into a list of tokens.
func NewScanner ¶
NewScanner creates a new Scanner bound to a given io.Reader. The scanner does not close the provided reader. See also: Scan
type Service ¶
type Service struct { Offset Offset Name string Comments []string Annotations AnnotationCollection Methods []Method }
Service represents a single `service` declared in a source file.
type SourceFileNotFoundError ¶
type SourceFileNotFoundError struct{ Path string }
SourceFileNotFoundError indicates that the process could not find an input file provided by the user.
func (SourceFileNotFoundError) Error ¶
func (s SourceFileNotFoundError) Error() string
type SourceIsDirectoryError ¶
type SourceIsDirectoryError struct{ Path string }
SourceIsDirectoryError indicates that a given source file is, in fact, a directory, and therefore cannot be read.
func (SourceIsDirectoryError) Error ¶
func (s SourceIsDirectoryError) Error() string
type SyntaxError ¶
SyntaxError indicates that a provided file does not contain a valid YARP Interface Description File.
func (SyntaxError) Error ¶
func (s SyntaxError) Error() string
type Token ¶
Token represents a single token present in a source file
type Unresolved ¶
type Unresolved struct {
Name string
}
func (Unresolved) Type ¶
func (Unresolved) Type() TypeType