문제

I have a single Bison parser definition to apply to several streams. Each stream is produced in chunks at certain intervals, thus I would like to save the state of a given parsing instance, in order to switch among different streams, while keeping the state (with their associated stacks) of each of parsing instance.

I know there is the possibility to switch among several buffers from the scanner, but this does not help me with building a different parsing tree for each stream I am analyzing.

Is there any Bison functionality which allows to perform what function yy_switch_to_buffer() does in flex?

도움이 되었습니까?

해결책

I think you are looking for the pure (reentrant) parser interface, which allows you to maintain separate parser states. You'll probably also want to use a reentrant flex lexer, so that each parser state has its own lexer state. (You could use a single lexer and switch buffers every time you call it, but the reentrant lexer interface is a lot cleaner, and more general since it preserves all lexer state including, for example, start condition and buffer stacks.)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top