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: docs/custom-productions.md
+32
Original file line number
Diff line number
Diff line change
@@ -78,3 +78,35 @@ interface Tokeniser {
78
78
unconsume(position:number);
79
79
}
80
80
```
81
+
82
+
## Using existing productions
83
+
84
+
This library exposes member productions in `webidl2/productions`. (Note that this only works with ES module import)
85
+
86
+
*`Argument`
87
+
*`Attribute`
88
+
*`Base`
89
+
*`Constant`
90
+
*`Constructor`
91
+
*`Container`
92
+
*`Default`
93
+
*`ExtendedAttributes` / `SimpleExtendedAttribute`
94
+
*`Field`
95
+
*`IterableLike`
96
+
*`Operation`
97
+
*`Type`
98
+
99
+
You can call `Argument.parse(tokeniser)` inside your custom production to reuse it.
100
+
101
+
It also exposes some helper functions:
102
+
103
+
*`autoParenter`: This wraps your object in a proxy that assigns any object's `parent` field to `this`. Useful when tracking the parent of member productions.
104
+
105
+
```js
106
+
constret=autoParenter(this);
107
+
ret.default=Default.parse(tokeniser);
108
+
default.parent// this
109
+
```
110
+
111
+
*`argument_list`: Receives a tokeniser object and parses arguments separated by commas. Can be used to implement function-like syntax.
112
+
*`unescape`: Trims preceding underscore `_` if the string argument has one.
0 commit comments