Open Krantz-XRF opened 3 years ago
This is pretty useful for language reuse. I have something like this:
~[a-z]('([^'\\]|\\['\\])*'|(/([^/\\]|\\[/\\])*)?/([^/\\]|\\[/\\])*/)
To tokenize a limited subset of elixir's sigils. And it keeps growing 💀
Okay this can potentially be workarounded by pomsky, but it is blocked by https://github.com/rust-lang/rust/issues/52393
The current
logos-derive
use derive procedural macros and attribute annotations on aenum
as a front-end. I know this design guarantees that theenum
declaration is presented as-is, but I personally find regular expressions written as string literals hard to read and reason about:I would prefer a DSL processed by a function-like procedural macro, like the following (the syntax could be revised, of course):
Here
$Digit
$Letter
should resolve to the corresponding Unicode character properties or general categories. entries withoutpub
serves as sub-patterns, and entries withpub
are exposed asenum
variants of the token type.I am currently working on this, with the new front-end targeting
Mir
. However, I don't know whether or not you would want to merge it. If you decide not, would you consider extracting the back-end code-generation logic inlogos-derive
to a non-procedural macro crate (so that it becomes a publicly available API for reuse)?