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
Copy file name to clipboardExpand all lines: doc/src/actioncode.md
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,3 +69,19 @@ R -> ...:
69
69
'ID' { format!("{}{}", p, ...) }
70
70
;
71
71
```
72
+
73
+
# Generic parse parameter
74
+
75
+
If `%parse-param` needs to be generic, additional type variables and lifetimes
76
+
can be specified in the `%parse-generics T1, T2, ...` declaration.
77
+
78
+
For example, if a grammar has following declarations:
79
+
80
+
```
81
+
%parse-generics T: FromStr
82
+
%parse-param p: T
83
+
```
84
+
85
+
then the `parse` function will take an additional parameter of type `T`.
86
+
87
+
This can be used, for example, [to allocate AST nodes in a memory arena.](https://github.com/softdevteam/grmtools/tree/master/lrpar/examples/calc_ast_arena).
0 commit comments