Mirror: The magical sticky regex-based parser generator 🧙
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add notes on self-referential matchers

+18
+18
README.md
··· 196 196 */ 197 197 ``` 198 198 199 + Furthermore, interpolations don't have to just be RegHex matchers. They can 200 + also be functions returning matchers or completely custom matching functions. 201 + This is useful when your DSL becomes _self-referential_, i.e. when one matchers 202 + start referencing each other forming a loop. To fix this we can create a 203 + function that returns our root matcher: 204 + 205 + ```js 206 + import match from 'reghex'; 207 + 208 + const value = match('value')` 209 + (${/\w+/} | ${() => root})+ 210 + `; 211 + 212 + const root = match('root')` 213 + ${/root/}+ ${value} 214 + `; 215 + ``` 216 + 199 217 ### Regex-like DSL 200 218 201 219 We've seen in the previous examples that matchers are authored using tagged