Skip to documentation
SLOP

tiny.zen.parseQuiz

Reference tiny.zen parseQuiz

Defined in tiny.zen.

No direct callersNo direct callstiny.zenparseQuiz
Static calls · unresolved targets: 1 · external targets: 4.

Source

Source: lib/zen/src/quiz/parse.zig:6

zig
pub fn parse(storage: *storage_mod.Storage, source: []const u8) model.Error!model.Quiz {    var regions = try storage.acquire(source);    var iterator = scan.Iterator.init(source);    var question_index: usize = 0;    var option_index: usize = 0;    var byte_index: usize = 0;    var current: ?Current = null;    while (iterator.next()) |token| switch (token) {        .prompt => |text| {            if (current) |active| active.finish(&regions, option_index);            std.debug.assert(question_index < regions.questions.len);            regions.questions[question_index] = .{                .prompt = text,                .options = &.{},                .explanation = "",            };            current = .{                .question = question_index,                .option_start = option_index,                .active = .{ .prompt = question_index },            };            question_index += 1;        },        .option => |option| {            std.debug.assert(current != null);            var active = &current.?;            std.debug.assert(option_index < regions.options.len);            regions.options[option_index] = .{                .text = option.text,                .correct = option.correct,            };            active.active = .{ .option = option_index };            active.joined_start = null;            option_index += 1;        },        .explanation => |text| {            std.debug.assert(current != null);            var active = &current.?;            switch (active.active) {                .explanation => active.join(&regions, &byte_index, text),                else => {                    regions.questions[active.question].explanation = text;                    active.active = .{ .explanation = active.question };                    active.joined_start = null;                },            }        },        .continuation => |text| {            std.debug.assert(current != null);            var active = &current.?;            active.join(&regions, &byte_index, text);        },    };    std.debug.assert(current != null);    current.?.finish(&regions, option_index);    std.debug.assert(question_index == regions.questions.len);    std.debug.assert(option_index == regions.options.len);    std.debug.assert(byte_index == regions.joined_text.len);    return .{ .questions = regions.questions };}

Source: lib/zen/src/root.zig:166

zig
/// Parses into active storage; the quiz borrows it until `reset`.pub const parseQuiz = quiz.parse;

Also reachable as

quiz.parse.

Audit

Definitions1
Public names2
Members0
Version26.7.0
Revisiondaab053ee433