Documentation
¶
Index ¶
- func ComputeChecksum(idl *IDL) (string, error)
- func ValidateIDL(idl *IDL) error
- type ArrayType
- type Enum
- type EnumDef
- type EnumValue
- type ErrorDecl
- type ErrorDef
- type ErrorsDef
- type Field
- type FieldDef
- type IDL
- type IDLElement
- type IDLFile
- type ImportDef
- type ImportString
- type Interface
- type InterfaceDef
- type MapTypeExpr
- type Method
- type MethodDef
- type NamespaceDef
- type Parameter
- type ParameterDef
- type ParseError
- type QualifiedName
- type RaisesIdentifier
- type Struct
- type StructDef
- type Type
- type TypeExpr
- type ValidationError
- type ValidationErrors
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeChecksum ¶ added in v0.2.7
func ValidateIDL ¶
ValidateIDL validates the parsed IDL and returns any validation errors
Types ¶
type ArrayType ¶
type ArrayType struct {
Pos lexer.Position
ArrayMarkers string `parser:"'[' ']'"`
// Capture the element type - can be nested
ElementType *TypeExpr `parser:"@@"`
}
ArrayType represents []Type - uses TextUnmarshaler for recursive parsing
type Enum ¶
type Enum struct {
Pos lexer.Position `json:"-"`
Name string `json:"name"`
Namespace string `json:"namespace,omitempty"`
Comment string `json:"comment,omitempty"`
Values []*EnumValue `json:"values,omitempty"`
}
Enum represents an enum definition with values
type EnumDef ¶
type EnumDef struct {
Pos lexer.Position
Name string `parser:"@Ident '{'"`
Values []string `parser:"@Ident* '}'"`
}
EnumDef represents an enum definition
type ErrorDecl ¶ added in v0.2.1
type ErrorDecl struct {
Pos lexer.Position
Code int `parser:"@IntLiteral"`
Name string `parser:"@Ident"`
Message string `parser:"@StringLiteral"`
}
ErrorDecl represents a single error declaration: <code> <name> <message>
type ErrorDef ¶ added in v0.2.1
type ErrorDef struct {
Pos lexer.Position `json:"-"`
Name string `json:"name"` // e.g., "NotFound" or "errors.NotFound" if imported
Namespace string `json:"namespace,omitempty"` // Namespace where declared
Code int `json:"code"` // JSON-RPC error code
Message string `json:"message"` // Error message template
Comment string `json:"comment,omitempty"` // Documentation comment
}
ErrorDef represents a declared error with code, name, and message
type Field ¶
type Field struct {
Pos lexer.Position `json:"-"`
Name string `json:"name"`
Type *Type `json:"type"`
Optional bool `json:"optional,omitempty"`
Comment string `json:"comment,omitempty"`
}
Field represents a struct field with type, optional flag, and comments
type FieldDef ¶
type FieldDef struct {
Pos lexer.Position
Name string `parser:"@Ident"`
Type *TypeExpr `parser:"@@"`
Optional bool `parser:"( @Optional )?"`
}
FieldDef represents a field definition
type IDL ¶
type IDL struct {
RootNamespace string `json:"rootNamespace,omitempty"` // Namespace of the root file being parsed
Checksum string `json:"checksum,omitempty"` // SHA-256 checksum of structural elements
Interfaces []*Interface `json:"interfaces,omitempty"`
Structs []*Struct `json:"structs,omitempty"`
Enums []*Enum `json:"enums,omitempty"`
Errors []*ErrorDef `json:"errors,omitempty"`
}
IDL represents the root structure containing all parsed IDL elements
type IDLElement ¶
type IDLElement struct {
Pos lexer.Position
Namespace *NamespaceDef `parser:" 'namespace' @@"`
Interface *InterfaceDef `parser:"| 'interface' @@"`
Struct *StructDef `parser:"| 'struct' @@"`
Enum *EnumDef `parser:"| 'enum' @@"`
Errors *ErrorsDef `parser:"| 'errors' @@"`
}
IDLElement represents any top-level IDL element
type IDLFile ¶
type IDLFile struct {
Pos lexer.Position
Elements []*IDLElement `parser:"@@*"`
}
IDLFile is the root grammar structure
type Interface ¶
type Interface struct {
Pos lexer.Position `json:"-"`
Name string `json:"name"`
Namespace string `json:"namespace,omitempty"`
Comment string `json:"comment,omitempty"`
Methods []*Method `json:"methods,omitempty"`
}
Interface represents a service interface with methods
type InterfaceDef ¶
type InterfaceDef struct {
Pos lexer.Position
Name string `parser:"@Ident '{'"`
Methods []*MethodDef `parser:"@@* '}'"`
}
InterfaceDef represents an interface definition
type MapTypeExpr ¶
type MapTypeExpr struct {
Pos lexer.Position
MapPattern string `parser:"@Map '[' @String ']'"`
// Capture the value type - can be nested
ValueType *TypeExpr `parser:"@@"`
}
MapTypeExpr represents map[string]ValueType - matches map pattern, value type parsed in post-processing
type Method ¶
type Method struct {
Pos lexer.Position `json:"-"`
Name string `json:"name"`
Parameters []*Parameter `json:"parameters,omitempty"`
ReturnType *Type `json:"returnType"`
ReturnOptional bool `json:"returnOptional,omitempty"`
Raises []string `json:"raises,omitempty"`
}
Method represents an interface method with parameters and return type
type MethodDef ¶
type MethodDef struct {
Pos lexer.Position
Name string `parser:"@Ident '('"`
Parameters []*ParameterDef `parser:"( @@ (',' @@)* )? ')' "`
ReturnType *TypeExpr `parser:"@@"`
ReturnOptional bool `parser:"( @Optional )?"`
Raises []*RaisesIdentifier `parser:"( 'raises' '(' @@ ( ',' @@ )* ')' )?"`
}
MethodDef represents a method definition
type NamespaceDef ¶
NamespaceDef represents a namespace declaration
type Parameter ¶
type Parameter struct {
Pos lexer.Position `json:"-"`
Name string `json:"name"`
Type *Type `json:"type"`
}
Parameter represents a method parameter
type ParameterDef ¶
type ParameterDef struct {
Pos lexer.Position
Name string `parser:"@Ident"`
Type *TypeExpr `parser:"@@"`
}
ParameterDef represents a parameter definition
type ParseError ¶
ParseError represents a parsing error with position information
func (*ParseError) Error ¶
func (e *ParseError) Error() string
type QualifiedName ¶
QualifiedName represents a qualified type name (e.g., "inc.Response" or "Response")
func (*QualifiedName) String ¶
func (q *QualifiedName) String() string
String returns the qualified name as a string
type RaisesIdentifier ¶ added in v0.2.1
type RaisesIdentifier struct {
Name *QualifiedName `parser:"@@"`
}
RaisesIdentifier represents an error identifier in a raises clause
type Struct ¶
type Struct struct {
Pos lexer.Position `json:"-"`
Name string `json:"name"`
Namespace string `json:"namespace,omitempty"`
Extends string `json:"extends,omitempty"` // Empty if no extends, can be qualified (e.g., "inc.Response")
Comment string `json:"comment,omitempty"`
Fields []*Field `json:"fields,omitempty"`
}
Struct represents a struct definition with fields and optional extends
type StructDef ¶
type StructDef struct {
Pos lexer.Position
Name string `parser:"@Ident"`
Extends *QualifiedName `parser:"( 'extends' @@ )?"`
Fields []*FieldDef `parser:"'{' @@* '}'"`
}
StructDef represents a struct definition
type Type ¶
type Type struct {
Pos lexer.Position `json:"-"`
// For built-in types: string, int, float, bool
BuiltIn string `json:"builtIn,omitempty"`
// For arrays: []Type
Array *Type `json:"array,omitempty"`
// For maps: map[string]ValueType
MapValue *Type `json:"mapValue,omitempty"`
// For user-defined types (interfaces, structs, enums)
UserDefined string `json:"userDefined,omitempty"`
}
Type represents a type (built-in, array, map, or user-defined)
func (*Type) IsUserDefined ¶
IsUserDefined returns true if this is a user-defined type
type TypeExpr ¶
type TypeExpr struct {
Pos lexer.Position
BuiltIn *string `parser:"( @String | @Int | @Float | @Bool )"`
Array *ArrayType `parser:"| @@"`
MapType *MapTypeExpr `parser:"| @@"`
UserDefined *QualifiedName `parser:"| @@"`
}
TypeExpr represents a type expression
type ValidationError ¶
ValidationError represents a validation error with position information
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
type ValidationErrors ¶
type ValidationErrors struct {
Errors []*ValidationError
}
ValidationErrors is a collection of validation errors
func (*ValidationErrors) Add ¶
func (e *ValidationErrors) Add(err *ValidationError)
func (*ValidationErrors) Error ¶
func (e *ValidationErrors) Error() string
func (*ValidationErrors) HasErrors ¶
func (e *ValidationErrors) HasErrors() bool