Boost logo

Boost :

From: Seth (bugs_at_[hidden])
Date: 2021-03-08 02:04:15


Op 06-03-2021 om 19:28 schreef Serguei TARASSOV via Boost:
> Hello,
> is it possible to have a custom error handler on the rule level (for
> every rule in the limit) ? Cannot find this point in docs/examples.
> I.e. when parsing following texts (// are inline comments):
> DO_JOB WITH not_a_opt1; // should raise "Option not_a_opt1 is unknown"
> DO_JOB WITH opt2 = 123; // should raise "Invalid value 123 for option
> opt2"
> Regards,
>
I'm really confused what "limit" means. "The limit"?

Maybe this example can be inspiring: https://godbolt.org/z/r8x34P:

    Error: Option not_a_opt1; is unknown
    Error: Expected <strvalue> after ' opt2 = '
    ==== [DO_JOB WITH not_a_opt1;] ====
    ==== [DO_JOB WITH opt2 = 123;] ====
    ==== [DO_JOB WITH opt2 = "hello \"world\"";
    QUIT WITH opt1 = -9999;
    DO_JOB WITH opt2 = "LtUaE", opt1 = 42;
    QUIT] ====
    Parsed
    [DO_JOB, {(hello "world")}]
    [QUIT, {(-9999)}]
    [DO_JOB, {(LtUaE), (42)}]
    [QUIT, {}]

See on_error for generialized error handlers:
https://www.boost.org/doc/libs/1_75_0/libs/spirit/doc/html/spirit/qi/tutorials/mini_xml___error_handling.html

See here for ideas for comprehensive error handling and reporting:
https://stackoverflow.com/a/47383910/85371 or

Cheers,
Seth

> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk