Motivation
Prism supports a rest
property in grammars that essentially functions as an object spread replacement. The behavior of rest
and object spread is subtly different, so we can't remove support for rest
, unfortunately. However, we may as well fix the worst aspect of rest
: it gets in the way of token iteration.
Everything that processes or analyses grammars has to take rest
into account, because rest
is the only property of a grammar that isn't a token (this also creates problems with TS).
Description
Replace the rest
property with a symbol, let's call it Prism.rest
.
This will solve the iteration problem, because symbols are non-enumerable by default.
This will also make it possible to finally define a proper type for Prism grammars, which simply wasn't possible before.
interface Grammar { [key: string]: RegExp | GrammarToken | Array<RegExp | GrammarToken>; [Prism.rest]?: Grammar; }
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4