Skip to documentation
SLOP

tiny.smg.tree.runtime.scanner

Reference tiny.smg tree runtime scanner

Defined in tree.runtime.

API (6)

Actions

Public operations.

Types and contracts

Public types and contracts.

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

Source

Called byCallsNo direct callstest; no linktools.smg.src.tree.runtime.scannertest: scanner state is copied by valuetree.runtime.scanner.Stateeql
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate; no linktools.smg.src.tree.runtime.parsertestVersiontest; no linktools.smg.src.tree.runtime.parsertest: focused active version compacti...test; no linktools.smg.src.tree.runtime.parsertest: focused equal-precedence active...test; no linktools.smg.src.tree.runtime.scannertest: runtime scanner dispatch never ...test; no linktools.smg.src.tree.runtime.scannertest: scanner state is copied by value+2 moretree.runtime.scanner.Stateinit
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsprivate; no linktools.smg.src.tree.runtime.parserlextest; no linktools.smg.src.tree.runtime.scannertest: runtime scanner dispatch never ...private; no linktools.smg.src.tree.runtime.scannerbitstree.runtime.scannerscan
Static calls · unresolved targets: 0 · external targets: 2.

Source: tools/smg/src/tree/runtime/root.zig:6

zig
pub const scanner = @import("scanner.zig");

Source: tools/smg/src/tree/runtime/scanner.zig

zig
const std = @import("std");const scanners = @import("../scanner/root.zig");const abi = @import("abi.zig");const lexer = @import("lexer.zig");pub const Kind = enum {    zig,    javascript,    typescript,    tsx,    c,    cpp,};pub const State = union(enum) {    none,    cpp: scanners.cpp.Scanner,    pub fn init(kind: Kind) State {        return if (kind == .cpp) .{ .cpp = .{} } else .none;    }    pub fn eql(left: State, right: State) bool {        if (std.meta.activeTag(left) != std.meta.activeTag(right)) return false;        return switch (left) {            .none => true,            .cpp => |value| std.meta.eql(value, right.cpp),        };    }    pub fn isEmpty(self: State) bool {        return switch (self) {            .none => true,            .cpp => |value| value.delimiter_length == 0,        };    }};pub fn scan(kind: Kind, state: *State, input: *lexer.Lexer, valid: []const bool) bool {    return switch (kind) {        .zig, .c => false,        .javascript => blk: {            var value = scanners.javascript.Scanner{};            break :blk value.scan(input, @bitCast(bits(u8, valid)));        },        .typescript, .tsx => blk: {            var value = scanners.typescript.Scanner{};            break :blk value.scan(input, @bitCast(bits(u16, valid)));        },        .cpp => state.cpp.scan(input, @bitCast(bits(u8, valid))),    };}fn bits(comptime T: type, valid: []const bool) T {    var result: T = 0;    for (valid, 0..) |enabled, index| {        if (enabled) result |= @as(T, 1) << @intCast(index);    }    return result;}test "scanner state is copied by value" {    var left = State.init(.cpp);    const right = left;    try std.testing.expect(left.eql(right));    left.cpp.delimiter_length = 1;    try std.testing.expect(!left.eql(right));}test "runtime scanner dispatch never calls grammar link anchors" {    var state = State.init(.javascript);    var input = lexer.Lexer.init("}", .{ .byte = 0, .point = .{ .row = 0, .column = 0 } });    input.start();    var valid = @as([8]bool, @splat(false));    valid[0] = true;    try std.testing.expect(scan(.javascript, &state, &input, &valid));    try std.testing.expectEqual(@as(abi.Symbol, 0), input.abi.result_symbol);}

Complete caller list for tree.runtime.scanner.State.init

7 direct callers.

Audit

Definitions7
Public names7
Members8
Version26.7.0
Revisiondaab053ee433