simplify updating the token position markers
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@23611 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
parent
7343d311f1
commit
36a26a9197
File diff suppressed because it is too large
Load Diff
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue