Gmane
From: Flogromp N. <looseonthestreet <at> gmail.com>
Subject: Parsing of non-strings.
Newsgroups: gmane.comp.parsers.spirit.general
Date: 2007-11-27 01:21:46 GMT (1 year, 1 week and 20 hours ago)

Hello good spirits,

I am parsing a linked-list of tagged-union containers.
These come from a C-api.
I will never touch or deal with parsing or lexxing of any whole strings. This is already done for me in all cases.
I will however need to parse based upon individual smaller strings which are inside of some of those tagged-union containers.

It's like this:
The api provides "Atom" struct which holds a union which can contain: a double, an integer, or a char* to a string.
This Atom struct also contains an integer / enum for keeping track of which type of data is in the union.
I can get the data in and out of these Atoms and query them for type.

I don't ever need to use something like real_p, because my data is     already    a double.
I just wish to use Spirit to parse the *structure* of this linked-list so that I can build a tree out of it.
An example might look like this:

atom with char* -> "foo"
atom with char* -> "{"
atom with char* -> "key1"
atom with double == 1.111
atom with char* -> "key2"
atom with char* -> "["
atom with int == 777
atom with int == 888
atom with int == 999
atom with char* -> "]"
atom with char* -> "key3"
atom with char* -> "bar"
atom with char* -> "}"

The structure is found in char* Atoms which have "{" etc, for a hierarchical tree which is something like JSON.
And the values are POD unless they are char*'s.
So I am parsing this for its hierarchical structure to match my grammar.
How can I do this with Spirit? Will it take a lot of work? Or is spirit already-ready-already to work with this kind of non-string data? Must I modify the Scanner?

I definitely do not want to push all of my atoms into a stringstream, only to turn around and re-lex them again; it's already done for me, and I need speed.
Please point me in the right direction,
appreciated,

- Flogromp N.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Spirit-general mailing list
Spirit-general <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spirit-general