Recursion in Menhir lexer for small DSL

OK, my current (“working”, so far) solution is to just split it up in two different lexer/parser systems instead. Downside is I have to duplicate some token defs that are used in both lexers, but I guess I’ll live with that for now.

Instead of parsing the docblock to tokens in the main lexer, I do

  | "/**" _* as s "*/"            { DOCBLOCK_AS_STR s }

and then the docblock lexer/parser is called from the main parser, like

    | doc=DOCBLOCK_AS_STR "function" {
        let linebuf = Lexing.from_string doc in
        let cb = Docblockparser.docblock Docblocklexer.docblock linebuf in
        Function {
            docblock = cb;
            (* Code omitted *)
        }

Thanks for all help and feedback, learned a lot, maybe I can get it tighter at a later stage. :nerd_face: