[Home]

Summary:ASTERISK-13789: error/warnings for difficult if() statement in AEL
Reporter:caspy (caspy)Labels:
Date Opened:2009-03-20 09:40:32Date Closed:2011-06-07 14:08:04
Priority:MinorRegression?No
Status:Closed/CompleteComponents:PBX/pbx_ael
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
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.
Comments:By: Dmitry Andrianov (dimas) 2009-03-25 15:53:28

you clearly have extra $[]. It should be like
if (${LEN(${var})} == 0 || ${LEN(${var})} == 4 || "${var}" == "value") {

so what is your point? You want AEL parser produce an error?



By: caspy (caspy) 2009-03-26 02:58:37

dimas,
where did you find out any docs about usage of "||" expression in if-statements?
In descripton of GotoIf() there is nothing about "||", only "|".

By: Dmitry Andrianov (dimas) 2009-03-26 03:41:17

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 $[$[]].

By: Leif Madsen (lmadsen) 2009-05-22 13:36:42

Closed as no change required (if I'm reading the comments correctly).