Add variadic functions.

Already extending QuakePascal, and many basics aren't there yet :P
This commit is contained in:
Bill Currie 2011-01-12 23:39:59 +09:00
parent 02b3dde83b
commit 9ce9b70484
2 changed files with 14 additions and 1 deletions

View file

@ -82,6 +82,7 @@ ADDOP [\-+]
MULOP [*/]
ASSIGNOP :=
RANGE \.\.
ELLIPSIS \.\.\.
FRAMEID {ID}(\.{ID})*
%x GRAB_FRAME GRAB_OTHER COMMENT
@ -153,6 +154,7 @@ FRAMEID {ID}(\.{ID})*
{ASSIGNOP} return ASSIGNOP;
{RANGE} return RANGE;
{ELLIPSIS} return ELLIPSIS;
[!(){}.&|^~\[\];,#%?:] return yytext[0];

View file

@ -136,7 +136,7 @@ int yylex (void);
%token <float_val> FLOAT_VAL
%token PROGRAM VAR ARRAY OF FUNCTION PROCEDURE PBEGIN END IF THEN ELSE
%token WHILE DO RANGE ASSIGNOP NOT
%token WHILE DO RANGE ASSIGNOP NOT ELLIPSIS
%type <type> standard_type type
%type <expr> const num identifier_list statement_list statement
@ -294,6 +294,17 @@ subprogram_head
arguments
: '(' parameter_list ')' { $$ = $2; }
| '(' parameter_list ';' ELLIPSIS ')'
{
param_t **p;
$$ = $2;
p = &$$;
for ( ; *p; p = &(*p)->next)
;
*p = new_param (0, 0, 0);
}
| '(' ELLIPSIS ')' { $$ = new_param (0, 0, 0); }
| /* emtpy */ { $$ = 0; }
;