[Flex-help] Building a push parser
flex is a tool for generating scanners
Brought to you by:
wlestes
From: Jerome H. <jer...@gm...> - 2021-01-23 14:02:32
|
Hi, Thank you all for your excellent work on flex, I am happy to be able to stand on the shoulders of giants (not that I compare myself the least to the genius Newton). Now, I am really sorry if I missed a ressource that documents my needs, and I would be grateful to be pointed to it. I would like to build a push parser, and would like the lexer to behave in accordance. I found this excellent ressource (https://github.com/mwberry/yacc-examples), but its data is available beforehand or needs to be fed through blocking in YY_INPUT (for example with a thread, which I cannot use in my case). This is what I would call a PULL lexer. Is it (or would it be without breaking the internals of flex) possible to return a special value from YY_INPUT saying "I don't have any more data JUST YET" and later being able to be called again and feed the new data (either from YY_INPUT or from a buffer re-filling function). This would then be a PUSH lexer. Also, on another point, I sometimes feel that I need to enter a new start state but this is not recognizable by the lexer, but only by the parser. Am I doing something wrong? Is the grammar I am trying to implement broken? Or is it legitimate? Best regards, Jérôme. |