how to handle nested comment in flex

后端 未结 3 1402
轻奢々
轻奢々 2021-01-24 17:32

I am working on writing a flex scanner for a language supporting nested comment like this:

/*
/**/
*/

I use to work on ocaml/ocamllex that supp

3条回答
  •  Happy的楠姐
    2021-01-24 17:51

    Same way you would any nested stuff: Stacks

    Stack the openings until their respective closings are found. If the stack is uneven at the end, you're missing either an opening or a closing element.

提交回复
热议问题