Skip to main content

Module semantics

Module semantics 

Source
Expand description

Resolved semantic types for Lemma

This module contains all types that represent resolved semantics after planning. These types are created during the planning phase and used by evaluation, inversion, etc.

Re-exports§

pub use crate::parsing::ast::ArithmeticComputation;
pub use crate::parsing::ast::ComparisonComputation;
pub use crate::parsing::ast::MathematicalComputation;
pub use crate::parsing::ast::NegationType;
pub use crate::parsing::ast::Span;
pub use crate::parsing::ast::VetoExpression;
pub use crate::parsing::source::Source;

Structs§

Expression
Resolved expression (all references resolved to paths, all literals typed)
Fact
Fact: path, value, and source location.
FactPath
Resolved path to a fact (created during planning from AST FactReference)
LemmaType
Resolved type after planning
LiteralValue
Literal value with type. The single value type in semantics.
PathSegment
A single segment in a resolved path traversal
RatioUnit
RatioUnits
RulePath
Resolved path to a rule (created during planning from RuleReference)
ScaleUnit
ScaleUnits
SemanticDateTime
Date-time for semantic values
SemanticTime
Time-of-day for semantic values
SemanticTimezone
Timezone for semantic date/time values

Enums§

ExpressionKind
Resolved expression kind (only resolved variants, no unresolved references)
FactData
Resolved fact value for the execution plan: aligned with FactValue but with source per variant.
FactValue
Fact value: literal, type declaration (resolved type only), or spec reference.
LogicalComputation
Logical computation operators (defined in semantics, not used by the parser).
SemanticConversionTarget
Target unit for conversion (semantic; used by evaluation/computation). Planning converts AST ConversionTarget into this so computation does not depend on parsing. Ratio vs scale is determined by looking up the unit in the type registry’s unit index.
SemanticDurationUnit
Duration unit for semantic values (duplicated from parser to avoid parser dependency)
TypeExtends
What this type extends (primitive built-in or custom type by name).
TypeSpecification
ValueKind
Value payload (shape of a literal). No type attached. Scale unit is required; Ratio unit is optional (see plan ratio-units-optional.md).

Functions§

conversion_target_to_semantic
Convert AST conversion target to semantic (planning boundary; evaluation/computation use only semantic).
negated_comparison
Returns the logical negation of a comparison (for displaying conditions as true in explanations).
parse_number_unit
Parse a “number unit” string into a Scale or Ratio value according to the type. Caller must have obtained the TypeSpecification via unit_index from the unit in the string.
parse_value_from_string
Parse a string value according to a TypeSpecification. Used to parse runtime user input into typed values.
primitive_boolean
Primitive types use the default TypeSpecification from the parser (single source of truth).
primitive_date
primitive_duration
primitive_number
primitive_ratio
primitive_scale
primitive_text
primitive_time
value_to_semantic
Convert parser Value to ValueKind. Fails if Scale/Ratio have no unit (strict).