Skip to documentation
SLOP

tiny.chant.parse.state.start

Reference tiny.chant parse state start

Defined in parse.state.

API (2)

Actions

Public operations.

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

Source

Called byCallstest sourcelib.chant.src.parse.state.starttest: start detects declarations and ...private sourcelib.chant.src.parse.statementparseBlockItemprivate sourcelib.chant.src.parse.statementparseForparse.state.cursoraheadparse.state.cursorpeekparse.state.typedefisNameparse.state.startdeclaration
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallstest sourcelib.chant.src.parse.state.starttest: start detects declarations and ...private sourcelib.chant.src.parse.type.specparseAlignasprivate sourcelib.chant.src.parse.type.specparseTypeofparse.state.cursoraheadparse.state.typedefisNameparse.state.starttypename
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/chant/src/parse/state/root.zig:8

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

Source: lib/chant/src/parse/state/start.zig

zig
const std = @import("std");const chant = @import("../../root.zig");const ast = @import("../../ast/root.zig");const types = @import("types.zig");const cursor = @import("cursor.zig");const typedef = @import("typedef.zig");const Token = chant.token.Token;const Parser = types.Parser;pub fn declaration(parser: *const Parser) bool {    return switch (cursor.peek(parser).kind) {        .kw_void,        .kw_char,        .kw_short,        .kw_int,        .kw_long,        .kw_float,        .kw_double,        .kw_decimal32,        .kw_decimal64,        .kw_decimal128,        .kw_signed,        .kw_unsigned,        .kw_bitint,        .kw_bool,        .kw_const,        .kw_volatile,        .kw_restrict,        .kw_static,        .kw_extern,        .kw_inline,        .kw_register,        .kw_auto,        .kw_constexpr,        .kw_typedef,        .kw_alignas,        .kw_thread_local,        .kw_typeof,        .kw_typeof_unqual,        .kw_struct,        .kw_union,        .kw_enum,        => true,        .lbracket => cursor.ahead(parser, 1).kind == .lbracket,        .identifier => typedef.isName(parser, cursor.peek(parser).text),        else => false,    };}pub fn typename(parser: *const Parser, offset: usize) bool {    const tok = cursor.ahead(parser, offset);    return switch (tok.kind) {        .kw_void,        .kw_char,        .kw_short,        .kw_int,        .kw_long,        .kw_float,        .kw_double,        .kw_decimal32,        .kw_decimal64,        .kw_decimal128,        .kw_signed,        .kw_unsigned,        .kw_bitint,        .kw_bool,        .kw_const,        .kw_volatile,        .kw_typeof,        .kw_typeof_unqual,        .kw_struct,        .kw_union,        .kw_enum,        => true,        .identifier => typedef.isName(parser, tok.text),        else => false,    };}test "start detects declarations and type names" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const arena = arena_state.allocator();    const tokens = [_]Token{        .{ .kind = .identifier, .text = "size_t", .file = "test.c", .line = 1, .column = 1 },        .{ .kind = .identifier, .text = "value", .file = "test.c", .line = 1, .column = 8 },        .{ .kind = .eof, .text = "", .file = "test.c", .line = 1, .column = 13 },    };    var parser = try @import("test.zig").initParser(arena, &tokens);    try typedef.register(&parser, "size_t", &ast.types.ulong_type);    try std.testing.expect(declaration(&parser));    try std.testing.expect(typename(&parser, 0));    try std.testing.expect(!typename(&parser, 1));}

Audit

Definitions3
Public names3
Members0
Version26.7.0
Revisiondaab053ee433