Sign in

    moonrockz/diagrams/railroad-trace does not have a README file

    RailroadTraceProvider

    pub(open) trait RailroadTraceProvider {
    fn trace(Self, TraceRequest) -> TraceResult
    }

    A publicly implementable hook for an external regex matcher or grammar parser. This library bundles no implementation. A provider that supports one subject kind returns Unsupported for the other.

    Attempt

    pub struct Attempt {
    id : String
    status : AttemptStatus
    steps : ReadOnlyArray[Step]
    failure : FailurePoint?
    continuous : Bool
    label : String?
    } derive(Eq,
    Debug
    )

    One finite attempt of an external engine. Repeated or backtracked steps stay separate, even when they reuse a term or connector.

    Attempt::equal

    fn Attempt::equal(Attempt, Attempt) -> Bool

    Attempt::new

    fn Attempt::new(id : String, status : AttemptStatus, steps : ArrayView[Step], failure? : FailurePoint, continuous? : Bool, label? : String) -> Attempt

    Attempt::not_equal

    fn Attempt::not_equal(x : Attempt, y : Attempt) -> Bool

    Attempt::to_repr

    AttemptStatus

    pub(all) enum AttemptStatus {
    Matched
    NotMatched
    } derive(Eq,
    Debug
    )

    AttemptStatus::equal

    AttemptStatus::not_equal

    fn AttemptStatus::not_equal(x : AttemptStatus, y : AttemptStatus) -> Bool

    Connector

    pub struct Connector {
    id : String
    owner : String
    role : ConnectorRole
    from : String
    to : String
    rule : String
    constraint : Bool
    } derive(Eq,
    Debug
    )

    One drawn connector between two points, in its semantic direction.

    Connector::equal

    fn Connector::equal(Connector, Connector) -> Bool

    Connector::not_equal

    fn Connector::not_equal(x : Connector, y : Connector) -> Bool

    ConnectorRole

    pub(all) enum ConnectorRole {
    Start
    End
    Gap
    Split(Int)
    Join(Int)
    Enter
    Leave
    Bypass
    Return
    Empty
    } derive(Eq,
    Debug
    )

    The structural role of a drawn connector.

    ConnectorRole::equal

    ConnectorRole::name

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

    ConnectorRole::not_equal

    fn ConnectorRole::not_equal(x : ConnectorRole, y : ConnectorRole) -> Bool

    FailurePoint

    pub struct FailurePoint {
    target : FailureTarget
    position : Int?
    message : String?
    } derive(Eq,
    Debug
    )

    FailurePoint::equal

    FailurePoint::new

    fn FailurePoint::new(target : FailureTarget, position? : Int, message? : String) -> FailurePoint

    FailurePoint::not_equal

    fn FailurePoint::not_equal(x : FailurePoint, y : FailurePoint) -> Bool

    FailureTarget

    pub(all) enum FailureTarget {
    Terminal(String)
    Assertion(String)
    Entry(String)
    Exit(String)
    } derive(Eq,
    Debug
    )

    The place where an attempt failed.

    FailureTarget::equal

    FailureTarget::not_equal

    fn FailureTarget::not_equal(x : FailureTarget, y : FailureTarget) -> Bool

    InputSpan

    pub struct InputSpan {
    start : Int
    end : Int
    } derive(Eq,
    Debug
    )

    A half-open UTF-16 span of the input.

    InputSpan::equal

    fn InputSpan::equal(InputSpan, InputSpan) -> Bool

    InputSpan::new

    fn InputSpan::new(start : Int, end : Int) -> InputSpan

    InputSpan::not_equal

    fn InputSpan::not_equal(x : InputSpan, y : InputSpan) -> Bool

    Step

    pub(all) enum Step {
    Visit(String, InputSpan?)
    Traverse(String, Bool)
    } derive(Eq,
    Debug
    )

    One oriented trace step. A visit passes through a term from its entry to its exit. A traversal follows a drawn connector, forward or reversed.

    Step::equal

    fn Step::equal(Step, Step) -> Bool

    Step::not_equal

    fn Step::not_equal(x : Step, y : Step) -> Bool

    Step::to_repr

    Subject

    The typed subject of a trace request. An EBNF subject names its start rule by rule identity.

    Subject::equal

    fn Subject::equal(Subject, Subject) -> Bool

    Subject::fingerprint

    fn Subject::fingerprint(self : Subject) -> String

    The fingerprint of the structure of a subject. A trace for an edited or different model has a different fingerprint, even with equal identities.

    Subject::identity

    fn Subject::identity(self : Subject, view_id? : String) -> SubjectIdentity

    Subject::kind

    fn Subject::kind(self : Subject) -> SubjectKind

    Subject::model_id

    fn Subject::model_id(self : Subject) -> String

    Subject::not_equal

    fn Subject::not_equal(x : Subject, y : Subject) -> Bool

    Subject::to_repr

    SubjectIdentity

    pub struct SubjectIdentity {
    kind : SubjectKind
    model_id : String
    view_id : String
    fingerprint : String
    start_rule : String?
    } derive(Eq,
    Debug
    )

    The provenance of a trace: subject kind, model and view identity and the structural fingerprint of the model.

    SubjectIdentity::equal

    SubjectIdentity::not_equal

    fn SubjectIdentity::not_equal(x : SubjectIdentity, y : SubjectIdentity) -> Bool

    SubjectKind

    pub(all) enum SubjectKind {
    Regex
    Ebnf
    } derive(Eq,
    Debug
    )

    The two railroad subject kinds.

    SubjectKind::equal

    fn SubjectKind::equal(SubjectKind, SubjectKind) -> Bool

    SubjectKind::not_equal

    fn SubjectKind::not_equal(x : SubjectKind, y : SubjectKind) -> Bool

    Term

    pub struct Term {
    id : String
    kind : TermKind
    label : String
    rule : String
    constraint : Bool
    entry : String
    exit : String
    } derive(Eq,
    Debug
    )

    One visible term occurrence. Equal labels in different positions have different identities.

    Term::equal

    fn Term::equal(Term, Term) -> Bool

    Term::not_equal

    fn Term::not_equal(x : Term, y : Term) -> Bool

    Term::to_repr

    TermKind

    pub(all) enum TermKind {
    Consumed
    Reference(
    Resolution
    )
    Anchor
    Assertion
    Empty
    } derive(Eq,
    Debug
    )

    The role of one visible term. Terms are visit targets.

    TermKind::equal

    fn TermKind::equal(TermKind, TermKind) -> Bool

    TermKind::not_equal

    fn TermKind::not_equal(x : TermKind, y : TermKind) -> Bool

    TermKind::to_repr

    Topology

    pub struct Topology {
    kind : SubjectKind
    model_id : String
    fingerprint : String
    tracks : ReadOnlyArray[Track]
    terms : ReadOnlyArray[Term]
    connectors : ReadOnlyArray[Connector]
    walk : ReadOnlyArray[Step]
    // private fields
    }

    The semantic railroad topology of a model: visible terms, points and drawn connectors. External engines map their events to these identities before any SVG or animation exists.

    Topology::connector

    fn Topology::connector(self : Topology, id : String) -> Connector?

    Topology::connector_between

    fn Topology::connector_between(self : Topology, from : String, to : String) -> Connector?

    The connector between two points, if one is drawn.

    Topology::connector_of

    fn Topology::connector_of(self : Topology, owner : String, role : ConnectorRole) -> Connector?

    The connector with role that owner draws, if any.

    Topology::connectors_from

    fn Topology::connectors_from(self : Topology, point : String) -> Array[Connector]

    The connectors that leave point, in drawing order.

    Topology::ebnf

    Build the topology of a grammar. Each rule is one track. References are terms; no connector joins two rules.

    Topology::entry

    fn Topology::entry(self : Topology, id : String) -> String?

    The entry point of a node, rule or model identity.

    Topology::exit

    fn Topology::exit(self : Topology, id : String) -> String?

    The exit point of a node, rule or model identity.

    Topology::has_point

    fn Topology::has_point(self : Topology, point : String) -> Bool

    Topology::regex

    Build the topology of a regex model. The pattern is one track whose identity is the model identity.

    Topology::term

    fn Topology::term(self : Topology, id : String) -> Term?

    TopologyResult

    pub struct TopologyResult {
    topology : Topology?
    diagnostics : ReadOnlyArray[
    Diagnostic
    ]
    }

    Trace

    pub struct Trace {
    subject : SubjectIdentity
    input : String
    provider : String
    attempts : ReadOnlyArray[Attempt]
    } derive(Eq,
    Debug
    )

    Immutable evidence that an external engine supplied. It is separate from the diagram and is never computed by this library.

    Trace::equal

    fn Trace::equal(Trace, Trace) -> Bool

    Trace::new

    fn Trace::new(request : TraceRequest, provider : String, attempts : ArrayView[Attempt]) -> Trace

    Make a trace bound to the subject of request.

    Trace::not_equal

    fn Trace::not_equal(x : Trace, y : Trace) -> Bool

    Trace::to_repr

    TraceLimits

    pub struct TraceLimits {
    input : Int
    attempts : Int
    steps : Int
    depth : Int
    work : Int
    } derive(Eq,
    Debug
    )

    Explicit trace bounds. Providers honor them cooperatively; validation enforces them for every supplied trace.

    TraceLimits::equal

    fn TraceLimits::equal(TraceLimits, TraceLimits) -> Bool

    TraceLimits::new

    fn TraceLimits::new(input? : Int, attempts? : Int, steps? : Int, depth? : Int, work? : Int) -> TraceLimits

    TraceLimits::not_equal

    fn TraceLimits::not_equal(x : TraceLimits, y : TraceLimits) -> Bool

    TraceLimits::valid

    fn TraceLimits::valid(self : TraceLimits) -> Bool

    TraceRequest

    pub struct TraceRequest {
    subject : Subject
    view_id : String
    input : String
    limits : TraceLimits
    } derive(Eq,
    Debug
    )

    One immutable request to an external matching or parsing engine.

    TraceRequest::ebnf

    fn TraceRequest::ebnf(grammar :
    Grammar
    , start_rule : String, input : String, view_id? : String, limits? : TraceLimits) -> TraceRequest

    TraceRequest::equal

    TraceRequest::identity

    fn TraceRequest::identity(self : TraceRequest) -> SubjectIdentity

    The provenance that a trace for this request must carry.

    TraceRequest::not_equal

    fn TraceRequest::not_equal(x : TraceRequest, y : TraceRequest) -> Bool

    TraceRequest::regex

    fn TraceRequest::regex(model :
    Regex
    , input : String, view_id? : String, limits? : TraceLimits) -> TraceRequest

    TraceRequest::topology

    fn TraceRequest::topology(self : TraceRequest) -> TopologyResult

    The semantic topology of the requested subject, for mapping engine events.

    TraceRequest::validate

    Check a request before a provider receives it.

    TraceResult

    pub(all) enum TraceResult {
    Matched(Trace)
    NotMatched(Trace)
    Unsupported(String)
    Exhausted(String)
    ProviderError(String)
    } derive(Eq,
    Debug
    )

    The outcome of a provider. Unsupported, exhausted and error results are not evidence of a non-match.

    TraceResult::equal

    fn TraceResult::equal(TraceResult, TraceResult) -> Bool

    TraceResult::not_equal

    fn TraceResult::not_equal(x : TraceResult, y : TraceResult) -> Bool

    TraceRun

    pub struct TraceRun {
    result : TraceResult?
    validated : ValidatedTrace?
    diagnostics : ReadOnlyArray[
    Diagnostic
    ]
    }

    The result of an explicit provider run.

    TraceRun::refused

    A run that did not reach a provider, with the reasons.

    TraceValidation

    pub struct TraceValidation {
    validated : ValidatedTrace?
    diagnostics : ReadOnlyArray[
    Diagnostic
    ]
    }

    Track

    pub struct Track {
    id : String
    name : String
    start : String
    end : String
    } derive(Eq,
    Debug
    )

    One rule, or the single pattern of a regex, with its boundary points.

    Track::equal

    fn Track::equal(Track, Track) -> Bool

    Track::not_equal

    fn Track::not_equal(x : Track, y : Track) -> Bool

    Track::to_repr

    ValidatedTrace

    pub struct ValidatedTrace {
    trace : Trace
    topology : Topology
    }

    A trace that passed structural validation against one subject, with the topology it refers to. Validation never re-runs or verifies matching.

    connector_id

    fn connector_id(owner : String, role : ConnectorRole) -> String

    The stable identity of the connector that owner draws with role.

    diagnostic_codes

    let diagnostic_codes : ReadOnlyArray[String]

    The stable diagnostic codes of trace validation and the provider driver.

    point_id

    fn point_id(owner : String, side : String) -> String

    The stable identity of a point. Identities are length-prefixed, so a node identity that contains : cannot collide with another point.

    run

    fn[P : RailroadTraceProvider] run(provider : P, request : TraceRequest) -> TraceRun

    Invoke provider once for request and validate its result. This is the only library entry point that calls a provider.

    validate_result

    fn validate_result(result : TraceResult, subject : Subject, view_id? : String, limits? : TraceLimits) -> TraceValidation

    Validate a provider result. A matched result needs a matched attempt; a non-match result has none.

    validate_trace

    fn validate_trace(trace : Trace, subject : Subject, view_id? : String, limits? : TraceLimits) -> TraceValidation

    Validate supplied evidence: subject kind, model/view identity, structural fingerprint, targets, roles, declared continuity, spans and bounds. It reports invalid evidence without guessing targets from labels.