moonrockz/rego/ast does not have a README file

    AnnotationError

    pub(all) suberror AnnotationError {
    InvalidYaml(span~ :
    SourceSpan
    , message~ : String)
    NotAMapping(span~ :
    SourceSpan
    )
    InvalidScope(span~ :
    SourceSpan
    , value~ : String)
    InvalidFieldShape(span~ :
    SourceSpan
    , field~ : String, message~ : String)
    } derive(Eq,
    Debug
    )

    Raised when a # METADATA comment block contains invalid YAML, an unknown scope, or a malformed standard annotation field.

    AstError

    pub(all) suberror AstError {
    InvalidIdent(text~ : String)
    ReservedKeyword(text~ : String)
    InvalidNumberLiteral(text~ : String)
    EmptyPackagePath
    } derive(Eq,
    Debug
    )

    Raised when an AST domain value breaks its construction invariants.

    LowerError

    pub(all) suberror LowerError {
    SyntaxErrors(ReadOnlyArray[
    SyntaxDiagnostic
    ])
    AnnotationFailure(AnnotationError)
    InvalidTree(span~ :
    SourceSpan
    , message~ : String)
    } derive(Eq,
    Debug
    )

    Raised when lowering a CST to an immutable Rego v1 AST fails.
    impl Show for LowerError

    Annotation

    type Annotation derive(Eq,
    Debug
    )

    One parsed OPA v1.23.0 # METADATA annotation block.

    Annotation::authors

    fn Annotation::authors(self : Annotation) -> ReadOnlyArray[AuthorAnnotation]

    Annotation::compile

    fn Annotation::compile(self : Annotation) -> CompileAnnotation?

    Annotation::custom

    fn Annotation::custom(self : Annotation) -> MetadataValue?

    Annotation::description

    fn Annotation::description(self : Annotation) -> String?

    Annotation::entrypoint

    fn Annotation::entrypoint(self : Annotation) -> Bool

    Annotation::labels

    fn Annotation::labels(self : Annotation) -> MetadataValue?

    Annotation::organizations

    fn Annotation::organizations(self : Annotation) -> ReadOnlyArray[String]

    Annotation::related_resources

    fn Annotation::related_resources(self : Annotation) -> ReadOnlyArray[RelatedResourceAnnotation]

    Annotation::schemas

    fn Annotation::schemas(self : Annotation) -> ReadOnlyArray[SchemaAnnotation]

    Annotation::scope

    Annotation::title

    fn Annotation::title(self : Annotation) -> String?

    AnnotationScope

    pub(all) enum AnnotationScope {
    Rule
    Document
    Package
    Subpackages
    } derive(Compare, Eq, Hash,
    Debug
    )

    The attachment scope of an OPA # METADATA annotation block.

    AnnotationScope::parse

    AnnotationScope::to_string

    fn AnnotationScope::to_string(self : AnnotationScope) -> String

    AssignOp

    pub(all) enum AssignOp {
    Assign
    Unify
    } derive(Eq, Hash,
    Debug
    )

    Assignment or unification operator in rule heads.

    AssignedValue

    type AssignedValue derive(Eq,
    Debug
    )

    A paired assignment or unification operator and value term, preventing mismatched (Some(op), None) or (None, Some(term)) states.

    AssignedValue::AssignedValue

    fn AssignedValue::AssignedValue(op~ : AssignOp, value~ : Term) -> AssignedValue

    Constructs an assigned value pairing an operator with its term.

    AssignedValue::op

    Returns the assignment or unification operator.

    AssignedValue::value

    fn AssignedValue::value(self : AssignedValue) -> Term

    Returns the assigned value term.

    AuthorAnnotation

    type AuthorAnnotation derive(Eq,
    Debug
    )

    Author entry in # METADATA (authors).

    AuthorAnnotation::email

    fn AuthorAnnotation::email(self : AuthorAnnotation) -> String?

    AuthorAnnotation::name

    fn AuthorAnnotation::name(self : AuthorAnnotation) -> String

    BinaryOp

    pub(all) enum BinaryOp {
    Equal
    Neq
    Lt
    Gt
    Lte
    Gte
    Or
    And
    Add
    Sub
    Mul
    Quo
    Rem
    } derive(Eq, Hash,
    Debug
    )

    Binary infix operator in Rego v1 expressions (excluding :=, = and in).

    CompileAnnotation

    type CompileAnnotation derive(Eq,
    Debug
    )

    Compile hint entry in # METADATA (compile).

    CompileAnnotation::mask_rule

    fn CompileAnnotation::mask_rule(self : CompileAnnotation) -> String?

    CompileAnnotation::unknowns

    fn CompileAnnotation::unknowns(self : CompileAnnotation) -> ReadOnlyArray[String]

    DotKey

    A validated dot-chained reference key (a.key, a.if, a.default). Accepts any valid Rego identifier character sequence, including keywords.
    impl Show for DotKey

    DotKey::DotKey

    fn DotKey::DotKey(text : String) -> DotKey raise AstError

    Constructs a validated dot-chained reference key.

    DotKey::to_string

    fn DotKey::to_string(self : DotKey) -> String

    Returns the raw text of this dot key.

    ElseBranch

    type ElseBranch derive(Eq,
    Debug
    )

    One else branch attached to a rule.

    ElseBranch::ElseBranch

    Constructs an else branch.

    ElseBranch::assigned

    fn ElseBranch::assigned(self : ElseBranch) -> AssignedValue?

    Returns the optional assigned value of this else branch.

    ElseBranch::body

    fn ElseBranch::body(self : ElseBranch) -> RuleBody?

    Returns the optional body of this else branch.

    ElseBranch::span

    Returns the UTF-16 span of this else branch.

    Expr

    One Rego v1 expression with optional with modifiers and source span.

    Expr::Expr

    fn Expr::Expr(kind~ : ExprKind, with_modifiers~ : ArrayView[WithModifier], span~ :
    SourceSpan
    ) -> Expr

    Expr::kind

    fn Expr::kind(self : Expr) -> ExprKind

    Expr::with_modifiers

    fn Expr::with_modifiers(self : Expr) -> ReadOnlyArray[WithModifier]

    ExprKind

    pub(all) enum ExprKind {
    Term(Term)
    Assign(Term, Term)
    Unify(Term, Term)
    Not(ExprKind)
    SomeDecl(first~ : Ident, rest~ : ReadOnlyArray[Ident])
    SomeIn(key~ : Term?, value~ : Term, domain~ : Term)
    Every(key~ : Ident?, value~ : Ident, domain~ : Term, body~ : RuleBody)
    } derive(Eq,
    Debug
    )

    Every Rego v1 expression form.

    Ident

    A validated Rego v1 variable/rule identifier. In OPA v1.23.0, contains, and, or and _ are valid identifiers, while if, in, every and core keywords are rejected as standalone variables.
    impl Show for Ident

    Ident::Ident

    fn Ident::Ident(text : String) -> Ident raise AstError

    Ident::to_string

    fn Ident::to_string(self : Ident) -> String

    Import

    One import <path> [as <alias>] declaration.

    Import::Import

    fn Import::Import(path~ : Ref, alias_name~ : Ident?, span~ :
    SourceSpan
    ) -> Import

    Import::alias_name

    fn Import::alias_name(self : Import) -> Ident?

    Import::path

    fn Import::path(self : Import) -> Ref

    MetadataValue

    pub(all) enum MetadataValue {
    Null
    Bool(Bool)
    Int(Int64)
    Float(Double)
    String(String)
    Seq(ReadOnlyArray[MetadataValue])
    Mapping(ReadOnlyArray[(String, MetadataValue)])
    } derive(Eq,
    Debug
    )

    Deeply immutable value representation for arbitrary # METADATA custom, labels, and schema definition payloads.

    Module

    A parsed and lowered Rego v1 module.

    Module::Module

    fn Module::Module(package_path~ : PackagePath, package_annotations~ : ArrayView[Annotation], imports~ : ArrayView[Import], rules~ : ArrayView[Rule], span~ :
    SourceSpan
    ) -> Module

    Module::imports

    fn Module::imports(self : Module) -> ReadOnlyArray[Import]

    Module::package_annotations

    fn Module::package_annotations(self : Module) -> ReadOnlyArray[Annotation]

    Module::package_path

    fn Module::package_path(self : Module) -> PackagePath

    Module::rules

    fn Module::rules(self : Module) -> ReadOnlyArray[Rule]

    NumberLiteral

    type NumberLiteral derive(Eq, Hash,
    Debug
    )

    Validated raw text of a Rego numeric literal, preserved verbatim so Phase 2 can parse exact arbitrary-precision decimals without IEEE-754 loss.

    NumberLiteral::NumberLiteral

    fn NumberLiteral::NumberLiteral(raw : String) -> NumberLiteral raise AstError

    NumberLiteral::raw

    fn NumberLiteral::raw(self : NumberLiteral) -> String

    PackagePath

    type PackagePath derive(Eq,
    Debug
    )

    A validated non-empty package path (package a.b["c-d"]).

    PackagePath::PackagePath

    PackagePath::segments

    fn PackagePath::segments(self : PackagePath) -> ReadOnlyArray[RefSegment]

    PackagePath::to_string

    fn PackagePath::to_string(self : PackagePath) -> String

    Formats dot segments joined by . and bracket segments with [...].

    Query

    A parsed and lowered standalone Rego v1 query.

    Query::Query

    Query::exprs

    fn Query::exprs(self : Query) -> ReadOnlyArray[Expr]

    Ref

    A Rego reference chain: base term followed by zero or more segments.

    Ref::Ref

    fn Ref::Ref(base~ : Term, segments~ : ArrayView[RefSegment], span~ :
    SourceSpan
    ) -> Ref

    Ref::base

    fn Ref::base(self : Ref) -> Term

    Ref::segments

    fn Ref::segments(self : Ref) -> ReadOnlyArray[RefSegment]

    RefSegment

    pub(all) enum RefSegment {
    Dot(DotKey)
    Bracket(Term)
    } derive(Eq,
    Debug
    )

    One segment of a Rego reference (a.b or a[expr]).

    RelatedResourceAnnotation

    type RelatedResourceAnnotation derive(Eq,
    Debug
    )

    Related resource entry in # METADATA (related_resources).

    RelatedResourceAnnotation::description

    fn RelatedResourceAnnotation::description(self : RelatedResourceAnnotation) -> String?

    RelatedResourceAnnotation::ref_uri

    Rule

    One Rego v1 rule (complete, partial set, partial object, function or default).

    Rule::Rule

    fn Rule::Rule(head~ : RuleHead, body~ : RuleBody?, else_branches~ : ArrayView[ElseBranch], annotations~ : ArrayView[Annotation], span~ :
    SourceSpan
    ) -> Rule

    Rule::annotations

    fn Rule::annotations(self : Rule) -> ReadOnlyArray[Annotation]

    Rule::body

    fn Rule::body(self : Rule) -> RuleBody?

    Rule::else_branches

    fn Rule::else_branches(self : Rule) -> ReadOnlyArray[ElseBranch]

    Rule::head

    fn Rule::head(self : Rule) -> RuleHead

    RuleBody

    type RuleBody derive(Eq,
    Debug
    )

    An ordered conjunction of expressions forming a rule, every, or comprehension body.

    RuleBody::RuleBody

    RuleBody::exprs

    fn RuleBody::exprs(self : RuleBody) -> ReadOnlyArray[Expr]

    RuleHead

    pub(all) enum RuleHead {
    Complete(ref_head~ : Ref, assigned~ : AssignedValue?)
    PartialSet(ref_head~ : Ref, key~ : Term)
    PartialObject(ref_head~ : Ref, key~ : Term, assigned~ : AssignedValue)
    Function(ref_head~ : Ref, args~ : ReadOnlyArray[Term], assigned~ : AssignedValue?)
    Default(ref_head~ : Ref, args~ : ReadOnlyArray[Term], assigned~ : AssignedValue)
    } derive(Eq,
    Debug
    )

    The algebraic classification of a strict Rego v1 rule head.

    SchemaAnnotation

    type SchemaAnnotation derive(Eq,
    Debug
    )

    Schema declaration in # METADATA (schemas).

    SchemaAnnotation::definition

    SchemaAnnotation::path

    fn SchemaAnnotation::path(self : SchemaAnnotation) -> String

    SchemaAnnotation::schema

    fn SchemaAnnotation::schema(self : SchemaAnnotation) -> String?

    TemplatePart

    pub(all) enum TemplatePart {
    Literal(String)
    Expr(Expr)
    } derive(Eq,
    Debug
    )

    One segment of a Rego v1.9+ template string ($"..." or $`...` ).

    Term

    An immutable Rego v1 term paired with its UTF-16 source span.

    Term::Term

    Term::kind

    fn Term::kind(self : Term) -> TermKind

    TermKind

    pub(all) enum TermKind {
    Null
    Bool(Bool)
    Number(NumberLiteral)
    String(String)
    TemplateString(raw~ : Bool, parts~ : ReadOnlyArray[TemplatePart])
    Var(Ident)
    Ref(Ref)
    Call(callee~ : Term, args~ : ReadOnlyArray[Term])
    UnaryNeg(Term)
    Binary(BinaryOp, Term, Term)
    In(key~ : Term?, value~ : Term, domain~ : Term)
    Array(ReadOnlyArray[Term])
    Set(ReadOnlyArray[Term])
    Object(ReadOnlyArray[(Term, Term)])
    ArrayComprehension(term~ : Term, body~ : RuleBody)
    SetComprehension(term~ : Term, body~ : RuleBody)
    ObjectComprehension(key~ : Term, value~ : Term, body~ : RuleBody)
    } derive(Eq,
    Debug
    )

    Every Rego v1 term kind.

    WithModifier

    type WithModifier derive(Eq,
    Debug
    )

    A with <target> as <value> modifier attached to an expression.

    WithModifier::WithModifier

    fn WithModifier::WithModifier(target~ : Ref, value~ : Term, span~ :
    SourceSpan
    ) -> WithModifier

    WithModifier::target

    fn WithModifier::target(self : WithModifier) -> Ref

    WithModifier::value

    fn WithModifier::value(self : WithModifier) -> Term

    lower_module

    Lowers a validated module ParseResult into an immutable Rego v1 Module. Raises SyntaxErrors if the CST contains any diagnostics, or AnnotationFailure if a # METADATA block is malformed.

    lower_query

    Lowers a validated query ParseResult into an immutable Rego v1 Query. Raises SyntaxErrors if the CST contains any diagnostics.

    parse_metadata_yaml

    fn parse_metadata_yaml(yaml_text : String, default_scope~ : AnnotationScope, span~ :
    SourceSpan
    ) -> Annotation raise AnnotationError

    Parses a stripped # METADATA YAML body into a typed Annotation.