feat: parse module
This commit is contained in:
parent
5337ba48a4
commit
fb30e1195e
@ -34,5 +34,6 @@ Now in Zig!
|
|||||||
- [x] Parse minimal expression
|
- [x] Parse minimal expression
|
||||||
- [x] Parse minimal variable binding
|
- [x] Parse minimal variable binding
|
||||||
- [x] Parse minimal statement
|
- [x] Parse minimal statement
|
||||||
|
- [x] Parse minimal module
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ pub fn build(b: *std.Build) void {
|
|||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
syntax_module.addImport("lexic", lexic_module);
|
||||||
exe.root_module.addImport("syntax", syntax_module);
|
exe.root_module.addImport("syntax", syntax_module);
|
||||||
|
|
||||||
// This declares intent for the executable to be installed into the
|
// This declares intent for the executable to be installed into the
|
||||||
@ -92,9 +93,6 @@ pub fn build(b: *std.Build) void {
|
|||||||
const files = [_][]const u8{
|
const files = [_][]const u8{
|
||||||
"src/01_lexic/root.zig",
|
"src/01_lexic/root.zig",
|
||||||
"src/02_syntax/root.zig",
|
"src/02_syntax/root.zig",
|
||||||
"src/02_syntax/variable.zig",
|
|
||||||
"src/02_syntax/expression.zig",
|
|
||||||
"src/02_syntax/statement.zig",
|
|
||||||
};
|
};
|
||||||
for (files) |file| {
|
for (files) |file| {
|
||||||
const file_unit_test = b.addTest(.{
|
const file_unit_test = b.addTest(.{
|
||||||
|
@ -68,6 +68,7 @@ test "should parse a variable declaration statement" {
|
|||||||
switch (statement.value) {
|
switch (statement.value) {
|
||||||
.variableBinding => |v| {
|
.variableBinding => |v| {
|
||||||
try std.testing.expectEqual(true, v.is_mutable);
|
try std.testing.expectEqual(true, v.is_mutable);
|
||||||
|
try std.testing.expectEqualDeep("my_variable", v.identifier.value);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,5 +31,8 @@ fn repl() !void {
|
|||||||
const tokens = try lexic.tokenize(line, alloc);
|
const tokens = try lexic.tokenize(line, alloc);
|
||||||
defer tokens.deinit();
|
defer tokens.deinit();
|
||||||
|
|
||||||
|
var module_ast: syntax.Module = undefined;
|
||||||
|
try module_ast.init(&tokens, 0, alloc);
|
||||||
|
|
||||||
try bw.flush();
|
try bw.flush();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user