title: lexical analyser generator in kernel space
body: <p>Kernel Modular debugger (kmdb) uses lex to generate lexical analyser to use <em>from kernel space</em> [1]. There are some hacks, some of them even are not POSIX compatible.</p>
  
  <p>I have questions:</p>
  
  <ol>
  <li>What are pitfalls in using lex in kernel mode?</li>
  <li>It there any reasonable way to adopt [1] for flex [2]?</li>
  <li>What are alternatives to lex/flex for kernel space?</li>
  </ol>
  
  <p>(In the last resort I'm going to build and use illumos' lex, but I really want to avoid it)</p>
  
  <p>[1] <a href="https://github.com/illumos/illumos-gate/blob/master/usr/src/cmd/mdb/common/mdb/mdb_lex.l" rel="nofollow noreferrer">https://github.com/illumos/illumos-gate/blob/master/usr/src/cmd/mdb/common/mdb/mdb_lex.l</a></p>
  
  <p>[2] <a href="https://github.com/westes/flex/" rel="nofollow noreferrer">https://github.com/westes/flex/</a></p>