Re: Parsing lines in a file
Seth <[email protected]>
| Newsgroups | gmane.comp.parsers.spirit.general |
|---|---|
| Message-ID | <[email protected]> |
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