compiler

package
v1.36.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: Apache-2.0 Imports: 17 Imported by: 5

Documentation

Index

Constants

View Source
const Ellipsis = "..."

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseCompilerError added in v1.5.0

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 CompiledSchema added in v1.14.0

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 added in v1.31.0

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

SourcePositionToRunePosition converts a source position to a rune position.

type DSLNode added in v1.31.0

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 ErrorWithContext

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

ErrorWithContext defines an error which contains contextual information.

func (ErrorWithContext) DetailsMetadata added in v1.14.0

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

DetailsMetadata returns the metadata for details for this error.

func (ErrorWithContext) Unwrap added in v1.14.0

func (ewc ErrorWithContext) Unwrap() error

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 added in v1.31.0

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

NodeChain is a chain of nodes in the DSL AST.

func PositionToAstNodeChain added in v1.31.0

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 added in v1.31.0

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 added in v1.31.0

func (nc *NodeChain) ForRunePosition() int

ForRunePosition returns the rune position of the chain.

func (*NodeChain) HasHeadType added in v1.31.0

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 added in v1.31.0

func (nc *NodeChain) Head() DSLNode

Head returns the head node of the chain.

func (*NodeChain) String added in v1.31.0

func (nc *NodeChain) String() string

type ObjectPrefixOption added in v1.29.0

type ObjectPrefixOption func(*config)

func AllowUnprefixedObjectType added in v1.29.0

func AllowUnprefixedObjectType() ObjectPrefixOption

func ObjectTypePrefix added in v1.29.0

func ObjectTypePrefix(prefix string) ObjectPrefixOption

func RequirePrefixedObjectType added in v1.29.0

func RequirePrefixedObjectType() ObjectPrefixOption

type Option added in v1.29.0

type Option func(*config)

func SkipValidation added in v1.29.0

func SkipValidation() Option

type SchemaDefinition added in v1.14.0

type SchemaDefinition interface {
	proto.Message

	GetName() string
}

SchemaDefinition represents an object or caveat definition in a schema.

Jump to

Keyboard shortcuts

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