Boost logo

Boost Users :

Subject: Re: [Boost-users] [Proto] implementing an computer algebra systemwith proto
From: Dave Jenkins (david_at_[hidden])
Date: 2009-01-28 16:55:21


"Kim Kuen Tang" <kuentang_at_[hidden]> wrote in message
news:4980CB95.2010706_at_vodafone.de...

> I see that this is a problem. (What does UB stand for?)

UB = Undefined Behavior (the compiler can crash, produce wrong results, or
anything else)

> But can a correct implemented grammar be a workaround?

The grammar was correct, but it was given an invald expression (that sort-of
looked valid).

> Perhaps we can first check whether var1_ appears in the expression. If not
> we can return the expression unmodified.

The way to check if the expression is valid for a grammar is something like
the code below.
I'm hoping Eric can automatically do this check when a compile-time debug
flag is defined.

Regards,
Dave Jenkins

template< typename Expr >
void Solve_check( Expr const & expr )
{
    if ( !proto::matches< Expr, Solve >::value )
    {
        std::cout << "Expression does not match grammar\n\n";
    }
}

int main()
{
    Solve_check(var_ + 1 = 2);
    proto::display_expr( var_ + 1 = 2 );
    proto::display_expr( Solve()( var_ + 1 = 2 ) );
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net