Skip to content

Commit c90afb0

Browse files
committed
Splice zig's parser into zls
1 parent 645f728 commit c90afb0

File tree

6 files changed

+19117
-2
lines changed

6 files changed

+19117
-2
lines changed

src/DocumentStore.zig

+11-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const Config = @import("Config.zig");
1313
const ZigVersionWrapper = @import("ZigVersionWrapper.zig");
1414
const translate_c = @import("translate_c.zig");
1515
const ComptimeInterpreter = @import("ComptimeInterpreter.zig");
16+
const Parser = @import("stage2/Ast.zig");
1617
const AstGen = @import("stage2/AstGen.zig");
1718
const Zir = @import("stage2/Zir.zig");
1819
const InternPool = @import("analyser/InternPool.zig");
@@ -755,8 +756,16 @@ fn createDocument(self: *DocumentStore, uri: Uri, text: [:0]const u8, open: bool
755756
var duped_uri = try self.allocator.dupe(u8, uri);
756757
errdefer self.allocator.free(duped_uri);
757758

758-
var tree = try Ast.parse(self.allocator, text, .zig);
759-
errdefer tree.deinit(self.allocator);
759+
// var tree = try Ast.parse(self.allocator, text, .zig);
760+
var zls_ast = try Parser.parse(self.allocator, text, .zig);
761+
errdefer zls_ast.deinit(self.allocator);
762+
var tree = Ast{
763+
.source = zls_ast.source,
764+
.tokens = zls_ast.tokens,
765+
.nodes = zls_ast.nodes,
766+
.extra_data = zls_ast.extra_data,
767+
.errors = zls_ast.errors,
768+
};
760769

761770
// remove unused capacity
762771
var nodes = tree.nodes.toMultiArrayList();

0 commit comments

Comments
 (0)