Flex / Bison Integration with External Program

I am working on an intelligent agent model that requires an event list as input. Events come from the output of another model and are in a (large) text file. The text file is a list of all events (including unnecessary events that do not bother me), so I wrote a scanner using flex that can find useful bits. The structure for the intelligent agent model is already written in C ++.

Each event has a time stamp and contains a large amount of information about the event. The input file format is constant, so I really don't need to check the syntax. I donโ€™t know if Bison really gives me any advantages, because the grammar is actually quite simple. There are no real changes.

I just need a way to push each event (and all the information from this event) onto the stack. The intelligent agent acts on each event in chronological order, so I need a program to scan the entire input file, and then push each event on the stack in the reverse order (the first event in the input file should be the last event pushed onto the stack). This will allow the intelligent agent to pop events from the stack and process them one at a time.

My idea is that the bison will not help me very much, because the grammar is simply to list all tokens in sequence. It will look something like this:

eventlist: /* nothing */
| eventlist event EOL
;

event: token1 token2 token3 ... tokenN-1 tokenN

Here is a small snippet of the input file, so you can see what I mean:

: 1 00:00:00
[ ]
: -
Fusion : CVN Enterprise_0
Fusion: DEFAULT FUSION
:
:
:

:

1) , flex, , ?
2) - , ? 2a) , 1, bison , bison , ?

//: , flex ++. , , ( , ).

+2
1

, . .

, -, ?

-2

All Articles