%{ /* * Copyright 1994 Martin von Loewis * Copyright 1998-2000 Bertho A. Stultiens (BS) * 1999 Juergen Schmied (JS) * * 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 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * History: * 24-Jul-2000 BS - Made a fix for broken Berkeley yacc on * non-terminals (see cjunk rule). * 21-May-2000 BS - Partial implementation of font resources. * - Corrected language propagation for binary * resources such as bitmaps, icons, cursors, * userres and rcdata. The language is now * correct in .res files. * - Fixed reading the resource name as ident, * so that it may overlap keywords. * 20-May-2000 BS - Implemented animated cursors and icons * resource types. * 30-Apr-2000 BS - Reintegration into the wine-tree * 14-Jan-2000 BS - Redid the usertype resources so that they * are compatible. * 02-Jan-2000 BS - Removed the preprocessor from the grammar * except for the # command (line numbers). * * 06-Nov-1999 JS - see CHANGES * * 29-Dec-1998 AdH - Grammar and function extensions. * grammar: TOOLBAR resources, Named ICONs in * DIALOGS * functions: semantic actions for the grammar * changes, resource files can now be anywhere * on the include path instead of just in the * current directory * * 20-Jun-1998 BS - Fixed a bug in load_file() where the name was not * printed out correctly. * * 17-Jun-1998 BS - Fixed a bug in CLASS statement parsing which should * also accept a tSTRING as argument. * * 25-May-1998 BS - Found out that I need to support language, version * and characteristics in inline resources (bitmap, * cursor, etc) but they can also be specified with * a filename. This renders my filename-scanning scheme * worthless. Need to build newline parsing to solve * this one. * It will come with version 1.1.0 (sigh). * * 19-May-1998 BS - Started to build a builtin preprocessor * * 30-Apr-1998 BS - Redid the stringtable parsing/handling. My previous * ideas had some serious flaws. * * 27-Apr-1998 BS - Removed a lot of dead comments and put it in a doc * file. * * 21-Apr-1998 BS - Added correct behavior for cursors and icons. * - This file is growing too big. It is time to strip * things and put it in a support file. * * 19-Apr-1998 BS - Tagged the stringtable resource so that only one * resource will be created. This because the table * has a different layout than other resources. The * table has to be sorted, and divided into smaller * resource entries (see comment in source). * * 17-Apr-1998 BS - Almost all strings, including identifiers, are parsed * as string_t which include unicode strings upon * input. * - Parser now emits a warning when compiling win32 * extensions in win16 mode. * * 16-Apr-1998 BS - Raw data elements are now *optionally* separated * by commas. Read the comments in file sq2dq.l. * - FIXME: there are instances in the source that rely * on the fact that int==32bit and pointers are int size. * - Fixed the conflict in menuex by changing a rule * back into right recursion. See note in source. * - UserType resources cannot have an expression as its * typeclass. See note in source. * * 15-Apr-1998 BS - Changed all right recursion into left recursion to * get reduction of the parsestack. * This also helps communication between bison and flex. * Main advantage is that the Empty rule gets reduced * first, which is used to allocate/link things. * It also added a shift/reduce conflict in the menuex * handling, due to expression/option possibility, * although not serious. * * 14-Apr-1998 BS - Redone almost the entire parser. We're not talking * about making it more efficient, but readable (for me) * and slightly easier to expand/change. * This is done primarily by using more reduce states * with many (intuitive) types for the various resource * statements. * - Added expression handling for all resources where a * number is accepted (not only for win32). Also added * multiply and division (not MS compatible, but handy). * Unary minus introduced a shift/reduce conflict, but * it is not serious. * * 13-Apr-1998 BS - Reordered a lot of things * - Made the source more readable * - Added Win32 resource definitions * - Corrected syntax problems with an old yacc (;) * - Added extra comment about grammar */ #include "config.h" #include #include #include #include #include #include #ifdef HAVE_ALLOCA_H #include #endif #include "wrc.h" #include "utils.h" #include "newstruc.h" #include "dumpres.h" #include "wine/wpp.h" #include "wine/unicode.h" #include "parser.h" #include "windef.h" #include "winbase.h" #include "wingdi.h" #include "winuser.h" #if defined(YYBYACC) /* Berkeley yacc (byacc) doesn't seem to know about these */ /* Some *BSD supplied versions do define these though */ # ifndef YYEMPTY # define YYEMPTY (-1) /* Empty lookahead value of yychar */ # endif # ifndef YYLEX # define YYLEX yylex() # endif #elif defined(YYBISON) /* Bison was used for original development */ /* #define YYEMPTY -2 */ /* #define YYLEX yylex() */ #else /* No yacc we know yet */ # if !defined(YYEMPTY) || !defined(YYLEX) # error Yacc version/type unknown. This version needs to be verified for settings of YYEMPTY and YYLEX. # elif defined(__GNUC__) /* gcc defines the #warning directive */ # warning Yacc version/type unknown. It defines YYEMPTY and YYLEX, but is not tested /* #else we just take a chance that it works... */ # endif #endif int want_nl = 0; /* Signal flex that we need the next newline */ int want_id = 0; /* Signal flex that we need the next identifier */ stringtable_t *tagstt; /* Stringtable tag. * It is set while parsing a stringtable to one of * the stringtables in the sttres list or a new one * if the language was not parsed before. */ stringtable_t *sttres; /* Stringtable resources. This holds the list of * stringtables with different lanuages */ static int dont_want_id = 0; /* See language parsing for details */ /* Set to the current options of the currently scanning stringtable */ static int *tagstt_memopt; static characts_t *tagstt_characts; static version_t *tagstt_version; static const char riff[4] = "RIFF"; /* RIFF file magic for animated cursor/icon */ /* Prototypes of here defined functions */ static event_t *get_event_head(event_t *p); static control_t *get_control_head(control_t *p); static ver_value_t *get_ver_value_head(ver_value_t *p); static ver_block_t *get_ver_block_head(ver_block_t *p); static resource_t *get_resource_head(resource_t *p); static menuex_item_t *get_itemex_head(menuex_item_t *p); static menu_item_t *get_item_head(menu_item_t *p); static raw_data_t *merge_raw_data_str(raw_data_t *r1, string_t *str); static raw_data_t *merge_raw_data_int(raw_data_t *r1, int i); static raw_data_t *merge_raw_data_long(raw_data_t *r1, int i); static raw_data_t *merge_raw_data(raw_data_t *r1, raw_data_t *r2); static raw_data_t *str2raw_data(string_t *str); static raw_data_t *int2raw_data(int i); static raw_data_t *long2raw_data(int i); static raw_data_t *load_file(string_t *name, language_t *lang); static itemex_opt_t *new_itemex_opt(int id, int type, int state, int helpid); static event_t *add_string_event(string_t *key, int id, int flags, event_t *prev); static event_t *add_event(int key, int id, int flags, event_t *prev); static dialogex_t *dialogex_version(version_t *v, dialogex_t *dlg); static dialogex_t *dialogex_characteristics(characts_t *c, dialogex_t *dlg); static dialogex_t *dialogex_language(language_t *l, dialogex_t *dlg); static dialogex_t *dialogex_menu(name_id_t *m, dialogex_t *dlg); static dialogex_t *dialogex_class(name_id_t *n, dialogex_t *dlg); static dialogex_t *dialogex_font(font_id_t *f, dialogex_t *dlg); static dialogex_t *dialogex_caption(string_t *s, dialogex_t *dlg); static dialogex_t *dialogex_exstyle(style_t *st, dialogex_t *dlg); static dialogex_t *dialogex_style(style_t *st, dialogex_t *dlg); static name_id_t *convert_ctlclass(name_id_t *cls); static control_t *ins_ctrl(int type, int special_style, control_t *ctrl, control_t *prev); static dialog_t *dialog_version(version_t *v, dialog_t *dlg); static dialog_t *dialog_characteristics(characts_t *c, dialog_t *dlg); static dialog_t *dialog_language(language_t *l, dialog_t *dlg); static dialog_t *dialog_menu(name_id_t *m, dialog_t *dlg); static dialog_t *dialog_class(name_id_t *n, dialog_t *dlg); static dialog_t *dialog_font(font_id_t *f, dialog_t *dlg); static dialog_t *dialog_caption(string_t *s, dialog_t *dlg); static dialog_t *dialog_exstyle(style_t * st, dialog_t *dlg); static dialog_t *dialog_style(style_t * st, dialog_t *dlg); static resource_t *build_stt_resources(stringtable_t *stthead); static stringtable_t *find_stringtable(lvc_t *lvc); static toolbar_item_t *ins_tlbr_button(toolbar_item_t *prev, toolbar_item_t *idrec); static toolbar_item_t *get_tlbr_buttons_head(toolbar_item_t *p, int *nitems); static string_t *make_filename(string_t *s); static resource_t *build_fontdirs(resource_t *tail); static resource_t *build_fontdir(resource_t **fnt, int nfnt); static int rsrcid_to_token(int lookahead); %} %union{ string_t *str; int num; int *iptr; char *cptr; resource_t *res; accelerator_t *acc; bitmap_t *bmp; dialog_t *dlg; dialogex_t *dlgex; font_t *fnt; fontdir_t *fnd; menu_t *men; menuex_t *menex; rcdata_t *rdt; stringtable_t *stt; stt_entry_t *stte; user_t *usr; messagetable_t *msg; versioninfo_t *veri; control_t *ctl; name_id_t *nid; font_id_t *fntid; language_t *lan; version_t *ver; characts_t *chars; event_t *event; menu_item_t *menitm; menuex_item_t *menexitm; itemex_opt_t *exopt; raw_data_t *raw; lvc_t *lvc; ver_value_t *val; ver_block_t *blk; ver_words_t *verw; toolbar_t *tlbar; toolbar_item_t *tlbarItems; dlginit_t *dginit; style_pair_t *styles; style_t *style; ani_any_t *ani; } %token tNL %token tNUMBER tLNUMBER %token tSTRING tIDENT tFILENAME %token tRAWDATA %token tACCELERATORS tBITMAP tCURSOR tDIALOG tDIALOGEX tMENU tMENUEX tMESSAGETABLE %token tRCDATA tVERSIONINFO tSTRINGTABLE tFONT tFONTDIR tICON %token tAUTO3STATE tAUTOCHECKBOX tAUTORADIOBUTTON tCHECKBOX tDEFPUSHBUTTON %token tPUSHBUTTON tRADIOBUTTON tSTATE3 /* PUSHBOX */ %token tGROUPBOX tCOMBOBOX tLISTBOX tSCROLLBAR %token tCONTROL tEDITTEXT %token tRTEXT tCTEXT tLTEXT %token tBLOCK tVALUE %token tSHIFT tALT tASCII tVIRTKEY tGRAYED tCHECKED tINACTIVE tNOINVERT %token tPURE tIMPURE tDISCARDABLE tLOADONCALL tPRELOAD tFIXED tMOVEABLE %token tCLASS tCAPTION tCHARACTERISTICS tEXSTYLE tSTYLE tVERSION tLANGUAGE %token tFILEVERSION tPRODUCTVERSION tFILEFLAGSMASK tFILEOS tFILETYPE tFILEFLAGS tFILESUBTYPE %token tMENUBARBREAK tMENUBREAK tMENUITEM tPOPUP tSEPARATOR %token tHELP %token tSTRING tIDENT tRAWDATA %token tTOOLBAR tBUTTON %token tBEGIN tEND %token tDLGINIT %left '|' %left '^' %left '&' %left '+' '-' %left '*' '/' %right '~' tNOT %left pUPM %type resource_file resource resources resource_definition %type stringtable strings %type font %type fontdir %type accelerators %type events %type bitmap %type cursor icon %type dialog dlg_attributes %type ctrls gen_ctrl lab_ctrl ctrl_desc iconinfo %type helpid %type dialogex dlgex_attribs %type exctrls gen_exctrl lab_exctrl exctrl_desc %type rcdata %type raw_data raw_elements opt_data file_raw %type versioninfo fix_version %type ver_words %type ver_blocks ver_block %type ver_values ver_value %type menu %type item_definitions menu_body %type menuex %type itemex_definitions menuex_body %type itemex_p_options itemex_options %type messagetable %type userres %type item_options %type nameid nameid_s ctlclass usertype %type acc_opt acc accs %type loadmemopts lamo lama %type opt_font opt_exfont opt_expr %type opt_lvc %type opt_language %type opt_characts %type opt_version %type expr xpr %type e_expr %type toolbar %type toolbar_items %type dlginit %type optional_style_pair %type any_num %type