2006-01-03 11:16:05 +00:00
|
|
|
/* -*-C-*-
|
2002-07-16 03:20:45 +00:00
|
|
|
* IDL Compiler
|
|
|
|
*
|
|
|
|
* Copyright 2002 Ove Kaaven
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-07-16 03:20:45 +00:00
|
|
|
*/
|
|
|
|
|
2023-01-24 21:19:45 +00:00
|
|
|
%option bison-bridge
|
2002-07-16 03:20:45 +00:00
|
|
|
%option stack
|
2008-07-07 10:31:33 +00:00
|
|
|
%option noinput nounput noyy_top_state
|
2023-01-24 21:19:45 +00:00
|
|
|
%option noyywrap
|
2006-09-12 07:05:07 +00:00
|
|
|
%option 8bit never-interactive prefix="parser_"
|
2002-07-16 03:20:45 +00:00
|
|
|
|
|
|
|
nl \r?\n
|
|
|
|
ws [ \f\t\r]
|
|
|
|
cident [a-zA-Z_][0-9a-zA-Z_]*
|
2008-04-27 22:05:31 +00:00
|
|
|
u_suffix (u|U)
|
|
|
|
l_suffix (l|L)
|
|
|
|
int [0-9]+({l_suffix}?{u_suffix}?|{u_suffix}?{l_suffix}?)?
|
2002-07-16 03:20:45 +00:00
|
|
|
hexd [0-9a-fA-F]
|
2008-04-27 22:05:31 +00:00
|
|
|
hex 0(x|X){hexd}+({l_suffix}?{u_suffix}?|{u_suffix}?{l_suffix}?)?
|
2002-07-16 03:20:45 +00:00
|
|
|
uuid {hexd}{8}-{hexd}{4}-{hexd}{4}-{hexd}{4}-{hexd}{12}
|
2007-07-17 11:09:03 +00:00
|
|
|
double [0-9]+\.[0-9]+([eE][+-]?[0-9]+)*
|
2002-07-16 03:20:45 +00:00
|
|
|
|
2007-02-08 10:55:35 +00:00
|
|
|
%x ATTR
|
|
|
|
%x PP_LINE
|
2013-11-04 13:13:06 +00:00
|
|
|
%x PP_PRAGMA
|
2002-07-16 03:20:45 +00:00
|
|
|
|
|
|
|
%{
|
|
|
|
|
2002-08-17 18:28:43 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2002-07-16 03:20:45 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <assert.h>
|
2008-10-20 12:55:38 +00:00
|
|
|
#include <errno.h>
|
2008-10-18 10:50:20 +00:00
|
|
|
#include <limits.h>
|
2008-02-19 14:42:49 +00:00
|
|
|
#define YY_NO_UNISTD_H
|
2002-07-16 03:20:45 +00:00
|
|
|
|
|
|
|
#include "widl.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "parser.h"
|
2021-09-23 20:00:36 +00:00
|
|
|
#include "wpp_private.h"
|
2002-07-16 03:20:45 +00:00
|
|
|
|
2023-01-24 21:19:45 +00:00
|
|
|
#define YYerror PARSER_error
|
|
|
|
#define YYSTYPE PARSER_STYPE
|
|
|
|
#define YYUNDEF PARSER_UNDEF
|
|
|
|
#define yyerror parser_error
|
|
|
|
|
2005-09-28 18:17:08 +00:00
|
|
|
#include "parser.tab.h"
|
2002-07-16 03:20:45 +00:00
|
|
|
|
2023-01-24 21:19:45 +00:00
|
|
|
static int kw_token(const char *kw, YYSTYPE *yylval);
|
|
|
|
static int attr_token(const char *kw, YYSTYPE *yylval);
|
2002-07-16 03:20:45 +00:00
|
|
|
|
2018-11-09 12:51:00 +00:00
|
|
|
static void switch_to_acf(void);
|
|
|
|
|
2016-03-29 20:06:45 +00:00
|
|
|
static warning_list_t *disabled_warnings = NULL;
|
|
|
|
|
2023-01-25 22:05:44 +00:00
|
|
|
struct import_state
|
|
|
|
{
|
|
|
|
YY_BUFFER_STATE buffer;
|
|
|
|
char *input_name;
|
|
|
|
int line_number;
|
|
|
|
struct list entry;
|
|
|
|
};
|
|
|
|
static struct list import_stack = LIST_INIT( import_stack );
|
|
|
|
int parse_only = 0;
|
2002-07-16 03:20:45 +00:00
|
|
|
|
2023-01-24 21:19:45 +00:00
|
|
|
struct import
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
struct list entry;
|
|
|
|
};
|
|
|
|
static struct list imports = LIST_INIT( imports );
|
|
|
|
|
2008-10-18 10:50:20 +00:00
|
|
|
/* converts an integer in string form to an unsigned long and prints an error
|
|
|
|
* on overflow */
|
2010-03-26 10:42:28 +00:00
|
|
|
static unsigned int xstrtoul(const char *nptr, char **endptr, int base)
|
2008-10-18 10:50:20 +00:00
|
|
|
{
|
2010-03-26 10:42:28 +00:00
|
|
|
unsigned long val;
|
2008-10-18 10:50:20 +00:00
|
|
|
|
|
|
|
errno = 0;
|
2010-03-26 10:42:28 +00:00
|
|
|
val = strtoul(nptr, endptr, base);
|
|
|
|
if ((val == ULONG_MAX && errno == ERANGE) || ((unsigned int)val != val))
|
2008-10-18 10:50:20 +00:00
|
|
|
error_loc("integer constant %s is too large\n", nptr);
|
2010-03-26 10:42:28 +00:00
|
|
|
return val;
|
2008-10-18 10:50:20 +00:00
|
|
|
}
|
|
|
|
|
2022-01-25 07:45:39 +00:00
|
|
|
struct uuid *parse_uuid(const char *u)
|
2002-11-12 02:12:35 +00:00
|
|
|
{
|
2022-01-25 07:45:39 +00:00
|
|
|
struct uuid* uuid = xmalloc(sizeof(*uuid));
|
2002-11-12 02:12:35 +00:00
|
|
|
char b[3];
|
|
|
|
/* it would be nice to use UuidFromStringA */
|
2002-12-03 19:12:07 +00:00
|
|
|
uuid->Data1 = strtoul(u, NULL, 16);
|
|
|
|
uuid->Data2 = strtoul(u+9, NULL, 16);
|
|
|
|
uuid->Data3 = strtoul(u+14, NULL, 16);
|
2002-11-12 02:12:35 +00:00
|
|
|
b[2] = 0;
|
2002-12-03 19:12:07 +00:00
|
|
|
memcpy(b, u+19, 2); uuid->Data4[0] = strtoul(b, NULL, 16);
|
|
|
|
memcpy(b, u+21, 2); uuid->Data4[1] = strtoul(b, NULL, 16);
|
|
|
|
memcpy(b, u+24, 2); uuid->Data4[2] = strtoul(b, NULL, 16);
|
|
|
|
memcpy(b, u+26, 2); uuid->Data4[3] = strtoul(b, NULL, 16);
|
|
|
|
memcpy(b, u+28, 2); uuid->Data4[4] = strtoul(b, NULL, 16);
|
|
|
|
memcpy(b, u+30, 2); uuid->Data4[5] = strtoul(b, NULL, 16);
|
|
|
|
memcpy(b, u+32, 2); uuid->Data4[6] = strtoul(b, NULL, 16);
|
|
|
|
memcpy(b, u+34, 2); uuid->Data4[7] = strtoul(b, NULL, 16);
|
2002-11-12 02:12:35 +00:00
|
|
|
return uuid;
|
|
|
|
}
|
|
|
|
|
2023-03-17 08:04:57 +00:00
|
|
|
static int token_str( int token, const char *str, YYSTYPE *yylval )
|
|
|
|
{
|
|
|
|
char *tmp = xstrdup( str );
|
|
|
|
|
|
|
|
if (token == aWSTRING || token == aSTRING || token == aSQSTRING)
|
|
|
|
{
|
|
|
|
char *src, *dst;
|
|
|
|
src = dst = ++tmp; /* skip first quote */
|
|
|
|
while (*src)
|
|
|
|
{
|
|
|
|
if (*src == '\\') src++;
|
|
|
|
*dst++ = *src++;
|
|
|
|
}
|
|
|
|
dst[-1] = 0; /* strip last quote */
|
|
|
|
}
|
|
|
|
|
|
|
|
yylval->str = tmp;
|
|
|
|
return token;
|
|
|
|
}
|
|
|
|
|
2023-01-24 21:19:45 +00:00
|
|
|
static int token_num( int token, const char *yytext, YYSTYPE *yylval )
|
|
|
|
{
|
|
|
|
yylval->num = xstrtoul( yytext, NULL, 0 );
|
|
|
|
return token;
|
|
|
|
}
|
|
|
|
|
2002-07-16 03:20:45 +00:00
|
|
|
%}
|
|
|
|
|
|
|
|
/*
|
|
|
|
**************************************************************************
|
|
|
|
* The flexer starts here
|
|
|
|
**************************************************************************
|
|
|
|
*/
|
|
|
|
%%
|
2007-02-08 10:55:35 +00:00
|
|
|
<PP_LINE>[^\n]* {
|
2003-03-16 23:52:24 +00:00
|
|
|
int lineno;
|
|
|
|
char *cptr, *fname;
|
|
|
|
yy_pop_state();
|
|
|
|
lineno = (int)strtol(yytext, &cptr, 10);
|
|
|
|
if(!lineno)
|
2007-10-24 03:18:18 +00:00
|
|
|
error_loc("Malformed '#...' line-directive; invalid linenumber\n");
|
2003-03-16 23:52:24 +00:00
|
|
|
fname = strchr(cptr, '"');
|
|
|
|
if(!fname)
|
2007-10-24 03:18:18 +00:00
|
|
|
error_loc("Malformed '#...' line-directive; missing filename\n");
|
2003-03-16 23:52:24 +00:00
|
|
|
fname++;
|
|
|
|
cptr = strchr(fname, '"');
|
|
|
|
if(!cptr)
|
2007-10-24 03:18:18 +00:00
|
|
|
error_loc("Malformed '#...' line-directive; missing terminating \"\n");
|
2003-03-16 23:52:24 +00:00
|
|
|
*cptr = '\0';
|
|
|
|
line_number = lineno - 1; /* We didn't read the newline */
|
|
|
|
input_name = xstrdup(fname);
|
|
|
|
}
|
2013-11-04 13:13:06 +00:00
|
|
|
<PP_PRAGMA>midl_echo[^\n]* yyless(9); yy_pop_state(); return tCPPQUOTE;
|
2015-08-03 12:38:27 +00:00
|
|
|
<PP_PRAGMA>winrt[^\n]* {
|
2023-01-25 22:05:44 +00:00
|
|
|
if (!list_empty( &import_stack ))
|
|
|
|
{
|
2015-08-03 12:38:27 +00:00
|
|
|
if(!winrt_mode)
|
|
|
|
error_loc("winrt IDL file imported in non-winrt mode\n");
|
|
|
|
}else {
|
2015-08-05 10:52:15 +00:00
|
|
|
const char *ptr = yytext+5;
|
|
|
|
|
2015-08-03 12:38:27 +00:00
|
|
|
winrt_mode = TRUE;
|
2015-08-05 10:52:15 +00:00
|
|
|
|
|
|
|
while(isspace(*ptr))
|
|
|
|
ptr++;
|
|
|
|
if(!strncmp(ptr, "ns_prefix", 9) && (!*(ptr += 9) || isspace(*ptr)))
|
|
|
|
use_abi_namespace = TRUE;
|
2015-08-03 12:38:27 +00:00
|
|
|
}
|
|
|
|
yy_pop_state();
|
|
|
|
}
|
2023-01-24 21:19:45 +00:00
|
|
|
<PP_PRAGMA>[^\n]* yylval->str = xstrdup(yytext); yy_pop_state(); return aPRAGMA;
|
2023-01-24 21:19:45 +00:00
|
|
|
|
|
|
|
<ATTR>{
|
|
|
|
\] { yy_pop_state(); return ']'; }
|
|
|
|
|
|
|
|
{cident} { return attr_token( yytext, yylval ); }
|
|
|
|
{uuid} {
|
|
|
|
yylval->uuid = parse_uuid( yytext );
|
|
|
|
return aUUID;
|
|
|
|
}
|
|
|
|
}
|
2023-01-24 21:19:45 +00:00
|
|
|
|
|
|
|
<INITIAL>{
|
|
|
|
^{ws}*\#{ws}*pragma{ws}+ { yy_push_state( PP_PRAGMA ); }
|
|
|
|
^{ws}*midl_pragma{ws}+warning { return tPRAGMA_WARNING; }
|
|
|
|
|
|
|
|
{double} {
|
|
|
|
yylval->dbl = strtod( yytext, NULL );
|
|
|
|
return aDOUBLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-24 21:40:44 +00:00
|
|
|
SAFEARRAY{ws}*/\( return tSAFEARRAY;
|
2023-01-24 21:19:45 +00:00
|
|
|
{cident} return kw_token(yytext, yylval);
|
2023-01-24 21:19:45 +00:00
|
|
|
|
|
|
|
<INITIAL,ATTR>{
|
|
|
|
^{ws}*\#{ws}* { yy_push_state(PP_LINE); }
|
|
|
|
\[ { yy_push_state(ATTR); return '['; }
|
|
|
|
|
2023-01-24 21:19:45 +00:00
|
|
|
{hex} { return token_num( aHEXNUM, yytext, yylval ); }
|
|
|
|
{int} { return token_num( aNUM, yytext, yylval ); }
|
2023-01-24 21:19:45 +00:00
|
|
|
|
2023-03-17 08:04:57 +00:00
|
|
|
L\"(\\.|[^"\\])*\" { return token_str( aWSTRING, yytext + 1, yylval ); }
|
|
|
|
\"(\\.|[^"\\])*\" { return token_str( aSTRING, yytext, yylval ); }
|
|
|
|
\'(\\.|[^'\\])*\' { return token_str( aSQSTRING, yytext, yylval ); }
|
|
|
|
|
2023-01-24 21:19:45 +00:00
|
|
|
\n { line_number++; }
|
|
|
|
{ws} {}
|
|
|
|
\<\< { return SHL; }
|
|
|
|
\>\> { return SHR; }
|
|
|
|
\-\> { return MEMBERPTR; }
|
|
|
|
== { return EQUALITY; }
|
|
|
|
!= { return INEQUALITY; }
|
|
|
|
\>= { return GREATEREQUAL; }
|
|
|
|
\<= { return LESSEQUAL; }
|
|
|
|
\|\| { return LOGICALOR; }
|
|
|
|
&& { return LOGICALAND; }
|
|
|
|
\.\.\. { return ELLIPSIS; }
|
|
|
|
. { return yytext[0]; }
|
|
|
|
}
|
|
|
|
|
2002-07-16 03:20:45 +00:00
|
|
|
<<EOF>> {
|
2023-01-25 22:05:44 +00:00
|
|
|
if (!list_empty( &import_stack ))
|
2018-11-09 12:51:00 +00:00
|
|
|
return aEOF;
|
|
|
|
if (acf_name)
|
|
|
|
{
|
|
|
|
switch_to_acf();
|
|
|
|
return aACF;
|
|
|
|
}
|
|
|
|
yyterminate();
|
2002-07-16 03:20:45 +00:00
|
|
|
}
|
|
|
|
%%
|
|
|
|
|
2007-02-07 16:50:17 +00:00
|
|
|
struct keyword {
|
2002-07-16 03:20:45 +00:00
|
|
|
const char *kw;
|
|
|
|
int token;
|
2020-11-04 18:49:28 +00:00
|
|
|
int winrt_only : 1;
|
2007-02-07 16:50:17 +00:00
|
|
|
};
|
|
|
|
|
2008-05-06 14:05:40 +00:00
|
|
|
/* This table MUST be alphabetically sorted on the kw field */
|
2007-02-07 16:50:17 +00:00
|
|
|
static const struct keyword keywords[] = {
|
2020-11-04 18:49:28 +00:00
|
|
|
{"FALSE", tFALSE, 0},
|
|
|
|
{"NULL", tNULL, 0},
|
|
|
|
{"TRUE", tTRUE, 0},
|
|
|
|
{"__cdecl", tCDECL, 0},
|
|
|
|
{"__fastcall", tFASTCALL, 0},
|
|
|
|
{"__int32", tINT32, 0},
|
|
|
|
{"__int3264", tINT3264, 0},
|
|
|
|
{"__int64", tINT64, 0},
|
|
|
|
{"__pascal", tPASCAL, 0},
|
|
|
|
{"__stdcall", tSTDCALL, 0},
|
|
|
|
{"_cdecl", tCDECL, 0},
|
|
|
|
{"_fastcall", tFASTCALL, 0},
|
|
|
|
{"_pascal", tPASCAL, 0},
|
|
|
|
{"_stdcall", tSTDCALL, 0},
|
2020-12-01 14:01:56 +00:00
|
|
|
{"apicontract", tAPICONTRACT, 1},
|
2020-11-04 18:49:28 +00:00
|
|
|
{"boolean", tBOOLEAN, 0},
|
|
|
|
{"byte", tBYTE, 0},
|
|
|
|
{"case", tCASE, 0},
|
|
|
|
{"cdecl", tCDECL, 0},
|
|
|
|
{"char", tCHAR, 0},
|
|
|
|
{"coclass", tCOCLASS, 0},
|
|
|
|
{"const", tCONST, 0},
|
|
|
|
{"cpp_quote", tCPPQUOTE, 0},
|
2021-02-17 18:33:35 +00:00
|
|
|
{"declare", tDECLARE, 1},
|
2020-11-04 18:49:28 +00:00
|
|
|
{"default", tDEFAULT, 0},
|
2021-02-18 09:38:59 +00:00
|
|
|
{"delegate", tDELEGATE, 1},
|
2020-11-04 18:49:28 +00:00
|
|
|
{"dispinterface", tDISPINTERFACE, 0},
|
|
|
|
{"double", tDOUBLE, 0},
|
|
|
|
{"enum", tENUM, 0},
|
|
|
|
{"error_status_t", tERRORSTATUST, 0},
|
|
|
|
{"extern", tEXTERN, 0},
|
|
|
|
{"float", tFLOAT, 0},
|
|
|
|
{"handle_t", tHANDLET, 0},
|
|
|
|
{"hyper", tHYPER, 0},
|
|
|
|
{"import", tIMPORT, 0},
|
|
|
|
{"importlib", tIMPORTLIB, 0},
|
|
|
|
{"inline", tINLINE, 0},
|
|
|
|
{"int", tINT, 0},
|
|
|
|
{"interface", tINTERFACE, 0},
|
|
|
|
{"library", tLIBRARY, 0},
|
|
|
|
{"long", tLONG, 0},
|
|
|
|
{"methods", tMETHODS, 0},
|
|
|
|
{"module", tMODULE, 0},
|
|
|
|
{"namespace", tNAMESPACE, 1},
|
|
|
|
{"pascal", tPASCAL, 0},
|
|
|
|
{"properties", tPROPERTIES, 0},
|
|
|
|
{"register", tREGISTER, 0},
|
2021-02-09 09:37:21 +00:00
|
|
|
{"requires", tREQUIRES, 1},
|
2021-01-27 20:20:45 +00:00
|
|
|
{"runtimeclass", tRUNTIMECLASS, 1},
|
2020-11-04 18:49:28 +00:00
|
|
|
{"short", tSHORT, 0},
|
|
|
|
{"signed", tSIGNED, 0},
|
|
|
|
{"sizeof", tSIZEOF, 0},
|
|
|
|
{"small", tSMALL, 0},
|
|
|
|
{"static", tSTATIC, 0},
|
|
|
|
{"stdcall", tSTDCALL, 0},
|
|
|
|
{"struct", tSTRUCT, 0},
|
|
|
|
{"switch", tSWITCH, 0},
|
|
|
|
{"typedef", tTYPEDEF, 0},
|
|
|
|
{"union", tUNION, 0},
|
|
|
|
{"unsigned", tUNSIGNED, 0},
|
|
|
|
{"void", tVOID, 0},
|
|
|
|
{"wchar_t", tWCHAR, 0},
|
2002-07-16 03:20:45 +00:00
|
|
|
};
|
2002-11-30 01:49:46 +00:00
|
|
|
#define NKEYWORDS (sizeof(keywords)/sizeof(keywords[0]))
|
2007-02-07 16:50:17 +00:00
|
|
|
|
2008-05-06 14:05:40 +00:00
|
|
|
/* keywords only recognized in attribute lists
|
|
|
|
* This table MUST be alphabetically sorted on the kw field
|
|
|
|
*/
|
2007-02-07 16:50:17 +00:00
|
|
|
static const struct keyword attr_keywords[] =
|
|
|
|
{
|
2021-02-09 09:37:19 +00:00
|
|
|
{"activatable", tACTIVATABLE, 1},
|
2020-11-04 18:49:28 +00:00
|
|
|
{"aggregatable", tAGGREGATABLE, 0},
|
2021-01-25 11:35:29 +00:00
|
|
|
{"agile", tAGILE, 1},
|
2020-11-04 18:49:28 +00:00
|
|
|
{"all_nodes", tALLNODES, 0},
|
|
|
|
{"allocate", tALLOCATE, 0},
|
|
|
|
{"annotation", tANNOTATION, 0},
|
|
|
|
{"apartment", tAPARTMENT, 0},
|
|
|
|
{"appobject", tAPPOBJECT, 0},
|
|
|
|
{"async", tASYNC, 0},
|
|
|
|
{"async_uuid", tASYNCUUID, 0},
|
|
|
|
{"auto_handle", tAUTOHANDLE, 0},
|
|
|
|
{"bindable", tBINDABLE, 0},
|
|
|
|
{"both", tBOTH, 0},
|
|
|
|
{"broadcast", tBROADCAST, 0},
|
|
|
|
{"byte_count", tBYTECOUNT, 0},
|
|
|
|
{"call_as", tCALLAS, 0},
|
|
|
|
{"callback", tCALLBACK, 0},
|
|
|
|
{"code", tCODE, 0},
|
|
|
|
{"comm_status", tCOMMSTATUS, 0},
|
|
|
|
{"context_handle", tCONTEXTHANDLE, 0},
|
|
|
|
{"context_handle_noserialize", tCONTEXTHANDLENOSERIALIZE, 0},
|
|
|
|
{"context_handle_serialize", tCONTEXTHANDLENOSERIALIZE, 0},
|
2020-12-01 14:01:57 +00:00
|
|
|
{"contract", tCONTRACT, 1},
|
2020-12-01 14:01:55 +00:00
|
|
|
{"contractversion", tCONTRACTVERSION, 1},
|
2020-11-04 18:49:28 +00:00
|
|
|
{"control", tCONTROL, 0},
|
2020-11-18 01:14:14 +00:00
|
|
|
{"custom", tCUSTOM, 0},
|
2020-11-04 18:49:28 +00:00
|
|
|
{"decode", tDECODE, 0},
|
|
|
|
{"defaultbind", tDEFAULTBIND, 0},
|
|
|
|
{"defaultcollelem", tDEFAULTCOLLELEM, 0},
|
|
|
|
{"defaultvalue", tDEFAULTVALUE, 0},
|
|
|
|
{"defaultvtable", tDEFAULTVTABLE, 0},
|
|
|
|
{"disable_consistency_check", tDISABLECONSISTENCYCHECK, 0},
|
|
|
|
{"displaybind", tDISPLAYBIND, 0},
|
|
|
|
{"dllname", tDLLNAME, 0},
|
|
|
|
{"dont_free", tDONTFREE, 0},
|
|
|
|
{"dual", tDUAL, 0},
|
|
|
|
{"enable_allocate", tENABLEALLOCATE, 0},
|
|
|
|
{"encode", tENCODE, 0},
|
|
|
|
{"endpoint", tENDPOINT, 0},
|
|
|
|
{"entry", tENTRY, 0},
|
2021-01-29 08:50:06 +00:00
|
|
|
{"eventadd", tEVENTADD, 1},
|
|
|
|
{"eventremove", tEVENTREMOVE, 1},
|
2021-01-26 14:36:30 +00:00
|
|
|
{"exclusiveto", tEXCLUSIVETO, 1},
|
2020-11-04 18:49:28 +00:00
|
|
|
{"explicit_handle", tEXPLICITHANDLE, 0},
|
|
|
|
{"fault_status", tFAULTSTATUS, 0},
|
2021-01-29 08:50:05 +00:00
|
|
|
{"flags", tFLAGS, 1},
|
2020-11-04 18:49:28 +00:00
|
|
|
{"force_allocate", tFORCEALLOCATE, 0},
|
|
|
|
{"free", tFREE, 0},
|
|
|
|
{"handle", tHANDLE, 0},
|
|
|
|
{"helpcontext", tHELPCONTEXT, 0},
|
|
|
|
{"helpfile", tHELPFILE, 0},
|
|
|
|
{"helpstring", tHELPSTRING, 0},
|
|
|
|
{"helpstringcontext", tHELPSTRINGCONTEXT, 0},
|
|
|
|
{"helpstringdll", tHELPSTRINGDLL, 0},
|
|
|
|
{"hidden", tHIDDEN, 0},
|
|
|
|
{"id", tID, 0},
|
|
|
|
{"idempotent", tIDEMPOTENT, 0},
|
|
|
|
{"ignore", tIGNORE, 0},
|
|
|
|
{"iid_is", tIIDIS, 0},
|
|
|
|
{"immediatebind", tIMMEDIATEBIND, 0},
|
|
|
|
{"implicit_handle", tIMPLICITHANDLE, 0},
|
|
|
|
{"in", tIN, 0},
|
|
|
|
{"in_line", tIN_LINE, 0},
|
|
|
|
{"input_sync", tINPUTSYNC, 0},
|
|
|
|
{"lcid", tLCID, 0},
|
|
|
|
{"length_is", tLENGTHIS, 0},
|
|
|
|
{"licensed", tLICENSED, 0},
|
|
|
|
{"local", tLOCAL, 0},
|
2021-01-25 11:35:29 +00:00
|
|
|
{"marshaling_behavior", tMARSHALINGBEHAVIOR, 1},
|
2020-11-04 18:49:28 +00:00
|
|
|
{"maybe", tMAYBE, 0},
|
|
|
|
{"message", tMESSAGE, 0},
|
2021-01-26 14:36:29 +00:00
|
|
|
{"mta" , tMTA, 0},
|
2020-11-04 18:49:28 +00:00
|
|
|
{"neutral", tNEUTRAL, 0},
|
|
|
|
{"nocode", tNOCODE, 0},
|
|
|
|
{"nonbrowsable", tNONBROWSABLE, 0},
|
|
|
|
{"noncreatable", tNONCREATABLE, 0},
|
2021-01-25 11:35:29 +00:00
|
|
|
{"none", tNONE, 1},
|
2020-11-04 18:49:28 +00:00
|
|
|
{"nonextensible", tNONEXTENSIBLE, 0},
|
|
|
|
{"notify", tNOTIFY, 0},
|
|
|
|
{"notify_flag", tNOTIFYFLAG, 0},
|
|
|
|
{"object", tOBJECT, 0},
|
|
|
|
{"odl", tODL, 0},
|
|
|
|
{"oleautomation", tOLEAUTOMATION, 0},
|
|
|
|
{"optimize", tOPTIMIZE, 0},
|
|
|
|
{"optional", tOPTIONAL, 0},
|
|
|
|
{"out", tOUT, 0},
|
2022-01-25 16:07:28 +00:00
|
|
|
{"overload", tOVERLOAD, 0},
|
2020-11-04 18:49:28 +00:00
|
|
|
{"partial_ignore", tPARTIALIGNORE, 0},
|
|
|
|
{"pointer_default", tPOINTERDEFAULT, 0},
|
|
|
|
{"progid", tPROGID, 0},
|
|
|
|
{"propget", tPROPGET, 0},
|
|
|
|
{"propput", tPROPPUT, 0},
|
|
|
|
{"propputref", tPROPPUTREF, 0},
|
|
|
|
{"proxy", tPROXY, 0},
|
|
|
|
{"ptr", tPTR, 0},
|
|
|
|
{"public", tPUBLIC, 0},
|
|
|
|
{"range", tRANGE, 0},
|
|
|
|
{"readonly", tREADONLY, 0},
|
|
|
|
{"ref", tREF, 0},
|
|
|
|
{"represent_as", tREPRESENTAS, 0},
|
|
|
|
{"requestedit", tREQUESTEDIT, 0},
|
|
|
|
{"restricted", tRESTRICTED, 0},
|
|
|
|
{"retval", tRETVAL, 0},
|
|
|
|
{"single", tSINGLE, 0},
|
|
|
|
{"single_node", tSINGLENODE, 0},
|
|
|
|
{"size_is", tSIZEIS, 0},
|
|
|
|
{"source", tSOURCE, 0},
|
2021-01-25 11:35:29 +00:00
|
|
|
{"standard", tSTANDARD, 1},
|
2021-02-09 09:37:20 +00:00
|
|
|
{"static", tSTATIC, 1},
|
2020-11-04 18:49:28 +00:00
|
|
|
{"strict_context_handle", tSTRICTCONTEXTHANDLE, 0},
|
|
|
|
{"string", tSTRING, 0},
|
|
|
|
{"switch_is", tSWITCHIS, 0},
|
|
|
|
{"switch_type", tSWITCHTYPE, 0},
|
|
|
|
{"threading", tTHREADING, 0},
|
|
|
|
{"transmit_as", tTRANSMITAS, 0},
|
|
|
|
{"uidefault", tUIDEFAULT, 0},
|
|
|
|
{"unique", tUNIQUE, 0},
|
|
|
|
{"user_marshal", tUSERMARSHAL, 0},
|
|
|
|
{"usesgetlasterror", tUSESGETLASTERROR, 0},
|
|
|
|
{"uuid", tUUID, 0},
|
|
|
|
{"v1_enum", tV1ENUM, 0},
|
|
|
|
{"vararg", tVARARG, 0},
|
|
|
|
{"version", tVERSION, 0},
|
|
|
|
{"vi_progid", tVIPROGID, 0},
|
|
|
|
{"wire_marshal", tWIREMARSHAL, 0},
|
2007-02-07 16:50:17 +00:00
|
|
|
};
|
|
|
|
|
2010-10-21 12:13:38 +00:00
|
|
|
/* attributes TODO:
|
|
|
|
first_is
|
|
|
|
last_is
|
|
|
|
max_is
|
|
|
|
min_is
|
|
|
|
*/
|
2007-02-07 16:50:17 +00:00
|
|
|
|
2004-12-06 20:43:55 +00:00
|
|
|
#define KWP(p) ((const struct keyword *)(p))
|
2002-11-30 01:49:46 +00:00
|
|
|
|
|
|
|
static int kw_cmp_func(const void *s1, const void *s2)
|
|
|
|
{
|
|
|
|
return strcmp(KWP(s1)->kw, KWP(s2)->kw);
|
|
|
|
}
|
2002-07-16 03:20:45 +00:00
|
|
|
|
2023-01-24 21:19:45 +00:00
|
|
|
static int kw_token(const char *kw, YYSTYPE *yylval)
|
2002-07-16 03:20:45 +00:00
|
|
|
{
|
2002-11-30 01:49:46 +00:00
|
|
|
struct keyword key, *kwp;
|
|
|
|
key.kw = kw;
|
|
|
|
kwp = bsearch(&key, keywords, NKEYWORDS, sizeof(keywords[0]), kw_cmp_func);
|
2020-11-04 18:49:28 +00:00
|
|
|
if (kwp && (!kwp->winrt_only || winrt_mode)) {
|
2023-01-24 21:19:45 +00:00
|
|
|
yylval->str = xstrdup(kwp->kw);
|
2002-12-03 19:12:07 +00:00
|
|
|
return kwp->token;
|
|
|
|
}
|
2023-01-24 21:19:45 +00:00
|
|
|
yylval->str = xstrdup(kw);
|
2021-02-08 08:30:46 +00:00
|
|
|
return is_type(kw) ? aKNOWNTYPE : aIDENTIFIER;
|
2002-07-16 03:20:45 +00:00
|
|
|
}
|
|
|
|
|
2023-01-24 21:19:45 +00:00
|
|
|
static int attr_token(const char *kw, YYSTYPE *yylval)
|
2007-02-07 16:50:17 +00:00
|
|
|
{
|
|
|
|
struct keyword key, *kwp;
|
|
|
|
key.kw = kw;
|
|
|
|
kwp = bsearch(&key, attr_keywords, sizeof(attr_keywords)/sizeof(attr_keywords[0]),
|
|
|
|
sizeof(attr_keywords[0]), kw_cmp_func);
|
2020-11-04 18:49:28 +00:00
|
|
|
if (kwp && (!kwp->winrt_only || winrt_mode)) {
|
2023-01-24 21:19:45 +00:00
|
|
|
yylval->str = xstrdup(kwp->kw);
|
2007-02-07 16:50:17 +00:00
|
|
|
return kwp->token;
|
|
|
|
}
|
2023-01-24 21:19:45 +00:00
|
|
|
return kw_token(kw, yylval);
|
2007-02-07 16:50:17 +00:00
|
|
|
}
|
|
|
|
|
2008-04-01 11:47:56 +00:00
|
|
|
void pop_import(void)
|
2002-07-16 03:20:45 +00:00
|
|
|
{
|
2023-01-25 22:05:44 +00:00
|
|
|
struct list *entry = list_head( &import_stack );
|
|
|
|
struct import_state *state;
|
|
|
|
assert( entry );
|
|
|
|
|
|
|
|
state = LIST_ENTRY( entry, struct import_state, entry );
|
|
|
|
list_remove( &state->entry );
|
|
|
|
parse_only = !list_empty( &import_stack );
|
|
|
|
|
|
|
|
if (yyin) fclose( yyin );
|
|
|
|
yy_delete_buffer( YY_CURRENT_BUFFER );
|
|
|
|
yy_switch_to_buffer( state->buffer );
|
2023-03-17 12:47:01 +00:00
|
|
|
|
2023-01-25 22:05:44 +00:00
|
|
|
input_name = state->input_name;
|
|
|
|
line_number = state->line_number;
|
|
|
|
free( state );
|
2002-07-16 03:20:45 +00:00
|
|
|
}
|
|
|
|
|
2023-01-25 22:02:38 +00:00
|
|
|
void push_import( char *import_name )
|
2002-07-16 03:20:45 +00:00
|
|
|
{
|
2023-01-25 22:05:44 +00:00
|
|
|
struct import_state *state;
|
2023-01-24 21:19:45 +00:00
|
|
|
struct import *import;
|
2023-03-15 08:48:20 +00:00
|
|
|
FILE *file;
|
2018-01-26 21:09:04 +00:00
|
|
|
|
2023-01-25 22:05:44 +00:00
|
|
|
state = xmalloc( sizeof(struct import_state ));
|
|
|
|
list_add_head( &import_stack, &state->entry );
|
|
|
|
parse_only = !list_empty( &import_stack );
|
2023-01-25 22:02:38 +00:00
|
|
|
|
2023-01-25 22:05:44 +00:00
|
|
|
state->buffer = YY_CURRENT_BUFFER;
|
|
|
|
state->input_name = input_name;
|
|
|
|
state->line_number = line_number;
|
|
|
|
input_name = NULL;
|
2023-01-25 22:02:38 +00:00
|
|
|
|
|
|
|
/* reset buffer for <<EOF>>, in case import fails or already imported */
|
|
|
|
yy_scan_string( "" );
|
|
|
|
|
2023-01-24 21:19:45 +00:00
|
|
|
LIST_FOR_EACH_ENTRY( import, &imports, struct import, entry )
|
2023-01-25 22:02:38 +00:00
|
|
|
if (!strcmp( import->name, import_name )) return; /* already imported */
|
2018-01-26 21:09:04 +00:00
|
|
|
|
2023-01-24 21:19:45 +00:00
|
|
|
import = xmalloc( sizeof(struct import) );
|
2023-01-25 22:02:38 +00:00
|
|
|
import->name = xstrdup( import_name );
|
2023-01-24 21:19:45 +00:00
|
|
|
list_add_tail( &imports, &import->entry );
|
2018-01-26 21:09:04 +00:00
|
|
|
|
2023-03-20 12:36:14 +00:00
|
|
|
input_name = find_input_file( import_name, state->input_name );
|
2023-03-15 08:48:20 +00:00
|
|
|
file = open_input_file( input_name );
|
2018-01-26 21:09:04 +00:00
|
|
|
line_number = 1;
|
2002-07-16 03:20:45 +00:00
|
|
|
|
2023-03-15 08:48:20 +00:00
|
|
|
yy_switch_to_buffer( yy_create_buffer( file, YY_BUF_SIZE ) );
|
2002-07-16 03:20:45 +00:00
|
|
|
}
|
|
|
|
|
2018-11-09 12:51:00 +00:00
|
|
|
static void switch_to_acf(void)
|
|
|
|
{
|
2023-03-15 08:48:20 +00:00
|
|
|
FILE *file;
|
2018-11-09 12:51:00 +00:00
|
|
|
|
2023-01-25 22:05:44 +00:00
|
|
|
if (yyin) fclose( yyin );
|
|
|
|
yy_delete_buffer( YY_CURRENT_BUFFER );
|
2018-11-09 12:51:00 +00:00
|
|
|
|
2023-03-15 08:48:20 +00:00
|
|
|
input_name = xstrdup( acf_name );
|
|
|
|
file = open_input_file( input_name );
|
2018-11-09 12:51:00 +00:00
|
|
|
line_number = 1;
|
2023-03-15 08:48:20 +00:00
|
|
|
acf_name = NULL;
|
2018-11-09 12:51:00 +00:00
|
|
|
|
2023-03-15 08:48:20 +00:00
|
|
|
yy_switch_to_buffer( yy_create_buffer( file, YY_BUF_SIZE ) );
|
2018-11-09 12:51:00 +00:00
|
|
|
}
|
|
|
|
|
2016-03-29 20:06:45 +00:00
|
|
|
static void warning_disable(int warning)
|
|
|
|
{
|
|
|
|
warning_t *warning_entry;
|
|
|
|
LIST_FOR_EACH_ENTRY(warning_entry, disabled_warnings, warning_t, entry)
|
|
|
|
if(warning_entry->num == warning)
|
|
|
|
return;
|
|
|
|
warning_entry = xmalloc( sizeof(*warning_entry) );
|
|
|
|
warning_entry->num = warning;
|
|
|
|
list_add_tail(disabled_warnings, &warning_entry->entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void warning_enable(int warning)
|
|
|
|
{
|
|
|
|
warning_t *warning_entry;
|
|
|
|
LIST_FOR_EACH_ENTRY(warning_entry, disabled_warnings, warning_t, entry)
|
|
|
|
if(warning_entry->num == warning)
|
|
|
|
{
|
|
|
|
list_remove(&warning_entry->entry);
|
|
|
|
free(warning_entry);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-16 19:53:52 +00:00
|
|
|
int do_warning(const char *toggle, warning_list_t *wnum)
|
2016-03-29 20:06:45 +00:00
|
|
|
{
|
|
|
|
warning_t *warning, *next;
|
|
|
|
int ret = 1;
|
|
|
|
if(!disabled_warnings)
|
|
|
|
{
|
|
|
|
disabled_warnings = xmalloc( sizeof(*disabled_warnings) );
|
|
|
|
list_init( disabled_warnings );
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!strcmp(toggle, "disable"))
|
|
|
|
LIST_FOR_EACH_ENTRY(warning, wnum, warning_t, entry)
|
|
|
|
warning_disable(warning->num);
|
2021-02-16 19:53:52 +00:00
|
|
|
else if(!strcmp(toggle, "enable") || !strcmp(toggle, "default"))
|
2016-03-29 20:06:45 +00:00
|
|
|
LIST_FOR_EACH_ENTRY(warning, wnum, warning_t, entry)
|
|
|
|
warning_enable(warning->num);
|
|
|
|
else
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(warning, next, wnum, warning_t, entry)
|
|
|
|
free(warning);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int is_warning_enabled(int warning)
|
|
|
|
{
|
|
|
|
warning_t *warning_entry;
|
|
|
|
if(!disabled_warnings)
|
|
|
|
return 1;
|
|
|
|
LIST_FOR_EACH_ENTRY(warning_entry, disabled_warnings, warning_t, entry)
|
|
|
|
if(warning_entry->num == warning)
|
|
|
|
return 0;
|
|
|
|
return 1;
|
|
|
|
}
|