Re: always success? - but dont!

Seth <[email protected]>
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <[email protected]>
On 28-11-16 19:17, Jens Kallup wrote:
> The result is always Success.

No it isn't. The simplest thing I can think of to complete this to a
self-contained example
<http://coliru.stacked-crooked.com/a/68743fbff3d931e9>:

    namespace SSCCE {
        using namespace boost::spirit::x3;

        auto symbol_alpha    = lexeme[*char_("a-zA-Z_")];
        auto qualified_id    = symbol_alpha >> *('.' > symbol_alpha);
        auto symbol_expr     = "42";
        auto symbol_def_expr =
            qualified_id > '=' > (
                  (lexeme["new"] > (qualified_id > ('(' > qualified_id >
    ')')))
                | (symbol_expr)
            );
    }

That's how you create a SSCCE. As you can see it prints:

 ---------------- Testing 'xxxx . xxx = new'

boost::spirit::x3::expectation_failure at '' 

 ---------------- Testing 'yss. ss = new xxx'

boost::spirit::x3::expectation_failure at '' 

 ---------------- Testing 'yy . sss = new ddd (ff fff)'

boost::spirit::x3::expectation_failure at 'fff)' 

Remaining unparsed: 'fff)'

 ---------------- Testing 'left.right = new Form(test.blah)'

Parse success


Here's how you should debug your rules: BOOST_SPIRIT_X3_DEBUG
<http://coliru.stacked-crooked.com/a/cb3e546d7d168c7e>


Prints:

 ---------------- Testing 'xxxx . xxx = new'

<symbol_def_expr>

  <try>xxxx . xxx = new</try>

  <qualified_id>

    <try>xxxx . xxx = new</try>

    <symbol_alpha>

      <try>xxxx . xxx = new</try>

      <success> . xxx = new</success>

    </symbol_alpha>

    <symbol_alpha>

      <try> xxx = new</try>

      <success> = new</success>

    </symbol_alpha>

    <success> = new</success>

  </qualified_id>

  <qualified_id>

    <try></try>

    <symbol_alpha>

      <try></try>

      <success></success>

    </symbol_alpha>

    <success></success>

  </qualified_id>

  <success>xxxx . xxx = new</success>

</symbol_def_expr>

boost::spirit::x3::expectation_failure at '' 

Remaining unparsed: 'xxxx . xxx = new'

 ---------------- Testing 'yss. ss = new xxx'

<symbol_def_expr>

  <try>yss. ss = new xxx</try>

  <qualified_id>

    <try>yss. ss = new xxx</try>

    <symbol_alpha>

      <try>yss. ss = new xxx</try>

      <success>. ss = new xxx</success>

    </symbol_alpha>

    <symbol_alpha>

      <try> ss = new xxx</try>

      <success> = new xxx</success>

    </symbol_alpha>

    <success> = new xxx</success>

  </qualified_id>

  <qualified_id>

    <try> xxx</try>

    <symbol_alpha>

      <try> xxx</try>

      <success></success>

    </symbol_alpha>

    <success></success>

  </qualified_id>

  <success>yss. ss = new xxx</success>

</symbol_def_expr>

boost::spirit::x3::expectation_failure at '' 

Remaining unparsed: 'yss. ss = new xxx'

 ---------------- Testing 'yy . sss = new ddd (ff fff)'

<symbol_def_expr>

  <try>yy . sss = new ddd (</try>

  <qualified_id>

    <try>yy . sss = new ddd (</try>

    <symbol_alpha>

      <try>yy . sss = new ddd (</try>

      <success> . sss = new ddd (ff</success>

    </symbol_alpha>

    <symbol_alpha>

      <try> sss = new ddd (ff f</try>

      <success> = new ddd (ff fff)</success>

    </symbol_alpha>

    <success> = new ddd (ff fff)</success>

  </qualified_id>

  <qualified_id>

    <try> ddd (ff fff)</try>

    <symbol_alpha>

      <try> ddd (ff fff)</try>

      <success> (ff fff)</success>

    </symbol_alpha>

    <success> (ff fff)</success>

  </qualified_id>

  <qualified_id>

    <try>ff fff)</try>

    <symbol_alpha>

      <try>ff fff)</try>

      <success> fff)</success>

    </symbol_alpha>

    <success> fff)</success>

  </qualified_id>

  <success>yy . sss = new ddd (</success>

</symbol_def_expr>

boost::spirit::x3::expectation_failure at 'fff)' 

Remaining unparsed: 'yy . sss = new ddd (ff fff)'

 ---------------- Testing 'left.right = new Form(test.blah)'

<symbol_def_expr>

  <try>left.right = new For</try>

  <qualified_id>

    <try>left.right = new For</try>

    <symbol_alpha>

      <try>left.right = new For</try>

      <success>.right = new Form(te</success>

    </symbol_alpha>

    <symbol_alpha>

      <try>right = new Form(tes</try>

      <success> = new Form(test.bla</success>

    </symbol_alpha>

    <success> = new Form(test.bla</success>

  </qualified_id>

  <qualified_id>

    <try> Form(test.blah)</try>

    <symbol_alpha>

      <try> Form(test.blah)</try>

      <success>(test.blah)</success>

    </symbol_alpha>

    <success>(test.blah)</success>

  </qualified_id>

  <qualified_id>

    <try>test.blah)</try>

    <symbol_alpha>

      <try>test.blah)</try>

      <success>.blah)</success>

    </symbol_alpha>

    <symbol_alpha>

      <try>blah)</try>

      <success>)</success>

    </symbol_alpha>

    <success>)</success>

  </qualified_id>

  <success></success>

</symbol_def_expr>

Parse success

------------------------------------------------------------------------------

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