Re: Parsing an empty member into a fusion adapted struct

Seth <[email protected]>
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <[email protected]>
On 05-05-17 19:54, Thomas Ellis wrote:
> I am currently working on developing a parse grammar which would allow me to handle the two input lines identified below with a single parse grammar.  The first input parses fine.  It is when there is nothing for that "field" where the difficulty lies.  Does anyone have any words of wisdom on how I might accomplish this?

The inputs strongly suggest that the format is fixed-width (and space
separated). So you would probably do best to parse it as such.

If you don't want to, and the trailing `request` value is mandatory, you
could look-ahead to assert that you're not able to parse the trailing
ushort_:

        linestruct = 
            ushort_ >> '-' >> ushort_ >> '-' >> ushort_ >>
            ushort_ >> ':' >> ushort_ >> ':' >> ushort_ >>
            -(~(ushort_ >> eoi) >> lexeme[ *alnum ]) >>
            -(~(ushort_ >> eoi) >> lexeme[ *alnum ]) >>
            ushort_;

Which _does_ work: http://coliru.stacked-crooked.com/a/53479b03385ca51d,
printing

<linestruct>

  <try>2017-04-18 23:59:55 </try>

  <success></success>

  <attributes>[[2017, 4, 18, 23, 59, 55, [h, p, c, h, l, p, 2, 0, 0], [6, Z, L, A], 9]]</attributes>

</linestruct>

Parse success

<linestruct>

  <try>2017-04-18 23:59:55 </try>

  <success></success>

  <attributes>[[2017, 4, 18, 23, 59, 55, [h, p, c, h, l, p, 2, 0, 0], [], 9]]</attributes>

</linestruct>

Parse success

------------------------------------------------------------------------------
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.