-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
7 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: "How to do backtracking and array-backed ASTs?" | ||
published: 3-6-2024 | ||
summary: "An observation that seems to make array-backed ASTs viable for backtracking grammars" | ||
--- | ||
|
||
I've wanted to make a parser for Python that spits outs an AST backed by an array like Zig's AST. The main trouble is that Python's grammar requires backtracking. I think the solution is to split the parsing into two phases: pre-commit (which is cached) and committing (which isn't). This should also make packrat parsing more memory efficient cause I'm storing just a bit per token, though that will likely end up a bool per token rather than a bitvec. (Actually, it might be 2 bits per token? I need to think about this more.) |