You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(wasm) New approach for parameterized rules (#519)
Implement a new approach for parameterized rules:
- Analyze the grammar and create specialized versions of parameterized rules — one for every possible set of actual parameters
- The specialized rules are effectively closures: they capture a particular set of concrete parameters, so they can be invoked without arguments. This also means we can memoize them.
- This allows us to remove the runtime closure creation code; it allows us to support arbitrary numbers of parameters; and it eliminates the runtime functions for evaluating rules with fixed numbers of parameters (`evalApply1`, etc.)
Copy file name to clipboardExpand all lines: packages/wasm/TODO.md
+4-3Lines changed: 4 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,11 @@
6
6
-[x] NonterminalNodes should keep track of the rule
7
7
-[ ] When iteration contains a sequence, the children are flattened into the iter node.
8
8
-[x] Basic parameterized rules
9
-
-[] Parameterized rules with >3 params
9
+
-[x] Parameterized rules with >3 params
10
10
-[x] Parameters that aren't terminals
11
-
-[ ] Memoization for parameterized rules
11
+
-[x] Memoization for parameterized rules
12
+
-[ ] Avoid unnecessary dispatch in generalized rules
13
+
-[ ] Avoid duplicate lifted rules.
12
14
-[x] Support direct left recursion.
13
15
-[ ] Handle left recursion detection at grammar parse time.
14
16
-[x] Separate API for _creating_ the Wasm module from the WasmMatcher interface.
@@ -26,4 +28,3 @@
26
28
27
29
- How to deal with matchLength in lookahead. In regular Ohm, lookahead _does_ bind things. But that is hard to square with the current CST representation, that stores only the matchLength. Because somehow the things inside a lookahead must consume nothing — but if you have `&("a" "b")`, the only way to make them consume nothing (in the current representation) is to rewrite the matchLength of the two terminal nodes.
28
30
- Could we introduce a pseudo-node for lookahead? It could get transparently unpacked when walking the tree.
29
-
- Memoization of parameterized rules: Alex suggested assigning memoization keys statically to unique applications
0 commit comments