README

Milky2018/diago/ir does not have a README file

#
CompileError

pub(all) suberror CompileError {
InvalidKey(String)
InvalidValue(String)
DuplicateField(String)
InvalidSubstitution(String)
ImportError(String)
} derive(Eq,
Debug
)

Compilation error

#
Composite

pub(all) enum Composite {
Array(IRArray)
Map(Map)
} derive(Eq,
Debug
)

Composite values (Array or Map)

#
Edge

pub struct Edge {
id : EdgeID
primary : Scalar?
map : Map?
references : Array[EdgeReference]
import_ast :
Node
?
path : NodePath?
} derive(Eq,
Debug
)

An edge in the IR

#
Edge::ast

#
Edge::copy

fn Edge::copy(self : Edge) -> Edge

#
Edge::import_ast

fn Edge::import_ast(self : Edge) ->
Node
?

#
Edge::last_primary_key

fn Edge::last_primary_key(self : Edge) ->
Key
?

#
Edge::last_primary_ref

fn Edge::last_primary_ref(self : Edge) -> Reference?

#
Edge::last_ref

fn Edge::last_ref(self : Edge) -> Reference?

#
Edge::new

fn Edge::new(id : EdgeID, primary : Scalar?, map : Map?, references : Array[EdgeReference]) -> Edge

#
Edge::parent

fn Edge::parent(self : Edge, root : Map) -> Node?

#
Edge::path

fn Edge::path(self : Edge) -> NodePath?

#
EdgeID

pub struct EdgeID {
src_path : Array[String]
src_path_syntax : Array[
StringValue
]
src_arrow : Bool
dst_path : Array[String]
dst_path_syntax : Array[
StringValue
]
dst_arrow : Bool
index : Int?
glob : Bool
} derive(Eq,
Debug
)

Unique identifier for an edge

#
EdgeID::copy

fn EdgeID::copy(self : EdgeID) -> EdgeID

Create a copy of this EdgeID

#
EdgeID::dst_path_syntax

#
EdgeID::matches

fn EdgeID::matches(self : EdgeID, other : EdgeID) -> Bool

Check if this EdgeID matches another (for queries)

#
EdgeID::new

fn EdgeID::new(src_path : Array[String], dst_path : Array[String], src_arrow : Bool, dst_arrow : Bool, src_path_syntax? : Array[
StringValue
]?, dst_path_syntax? : Array[
StringValue
]?) -> EdgeID

#
EdgeID::src_path_syntax

#
EdgeID::with_glob

fn EdgeID::with_glob(src_path : Array[String], dst_path : Array[String], src_arrow : Bool, dst_arrow : Bool, src_path_syntax? : Array[
StringValue
]?, dst_path_syntax? : Array[
StringValue
]?) -> EdgeID

#
EdgeID::with_index

fn EdgeID::with_index(src_path : Array[String], dst_path : Array[String], src_arrow : Bool, dst_arrow : Bool, index : Int, src_path_syntax? : Array[
StringValue
]?, dst_path_syntax? : Array[
StringValue
]?) -> EdgeID

#
EdgeReference

pub struct EdgeReference {
range :
Range

edge :
Edge
?
context : RefContext?
edge_index : Int
primary : Bool
due_to_glob : Bool
due_to_lazy_glob : Bool
} derive(Eq,
Debug
)

Reference to an edge from the AST

#
EdgeReference::ast

#
EdgeReference::context

fn EdgeReference::context(self : EdgeReference) -> RefContext?

#
EdgeReference::from_ast

fn EdgeReference::from_ast(edge :
Edge
, edge_index : Int, primary : Bool, context : RefContext, due_to_glob? : Bool, due_to_lazy_glob? : Bool) -> EdgeReference

#
EdgeReference::new

fn EdgeReference::new(range :
Range
, edge_index : Int, primary : Bool) -> EdgeReference

#
Field

pub struct Field {
name : String
name_syntax :
StringValue
?
primary : Scalar?
composite : Composite?
references : Array[FieldReference]
import_ast :
Node
?
path : NodePath?
} derive(Eq,
Debug
)

A field in the IR map

#
Field::array

fn Field::array(self : Field) -> IRArray?

Get the array composite if this field has one

#
Field::ast

#
Field::copy

fn Field::copy(self : Field) -> Field

#
Field::has_composite

fn Field::has_composite(self : Field) -> Bool

Check if this field has a composite value

#
Field::has_primary

fn Field::has_primary(self : Field) -> Bool

Check if this field has a primary value

#
Field::import_ast

fn Field::import_ast(self : Field) ->
Node
?

#
Field::is_board_keyword_name

fn Field::is_board_keyword_name(self : Field) -> Bool

#
Field::is_reserved_keyword_name

fn Field::is_reserved_keyword_name(self : Field) -> Bool

#
Field::last_primary_key

fn Field::last_primary_key(self : Field) ->
Key
?

#
Field::last_primary_ref

fn Field::last_primary_ref(self : Field) -> Reference?

#
Field::last_ref

fn Field::last_ref(self : Field) -> Reference?

#
Field::map

fn Field::map(self : Field) -> Map?

Get the map composite if this field has one

#
Field::name_is_unquoted

fn Field::name_is_unquoted(self : Field) -> Bool

#
Field::name_syntax

#
Field::new

fn Field::new(name : String, primary : Scalar?, composite : Composite?, references : Array[FieldReference], name_syntax? :
StringValue
?) -> Field

#
Field::parent

fn Field::parent(self : Field, root : Map) -> Node?

#
Field::path

fn Field::path(self : Field) -> NodePath?

#
Field::simple

fn Field::simple(name : String, name_syntax? :
StringValue
?) -> Field

#
FieldReference

pub struct FieldReference {
range :
Range

string : String
syntax :
StringValue
?
key_path :
KeyPath
?
context : RefContext?
key_path_index : Int
primary : Bool
due_to_glob : Bool
due_to_lazy_glob : Bool
} derive(Eq,
Debug
)

Reference to a field from the AST

#
FieldReference::ast

#
FieldReference::context

fn FieldReference::context(self : FieldReference) -> RefContext?

#
FieldReference::from_ast

fn FieldReference::from_ast(syntax :
StringValue
, key_path :
KeyPath
, key_path_index : Int, primary : Bool, context : RefContext, due_to_glob? : Bool, due_to_lazy_glob? : Bool) -> FieldReference

#
FieldReference::new

fn FieldReference::new(range :
Range
, string : String, key_path_index : Int, primary : Bool) -> FieldReference

#
FilterContext

pub struct FilterContext {
field : Field
parent_map : Map
}

Filter context for evaluating ampersand filters

#
FilterContext::new

fn FilterContext::new(field : Field, parent_map : Map) -> FilterContext

#
IRArray

pub struct IRArray {
values : Array[Value]
ast :
Node
?
source_path : String?
path : NodePath?
} derive(Eq,
Debug
)

An array of values

#
IRArray::ast

#
IRArray::copy

fn IRArray::copy(self : IRArray) -> IRArray

#
IRArray::from_ast

fn IRArray::from_ast(ast :
ArrayValue
, values : Array[Value], source_path? : String?) -> IRArray

#
IRArray::new

fn IRArray::new(values : Array[Value]) -> IRArray

#
IRArray::parent

fn IRArray::parent(self : IRArray, root : Map) -> Node?

#
IRArray::path

fn IRArray::path(self : IRArray) -> NodePath?

#
IRArray::source_path

fn IRArray::source_path(self : IRArray) -> String?

#
ImportResolver

pub struct ImportResolver((String) -> String?)

Import resolver function type Takes an import path and returns the file content, or None if not found

#
ImportResolver::new

fn ImportResolver::new(f : (String) -> String?) -> ImportResolver

Create a new import resolver from a function

#
Map

pub struct Map {
fields : Array[Field]
edges : Array[Edge]
ast :
Node
?
import_ast :
Node
?
source_path : String?
path : NodePath?
} derive(Eq,
Debug
)

An IR Map containing fields and edges

#
Map::add_edge

fn Map::add_edge(self : Map, edge : Edge) -> Unit

Add an edge to the map

#
Map::add_field

fn Map::add_field(self : Map, field : Field) -> Unit

Add a field to the map

#
Map::apply_glob_properties

fn Map::apply_glob_properties(self : Map, pattern : Array[String], properties : Map, filters : Array[(Bool, String, String)]) -> Unit

Apply properties to fields matching a glob pattern If filters are provided, only apply to fields that pass all filters

#
Map::ast

#
Map::copy

fn Map::copy(self : Map) -> Map

#
Map::delete_field

fn Map::delete_field(self : Map, name : String) -> Field?

Delete a field by name, returning it if found

#
Map::double_glob

fn Map::double_glob(self : Map) -> Array[Field]

Collect all fields matching a double glob (**) pattern This recursively collects all descendant fields except board keywords

#
Map::ensure_field

fn Map::ensure_field(self : Map, name : String) -> Field

Get or create a field by name

#
Map::ensure_field_by_syntax

fn Map::ensure_field_by_syntax(self : Map, name :
StringValue
) -> Field

#
Map::find_edges

fn Map::find_edges(self : Map, id : EdgeID) -> Array[Edge]

Find edges matching an EdgeID

#
Map::from_ast

fn Map::from_ast(ast :
Map
, source_path? : String?) -> Map

#
Map::get_field

fn Map::get_field(self : Map, name : String) -> Field?

Get a field by name (case-insensitive)

#
Map::get_field_by_syntax

fn Map::get_field_by_syntax(self : Map, name :
StringValue
) -> Field?

#
Map::get_node

fn Map::get_node(self : Map, path : NodePath) -> Node?

#
Map::has_field

fn Map::has_field(self : Map, name : String) -> Bool

Check if map has a field with given name

#
Map::import_ast

fn Map::import_ast(self : Map) ->
Node
?

#
Map::multi_glob

fn Map::multi_glob(self : Map, pattern : Array[String]) -> (Array[Field], Bool)

Collect fields matching a multi-glob pattern (** or ***) Returns (fields, is_glob_pattern)

#
Map::new

fn Map::new() -> Map

#
Map::overlay

fn Map::overlay(self : Map, overlay : Map) -> Map

Return a detached map created by overlaying overlay onto self.

#
Map::parent

fn Map::parent(self : Map, root : Map) -> Node?

#
Map::path

fn Map::path(self : Map) -> NodePath?

#
Map::reindex_paths

fn Map::reindex_paths(self : Map) -> Map

#
Map::single_glob

fn Map::single_glob(self : Map, pattern : Array[String]) -> Array[Field]

Collect fields at one level matching a single glob pattern

#
Map::source_path

fn Map::source_path(self : Map) -> String?

#
Map::triple_glob

fn Map::triple_glob(self : Map) -> Array[Field]

Collect all fields matching a triple glob (***) pattern This recursively collects all descendant fields including boards

#
Node

pub(all) enum Node {
Scalar(Scalar)
Field(Field)
Edge(Edge)
IRArray(IRArray)
Map(Map)
Composite(Composite)
Value(Value)
} derive(Eq,
Debug
)

Boxed IR node for generic traversal.

#
Node::ast

#
Node::children

fn Node::children(self : Node) -> Array[Node]

#
Node::copy

fn Node::copy(self : Node) -> Node

#
Node::import_ast

fn Node::import_ast(self : Node) ->
Node
?

#
Node::last_primary_key

fn Node::last_primary_key(self : Node) ->
Key
?

#
Node::last_primary_ref

fn Node::last_primary_ref(self : Node) -> Reference?

#
Node::last_ref

fn Node::last_ref(self : Node) -> Reference?

#
Node::node_type

fn Node::node_type(self : Node) -> String

#
Node::parent

fn Node::parent(self : Node, root : Map) -> Node?

#
Node::path

fn Node::path(self : Node) -> NodePath?

#
NodePath

pub struct NodePath {
segments : Array[NodePathSegment]
} derive(Eq,
Debug
)

Stable path to an IR node inside a compiled map.

#
NodePath::append

fn NodePath::append(self : NodePath, segment : NodePathSegment) -> NodePath

#
NodePath::parent

fn NodePath::parent(self : NodePath) -> NodePath?

#
NodePath::root

fn NodePath::root() -> NodePath

#
NodePathSegment

pub(all) enum NodePathSegment {
FieldStep(String, Bool)
EdgeStep(EdgeID)
PrimaryStep
CompositeStep
ArrayItemStep(Int)
} derive(Eq,
Debug
)

Stable path to an IR node inside a compiled map.

#
RefContext

pub struct RefContext {
edge :
Edge
?
key :
Key
?
scope :
Map
?
source_path : String?
} derive(Eq,
Debug
)

Reference context for a field or edge reference.

#
RefContext::new

#
Reference

pub(all) enum Reference {
FieldRef(FieldReference)
EdgeRef(EdgeReference)
} derive(Eq,
Debug
)

Boxed reference for generic traversal.

#
Reference::ast

#
Reference::context

fn Reference::context(self : Reference) -> RefContext?

#
Reference::due_to_glob

fn Reference::due_to_glob(self : Reference) -> Bool

#
Reference::due_to_lazy_glob

fn Reference::due_to_lazy_glob(self : Reference) -> Bool

#
Reference::primary

fn Reference::primary(self : Reference) -> Bool

#
Reference::range

#
Scalar

pub struct Scalar {
value : ScalarValue
range :
Range

ast :
Node
?
source_path : String?
path : NodePath?
} derive(Eq,
Debug
)

A scalar value in the IR.

Scalars carry a source range for error reporting and reference tracking.

#
Scalar::as_bool

fn Scalar::as_bool(self : Scalar) -> Bool?

Get boolean value if this is a boolean

#
Scalar::as_double

fn Scalar::as_double(self : Scalar) -> Double?

#
Scalar::as_int

fn Scalar::as_int(self : Scalar) -> Int?

#
Scalar::as_string_value

Get underlying string value (including block-string metadata) if present

#
Scalar::ast

#
Scalar::at

#
Scalar::block_string_tag

fn Scalar::block_string_tag(self : Scalar) -> String?

Get block-string language tag if this scalar is a block string

#
Scalar::bool

fn Scalar::bool(b : Bool) -> Scalar

#
Scalar::copy

fn Scalar::copy(self : Scalar) -> Scalar

#
Scalar::from_ast

fn Scalar::from_ast(ast :
Node
, value : ScalarValue, source_path? : String?) -> Scalar

#
Scalar::get_range

#
Scalar::is_bool

fn Scalar::is_bool(self : Scalar) -> Bool

Check if scalar is a boolean

#
Scalar::is_null

fn Scalar::is_null(self : Scalar) -> Bool

Check if scalar is null

#
Scalar::is_number

fn Scalar::is_number(self : Scalar) -> Bool

Check if scalar is a number

#
Scalar::is_string

fn Scalar::is_string(self : Scalar) -> Bool

Check if scalar is a string

#
Scalar::new

fn Scalar::new(value : ScalarValue) -> Scalar

#
Scalar::null

fn Scalar::null() -> Scalar

#
Scalar::number

fn Scalar::number(n : String) -> Scalar

#
Scalar::parent

fn Scalar::parent(self : Scalar, root : Map) -> Node?

#
Scalar::path

fn Scalar::path(self : Scalar) -> NodePath?

#
Scalar::source_path

fn Scalar::source_path(self : Scalar) -> String?

#
Scalar::string

fn Scalar::string(s : String) -> Scalar

#
Scalar::to_string

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

Get the string representation of a scalar value

#
ScalarValue

pub(all) enum ScalarValue {
Null
Bool(String)
Number(String)
String(
StringValue
)
} derive(Eq,
Debug
)

Types of scalar values

#
Value

pub(all) enum Value {
Scalar(Scalar)
Array(IRArray)
Map(Map)
} derive(Eq,
Debug
)

Value types in IR

#
Value::as_array

fn Value::as_array(self : Value) -> IRArray?

Get the array if this is an array

#
Value::as_map

fn Value::as_map(self : Value) -> Map?

Get the map if this is a map

#
Value::as_scalar

fn Value::as_scalar(self : Value) -> Scalar?

Get the scalar value if this is a scalar

#
compile

fn compile(ast :
Map
) -> Map raise CompileError

Compile an AST Map to IR Map

#
compile_with_imports

fn compile_with_imports(ast :
Map
, resolver : ImportResolver) -> Map raise CompileError

Compile an AST Map with import resolution

#
evaluate_filter

fn evaluate_filter(ctx : FilterContext, filter_key : String, filter_value : String) -> Bool

Evaluate a filter condition against a field Returns true if the field passes the filter

#
filter_value_matches

fn filter_value_matches(actual : String, pattern : String) -> Bool

#
is_board_keyword

fn is_board_keyword(name : String) -> Bool

Check if a keyword is a board keyword

#
is_double_glob

fn is_double_glob(pattern : Array[String]) -> Bool

Check if pattern represents a double glob () Parser stores ** as ["", "", ""]

#
is_reserved_keyword

fn is_reserved_keyword(name : String) -> Bool

Check if a keyword is reserved

#
is_triple_glob

fn is_triple_glob(pattern : Array[String]) -> Bool

Check if pattern represents a triple glob () Parser stores *** as ["", "", "", "", ""]

#
match_pattern

fn match_pattern(s : String, pattern : Array[String]) -> Bool

Match a string against a glob pattern Pattern is an array where elements are either:
  • literal text to match
  • "*" to match any characters