I'm trying to write a small DSL parser using fslex
and fsyacc
. The input is composed of interleaving chunks of two different languages which require different lexing rules. How do I write my fslex
file to support that?
(I guess a similar case would be how to define an fslex
file for the c language but with support for inline assembly, which requires different lexing rules?)
What I have currently is something like this:
rule tokenize = parse
| "core" { core lexbuf }
...
and core = parse
| ...
The thing is, once a token gets returned by the core
parser, the next part of the input gets passed to tokenize
instead. However I want to stay (as it were) in the core
state. How do I do that?
Thanks!