Skip to documentation
SLOP

tiny.syn.State

Reference tiny.syn State

Defined in state.

The continuation state: what the last scanned line left open.

API (6)

Actions

Public operations.

Fields and members

Public fields and members.

No direct callersNo direct callsstateState
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/syn/src/state.zig:97

zig
/// The continuation state: what the last scanned line left open. A caller keeps one for each/// document and passes it to every `highlightLine` call for that document. The value `.{}` is the/// fresh state for the start of a document. The struct holds no pointers and needs no cleanup. The/// state records no document, so a caller that moves to another document calls `reset`.pub const State = struct {    /// The open mode with its owning language, or null when nothing is open. The package changes it    /// only through `reset`, `rebind` and `retain`, which keep the mode admitted by its language.    continuation: ?Continuation = null,    /// Clears the state, so nothing is open, for a caller starting a new document.    pub fn reset(self: *State) void {        self.* = .{};    }    /// Keeps the open mode when `language` owns it, and clears the state otherwise, for    /// `highlightLine` at the start of each line so an open comment or string from another language    /// never reaches this one. The call asserts that a stored mode is admitted by its owning    /// language.    pub fn rebind(self: *State, language: Language) void {        const continuation = self.continuation orelse return;        std.debug.assert(continuation.mode.admittedBy(            continuation.language,        ));        if (continuation.language != language) self.reset();    }    /// Stores `next_mode` with `language` as its owner, or clears the state when `next_mode` is    /// null, for `highlightLine` after scanning a line to store what the line left open. The call    /// asserts that `language` admits `next_mode`.    pub fn retain(        self: *State,        language: Language,        next_mode: ?Mode,    ) void {        if (next_mode) |actual| {            std.debug.assert(actual.admittedBy(language));        }        self.continuation = if (next_mode) |actual|            .{ .language = language, .mode = actual }        else            null;    }    /// Returns the owning language, or null when nothing is open, for a caller or a test reading    /// which language left something open.    pub fn owner(self: *const State) ?Language {        const continuation = self.continuation orelse return null;        return continuation.language;    }    /// Returns the open mode, or null when nothing is open, for a caller or a test reading which    /// comment or string is open after a line.    pub fn mode(self: *const State) ?Mode {        const continuation = self.continuation orelse return null;        return continuation.mode;    }};

Source: lib/syn/src/root.zig:52

zig
pub const State = state.State;
Called byCallsNo direct callstest sourcelib.syn.src.scan.testtest: activated syntax highlighting p...test sourcelib.syn.src.scan.testtest: foreign continuation equals a f...test sourcelib.syn.src.scan.testtest: rust lifetime and block opener ...test sourcelib.syn.src.scan.testtest: syn line state carries a new bl...test sourcelib.syn.src.scan.testtest: syn line state carries generic ...+3 moreStatemode
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callstest sourcelib.syn.src.scan.testtest: syn line state carries generic ...Stateowner
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersStateresetStaterebind
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callsStaterebindStatereset
Static calls · unresolved targets: 0 · external targets: 0.

Complete caller list for State.mode

8 direct callers.

Audit

Definitions6
Public names12
Members1
Version26.7.0
Revisiondaab053ee433