Usage of complex expressions in regular if-statements apart from string literals.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Usage of complex expressions in regular if-statements apart from string literals.

dimak
Hi bjam gurus.

I am kindly asking you if it is possible to extend without much pain bjam functionality in order to support complex expressions (like per-lists comparisons or rule invocations) in regular if-statements?
For example, it is not possible for now to perform neither such comparison:
if "bla" "bla" = "bla" "bla"
{
    ECHO Yes! ;
}
else
{
    ECHO No... ;
}

nor such (with grouping):
if ("bla" "bla") = ("bla" "bla")
{
    ECHO Yes! ;
}
else
{
    ECHO No... ;
}

The following works OK:
if ( "bla""bla" ) = ( "bla""bla" )
{
    ECHO Yes! ;
}
else
{
    ECHO No... ;
}

but we cannot use it when for example invoking a rule:
if ( [ rule-that-returns-bla ] "bla" ) = ( "bla""bla" )
{
    ECHO Yes! ;
}
else
{
    ECHO No... ;
}
Note that we cannot use [ rule-that-returns-bla ]"bla" as one word... (it's a topic of my previous post http://boost.2283326.n4.nabble.com/How-to-use-function-invocation-result-in-string-without-white-space-td4633263.html).

Do you have any suggestions? Thank you!
Reply | Threaded
Open this post in threaded view
|

Re: Usage of complex expressions in regular if-statements apart from string literals.

Jurko Gospodnetić-2
   Hi.

> I am kindly asking you if it is possible to extend without much pain bjam
> functionality in order to support complex expressions (like per-lists
> comparisons or rule invocations) in regular if-statements?
> For example, it is not possible for now to perform neither such comparison:
> if "bla" "bla" = "bla" "bla"
> {
>      ECHO Yes! ;
> }
> else
> {
>      ECHO No... ;
> }

   Actually, all variables are lists so you can do this by using two
additional variables as in:

> local lhs = foo bar ;
> local rhs = foo bar ;
>
> if $(lhs) = $(rhs)
> {
>     ECHO Yes! ;
> }
> else
> {
>     ECHO No... ;
> }

   or you can do something like this to check a rule's return value:

> rule foo
> {
>     return figaro bar ;
> }
>
> local expected-result = figaro bar ;
> if [ foo ] = $(expected-result)
> {
>     ECHO Yes! ;
> }
> else
> {
>     ECHO No... ;
> }

   Hope this helps.

   Best regards,
     Jurko Gospodnetić

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: Usage of complex expressions in regular if-statements apart from string literals.

dimak
Hi, Jurko.

I've caught important principle in bjam language - if you construct more complex expression that simple string literal, it is better to put it into temporal variable. However, my personal feeling is that in this particular case it is not so difficult to extend existent functionality of bjam lexer/parser in order to support "anonymous" bjam lists evaluation in if-statements.

Not having much time right now to dive into bjam's engine, I could add this language feature later on if you kindly point me the place in source code where I should advance.

Kind regards,
Dima Kinoshenko