a lisp-like language, loosely based on John N. Shutt's "Kernel" language
1const std = @import("std");
2const rats = @import("rats");
3
4const version = "0.0.0"; // TODO: pull this from build.zig.zon
5
6pub fn main() !void {
7 var gpa: std.heap.DebugAllocator(.{}) = .init;
8 defer std.debug.assert(gpa.deinit() == .ok);
9 const allocator = gpa.allocator();
10
11 var file_path: ?[]const u8 = null;
12
13 { // argument parsing
14 var args = try std.process.argsWithAllocator(allocator);
15 defer args.deinit();
16 _ = args.next(); // Discargd argv[0];
17
18 while (args.next()) |arg| {
19 const eql = std.mem.eql;
20 if (file_path != null) {
21 std.debug.print("Ignoring argument after file path: {s}\n", .{arg});
22 } else if (eql(u8, arg, "-h") or eql(u8, arg, "--help")) {
23 std.debug.print(
24 \\Usage: rats [options] [file]
25 \\
26 \\Options:
27 \\ -h, --help Display this help and exit.
28 \\ -v, --version Display version information and exit.
29 \\
30 , .{});
31 return;
32 } else if (eql(u8, arg, "-v") or eql(u8, arg, "--version")) {
33 std.debug.print("rats v{s}\n", .{version});
34 return;
35 } else {
36 file_path = arg;
37 }
38 }
39 } // end argument parsing
40
41 const use_stdin = (file_path == null) or std.mem.eql(u8, file_path.?, "-");
42
43 std.debug.print(
44 \\File path: {?s}
45 \\Stdin mode: {}
46 \\
47 , .{ file_path, use_stdin });
48
49 // TODO: actually parse and run the file, or do a repl on stdin.
50}