compiler

package
v1.45.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const Ellipsis = "..."

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseCompilerError

type BaseCompilerError struct {
	BaseMessage string
	// contains filtered or unexported fields
}

BaseCompilerError defines an error with contains the base message of the issue that occurred.

type CircularImportError

type CircularImportError struct {
	// contains filtered or unexported fields
}

type CompiledSchema

type CompiledSchema struct {
	// ObjectDefinitions holds the object definitions in the schema.
	ObjectDefinitions []*core.NamespaceDefinition

	// CaveatDefinitions holds the caveat definitions in the schema.
	CaveatDefinitions []*core.CaveatDefinition

	// OrderedDefinitions holds the object and caveat definitions in the schema, in the
	// order in which they were found.
	OrderedDefinitions []SchemaDefinition
	// contains filtered or unexported fields
}

CompiledSchema is the result of compiling a schema when there are no errors.

func Compile

func Compile(schema InputSchema, prefix ObjectPrefixOption, opts ...Option) (*CompiledSchema, error)

Compile compilers the input schema into a set of namespace definition protos.

func (CompiledSchema) SourcePositionToRunePosition

func (cs CompiledSchema) SourcePositionToRunePosition(source input.Source, position input.Position) (int, error)

SourcePositionToRunePosition converts a source position to a rune position.

type DSLNode

type DSLNode interface {
	GetType() dslshape.NodeType
	GetString(predicateName string) (string, error)
	GetInt(predicateName string) (int, error)
	Lookup(predicateName string) (DSLNode, error)
}

DSLNode is a node in the DSL AST.

type InputSchema

type InputSchema struct {
	// Source is the source of the schema being compiled.
	Source input.Source

	// Schema is the contents being compiled.
	SchemaString string
}

InputSchema defines the input for a Compile.

type NodeChain

type NodeChain struct {
	// contains filtered or unexported fields
}

NodeChain is a chain of nodes in the DSL AST.

func PositionToAstNodeChain

func PositionToAstNodeChain(schema *CompiledSchema, source input.Source, position input.Position) (*NodeChain, error)

PositionToAstNodeChain returns the AST node, and its parents (if any), found at the given position in the source, if any.

func (*NodeChain) FindNodeOfType

func (nc *NodeChain) FindNodeOfType(nodeType dslshape.NodeType) DSLNode

FindNodeOfType returns the first node of the given type in the chain, if any.

func (*NodeChain) ForRunePosition

func (nc *NodeChain) ForRunePosition() int

ForRunePosition returns the rune position of the chain.

func (*NodeChain) HasHeadType

func (nc *NodeChain) HasHeadType(nodeType dslshape.NodeType) bool

HasHeadType returns true if the head node of the chain is of the given type.

func (*NodeChain) Head

func (nc *NodeChain) Head() DSLNode

Head returns the head node of the chain.

func (*NodeChain) String

func (nc *NodeChain) String() string

type ObjectPrefixOption

type ObjectPrefixOption func(*config)

func AllowUnprefixedObjectType

func AllowUnprefixedObjectType() ObjectPrefixOption

Config that allows for no prefix. This is the "normal" default.

func ObjectTypePrefix

func ObjectTypePrefix(prefix string) ObjectPrefixOption

Config for the prefix attached to all definitions, such as in Serverless where it's `someorganization/` in front of each definition.

func RequirePrefixedObjectType

func RequirePrefixedObjectType() ObjectPrefixOption

Config that does not supply the prefix but requires the prefix on all objects.

type Option

type Option func(*config)

func DisallowExpirationFlag added in v1.41.0

func DisallowExpirationFlag() Option

func SkipValidation

func SkipValidation() Option

func SourceFolder

func SourceFolder(sourceFolder string) Option

Config that supplies the root source folder for compilation. Required for relative import syntax to work properly.

func WithCaveatTypeSet added in v1.43.0

func WithCaveatTypeSet(caveatTypeSet *caveattypes.TypeSet) Option

WithCaveatTypeSet sets the caveat type set to use for the compilation.

type SchemaDefinition

type SchemaDefinition interface {
	proto.Message

	GetName() string
}

SchemaDefinition represents an object or caveat definition in a schema.

type WithContextError

type WithContextError struct {
	BaseCompilerError
	SourceRange     input.SourceRange
	Source          input.Source
	ErrorSourceCode string
}

WithContextError defines an error which contains contextual information.

func (WithContextError) DetailsMetadata

func (ewc WithContextError) DetailsMetadata() map[string]string

DetailsMetadata returns the metadata for details for this error.

func (WithContextError) Unwrap

func (ewc WithContextError) Unwrap() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL