Embedded programming language for Zig
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

recursive modules make the lsp choke

IamPyu 30c9d929 6afa270b

+17 -7
-1
build.zig
··· 15 15 .target = target, 16 16 .optimize = optimize, 17 17 }); 18 - mod.addImport("zexa", mod); 19 18 mod.addImport("mitochondria", mitochondria_mod); 20 19 21 20 const lib = b.addLibrary(.{
+1 -1
src/env.zig
··· 3 3 const ArrayList = std.ArrayList; 4 4 const SliceIterator = @import("mitochondria").SliceIterator; 5 5 6 - const zexa = @import("zexa"); 6 + const zexa = @import("./root.zig"); 7 7 const Scope = zexa.types.Scope; 8 8 const Value = zexa.types.Value; 9 9
+1 -1
src/parser.zig
··· 1 1 const std = @import("std"); 2 2 const Allocator = std.mem.Allocator; 3 3 4 - const zexa = @import("zexa"); 4 + const zexa = @import("./root.zig"); 5 5 const Value = zexa.types.Value; 6 6 const Scope = zexa.types.Scope; 7 7 const Number = zexa.types.Number;
+2 -1
src/root.zig
··· 1 - pub const types = @import("./types.zig"); 1 + pub const lang = @import("./lang.zig"); 2 + pub const types = lang; 2 3 pub const env = @import("./env.zig"); 3 4 pub const stdlib = @import("./std.zig"); 4 5 pub const lexer = @import("./lexer.zig");
+1 -1
src/std.zig
··· 1 1 const std = @import("std"); 2 - const zexa = @import("zexa"); 2 + const zexa = @import("./root.zig"); 3 3 const Scope = zexa.types.Scope; 4 4 const Value = zexa.types.Value; 5 5
+1 -1
src/std/core.zig
··· 4 4 5 5 const SliceIterator = @import("mitochondria").SliceIterator; 6 6 7 - const zexa = @import("zexa"); 7 + const zexa = @import("../root.zig"); 8 8 const Scope = zexa.types.Scope; 9 9 const Value = zexa.types.Value; 10 10 const AST = zexa.types.AST;
+1 -1
src/std/libload.zig
··· 1 1 const std = @import("std"); 2 2 const DynLib = std.DynLib; 3 3 4 - const zexa = @import("zexa"); 4 + const zexa = @import("../root.zig"); 5 5 const Scope = zexa.types.Scope; 6 6 const Value = zexa.types.Value; 7 7 const RuntimeError = zexa.types.RuntimeError;
src/test/test1.zexa test/test1.zexa
src/test/test2.zexa test/test2.zexa
src/test/test3.zexa test/test3.zexa
src/test/test4.zexa test/test4.zexa
src/test/test5.zexa test/test5.zexa
src/test/test6.zexa test/test6.zexa
src/test/test7.zexa test/test7.zexa
+10
src/types.zig src/lang.zig
··· 84 84 return value; 85 85 } 86 86 87 + /// Initialize as nil 87 88 pub fn initNil(scope: *Scope) RuntimeError!*Self { 88 89 const atom = try scope.createValue(); 89 90 atom.* = Self{ .atom = .nil }; ··· 97 98 return val; 98 99 } 99 100 101 + /// Initialize from any supported type 100 102 pub fn initFromAny(scope: *Scope, value: anytype) RuntimeError!*Self { 101 103 return switch (@TypeOf(value)) { 102 104 void => Self.initNil(scope), ··· 116 118 }; 117 119 } 118 120 121 + /// Create a string 119 122 pub fn initString(scope: *Scope, str: []const u8) RuntimeError!*Self { 120 123 const atom = try Self.initNil(scope); 121 124 const nstr = try scope.createString(str); ··· 123 126 return atom; 124 127 } 125 128 129 + /// Create a symbol 126 130 pub fn initSymbol(scope: *Scope, sym: []const u8) RuntimeError!*Self { 127 131 const atom = try Self.initNil(scope); 128 132 const nsym = try scope.createString(sym); ··· 130 134 return atom; 131 135 } 132 136 137 + /// Create a cons pair 133 138 pub fn initCons(scope: *Scope, car: *Value, cdr: *Value) RuntimeError!*Self { 134 139 const cons = try Self.initNil(scope); 135 140 cons.atom = .{ .cons = .{ .car = car, .cdr = cdr } }; 136 141 return cons; 137 142 } 138 143 144 + /// Create a function 139 145 pub fn initFunction(scope: *Scope, func: Function) RuntimeError!*Self { 140 146 return Self.initFrom(scope, .{ 141 147 .atom = .{ .function = func }, 142 148 }); 143 149 } 144 150 151 + /// Create a native function 145 152 pub fn initNativeFunc(scope: *Scope, func: NativeFunc) RuntimeError!*Self { 146 153 return Self.initFrom(scope, .{ 147 154 .atom = .{ .native_func = func }, 148 155 }); 149 156 } 150 157 158 + /// Create a native macro 151 159 pub fn initNativeMacro(scope: *Scope, func: NativeMacro) RuntimeError!*Self { 152 160 return Self.initFrom(scope, .{ 153 161 .atom = .{ .native_macro = func }, 154 162 }); 155 163 } 156 164 165 + /// Initialize from userdata 157 166 pub fn initUserData(scope: *Scope, userdata: *anyopaque) RuntimeError!*Self { 158 167 return Self.initFrom(scope, .{ 159 168 .atom = .{ .userdata = userdata }, 160 169 }); 161 170 } 162 171 172 + /// Initialize a list of values 163 173 pub fn initList(scope: *Scope, values: []const *Value) RuntimeError!*Self { 164 174 var cons = try Value.initCons(scope, try Value.initNil(scope), try Value.initNil(scope)); 165 175