|
From: Peep P. <so...@us...> - 2004-07-24 17:59:26
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32411 Modified Files: dfparse.y dfparse.h dflex.l Log Message: varargs functions Index: dfparse.h =================================================================== RCS file: /cvsroot/agd/server/src/dfparse.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- dfparse.h 8 Jun 2004 20:20:48 -0000 1.7 +++ dfparse.h 24 Jul 2004 17:59:15 -0000 1.8 @@ -30,17 +30,19 @@ know about them. */ enum yytokentype { L_IDENTIFIER = 258, - L_DATA_TYPE = 259 + L_DATA_TYPE = 259, + L_VARARGS = 260 }; #endif #define L_IDENTIFIER 258 #define L_DATA_TYPE 259 +#define L_VARARGS 260 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 66 "dfparse.y" +#line 69 "dfparse.y" typedef union YYSTYPE { char *s; int i; @@ -50,7 +52,7 @@ } a; } YYSTYPE; /* Line 1240 of yacc.c. */ -#line 54 "dfparse.h" +#line 56 "dfparse.h" # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 Index: dflex.l =================================================================== RCS file: /cvsroot/agd/server/src/dflex.l,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- dflex.l 23 Jul 2004 17:19:05 -0000 1.6 +++ dflex.l 24 Jul 2004 17:59:15 -0000 1.7 @@ -4,6 +4,7 @@ #include "sys.h" #include "lpc.h" #include "dfparse.h" + extern YYLTYPE yylloc; #define pos yylloc.first_column #define line yylloc.first_line @@ -44,6 +45,10 @@ pos += 6; return L_DATA_TYPE; } +varargs { + return L_VARARGS; +} + {IDENTIFIER} { char *s = xstrdup(yytext); yylval.s = s; Index: dfparse.y =================================================================== RCS file: /cvsroot/agd/server/src/dfparse.y,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- dfparse.y 23 Jul 2004 14:22:43 -0000 1.12 +++ dfparse.y 24 Jul 2004 17:59:15 -0000 1.13 @@ -4,6 +4,8 @@ NOTE: Maybe we could put the prototypes in dfuns.h or in dfuns.c? Changelog: + 0.10: + * varargs type modifier 0.09: * Not using argument variants any more. * Prints out return type as a string. @@ -41,7 +43,7 @@ #include "sys.h" /* xmalloc */ #include "lpc.h" -#define DFVERSION "0.09" +#define DFVERSION "0.10" #define DFDECL_T "typedef struct {\n\tint ret;\n\tchar *name;\n\tvoid (*fun)(void);\n\t"\ "int num_arg;\n\tint args[%d];\n} dfdecl_t;\n" @@ -75,8 +77,9 @@ %token <s> L_IDENTIFIER %token <i> L_DATA_TYPE +%token L_VARARGS -%type <i> type arg_type optional_star +%type <i> type fun_type_mod arg_type optional_star %type <a> arguments argument_and_another %% @@ -87,16 +90,16 @@ ; dfdecl: - type L_IDENTIFIER '(' arguments ')' + fun_type_mod type L_IDENTIFIER '(' arguments ')' { dfdecl_t decl; - decl.ret = $1; - decl.name = $2; - decl.num_arg = $4.len; + decl.ret = $1 | $2; + decl.name = $3; + decl.num_arg = $5.len; if(decl.num_arg > greatest_num_arg) greatest_num_arg = decl.num_arg; if(decl.num_arg) - decl.args = $4.data; + decl.args = $5.data; dfdecl = xrealloc(dfdecl, sizeof(dfdecl_t) * ++numdecl); dfdecl[numdecl-1] = decl; @@ -113,6 +116,11 @@ { $$ = $1|$2; } ; +fun_type_mod: + L_VARARGS { $$ = MOD_VARARGS; } + | /* empty */ { $$ = 0; } + ; + arg_type: type | '*' { $$ = T_ARRAY; } |