0

I'm considering writing some simple lexers with Boost's Spirit.Lex, but I can't seem to find any examples of what I'd like to do.

More or less, I'd like to lex an entire text file (this is easy). But, once the entire file has been processed, I would like to be able to "re-lex" an arbitrary line (e.g. if its contents have changed), using the state from the previous line to avoid lexing the entire file again.

I have seen related resources like this question as well as the Spirit.Lex API documentation (of course), but a simple, concise example of what I'm talking about would be very helpful.

Does such an example exist and/or is this even feasible with Sprit.Lex?

Community
  • 1
  • 1
CmdrMoozy
  • 3,870
  • 3
  • 19
  • 31
  • "a simple, concise example of what I'm talking about would be very helpful." - I second the motion. Note that lexing is sequential by nature. States can be switched, but you can't backtrack. I think you want Spirit Qi instead. – sehe Oct 06 '13 at 15:27
  • See potentially relevant: [Boost.Spirit: Setup sub-grammar during parsing](http://stackoverflow.com/questions/17790320/boost-spirit-setup-sub-grammar-during-parsing/17796038#17796038) – sehe Oct 06 '13 at 15:34

1 Answers1

-1

The following page documents API functions letting you specify the initial lexer state : Boost spirit API documentation.

Gilles
  • 1