Public Group

difficult time using boost::regex, simple parsing

This topic is 4480 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

this is impossible. can somebody recommend me an easy link to a quick and dirty guide to boost spirit? edit: originally thought spirit was the solutions to by problem, but found that regex can do the same thing (and regex was much easier) [Edited by - Tradone on March 17, 2006 10:50:26 AM]

Share on other sites
Isn't Boost.Spirit offical docs enough already? thats probably the reason why information on it is sparse since i believe there docs pretty much cover everything, there should be a quick calculator example around there.

Share on other sites
There is also some info at CodeProject...

Share on other sites
what would you like to parse?

Share on other sites
wow, they expect me to understand all that technical and that hard to understand manual?
I'm not at that level yet (talking about level, how good do I have to be in C++ to understand that? I just learned about the STL 2 weeks ago), and I've seen the tutorial on code project already and boy I can't understand it in a quick nutshell.

I would like to parse something like this on runtime.

($set cfg.hello=I am a newb)($set cfg.hello2=cfg.hello)($cfg.hello2)($if cfg.hello=cfg.hello2)  ($set cfg.hello2=I am a C++ pro)($else)  nope!($endif)($if cfg.hello=cfg.hello2)  nope!($else) yippie! I'm a pro now!!($endif)

output: yippie! I'm a pro now!!

I mean if I have to read the whole thing, I guess I have to.
but if I can do without it, I'd like to just know an easy way around it.

Share on other sites
Quote:
 Original post by Tradonewow, they expect me to understand all that technical and that hard to understand manual?I'm not at that level yet (talking about level, how good do I have to be in C++ to understand that? I just learned about the STL 2 weeks ago), and I've seen the tutorial on code project already and boy I can't understand it in a quick nutshell.I would like to parse something like this on runtime.*** Source Snippet Removed ***output: yippie! I'm a pro now!!I mean if I have to read the whole thing, I guess I have to.but if I can do without it, I'd like to just know an easy way around it.
You should pursue spirit if it interests you, but IMO it's not that easy to get into, especially if you don't already have a strong background in the STL, template programming, and perhaps the boost library in general. It is, as you note, very technical.

You might have an easier time with boost::tokenizer<>, which isn't nearly as powerful as spirit, but has some nice features and is very easy to use.

Share on other sites
Quote:
 Original post by Tradonewow, they expect me to understand all that technical and that hard to understand manual?I'm not at that level yet (talking about level, how good do I have to be in C++ to understand that? I just learned about the STL 2 weeks ago), and I've seen the tutorial on code project already and boy I can't understand it in a quick nutshell.I would like to parse something like this on runtime.*** Source Snippet Removed ***output: yippie! I'm a pro now!!I mean if I have to read the whole thing, I guess I have to.but if I can do without it, I'd like to just know an easy way around it.

It almost seems as though you're looking for code that you can copy+paste+edit to suit you. The Boost::Spirit documentation is about as simple as I expect you're going to get for a rather complicated parsing library. They don't expect you to understand the entire manual, or even every single feature of the library, but you should definitely read the FAQ, Quick Start, and maybe Quick Reference. Use other sections of the manual to expand upon the ideas presented in those sections if you're still unclear about things.

However, if you want something a bit more simplistic, you could certainly look at Boost::Tokenizer, or possibly Boost::Regex.

Share on other sites
thank you masters.

Yes, it was difficult to understand.
I guess I should not get into spirit, for now and perhaps just use the tokenizer.

Then I believe I can't parse them on runtime from a file containing the above source code. (Well, once I get better in C++ (god knows when), I can perform the upgrade then)

Boost::Regex vs Boost::Tokenizer

Which do you think is better for my scenario?
and another question, how good do I have to be in order to understand Boost::Spirit?

Share on other sites
Quote:
 Original post by TradoneBoost::Regex vs Boost::TokenizerWhich do you think is better for my scenario?
tokenizer<> is about as simple and straightforward as it gets, so if it meets your needs and ease of use is what you're after, I'd go for that. boost::regex is a little more complicated, I think.
Quote:
 and another question, how good do I have to be in order to understand Boost::Spirit?
An easy way to find out is to study the documentation and see if you understand it :-) This is just IMHO, but personally I wouldn't try to tackle it unless you're already comfortable with the STL and at least reasonably proficient in template programming techniques.

Share on other sites
Quote:
Original post by jyk
Quote:
 Original post by TradoneBoost::Regex vs Boost::TokenizerWhich do you think is better for my scenario?
tokenizer<> is about as simple and straightforward as it gets, so if it meets your needs and ease of use is what you're after, I'd go for that. boost::regex is a little more complicated, I think.
Quote:
 and another question, how good do I have to be in order to understand Boost::Spirit?
An easy way to find out is to study the documentation and see if you understand it :-) This is just IMHO, but personally I wouldn't try to tackle it unless you're already comfortable with the STL and at least reasonably proficient in template programming techniques.

I'll take your advice and not tackle it.
I'll come back to it next time when I think I'm up at that level :D
so Regex it is.
reading the first example and just looks like the same thing as string.find() so far...
we'll see...

1. 1
2. 2
3. 3
4. 4
5. 5
Rutin
17

• 10
• 12
• 9
• 12
• 37
• Forum Statistics

• Total Topics
631420
• Total Posts
2999987
×