Unnamed: 0
int64
0
0
repo_id
stringlengths
5
186
file_path
stringlengths
15
223
content
stringlengths
1
32.8M
0
repos/exercism-ziglang
repos/exercism-ziglang/darts/HELP.md
# Help ## Running the tests Write your code in `<exercise_name>.zig`. To run the tests for an exercise, run: ```bash zig test test_exercise_name.zig ``` in the exercise's root directory (replacing `exercise_name` with the name of the exercise). ## Submitting your solution You can submit your solution using the `...
0
repos/exercism-ziglang
repos/exercism-ziglang/darts/darts.zig
const std = @import("std"); pub const Coordinate = struct { x: f32, y: f32, pub fn init(x_coord: f32, y_coord: f32) Coordinate { return Coordinate{ .x = x_coord, .y = y_coord }; } pub fn score(self: Coordinate) usize { const radius: f32 = std.math.sqrt(std.math.pow(f32, self.x, 2) ...
0
repos/exercism-ziglang/darts
repos/exercism-ziglang/darts/.exercism/metadata.json
{"track":"zig","exercise":"darts","id":"f3c4b9b8b6a74b11af1d1f4ecb95940b","url":"https://exercism.org/tracks/zig/exercises/darts","handle":"exilesprx","is_requester":true,"auto_approve":false}
0
repos/exercism-ziglang/darts
repos/exercism-ziglang/darts/.exercism/config.json
{ "authors": [ "massivelivefun" ], "files": { "solution": [ "darts.zig" ], "test": [ "test_darts.zig" ], "example": [ ".meta/example.zig" ] }, "blurb": "Calculate the points scored in a single toss of a Darts game.", "source": "Inspired by an exercise created by...
0
repos/exercism-ziglang
repos/exercism-ziglang/isbn-verifier/test_isbn_verifier.zig
const std = @import("std"); const testing = std.testing; const isValidIsbn10 = @import("isbn_verifier.zig").isValidIsbn10; test "valid ISBN" { try testing.expect(isValidIsbn10("3-598-21508-8")); } test "invalid ISBN check digit" { try testing.expect(!isValidIsbn10("3-598-21508-9")); } test "valid ISBN with ...
0
repos/exercism-ziglang
repos/exercism-ziglang/isbn-verifier/README.md
# ISBN Verifier Welcome to ISBN Verifier on Exercism's Zig Track. If you need help running the tests or submitting your code, check out `HELP.md`. ## Instructions The [ISBN-10 verification process][isbn-verification] is used to validate book identification numbers. These normally contain dashes and look like: `3-598...
0
repos/exercism-ziglang
repos/exercism-ziglang/isbn-verifier/isbn_verifier.zig
const std = @import("std"); pub fn isValidIsbn10(s: []const u8) bool { var digits: usize = 0; var sum: usize = 0; for (s) |c| { var value: usize = undefined; switch (c) { '-' => continue, 'X' => if (digits == 9) { value = 10; } else return...
0
repos/exercism-ziglang
repos/exercism-ziglang/isbn-verifier/HELP.md
# Help ## Running the tests Write your code in `<exercise_name>.zig`. To run the tests for an exercise, run: ```bash zig test test_exercise_name.zig ``` in the exercise's root directory (replacing `exercise_name` with the name of the exercise). ## Submitting your solution You can submit your solution using the `...
0
repos/exercism-ziglang/isbn-verifier
repos/exercism-ziglang/isbn-verifier/.exercism/metadata.json
{"track":"zig","exercise":"isbn-verifier","id":"4e5dcd3d629c442a9c329f11a4d6cf8a","url":"https://exercism.org/tracks/zig/exercises/isbn-verifier","handle":"exilesprx","is_requester":true,"auto_approve":false}
0
repos/exercism-ziglang/isbn-verifier
repos/exercism-ziglang/isbn-verifier/.exercism/config.json
{ "authors": [ "ee7" ], "files": { "solution": [ "isbn_verifier.zig" ], "test": [ "test_isbn_verifier.zig" ], "example": [ ".meta/example.zig" ] }, "blurb": "Check if a given string is a valid ISBN-10 number.", "source": "Converting a string into a number and so...
0
repos/exercism-ziglang
repos/exercism-ziglang/difference-of-squares/README.md
# Difference of Squares Welcome to Difference of Squares on Exercism's Zig Track. If you need help running the tests or submitting your code, check out `HELP.md`. ## Instructions Find the difference between the square of the sum and the sum of the squares of the first N natural numbers. The square of the sum of the...
0
repos/exercism-ziglang
repos/exercism-ziglang/difference-of-squares/HELP.md
# Help ## Running the tests Write your code in `<exercise_name>.zig`. To run the tests for an exercise, run: ```bash zig test test_exercise_name.zig ``` in the exercise's root directory (replacing `exercise_name` with the name of the exercise). ## Submitting your solution You can submit your solution using the `...
0
repos/exercism-ziglang
repos/exercism-ziglang/difference-of-squares/test_difference_of_squares.zig
const std = @import("std"); const testing = std.testing; const difference_of_squares = @import("difference_of_squares.zig"); test "square of sum up to 1" { const expected: usize = 1; const actual = difference_of_squares.squareOfSum(1); try testing.expectEqual(expected, actual); } test "square of sum up t...
0
repos/exercism-ziglang
repos/exercism-ziglang/difference-of-squares/difference_of_squares.zig
pub fn squareOfSum(number: usize) usize { const sum: usize = number * (number + 1) / 2; return sum * sum; } pub fn sumOfSquares(number: usize) usize { return (number * (number + 1) * (2 * number + 1)) / 6; } pub fn differenceOfSquares(number: usize) usize { return squareOfSum(number) - sumOfSquares(nu...
0
repos/exercism-ziglang/difference-of-squares
repos/exercism-ziglang/difference-of-squares/.exercism/metadata.json
{"track":"zig","exercise":"difference-of-squares","id":"1ebbda10125c4dda9a686cc48e772e98","url":"https://exercism.org/tracks/zig/exercises/difference-of-squares","handle":"exilesprx","is_requester":true,"auto_approve":false}
0
repos/exercism-ziglang/difference-of-squares
repos/exercism-ziglang/difference-of-squares/.exercism/config.json
{ "authors": [ "massivelivefun" ], "files": { "solution": [ "difference_of_squares.zig" ], "test": [ "test_difference_of_squares.zig" ], "example": [ ".meta/example.zig" ] }, "blurb": "Find the difference between the square of the sum and the sum of the squares of...
0
repos/exercism-ziglang
repos/exercism-ziglang/resistor-color-duo/resistor_color_duo.zig
pub const ColorBand = enum { black, brown, red, orange, yellow, green, blue, violet, grey, white }; pub fn colorCode(colors: [2]ColorBand) usize { return @as(usize, @intFromEnum(colors[0])) * 10 + @as(usize, @intFromEnum(colors[1])); }
0
repos/exercism-ziglang
repos/exercism-ziglang/resistor-color-duo/test_resistor_color_duo.zig
const std = @import("std"); const testing = std.testing; const resistor_color_duo = @import("resistor_color_duo.zig"); const ColorBand = resistor_color_duo.ColorBand; test "brown and black" { const array = [_]ColorBand{ .brown, .black }; const expected: usize = 10; const actual = resistor_color_duo.colorC...
0
repos/exercism-ziglang
repos/exercism-ziglang/resistor-color-duo/README.md
# Resistor Color Duo Welcome to Resistor Color Duo on Exercism's Zig Track. If you need help running the tests or submitting your code, check out `HELP.md`. ## Instructions If you want to build something using a Raspberry Pi, you'll probably use _resistors_. For this exercise, you need to know two things about them:...
0
repos/exercism-ziglang
repos/exercism-ziglang/resistor-color-duo/HELP.md
# Help ## Running the tests Write your code in `<exercise_name>.zig`. To run the tests for an exercise, run: ```bash zig test test_exercise_name.zig ``` in the exercise's root directory (replacing `exercise_name` with the name of the exercise). ## Submitting your solution You can submit your solution using the `...
0
repos/exercism-ziglang/resistor-color-duo
repos/exercism-ziglang/resistor-color-duo/.exercism/metadata.json
{"track":"zig","exercise":"resistor-color-duo","id":"0d386e2dee2942288c73e88065ba4381","url":"https://exercism.org/tracks/zig/exercises/resistor-color-duo","handle":"exilesprx","is_requester":true,"auto_approve":false}
0
repos/exercism-ziglang/resistor-color-duo
repos/exercism-ziglang/resistor-color-duo/.exercism/config.json
{ "authors": [ "massivelivefun" ], "files": { "solution": [ "resistor_color_duo.zig" ], "test": [ "test_resistor_color_duo.zig" ], "example": [ ".meta/example.zig" ] }, "blurb": "Convert color codes, as used on resistors, to a numeric value.", "source": "Maud de...
0
repos/exercism-ziglang
repos/exercism-ziglang/pangram/pangram.zig
const std = @import("std"); const print = std.debug.print; pub fn isPangram(str: []const u8) bool { var alphabet: [26]u8 = undefined; for (str) |c| { if (std.ascii.isAlphabetic(c)) { // fill the alphabet array with 1s if the letter is found // and the index is the letter's posit...
0
repos/exercism-ziglang
repos/exercism-ziglang/pangram/README.md
# Pangram Welcome to Pangram on Exercism's Zig Track. If you need help running the tests or submitting your code, check out `HELP.md`. ## Introduction You work for a company that sells fonts through their website. They'd like to show a different sentence each time someone views a font on their website. To give a com...
0
repos/exercism-ziglang
repos/exercism-ziglang/pangram/HELP.md
# Help ## Running the tests Write your code in `<exercise_name>.zig`. To run the tests for an exercise, run: ```bash zig test test_exercise_name.zig ``` in the exercise's root directory (replacing `exercise_name` with the name of the exercise). ## Submitting your solution You can submit your solution using the `...
0
repos/exercism-ziglang
repos/exercism-ziglang/pangram/test_pangram.zig
const std = @import("std"); const testing = std.testing; const pangram = @import("pangram.zig"); test "empty sentence" { try testing.expect(!pangram.isPangram("")); } test "perfect lower case" { try testing.expect(pangram.isPangram("abcdefghijklmnopqrstuvwxyz")); } test "only lower case" { try testing.e...
0
repos/exercism-ziglang/pangram
repos/exercism-ziglang/pangram/.exercism/metadata.json
{"track":"zig","exercise":"pangram","id":"1bdd8ec73596487cb17d15f4a35c45ef","url":"https://exercism.org/tracks/zig/exercises/pangram","handle":"exilesprx","is_requester":true,"auto_approve":false}
0
repos/exercism-ziglang/pangram
repos/exercism-ziglang/pangram/.exercism/config.json
{ "authors": [ "massivelivefun" ], "files": { "solution": [ "pangram.zig" ], "test": [ "test_pangram.zig" ], "example": [ ".meta/example.zig" ] }, "blurb": "Determine if a sentence is a pangram.", "source": "Wikipedia", "source_url": "https://en.wikipedia.org/...
0
repos/exercism-ziglang
repos/exercism-ziglang/luhn/luhn.zig
const std = @import("std"); pub fn isValid(s: []const u8) bool { var sum: usize = 0; var digitCount: usize = 0; var i: usize = s.len; while (i > 0) : (i -= 1) { switch (s[i - 1]) { '0'...'9' => { digitCount += 1; const digit: u8 = std.fmt.charToDigit(...
0
repos/exercism-ziglang
repos/exercism-ziglang/luhn/README.md
# Luhn Welcome to Luhn on Exercism's Zig Track. If you need help running the tests or submitting your code, check out `HELP.md`. ## Instructions Given a number determine whether or not it is valid per the Luhn formula. The [Luhn algorithm][luhn] is a simple checksum formula used to validate a variety of identificat...
0
repos/exercism-ziglang
repos/exercism-ziglang/luhn/test_luhn.zig
const std = @import("std"); const testing = std.testing; const isValid = @import("luhn.zig").isValid; test "single digit strings cannot be valid" { try testing.expect(!isValid("1")); } test "a single zero is invalid" { try testing.expect(!isValid("0")); } test "a simple valid SIN that remains valid if rever...
0
repos/exercism-ziglang
repos/exercism-ziglang/luhn/HELP.md
# Help ## Running the tests Write your code in `<exercise_name>.zig`. To run the tests for an exercise, run: ```bash zig test test_exercise_name.zig ``` in the exercise's root directory (replacing `exercise_name` with the name of the exercise). ## Submitting your solution You can submit your solution using the `...
0
repos/exercism-ziglang/luhn
repos/exercism-ziglang/luhn/.exercism/metadata.json
{"track":"zig","exercise":"luhn","id":"8a93f9c4b0c84ee1a3b680239e79cafa","url":"https://exercism.org/tracks/zig/exercises/luhn","handle":"exilesprx","is_requester":true,"auto_approve":false}
0
repos/exercism-ziglang/luhn
repos/exercism-ziglang/luhn/.exercism/config.json
{ "authors": [ "ee7" ], "files": { "solution": [ "luhn.zig" ], "test": [ "test_luhn.zig" ], "example": [ ".meta/example.zig" ] }, "blurb": "Given a number determine whether or not it is valid per the Luhn formula.", "source": "The Luhn Algorithm on Wikipedia", ...
0
repos/exercism-ziglang
repos/exercism-ziglang/armstrong-numbers/test_armstrong_numbers.zig
const std = @import("std"); const testing = std.testing; const isArmstrongNumber = @import("armstrong_numbers.zig").isArmstrongNumber; test "zero is an armstrong number" { try testing.expect(isArmstrongNumber(0)); } test "single-digit numbers are armstrong numbers" { try testing.expect(isArmstrongNumber(5));...
0
repos/exercism-ziglang
repos/exercism-ziglang/armstrong-numbers/armstrong_numbers.zig
const std = @import("std"); const print = std.debug.print; pub fn isArmstrongNumber(num: u128) bool { const allocator = std.heap.page_allocator; const str = std.fmt.allocPrint(allocator, "{d}", .{num}) catch "Failed to format"; defer allocator.free(str); var sum: u128 = 0; for (str) |c| { ...
0
repos/exercism-ziglang
repos/exercism-ziglang/armstrong-numbers/README.md
# Armstrong Numbers Welcome to Armstrong Numbers on Exercism's Zig Track. If you need help running the tests or submitting your code, check out `HELP.md`. ## Instructions An [Armstrong number][armstrong-number] is a number that is the sum of its own digits each raised to the power of the number of digits. For examp...
0
repos/exercism-ziglang
repos/exercism-ziglang/armstrong-numbers/HELP.md
# Help ## Running the tests Write your code in `<exercise_name>.zig`. To run the tests for an exercise, run: ```bash zig test test_exercise_name.zig ``` in the exercise's root directory (replacing `exercise_name` with the name of the exercise). ## Submitting your solution You can submit your solution using the `...
0
repos/exercism-ziglang/armstrong-numbers
repos/exercism-ziglang/armstrong-numbers/.exercism/metadata.json
{"track":"zig","exercise":"armstrong-numbers","id":"35a77f619b0b4cdda64038ab73e23ab2","url":"https://exercism.org/tracks/zig/exercises/armstrong-numbers","handle":"exilesprx","is_requester":true,"auto_approve":false}
0
repos/exercism-ziglang/armstrong-numbers
repos/exercism-ziglang/armstrong-numbers/.exercism/config.json
{ "authors": [ "ee7" ], "files": { "solution": [ "armstrong_numbers.zig" ], "test": [ "test_armstrong_numbers.zig" ], "example": [ ".meta/example.zig" ] }, "blurb": "Determine if a number is an Armstrong number.", "source": "Wikipedia", "source_url": "https://...
0
repos
repos/dotenv/README.md
<h1 align="center"> dotenv 🌴 </h1> [![CI](https://github.com/dying-will-bullet/dotenv/actions/workflows/ci.yaml/badge.svg)](https://github.com/dying-will-bullet/dotenv/actions/workflows/ci.yaml) [![codecov](https://codecov.io/gh/dying-will-bullet/dotenv/branch/master/graph/badge.svg?token=D8DHON0VE5)](https://codecov...
0
repos
repos/dotenv/build.zig
const std = @import("std"); // Although this function looks imperative, note that its job is to // declaratively construct a build graph that will be executed by an external // runner. pub fn build(b: *std.Build) void { // Standard target options allows the person running `zig build` to choose // what target t...
0
repos/dotenv
repos/dotenv/src/utils.zig
const std = @import("std"); const testing = std.testing; /// libc setenv pub extern "c" fn setenv(name: [*:0]const u8, value: [*:0]const u8, overwrite: c_int) c_int; // https://github.com/ziglang/zig/wiki/Zig-Newcomer-Programming-FAQs#converting-from-t-to-0t pub fn toCString(str: []const u8) ![std.fs.MAX_PATH_BYTES -...
0
repos/dotenv
repos/dotenv/src/loader.zig
const std = @import("std"); const parser = @import("./parser.zig"); const setenv = @import("./utils.zig").setenv; const toCString = @import("./utils.zig").toCString; const Error = @import("./error.zig").Error; const testing = std.testing; pub const Options = struct { /// override existed env value, default `false...
0
repos/dotenv
repos/dotenv/src/parser.zig
const std = @import("std"); const Error = @import("./error.zig").Error; const testing = std.testing; const SubstitutionMode = enum { none, block, escaped_block, }; /// Parsed Result pub const ParsedResult = struct { // Key key: []const u8, // Value value: []const u8, }; // /// Parse a li...
0
repos/dotenv
repos/dotenv/src/lib.zig
const std = @import("std"); const testing = std.testing; const FileFinder = @import("./utils.zig").FileFinder; pub const Loader = @import("./loader.zig").Loader; /// Control loading behavior pub const Options = @import("./loader.zig").Options; /// Loads the `.env*` file from the current directory or parents. /// /// ...
0
repos/dotenv
repos/dotenv/src/error.zig
pub const Error = error{ ParseError, InvalidKey, InvalidValue, };
0
repos/dotenv
repos/dotenv/examples/build.zig
const std = @import("std"); const pkg_name = "dotenv"; const pkg_path = "../src/lib.zig"; const examples = .{ "basic", "substitution", "dry-run", }; pub fn build(b: *std.build.Builder) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); inline ...
0
repos/dotenv/examples
repos/dotenv/examples/basic/main.zig
const std = @import("std"); const dotenv = @import("dotenv"); pub fn main() !void { const allocator = std.heap.page_allocator; std.debug.print( "Before => GITHUB_REPOSITORY={s}\n", .{std.os.getenv("GITHUB_REPOSITORY") orelse ""}, ); try dotenv.load(allocator, .{}); std.debug.prin...
0
repos/dotenv/examples
repos/dotenv/examples/substitution/main.zig
const std = @import("std"); const dotenv = @import("dotenv"); pub fn main() !void { const allocator = std.heap.page_allocator; try dotenv.loadFrom(allocator, ".env2", .{}); std.debug.print( "VAR3=\"{s}\"\n", .{std.os.getenv("VAR3") orelse ""}, ); }
0
repos/dotenv/examples
repos/dotenv/examples/dry-run/main.zig
const std = @import("std"); const dotenv = @import("dotenv"); pub fn main() !void { const allocator = std.heap.page_allocator; std.debug.print( "Before => HOME={s}\n", .{std.os.getenv("HOME") orelse ""}, ); var envs = try dotenv.getDataFrom(allocator, "./.env3"); std.debug.print(...
0
repos
repos/honey/README.md
# honey honey is a small, embeddable scripting language written in Zig. At its core, honey takes inspiration from languages like Zig, JavaScript/TypeScript, Rust, and Elixir. It's designed to be a simple and easy to use language with a high ceiling for power users. Performance is a key goal of honey, and it's designed ...
0
repos
repos/honey/build.zig.zon
.{ .name = "honey", .version = "0.1.1", .dependencies = .{ .clap = .{ .url = "https://github.com/Hejsil/zig-clap/archive/refs/tags/0.9.1.tar.gz", .hash = "122062d301a203d003547b414237229b09a7980095061697349f8bef41be9c30266b", }, }, .paths = .{""}, }
0
repos
repos/honey/build.zig
const std = @import("std"); pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); // create exports for the wasm target if (target.result.isWasm()) { const exe = b.addExecutable(.{ .name = "honey", ...
0
repos/honey
repos/honey/src/wasm.zig
const std = @import("std"); const honey = @import("honey.zig"); pub const Lexer = @import("lexer/Lexer.zig"); pub const TokenData = @import("lexer/token.zig").TokenData; pub const ast = @import("parser/ast.zig"); pub const Parser = @import("parser/Parser.zig"); pub const Compiler = @import("compiler/Compiler.zig"); pub...
0
repos/honey
repos/honey/src/main.zig
const std = @import("std"); const clap = @import("clap"); pub const honey = @import("honey.zig"); const Repl = @import("utils/Repl.zig"); const ast = @import("parser/ast.zig"); const Parser = @import("parser/Parser.zig"); pub const utils = @import("utils/utils.zig"); const Header = \\ \\ _ _ \\ ...
0
repos/honey
repos/honey/src/honey.zig
const std = @import("std"); pub const Lexer = @import("lexer/Lexer.zig"); pub const TokenData = @import("lexer/token.zig").TokenData; pub const ast = @import("parser/ast.zig"); pub const Parser = @import("parser/Parser.zig"); pub const Compiler = @import("compiler/Compiler.zig"); pub const Bytecode = @import("compiler/...
0
repos/honey
repos/honey/src/tests.zig
const std = @import("std"); pub const Lexer = @import("lexer/Lexer.zig"); pub const Parser = @import("parser/Parser.zig"); pub const Compiler = @import("compiler/Compiler.zig"); pub const Vm = @import("vm/Vm.zig"); test { std.testing.refAllDeclsRecursive(@This()); }
0
repos/honey
repos/honey/src/wasm_builtins.zig
const std = @import("std"); const wasm = @import("wasm.zig"); const Vm = @import("vm/Vm.zig"); const Value = @import("compiler/value.zig").Value; /// use the existing builtins.zig module pub usingnamespace @import("builtins.zig"); pub fn alert(_: *Vm, args: []const Value) !?Value { var alert_writer = wasm.AlertWr...
0
repos/honey
repos/honey/src/builtins.zig
const std = @import("std"); const builtin = @import("builtin"); const honey = @import("../honey.zig"); const ast = @import("../parser/ast.zig"); const Value = @import("compiler/value.zig").Value; const Vm = @import("vm/Vm.zig"); const wasm = @import("wasm.zig"); pub fn rand(_: *Vm, args: []const Value) !?Value { ...
0
repos/honey/src
repos/honey/src/parser/Parser.zig
const std = @import("std"); const Lexer = @import("../lexer/Lexer.zig"); const Token = @import("../lexer/token.zig").Token; const TokenTag = @import("../lexer/token.zig").TokenTag; const TokenData = @import("../lexer/token.zig").TokenData; const ast = @import("ast.zig"); const Program = ast.Program; const Statement = ...
0
repos/honey/src
repos/honey/src/parser/ast.zig
const std = @import("std"); const Token = @import("../lexer/token.zig").Token; const TokenData = @import("../lexer/token.zig").TokenData; pub const Operator = enum { /// `plus` is the `+` operator. It adds two numbers together. plus, /// `minus` is the `-` operator. It subtracts two numbers. minus, ...
0
repos/honey/src
repos/honey/src/lexer/Lexer.zig
const std = @import("std"); const utils = @import("../utils/utils.zig"); const Token = @import("token.zig").Token; const TokenData = @import("token.zig").TokenData; /// The character used to denote a builtin function const BuiltinChar = '@'; /// A map of keywords to their respective tokens const KeywordMap = std.Stati...
0
repos/honey/src
repos/honey/src/lexer/token.zig
const std = @import("std"); const utils = @import("../utils/utils.zig"); pub const TokenTag = enum { /// .number represents an unparsed number (e.g. "123") number, /// .identifier represents an identifier (e.g. a variable name) identifier, /// .string represents a string literal (e.g. "hello world"...
0
repos/honey/src
repos/honey/src/utils/utils.zig
const std = @import("std"); pub const bytes = @import("bytes.zig"); pub const cursor = @import("cursor.zig"); pub const Cursor = cursor.Cursor; pub const Span = cursor.Span; pub const Diagnostics = @import("Diagnostics.zig"); pub const Repl = @import("Repl.zig"); pub const Stack = @import("stack.zig").Stack; pub cons...
0
repos/honey/src
repos/honey/src/utils/stack.zig
const std = @import("std"); /// A stack is a data structure that allows you to push and pop values. /// It is a LIFO (last in, first out) data structure. pub fn Stack(comptime T: type) type { return struct { const Error = error{ OutOfMemory, StackEmpty, OutOfBounds }; const Self = @This(); ...
0
repos/honey/src
repos/honey/src/utils/cursor.zig
const std = @import("std"); pub const Span = struct { /// The start of the span start: usize, /// The end of the span end: usize, pub fn format(self: Span, _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { try writer.print("{{ .start = {d}, .end = {d} }}", .{ self.start, se...
0
repos/honey/src
repos/honey/src/utils/Diagnostics.zig
const std = @import("std"); const token = @import("../lexer/token.zig"); const Self = @This(); pub const ErrorData = struct { msg: []const u8, token_data: token.TokenData, }; /// The allocator used for printing error messages ally: std.mem.Allocator, /// The last error message errors: std.MultiArrayList(Erro...
0
repos/honey/src
repos/honey/src/utils/Repl.zig
const std = @import("std"); const Self = @This(); const Command = struct { const RunFn = *const fn () anyerror!void; name: []const u8, description: []const u8, run: RunFn, }; allocator: std.mem.Allocator, buffer: []u8, prefix: u8 = ':', commands: std.StringHashMap(Command), stdin: std.fs.File.Reader...
0
repos/honey/src
repos/honey/src/utils/store.zig
const std = @import("std"); pub fn Store(comptime T: type) type { return struct { const Self = @This(); // We use a BufSet to store the keys so that the pointers to the keys are stable. keys: std.BufSet, values: std.StringHashMap(T), /// Initializes the store with the given...
0
repos/honey/src
repos/honey/src/utils/Terminal.zig
const std = @import("std"); const Color = struct {}; const Self = @This(); stdout: std.fs.File.Writer, pub fn init() Self { return .{ .stdout = std.io.getStdOut().writer() }; } pub fn writeColor(_: Self) void {}
0
repos/honey/src
repos/honey/src/utils/bytes.zig
const std = @import("std"); /// The number of bytes per line in the dump. const MaxBytesPerLine = 16; const ByteFormat = "{X:0<2}"; /// Converts a float to a byte array. pub inline fn floatToBytes(value: anytype) []const u8 { const ValueType = @TypeOf(value); const value_type_info = @typeInfo(ValueType); ...
0
repos/honey/src
repos/honey/src/vm/Vm.zig
const std = @import("std"); const utils = @import("../utils/utils.zig"); const honey = @import("../honey.zig"); const token = @import("../lexer/token.zig"); const Compiler = @import("../compiler/Compiler.zig"); const opcodes = @import("../compiler/opcodes.zig"); const Opcode = opcodes.Opcode; const Bytecode = @import...
0
repos/honey/src
repos/honey/src/compiler/Compiler.zig
const std = @import("std"); const utils = @import("../utils/utils.zig"); const token = @import("../lexer/token.zig"); const Token = token.Token; const ast = @import("../parser/ast.zig"); const honey = @import("../honey.zig"); const opcodes = @import("opcodes.zig"); const Opcode = opcodes.Opcode; const Instruction = opc...
0
repos/honey/src
repos/honey/src/compiler/opcodes.zig
const std = @import("std"); pub const Opcode = enum(u8) { /// The `return` opcode is used to return from a function. @"return" = 0x00, /// The `const` opcode is used to push a constant value onto the stack. @"const" = 0x01, /// The `list` opcode is used to create a list from the values on the stack...
0
repos/honey/src
repos/honey/src/compiler/Bytecode.zig
const std = @import("std"); const opcodes = @import("opcodes.zig"); const Opcode = opcodes.Opcode; const Instruction = opcodes.Instruction; const Value = @import("value.zig").Value; const Self = @This(); /// The generated instructions instructions: []const u8, /// The constant pool for which the instructions can refe...
0
repos/honey/src
repos/honey/src/compiler/generate_md.zig
const std = @import("std"); const opcodes = @import("opcodes.zig"); const OutputPath = "src/compiler/ARCHITECTURE.md"; const Header = \\ # Architecture \\ This document describes the architecture of the virtual machine. \\ \\ ## Instructions \\ ; /// Generates the architecture documentation and d...
0
repos/honey/src
repos/honey/src/compiler/ARCHITECTURE.md
# Architecture This document describes the architecture of the virtual machine. ## Instructions | Name | Opcode | Operands | | --------------- | ------ | -------- | | `return` | 0x00 | void | | `const` | 0x01 | u16 | | `list` | 0x02 | u16 | | `dict` | ...
0
repos/honey/src
repos/honey/src/compiler/value.zig
const std = @import("std"); pub const Value = union(enum) { pub const Error = error{ ExpectedNumber, ExpectedString, ExpectedBoolean, UnexpectedType, OutOfMemory, }; pub const True = Value{ .boolean = true }; pub const False = Value{ .boolean = false }; pub c...
0
repos
repos/ScriptHookVZig/CHANGELOG.md
<!-- insertion marker --> ## [0.2.0](https://github.com/nitanmarcel/ScriptHookVZig/releases/tag/0.2.0) - 2024-06-15 <small>[Compare with v0.0.1](https://github.com/nitanmarcel/ScriptHookVZig/compare/v0.0.1...0.2.0)</small> ### Added - Add documentation ([2578064](https://github.com/nitanmarcel/ScriptHookVZig/commit/...
0
repos
repos/ScriptHookVZig/README.md
# ScriptHookVZig Develop GTA V mods with the help of Zig - [ScriptHookVZig](#scripthookvzig) - [Requirements](#requirements) - [Usage](#usage) - [Adding to build.zig.zon](#adding-to-buildzigzon) - [Adding to build.zig](#adding-to-buildzig) - [Your first script](#your-first-script) - [Documentation](#...
0
repos
repos/ScriptHookVZig/build.zig.zon
.{ .name = "ScriptHookVZig", // This is a [Semantic Version](https://semver.org/). // In a future version of Zig it will be used for package deduplication. .version = "0.0.1", // This field is optional. // This is currently advisory only; Zig does not yet do anything // with this value. ...
0
repos
repos/ScriptHookVZig/build.zig
const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); // Compile a library to allow building docs const natives_lib = b.addSharedLibrary(.{ .name = "shvz", .root_source_file = b.path...
0
repos/ScriptHookVZig
repos/ScriptHookVZig/scripts/gen_natives.py
import urllib.request import json import os import subprocess JSON_URL = "https://raw.githubusercontent.com/alloc8or/gta5-nativedb-data/master/natives.json" NATIVES_PATH = os.path.join(os.path.dirname(__file__), "../src/natives.zig") TYPE_MAPPINGS = { "bool": "bool", "char": "u8", "signed char": "i8", ...
0
repos/ScriptHookVZig
repos/ScriptHookVZig/example/build.zig.zon
.{ .name = "example", .version = "0.0.0", .dependencies = .{ .shvz = .{ .path = "../", }, .logz = .{ .url = "git+https://github.com/karlseguin/log.zig.git#adc6910d2e8f50e0ec5a4792d6a7136f46778061", .hash = "1220a5687ab17f0691a64d19dfd7be1299df64d2...
0
repos/ScriptHookVZig
repos/ScriptHookVZig/example/build.zig
const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); // Shared/Dynamic library is required const lib = b.addSharedLibrary(.{ .name = "example", .root_source_file = b.path("src/root.zi...
0
repos/ScriptHookVZig/example
repos/ScriptHookVZig/example/src/root.zig
const std = @import("std"); const shvz = @import("shvz"); // Script entry point pub export fn scriptMain() void { var c_string = "Hello World".*; var c_text_entry = "STRING".*; // Start loop while (true) { // Write text on the screen. // All of this and more usage examples can be found...
0
repos/ScriptHookVZig
repos/ScriptHookVZig/src/nativeCaller.zig
const std = @import("std"); const utils = @import("utils.zig"); fn nativeCall() u64 { const call = utils.findSymbol(*const fn () callconv(.C) u64, "?nativeCall@@YAPEA_KXZ"); return call.?(); } fn nativeInit(hash: u64) void { const call = utils.findSymbol(*const fn (u64) callconv(.C) void, "?nativeInit@@YA...
0
repos/ScriptHookVZig
repos/ScriptHookVZig/src/panic_handler.zig
const std = @import("std"); const allocator = std.heap.page_allocator; pub fn panicThread(comptime fmt: []const u8, args: anytype) noreturn { const cwd = std.fs.cwd(); if (std.fmt.allocPrint(allocator, fmt, args)) |message| { defer allocator.free(message); if (std.fmt.allocPrint(allocator, "Sc...
0
repos/ScriptHookVZig
repos/ScriptHookVZig/src/utils.zig
const std = @import("std"); const panic_handler = @import("panic_handler.zig"); pub fn findSymbol(comptime T: type, name: [:0]const u8) ?T { const hModule = std.os.windows.kernel32.GetModuleHandleW(std.unicode.utf8ToUtf16LeStringLiteral("ScriptHookV.dll")); if (hModule == null) { panic_handler.panic("F...
0
repos/ScriptHookVZig
repos/ScriptHookVZig/src/types.zig
const std = @import("std"); const DWORD = std.os.windows.DWORD; pub const Void = DWORD; pub const Any = DWORD; pub const uint = DWORD; pub const Hash = DWORD; pub const Entity = c_int; pub const Player = c_int; pub const FireId = c_int; pub const Ped = c_int; pub const Vehicle = c_int; pub const Cam = c_int; ...
0
repos/ScriptHookVZig
repos/ScriptHookVZig/src/main.zig
const std = @import("std"); const utils = @import("utils.zig"); /// Create texture /// texFileName - texture file name, it's best to specify full texture path and use PNG textures /// returns internal texture id /// Texture deletion is performed automatically when game reloads scripts /// Can be called only in the sam...
0
repos/ScriptHookVZig
repos/ScriptHookVZig/src/shvz.zig
const std = @import("std"); /// Natives pub const natives = @import("natives.zig"); /// Enums pub const enums = @import("enums.zig"); /// Main pub const main = @import("main.zig"); // Types pub const types = @import("types.zig"); var ScriptHookVDLL: std.DynLib = undefined; pub fn init() !void { ScriptHookVDLL = ...
0
repos/ScriptHookVZig
repos/ScriptHookVZig/src/natives.zig
const std = @import("std"); const nativeCaller = @import("nativeCaller.zig"); const types = @import("types.zig"); const windows = std.os.windows; pub const SYSTEM = struct { /// Pauses execution of the current script, please note this behavior is only seen when called from one of the game script files(ysc). In ord...
0
repos/ScriptHookVZig
repos/ScriptHookVZig/src/enums.zig
const std = @import("std"); const DWORD = std.os.windows.DWORD; pub const eAudioFlag = extern struct { bits: c_int = 0, pub const AudioFlagActivateSwitchWheelAudio: eAudioFlag = .{ .bits = 0 }; pub const AudioFlagAllowCutsceneOverScreenFade: eAudioFlag = .{ .bits = 1 }; pub const AudioFlagAllowForceR...
0
repos/ScriptHookVZig
repos/ScriptHookVZig/docs/main.js
(function() { const CAT_namespace = 0; const CAT_global_variable = 1; const CAT_function = 2; const CAT_primitive = 3; const CAT_error_set = 4; const CAT_global_const = 5; const CAT_alias = 6; const CAT_type = 7; const CAT_type_type = 8; const CAT_type_function = 9; const do...
0
repos/ScriptHookVZig
repos/ScriptHookVZig/docs/index.html
<!doctype html> <html> <head> <meta charset="utf-8"> <title>Zig Documentation</title> <link rel="icon" href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNTMgMTQwIj48ZyBmaWxsPSIjRjdBNDFEIj48Zz48cG9seWdvbiBwb2ludHM9IjQ2LDIyIDI4LDQ0IDE5LDMwIi8+PHBvbHlnb24...
0
repos/pe-ziglang
repos/pe-ziglang/pe-0003/pe-0003.zig
//! Largest Prime Factor //! https://projecteuler.net/problem=3 const std = @import("std"); const time = std.time; const Instant = time.Instant; const print = std.debug.print; pub fn main() !void { const start = try Instant.now(); const answer = largestPrimeFactor(600_851_475_143); const en...
0
repos/pe-ziglang
repos/pe-ziglang/pe-0055/pe-0055.zig
//! Lychrel Numbers //! https://projecteuler.net/problem=55 const std = @import("std"); const time = std.time; const Instant = time.Instant; const print = std.debug.print; fn reverse_digits(n: u128) u128 { var reversed: u128 = 0; var num = n; while (num > 0) { const digit = num % 10; const...
0
repos/pe-ziglang
repos/pe-ziglang/pe-0001/pe-0001.zig
//! Multiples of 3 or 5 //! https://projecteuler.net/problem=1 const std = @import("std"); const time = std.time; const Instant = time.Instant; const print = std.debug.print; pub fn main() !void { const start = try Instant.now(); const answer = multiplesOf3or5(1_000); const end = try Instant.now(); ...