tiny.smt.smtlib.parse.token
Defined in smtlib.parse.
Splits SMT-LIB text into parentheses and atoms.
API (6)
Actions
Public operations.
atom: Skips whitespace and comments and returns the next atom: the characters up to the next whitespace or parenthesis.expectLeft: Skips whitespace and comments and consumes a(for the readers where a list has to open.expectRight: Skips whitespace and comments and consumes a)for the readers where a list has to close.peekLeft: Skips whitespace and comments and returns true when the next character is(, so the term and sort readers decide between an atom and a list.peekRight: Skips whitespace and comments and returns true when the next character is), so the list readers find the end of an operand list.skipSpace: Moves the position past spaces, tabs, carriage returns, newlines and;comments, which run to the end of their line.
Source
Source: lib/smt/src/smtlib/parse/root.zig:14
zig
pub const token = @import("token.zig");Source: lib/smt/src/smtlib/parse/token.zig
zig
//! Splits SMT-LIB text into parentheses and atoms. Every step of the reader has to skip whitespace//! and comments and then read one parenthesis or one atom. An atom is every character up to the//! next whitespace or parenthesis, so the reader has no quoted symbols and no string literals.const errors = @import("error.zig");const state = @import("state.zig");const Error = errors.Error;const ParseError = errors.ParseError;const Parser = state.Parser;/// Moves the position past spaces, tabs, carriage returns, newlines and `;` comments, which run to/// the end of their line. The call returns true when a character remains, so the command reader/// learns whether another command follows.pub fn skipSpace(parser: *Parser) bool { while (parser.pos < parser.source.len) { switch (parser.source[parser.pos]) { ' ', '\t', '\r', '\n' => parser.pos += 1, ';' => { while (parser.pos < parser.source.len and parser.source[parser.pos] != '\n') parser.pos += 1; }, else => return true, } } return false;}/// Skips whitespace and comments and returns true when the next character is `(`, so the term and/// sort readers decide between an atom and a list. The call leaves the parenthesis unconsumed.pub fn peekLeft(parser: *Parser) bool { _ = skipSpace(parser); return parser.pos < parser.source.len and parser.source[parser.pos] == '(';}/// Skips whitespace and comments and returns true when the next character is `)`, so the list/// readers find the end of an operand list. The call leaves the parenthesis unconsumed.pub fn peekRight(parser: *Parser) bool { _ = skipSpace(parser); return parser.pos < parser.source.len and parser.source[parser.pos] == ')';}/// Skips whitespace and comments and consumes a `(` for the readers where a list has to open. The/// call returns `ExpectedList` for any other character or the end of the text.pub fn expectLeft(parser: *Parser) Error!void { if (!peekLeft(parser)) return ParseError.ExpectedList; parser.pos += 1;}/// Skips whitespace and comments and consumes a `)` for the readers where a list has to close. The/// call returns `ExpectedRightParen` for any other character or the end of the text.pub fn expectRight(parser: *Parser) Error!void { if (!peekRight(parser)) return ParseError.ExpectedRightParen; parser.pos += 1;}/// Skips whitespace and comments and returns the next atom: the characters up to the next/// whitespace or parenthesis. The readers call it for every command name, operator, name and/// number. The atom is a slice of the parser's text. The call returns `ExpectedAtom` at the end of/// the text or at a parenthesis.pub fn atom(parser: *Parser) Error![]const u8 { _ = skipSpace(parser); if (parser.pos >= parser.source.len) return ParseError.ExpectedAtom; if (parser.source[parser.pos] == '(' or parser.source[parser.pos] == ')') return ParseError.ExpectedAtom; const start = parser.pos; while (parser.pos < parser.source.len) { switch (parser.source[parser.pos]) { ' ', '\t', '\r', '\n', '(', ')' => break, else => parser.pos += 1, } } return parser.source[start..parser.pos];}Complete caller list for smtlib.parse.token.expectRight
10 direct callers.
tiny.smt.smtlib.parse.script.parse[function] atlib/smt/src/smtlib/parse/script.zig:29tiny.smt.smtlib.parse.sort.list[function] atlib/smt/src/smtlib/parse/sort.zig:60tiny.smt.smtlib.parse.sort.parse[function] atlib/smt/src/smtlib/parse/sort.zig:23tiny.smt.smtlib.parse.term.parse[function] atlib/smt/src/smtlib/parse/term.zig:83lib.smt.src.smtlib.parse.term.parseApply[function] — private source atlib/smt/src/smtlib/parse/term.zig:208in nearest public ownertiny.smt.smtlib.parse.termlib.smt.src.smtlib.parse.term.parseBinary[function] — private source atlib/smt/src/smtlib/parse/term.zig:173in nearest public ownertiny.smt.smtlib.parse.termlib.smt.src.smtlib.parse.term.parseIndexed[function] — private source atlib/smt/src/smtlib/parse/term.zig:119in nearest public ownertiny.smt.smtlib.parse.termlib.smt.src.smtlib.parse.term.parseNary[function] — private source atlib/smt/src/smtlib/parse/term.zig:191in nearest public ownertiny.smt.smtlib.parse.termlib.smt.src.smtlib.parse.term.parseTernary[function] — private source atlib/smt/src/smtlib/parse/term.zig:180in nearest public ownertiny.smt.smtlib.parse.termlib.smt.src.smtlib.parse.term.parseUnary[function] — private source atlib/smt/src/smtlib/parse/term.zig:163in nearest public ownertiny.smt.smtlib.parse.term
Audit
| Definitions | 7 |
|---|---|
| Public names | 7 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |