summaryrefslogtreecommitdiff
path: root/pbx/ael/ael.y
diff options
context:
space:
mode:
Diffstat (limited to 'pbx/ael/ael.y')
-rw-r--r--pbx/ael/ael.y53
1 files changed, 25 insertions, 28 deletions
diff --git a/pbx/ael/ael.y b/pbx/ael/ael.y
index 0e3fe318c..c57b141fe 100644
--- a/pbx/ael/ael.y
+++ b/pbx/ael/ael.y
@@ -64,6 +64,9 @@ int ael_yylex (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , void * yyscanner
* Must be declared here because YYLTYPE is not known before
*/
static pval *npval2(pvaltype type, YYLTYPE *first, YYLTYPE *last);
+
+/* update end position of an object, return the object */
+static pval *update_last(pval *, YYLTYPE *);
%}
@@ -441,22 +444,14 @@ statement : LC statements RC {
$$->u1.str = $4;
$$->u2.statements = $6; }
| switch_head RC /* empty list OK */ {
- $$=$1;
- $$->endline = @2.last_line;
- $$->endcol = @2.last_column;}
+ $$ = update_last($1, &@2); }
| switch_head case_statements RC {
- $$=$1;
- $$->u2.statements = $2;
- $$->endline = @3.last_line;
- $$->endcol = @3.last_column;}
+ $$ = update_last($1, &@3);
+ $$->u2.statements = $2;}
| AMPER macro_call SEMI {
- $$ = $2;
- $$->endline = @2.last_line;
- $$->endcol = @2.last_column;}
+ $$ = update_last($2, &@2); }
| application_call SEMI {
- $$ = $1;
- $$->endline = @2.last_line;
- $$->endcol = @2.last_column;}
+ $$ = update_last($1, &@2); }
| word SEMI {
$$= npval2(PV_APPLICATION_CALL, &@1, &@2);
$$->u1.str = $1;}
@@ -497,11 +492,9 @@ statement : LC statements RC {
| KW_RETURN SEMI { $$ = npval2(PV_RETURN, &@1, &@2); }
| KW_CONTINUE SEMI { $$ = npval2(PV_CONTINUE, &@1, &@2); }
| random_head statement opt_else {
- $$=$1;
+ $$ = update_last($1, &@2); /* XXX probably @3... */
$$->u2.statements = $2;
- $$->endline = @2.last_line;
- $$->u3.else_statements = $3;
- $$->endcol = @2.last_column;}
+ $$->u3.else_statements = $3;}
/*
| random_head statement KW_ELSE statement {
$$=$1;
@@ -511,11 +504,9 @@ statement : LC statements RC {
$$->u3.else_statements = $4;}
*/
| if_head statement opt_else {
- $$=$1;
+ $$ = update_last($1, &@2); /* XXX probably @3... */
$$->u2.statements = $2;
- $$->endline = @2.last_line;
- $$->u3.else_statements = $3;
- $$->endcol = @2.last_column;}
+ $$->u3.else_statements = $3;}
/*
| if_head statement KW_ELSE statement {
$$=$1;
@@ -525,11 +516,9 @@ statement : LC statements RC {
$$->u3.else_statements = $4;}
*/
| iftime_head statement opt_else {
- $$=$1;
+ $$ = update_last($1, &@2); /* XXX probably @3... */
$$->u2.statements = $2;
- $$->endline = @2.last_line;
- $$->u3.else_statements = $3;
- $$->endcol = @2.last_column;}
+ $$->u3.else_statements = $3;}
/*
| iftime_head statement KW_ELSE statement {
$$=$1;
@@ -649,13 +638,14 @@ application_call_head: word {reset_argcount(parseio->scanner);} LP {
$$->u1.str = $1; }
;
-application_call : application_call_head eval_arglist RP {$$ = $1;
+application_call : application_call_head eval_arglist RP {
+ $$ = update_last($1, &@3);
if( $$->type == PV_GOTO )
$$->u1.list = $2;
else
$$->u2.arglist = $2;
- $$->endline = @3.last_line; $$->endcol = @3.last_column;}
- | application_call_head RP {$$=$1;$$->endline = @2.last_line; $$->endcol = @2.last_column;}
+ }
+ | application_call_head RP { $$ = update_last($1, &@2); }
;
opt_word : word { $$ = $1 }
@@ -993,6 +983,13 @@ static struct pval *npval2(pvaltype type, YYLTYPE *first, YYLTYPE *last)
first->first_column, last->last_column);
}
+static struct pval *update_last(pval *obj, YYLTYPE *last)
+{
+ obj->endline = last->last_line;
+ obj->endcol = last->last_column;
+ return obj;
+}
+
/* append second element to the list in the first one */
static pval * linku1(pval *head, pval *tail)
{