[asterisk-bugs] [Asterisk 0014710]: error/warnings for difficult if() statement in AEL

Asterisk Bug Tracker noreply at bugs.digium.com
Thu Mar 26 03:41:17 CDT 2009


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=14710 
====================================================================== 
Reported By:                caspy
Assigned To:                
====================================================================== 
Project:                    Asterisk
Issue ID:                   14710
Category:                   PBX/pbx_ael
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
Asterisk Version:           1.6.0.6 
Regression:                 No 
SVN Branch (only for SVN checkouts, not tarball releases): N/A 
SVN Revision (number only!):  
Request Review:              
====================================================================== 
Date Submitted:             2009-03-20 09:40 CDT
Last Modified:              2009-03-26 03:41 CDT
====================================================================== 
Summary:                    error/warnings for difficult if() statement in AEL
Description: 
I have such code in AEL config:
if ($[${LEN(${var})} = 0] | $[${LEN(${var})} = 4] | $["${var}" = "value"])
{

It is successfully converted into dialplan command, that's work like
expected:
GotoIf($[$[${LEN(${var})} = 0] | $[${LEN(${var})} = 4] | $["${var}" =
"value"]]?6:8)


But error messages are produced in log:
[Mar 20 17:30:45] WARNING[2638] ast_expr2.fl: ast_yyerror(): file
/etc/asterisk/extensions.ael, line 57, columns 7-7, if expr
'$[${LEN(${var})} = 0] | $[${LEN(${var})} = 4] | $["${var}" = "value"]':
syntax error: syntax error, unexpected '<token>', expecting $end; Input:
$[${LEN(${var})} = 0] | $[${LEN(${var})} = 4] | $["${var}" = "value"]
  ^
[Mar 20 17:30:45] WARNING[2638] ast_expr2.fl: If you have questions,
please refer to doc/tex/channelvariables.tex in the asterisk source.
[Mar 20 17:30:45] WARNING[2638] ael/pval.c: Warning: file
/etc/asterisk/extensions.ael, line 57-59: The expression '$[${LEN(${var})}
= 0] | $[${LEN(${var})} = 4] | $["${var}" = "value"]' is redundantly
wrapped in '$[ ]'.

seems like AEL parser can not to produce an error messages in such cases.
====================================================================== 

---------------------------------------------------------------------- 
 (0102215) dimas (reporter) - 2009-03-26 03:41
 http://bugs.digium.com/view.php?id=14710#c102215 
---------------------------------------------------------------------- 
doc/ael.txt :

Differences with the original version of AEL
============================================
   1. The $[...] expressions have been enhanced to include the ==, ||,
      and && operators. These operators are exactly equivalent to the
      =, |, and & operators, respectively. Why? So the C, Java, C++
      hackers feel at home here.
...

It works both ways. To  me it is just more convenient because other
languages I use (C, Java and C#) use == for comparison and normally
everybody do || instead of | in these languages. 

Anyway, as I understand the problem with your expression is not  | or =,
it is only $[] surrounding the expression because it is what AEL does
itself - it takes condition and puts it inside $[] which in your case
results in $[$[]]. 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2009-03-26 03:41 dimas          Note Added: 0102215                          
======================================================================




More information about the asterisk-bugs mailing list