[Asterisk-Users] Re: Everyone-- the scoop on Bison/Flex --

Tony Mountifield tony at softins.clara.co.uk
Fri Jun 3 08:24:38 MST 2005


Steve, thanks for the info:

In article <1117807754.24036.139.camel at monster>,
Steve Murphy <murf at e-tools.com> wrote:
> 
> What do you get if you hand-install flex-2.5.31? Well, now, your
> expressions don't have to have at least one space separating the tokens.
> You can pack them tighter if you want, if the syntax allows it. 
> For instance, you don't have to say $[2 * ${lala}]; you can say 
> $[2*${lala}] or $[2*   ${lala}] or whatever you want.
> 
> Also, you get some extra operators. You can now use Unary Minus, like 
> $[2 * -${lala}]; and You get a logical negation operator, "!". So, you
> can say $[ !${var} : "HELLO" ]  to test if var DOESN'T begin with
> "HELLO".  (or $[!${var}:"HELLO"] if you like!).  And, you also get the
> binary "=~"  matching operator, which is like :, but isn't anchored to
> the beginning of the string. You can read all about them in
> README.variables.
> 
> And, one final plus is that if we ever need to add new operators or
> syntax to the current $[ ] syntax, hopefully such can be done in bison
> and flex more easily and robustly than it could via the hand-written
> scanner, which was simple, yet a bit intricate, all at the same time.

I was trying to do something today for which I would have found the
following construct VERY useful:

$[ expr1 ? expr2 : expr3 ]

which, obviously, would evaluate expr1 as boolean, and return expr2 as
the expression value if expr1 was true, and return expr3 otherwise.

e.g. SetVar(CLID=$[ $[ ${CLID} : 00 ] ? ${CLID:2} : 44${CLID:1} ])

Or is it already lurking in there and I didn't know?

I had to use a couple of GotoIfs instead.

Cheers
Tony
-- 
Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org



More information about the asterisk-users mailing list