Skip to content

Commit

Permalink
Splice zig's parser into zls
Browse files Browse the repository at this point in the history
  • Loading branch information
llogick committed Oct 27, 2023
1 parent 4607ec8 commit 0c1f9be
Show file tree
Hide file tree
Showing 6 changed files with 19,116 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/DocumentStore.zig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const Config = @import("Config.zig");
const ZigVersionWrapper = @import("ZigVersionWrapper.zig");
const translate_c = @import("translate_c.zig");
const ComptimeInterpreter = @import("ComptimeInterpreter.zig");
const Parser = @import("stage2/Ast.zig");
const AstGen = @import("stage2/AstGen.zig");
const Zir = @import("stage2/Zir.zig");
const InternPool = @import("analyser/InternPool.zig");
Expand Down Expand Up @@ -279,8 +280,15 @@ pub const Handle = struct {
const tracy_zone_inner = tracy.traceNamed(@src(), "Ast.parse");
defer tracy_zone_inner.end();

var tree = try Ast.parse(allocator, new_text, .zig);
errdefer tree.deinit(allocator);
var zls_ast = try Parser.parse(allocator, new_text, .zig);
errdefer zls_ast.deinit(allocator);
var tree = Ast{
.source = zls_ast.source,
.tokens = zls_ast.tokens,
.nodes = zls_ast.nodes,
.extra_data = zls_ast.extra_data,
.errors = zls_ast.errors,
};

// remove unused capacity
var nodes = tree.nodes.toMultiArrayList();
Expand Down
Loading

0 comments on commit 0c1f9be

Please sign in to comment.