c++ - Integrating Flex/Bison with external program -


I am working on an intelligent agent model for which input is needed, list of events. The incidents come from the output of any other model and in one (large) text file, the text file is a list of all events (I do not care about unnecessary events), so I have written a scanner using Flex Find useful bits. The structure for the intelligent agent model has already been written in C ++.

Every event timestamp occurs and there is a large amount of information about this event. The format of the input file is stable, so I do not need to check syntax. I do not know that Bison will actually give me any benefit, because grammar is actually very simple, there is no real difference.

Let me put one on each stack (and all the information about that incident) on a stack The path is needed. Intelligent agent works in every event chronologically, so I need the program to scan the whole input file, then keep each event on the stack in the reverse order (the first event in the input file pushed the last event on the stack should go). This will allow the intelligent agent to get the closing incidents to pop up and deal with them at one time.

My idea is that Bison will not help me a lot, because grammar is just a matter of listing, all the tokens, gradually, looked like this originally:

  Eventlist: / * nothing * / | Evian Event Event EOL; Event: Token1 Token2 Token 3 ... Token N-1 TokenN   

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

Scenario event time: 1 1 00:00:00
[Data Fusion Event] New Track is Made
Summary
Real Target: RF Headquarters
Fusion Center Location: Name of CVN Enterprise-17 Fusion Center: Default Fission / Targeted Goal Targeted Identity: unknown
practice I have a few questions:

1) How can I integrate the scanner generated by Flex with a large program? I already exist?
2) Does twenty offers any benefit or do I just write my own program on all the tokens on the data structure and putting them on the stack? 2a) If the seedling is better, then it solves Question 1, but then how can I call Biceyn from within my program and after that Bison has returned an indicator on the stack so that the program uses it Could it?

EDITED: I have come to know how to call Flex from an external C ++ program. I have not been able to create a Bison program yet, what I want to do, though (i.e. , An indicator back on a stack of events).

If your grammar is simple then using a parser takes overkill. Simply process each line and scan the token in one collection.

Do you think you need a parser?

Comments