Skip to documentation
SLOP

tiny.smt.smtlib.parse.script

Reference tiny.smt smtlib parse script

Defined in smtlib.parse.

Reads the commands of an SMT-LIB script in order and collects its logic and assertions.

API (1)

Actions

Public operations.

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

Source

Called byCallsNo direct callerssmtlib.parse.sortlistsmtlib.parse.sortparsesmtlib.parse.tokenatomsmtlib.parse.tokenexpectLeftsmtlib.parse.tokenexpectRight+4 moresmtlib.parse.scriptparse
Static calls · unresolved targets: 3 · external targets: 5.

Source: lib/smt/src/smtlib/parse/root.zig:10

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

Source: lib/smt/src/smtlib/parse/script.zig

zig
//! Reads the commands of an SMT-LIB script in order and collects its logic and assertions. Each//! command either declares a name that later terms use or asserts a formula, so the commands are//! read in order and each declaration is known before the terms after it. The reader accepts five//! commands and refuses every other with `UnsupportedCommand`.const std = @import("std");const smt = @import("../../root.zig");const errors = @import("error.zig");const sort = @import("sort.zig");const state = @import("state.zig");const term_parser = @import("term.zig");const token = @import("token.zig");const Error = errors.Error;const ParseError = errors.ParseError;const Parser = state.Parser;const term = smt.term;/// Reads every command of the parser's text and returns a `Script` over the parser's `Context` with/// the script's logic and assertions. `parseScript` calls it, and code that builds its own `Parser`/// calls it to read a script with that state. `set-logic` sets the logic, which is `ALL` until one/// does. `declare-const` adds a constant and `declare-fun` a function to the `Context`, and both/// record the name for the terms that follow. `assert` reads a term and appends it to the/// assertions, and `check-sat` is read and ignored. It returns `DuplicateSymbol` for a name/// declared twice in the script, and `UnsupportedCommand` for any other command. It checks no/// sorts: an `assert` of a non-Boolean term is accepted. The logic name and the recorded names/// borrow the parser's text. On an error it frees the assertion list, and the terms already built/// stay in the `Context`.pub fn parse(parser: *Parser) Error!term.Script {    var parsed = term.Script.init(parser.ctx, "ALL");    errdefer parsed.deinit();    while (token.skipSpace(parser)) {        try token.expectLeft(parser);        const command = try token.atom(parser);        if (std.mem.eql(u8, command, "set-logic")) {            parsed.logic = try token.atom(parser);            try token.expectRight(parser);        } else if (std.mem.eql(u8, command, "declare-const")) {            const name = try token.atom(parser);            if (parser.symbols.contains(name) or parser.functions.contains(name)) return ParseError.DuplicateSymbol;            const symbol_sort = try sort.parse(parser);            const symbol = try parser.ctx.symbol(name, symbol_sort);            try parser.symbols.put(name, symbol);            try token.expectRight(parser);        } else if (std.mem.eql(u8, command, "declare-fun")) {            const name = try token.atom(parser);            if (parser.symbols.contains(name) or parser.functions.contains(name)) return ParseError.DuplicateSymbol;            const params = try sort.list(parser);            defer parser.ctx.allocator.free(params);            const result = try sort.parse(parser);            const function = try parser.ctx.function(name, params, result);            try parser.functions.put(name, function);            try token.expectRight(parser);        } else if (std.mem.eql(u8, command, "assert")) {            try parsed.assertTerm(try term_parser.parse(parser));            try token.expectRight(parser);        } else if (std.mem.eql(u8, command, "check-sat")) {            try token.expectRight(parser);        } else {            return ParseError.UnsupportedCommand;        }    }    return parsed;}

Complete call list for smtlib.parse.script.parse

9 direct calls.

Audit

Definitions2
Public names2
Members0
Version26.7.0
Revisiondaab053ee433