Re: Parsing lines in a file

Sean Farrow <[email protected]>
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <HE1PR0501MB25706E29521A9CEA8E34524BC6420@HE1PR0501MB2570.eurprd05.prod.outlook.com>
Hi,

Thanks, I think I was misunderstood though, I want to parse the two lines and set an enum value based on what is parsed.
Would the previous technique work for this?
Kind regards
Sean.

From: Seth [mailto:[email protected]]
Sent: Tuesday, February 07, 2017 20:42
To: Spirit General Mailing List <[email protected]>
Subject: Re: [Spirit-general] Parsing lines in a file

On 07-02-17 04:18, Sean Farrow wrote:

Using spirit, how do I translate the :script and :function to their enum equivalents,  what is the best way of reading any number of these lines in any order from a file?
Any help appreciated.

Have a look at these

- https://stackoverflow.com/questions/17012941/boostspirit-how-to-parse-and-call-c-function-like-expressions (on parsing function invocations and executing them later)

- This full blown example that actually parses line-by line till the end of the file https://stackoverflow.com/questions/17768152/what-is-the-correct-way-to-handle-multiple-input-command-differently-in-c/17776618#17776618 (live demo on Coliru<http://coliru.stacked-crooked.com/view?id=aeca4ca881a3b82ae26ad12a6ee7e473-acc21326bddb78ffadef615690276e19>)

I think they should be inspiritional and perhaps will help you get started.
Finally, how do I parse to the end of the line, excluding the line feed?
Like so:

     *(char_ - eol) >> (eol|eol)

Which means: parse as many non-newline characters as possible till the end of input or an actual newline.

You can combine it with a skipper, but not with `qi::space` because it would eat the newline too:

      skip(blank) [ *(char_ - eol) >> (eol|eol) ];

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot

_______________________________________________
Spirit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-general
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.