Documentation ¶
Index ¶
- func ValidPackage(pkgName string) error
- type Enum
- type EnumVal
- type File
- func (f *File) Enums() chan Enum
- func (f *File) FindNext(ctx context.Context, p *halfpike.Parser) halfpike.ParseFn
- func (f *File) ParseOptions(ctx context.Context, p *halfpike.Parser) halfpike.ParseFn
- func (f *File) ParsePackage(ctx context.Context, p *halfpike.Parser) halfpike.ParseFn
- func (f *File) ParseVersion(ctx context.Context, p *halfpike.Parser) halfpike.ParseFn
- func (f *File) PkgImports() chan string
- func (f *File) SkipLinesWithComments(p *halfpike.Parser)
- func (f *File) Start(ctx context.Context, p *halfpike.Parser) halfpike.ParseFn
- func (f *File) Structs() []Struct
- func (f *File) Validate() error
- type Import
- type ImportEntry
- type Option
- type Options
- type Struct
- type StructField
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidPackage ¶
ValidPackage determines if a package name is valid.
Types ¶
type Enum ¶
Enum is a set of name values that translate to a number.
func (Enum) OrderByNames ¶
func (Enum) OrderByValues ¶
type File ¶
type File struct { // Package is the name of the package. Package string // FullPath is the full path to the package. FullPath string // Version is the version of the Claw language. Version int // Options defines options that were defined on the file. Options map[string]Option // Identifers hold types that are defined in this file. Identifers map[string]any // External holds externally defined types that are imported here. External map[string]*File // Imports are all the package imports. Imports Import // RepoVersion is the version of the file in the repo. RepoVersion string // SHA256 is the file's SHA256 hash value. SHA256 string }
File represents the collected information from a .claw file.
func (*File) FindNext ¶
FindNext is used to scan lines until we find the next thing to parse and direct to the halfpike.ParseFn responsible.
func (*File) ParseOptions ¶
ParseOptions parses file options that follow the root "options" keyword.
func (*File) ParsePackage ¶
ParseVersion finds the version
func (*File) ParseVersion ¶
ParseVersion finds the version
func (*File) PkgImports ¶
PkgImports returns a deduped list of all Claw packages that need importing. This DOES NOT include packages needed for Claw decoding.
func (*File) SkipLinesWithComments ¶
type Import ¶
type Import struct {
Imports map[string]ImportEntry
}
Import represents an import block.
type ImportEntry ¶
ImportEntry represents an individual import entry.
type Option ¶
type Option struct { // Name is the name of the Option. Name string // Args are all the arguments to the Option. Args []string }
Option is an option for the file.
type Struct ¶
type Struct struct { // Name is the name of the Struct type. Name string // Fields are the fields in the Struct. Fields []StructField // File has all the information in the File. File *File }
Struct represents a Claw Struct type in the file.
type StructField ¶
type StructField struct { // Name is the name of the field. Name string // Index is the index of the field in the Struct. Index uint16 // Type is the type of the field. Type field.Type // IsExternal indicates this field type was defined external to the file that has // the containing Struct. IsExternal bool // Package is the name of the package this field type is defined in, but only if // IsExternal is set. This is not the path to the package, see FullPath for that. Package string // FullPath is the path to this package. This is only set if IsExternal is set. FullPath string // IsEnum indicates if the field represents an enumerator. IsEnum bool // IsList indicates if the field represents a list of items. This can normally // be determined by the .Type, but if the field type is defined externally, we won't // have that information available yet and we need to note it is a list. IsList bool // IdentName is the name of the Struct or Enum that goes in this field. If not a Struct or Enum, // this is empty. IdentName string // SelfReferential indicates this type is the same Struct type as the containing Struct. SelfReferential bool }
StructField represents a field in a Struct.
func (StructField) GoListType ¶
func (s StructField) GoListType() string
GoListType will return the list type: "uint8", "int8", "<Enum Name>", ... for use in templates. If called on a non-list type, this will panic.
func (StructField) IdentInFile ¶
func (s StructField) IdentInFile() string
IdentInFile returns the IdentName, removing a package identifier if it proceeds it in .IdentName.
func (StructField) TypeAsString ¶
func (s StructField) TypeAsString() string