1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014 |
- %{ /* rcparse.y -- parser for Windows rc files
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
- Written by Ian Lance Taylor, Cygnus Support.
- Extended by Kai Tietz, Onevision.
- This file is part of GNU Binutils.
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
- This program 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 General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
- 02110-1301, USA. */
- /* This is a parser for Windows rc files. It is based on the parser
- by Gunther Ebert <gunther.ebert@ixos-leipzig.de>. */
- #include "sysdep.h"
- #include "bfd.h"
- #include "bucomm.h"
- #include "libiberty.h"
- #include "windres.h"
- #include "safe-ctype.h"
- /* The current language. */
- static unsigned short language;
- /* The resource information during a sub statement. */
- static rc_res_res_info sub_res_info;
- /* Dialog information. This is built by the nonterminals styles and
- controls. */
- static rc_dialog dialog;
- /* This is used when building a style. It is modified by the
- nonterminal styleexpr. */
- static unsigned long style;
- /* These are used when building a control. They are set before using
- control_params. */
- static rc_uint_type base_style;
- static rc_uint_type default_style;
- static rc_res_id class;
- static rc_res_id res_text_field;
- static unichar null_unichar;
- /* This is used for COMBOBOX, LISTBOX and EDITTEXT which
- do not allow resource 'text' field in control definition. */
- static const rc_res_id res_null_text = { 1, {{0, &null_unichar}}};
- %}
- %union
- {
- rc_accelerator acc;
- rc_accelerator *pacc;
- rc_dialog_control *dialog_control;
- rc_menuitem *menuitem;
- struct
- {
- rc_rcdata_item *first;
- rc_rcdata_item *last;
- } rcdata;
- rc_rcdata_item *rcdata_item;
- rc_fixed_versioninfo *fixver;
- rc_ver_info *verinfo;
- rc_ver_stringtable *verstringtable;
- rc_ver_stringinfo *verstring;
- rc_ver_varinfo *vervar;
- rc_toolbar_item *toobar_item;
- rc_res_id id;
- rc_res_res_info res_info;
- struct
- {
- rc_uint_type on;
- rc_uint_type off;
- } memflags;
- struct
- {
- rc_uint_type val;
- /* Nonzero if this number was explicitly specified as long. */
- int dword;
- } i;
- rc_uint_type il;
- rc_uint_type is;
- const char *s;
- struct
- {
- rc_uint_type length;
- const char *s;
- } ss;
- unichar *uni;
- struct
- {
- rc_uint_type length;
- const unichar *s;
- } suni;
- };
- %token BEG END
- %token ACCELERATORS VIRTKEY ASCII NOINVERT SHIFT CONTROL ALT
- %token BITMAP
- %token CURSOR
- %token DIALOG DIALOGEX EXSTYLE CAPTION CLASS STYLE
- %token AUTO3STATE AUTOCHECKBOX AUTORADIOBUTTON CHECKBOX COMBOBOX CTEXT
- %token DEFPUSHBUTTON EDITTEXT GROUPBOX LISTBOX LTEXT PUSHBOX PUSHBUTTON
- %token RADIOBUTTON RTEXT SCROLLBAR STATE3 USERBUTTON
- %token BEDIT HEDIT IEDIT
- %token FONT
- %token ICON
- %token ANICURSOR ANIICON DLGINCLUDE DLGINIT FONTDIR HTML MANIFEST PLUGPLAY VXD TOOLBAR BUTTON
- %token LANGUAGE CHARACTERISTICS VERSIONK
- %token MENU MENUEX MENUITEM SEPARATOR POPUP CHECKED GRAYED HELP INACTIVE
- %token MENUBARBREAK MENUBREAK
- %token MESSAGETABLE
- %token RCDATA
- %token STRINGTABLE
- %token VERSIONINFO FILEVERSION PRODUCTVERSION FILEFLAGSMASK FILEFLAGS
- %token FILEOS FILETYPE FILESUBTYPE BLOCKSTRINGFILEINFO BLOCKVARFILEINFO
- %token VALUE
- %token <s> BLOCK
- %token MOVEABLE FIXED PURE IMPURE PRELOAD LOADONCALL DISCARDABLE
- %token NOT
- %token <uni> QUOTEDUNISTRING
- %token <s> QUOTEDSTRING STRING
- %token <i> NUMBER
- %token <suni> SIZEDUNISTRING
- %token <ss> SIZEDSTRING
- %token IGNORED_TOKEN
- %type <pacc> acc_entries
- %type <acc> acc_entry acc_event
- %type <dialog_control> control control_params
- %type <menuitem> menuitems menuitem menuexitems menuexitem
- %type <rcdata> optrcdata_data optrcdata_data_int rcdata_data
- %type <rcdata_item> opt_control_data
- %type <fixver> fixedverinfo
- %type <verinfo> verblocks
- %type <verstringtable> verstringtables
- %type <verstring> vervals
- %type <vervar> vertrans
- %type <toobar_item> toolbar_data
- %type <res_info> suboptions memflags_move_discard memflags_move
- %type <memflags> memflag
- %type <id> id rcdata_id optresidc resref resid cresid
- %type <il> exstyle parennumber
- %type <il> numexpr posnumexpr cnumexpr optcnumexpr cposnumexpr
- %type <is> acc_options acc_option menuitem_flags menuitem_flag
- %type <s> file_name
- %type <uni> res_unicode_string resname res_unicode_string_concat
- %type <ss> sizedstring
- %type <suni> sizedunistring res_unicode_sizedstring res_unicode_sizedstring_concat
- %type <i> sizednumexpr sizedposnumexpr
- %left '|'
- %left '^'
- %left '&'
- %left '+' '-'
- %left '*' '/' '%'
- %right '~' NEG
- %%
- input:
- /* empty */
- | input accelerator
- | input bitmap
- | input cursor
- | input dialog
- | input font
- | input icon
- | input language
- | input menu
- | input menuex
- | input messagetable
- | input stringtable
- | input toolbar
- | input user
- | input versioninfo
- | input IGNORED_TOKEN
- ;
- /* Accelerator resources. */
- accelerator:
- id ACCELERATORS suboptions BEG acc_entries END
- {
- define_accelerator ($1, &$3, $5);
- if (yychar != YYEMPTY)
- YYERROR;
- rcparse_discard_strings ();
- }
- ;
- acc_entries:
- /* empty */
- {
- $$ = NULL;
- }
- | acc_entries acc_entry
- {
- rc_accelerator *a;
- a = (rc_accelerator *) res_alloc (sizeof *a);
- *a = $2;
- if ($1 == NULL)
- $$ = a;
- else
- {
- rc_accelerator **pp;
- for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
- ;
- *pp = a;
- $$ = $1;
- }
- }
- ;
- acc_entry:
- acc_event cposnumexpr
- {
- $$ = $1;
- $$.id = $2;
- }
- | acc_event cposnumexpr ',' acc_options
- {
- $$ = $1;
- $$.id = $2;
- $$.flags |= $4;
- if (($$.flags & ACC_VIRTKEY) == 0
- && ($$.flags & (ACC_SHIFT | ACC_CONTROL)) != 0)
- rcparse_warning (_("inappropriate modifiers for non-VIRTKEY"));
- }
- ;
- acc_event:
- QUOTEDSTRING
- {
- const char *s = $1;
- char ch;
- $$.next = NULL;
- $$.id = 0;
- ch = *s;
- if (ch != '^')
- $$.flags = 0;
- else
- {
- $$.flags = ACC_CONTROL | ACC_VIRTKEY;
- ++s;
- ch = TOUPPER (s[0]);
- }
- $$.key = ch;
- if (s[1] != '\0')
- rcparse_warning (_("accelerator should only be one character"));
- }
- | posnumexpr
- {
- $$.next = NULL;
- $$.flags = 0;
- $$.id = 0;
- $$.key = $1;
- }
- ;
- acc_options:
- acc_option
- {
- $$ = $1;
- }
- | acc_options ',' acc_option
- {
- $$ = $1 | $3;
- }
- /* I've had one report that the comma is optional. */
- | acc_options acc_option
- {
- $$ = $1 | $2;
- }
- ;
- acc_option:
- VIRTKEY
- {
- $$ = ACC_VIRTKEY;
- }
- | ASCII
- {
- /* This is just the absence of VIRTKEY. */
- $$ = 0;
- }
- | NOINVERT
- {
- $$ = ACC_NOINVERT;
- }
- | SHIFT
- {
- $$ = ACC_SHIFT;
- }
- | CONTROL
- {
- $$ = ACC_CONTROL;
- }
- | ALT
- {
- $$ = ACC_ALT;
- }
- ;
- /* Bitmap resources. */
- bitmap:
- id BITMAP memflags_move file_name
- {
- define_bitmap ($1, &$3, $4);
- if (yychar != YYEMPTY)
- YYERROR;
- rcparse_discard_strings ();
- }
- ;
- /* Cursor resources. */
- cursor:
- id CURSOR memflags_move_discard file_name
- {
- define_cursor ($1, &$3, $4);
- if (yychar != YYEMPTY)
- YYERROR;
- rcparse_discard_strings ();
- }
- ;
- /* Dialog resources. */
- dialog:
- id DIALOG memflags_move exstyle posnumexpr cnumexpr cnumexpr
- cnumexpr
- {
- memset (&dialog, 0, sizeof dialog);
- dialog.x = $5;
- dialog.y = $6;
- dialog.width = $7;
- dialog.height = $8;
- dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
- dialog.exstyle = $4;
- dialog.menu.named = 1;
- dialog.class.named = 1;
- dialog.font = NULL;
- dialog.ex = NULL;
- dialog.controls = NULL;
- sub_res_info = $3;
- style = 0;
- }
- styles BEG controls END
- {
- define_dialog ($1, &sub_res_info, &dialog);
- if (yychar != YYEMPTY)
- YYERROR;
- rcparse_discard_strings ();
- }
- | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr
- cnumexpr
- {
- memset (&dialog, 0, sizeof dialog);
- dialog.x = $5;
- dialog.y = $6;
- dialog.width = $7;
- dialog.height = $8;
- dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
- dialog.exstyle = $4;
- dialog.menu.named = 1;
- dialog.class.named = 1;
- dialog.font = NULL;
- dialog.ex = ((rc_dialog_ex *)
- res_alloc (sizeof (rc_dialog_ex)));
- memset (dialog.ex, 0, sizeof (rc_dialog_ex));
- dialog.controls = NULL;
- sub_res_info = $3;
- style = 0;
- }
- styles BEG controls END
- {
- define_dialog ($1, &sub_res_info, &dialog);
- if (yychar != YYEMPTY)
- YYERROR;
- rcparse_discard_strings ();
- }
- | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr
- cnumexpr cnumexpr
- {
- memset (&dialog, 0, sizeof dialog);
- dialog.x = $5;
- dialog.y = $6;
- dialog.width = $7;
- dialog.height = $8;
- dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
- dialog.exstyle = $4;
- dialog.menu.named = 1;
- dialog.class.named = 1;
- dialog.font = NULL;
- dialog.ex = ((rc_dialog_ex *)
- res_alloc (sizeof (rc_dialog_ex)));
- memset (dialog.ex, 0, sizeof (rc_dialog_ex));
- dialog.ex->help = $9;
- dialog.controls = NULL;
- sub_res_info = $3;
- style = 0;
- }
- styles BEG controls END
- {
- define_dialog ($1, &sub_res_info, &dialog);
- if (yychar != YYEMPTY)
- YYERROR;
- rcparse_discard_strings ();
- }
- ;
- exstyle:
- /* empty */
- {
- $$ = 0;
- }
- | EXSTYLE '=' numexpr
- {
- $$ = $3;
- }
- ;
- styles:
- /* empty */
- | styles CAPTION res_unicode_string_concat
- {
- dialog.style |= WS_CAPTION;
- style |= WS_CAPTION;
- dialog.caption = $3;
- }
- | styles CLASS id
- {
- dialog.class = $3;
- }
- | styles STYLE
- styleexpr
- {
- dialog.style = style;
- }
- | styles EXSTYLE numexpr
- {
- dialog.exstyle = $3;
- }
- | styles CLASS res_unicode_string_concat
- {
- res_unistring_to_id (& dialog.class, $3);
- }
- | styles FONT numexpr ',' res_unicode_string_concat
- {
- dialog.style |= DS_SETFONT;
- style |= DS_SETFONT;
- dialog.pointsize = $3;
- dialog.font = $5;
- if (dialog.ex != NULL)
- {
- dialog.ex->weight = 0;
- dialog.ex->italic = 0;
- dialog.ex->charset = 1;
- }
- }
- | styles FONT numexpr ',' res_unicode_string_concat cnumexpr
- {
- dialog.style |= DS_SETFONT;
- style |= DS_SETFONT;
- dialog.pointsize = $3;
- dialog.font = $5;
- if (dialog.ex == NULL)
- rcparse_warning (_("extended FONT requires DIALOGEX"));
- else
- {
- dialog.ex->weight = $6;
- dialog.ex->italic = 0;
- dialog.ex->charset = 1;
- }
- }
- | styles FONT numexpr ',' res_unicode_string_concat cnumexpr cnumexpr
- {
- dialog.style |= DS_SETFONT;
- style |= DS_SETFONT;
- dialog.pointsize = $3;
- dialog.font = $5;
- if (dialog.ex == NULL)
- rcparse_warning (_("extended FONT requires DIALOGEX"));
- else
- {
- dialog.ex->weight = $6;
- dialog.ex->italic = $7;
- dialog.ex->charset = 1;
- }
- }
- | styles FONT numexpr ',' res_unicode_string_concat cnumexpr cnumexpr cnumexpr
- {
- dialog.style |= DS_SETFONT;
- style |= DS_SETFONT;
- dialog.pointsize = $3;
- dialog.font = $5;
- if (dialog.ex == NULL)
- rcparse_warning (_("extended FONT requires DIALOGEX"));
- else
- {
- dialog.ex->weight = $6;
- dialog.ex->italic = $7;
- dialog.ex->charset = $8;
- }
- }
- | styles MENU id
- {
- dialog.menu = $3;
- }
- | styles CHARACTERISTICS numexpr
- {
- sub_res_info.characteristics = $3;
- }
- | styles LANGUAGE numexpr cnumexpr
- {
- sub_res_info.language = $3 | ($4 << SUBLANG_SHIFT);
- }
- | styles VERSIONK numexpr
- {
- sub_res_info.version = $3;
- }
- ;
- controls:
- /* empty */
- | controls control
- {
- rc_dialog_control **pp;
- for (pp = &dialog.controls; *pp != NULL; pp = &(*pp)->next)
- ;
- *pp = $2;
- }
- ;
- control:
- AUTO3STATE optresidc
- {
- default_style = BS_AUTO3STATE | WS_TABSTOP;
- base_style = BS_AUTO3STATE;
- class.named = 0;
- class.u.id = CTL_BUTTON;
- res_text_field = $2;
- }
- control_params
- {
- $$ = $4;
- }
- | AUTOCHECKBOX optresidc
- {
- default_style = BS_AUTOCHECKBOX | WS_TABSTOP;
- base_style = BS_AUTOCHECKBOX;
- class.named = 0;
- class.u.id = CTL_BUTTON;
- res_text_field = $2;
- }
- control_params
- {
- $$ = $4;
- }
- | AUTORADIOBUTTON optresidc
- {
- default_style = BS_AUTORADIOBUTTON | WS_TABSTOP;
- base_style = BS_AUTORADIOBUTTON;
- class.named = 0;
- class.u.id = CTL_BUTTON;
- res_text_field = $2;
- }
- control_params
- {
- $$ = $4;
- }
- | BEDIT optresidc
- {
- default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
- base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
- class.named = 0;
- class.u.id = CTL_EDIT;
- res_text_field = $2;
- }
- control_params
- {
- $$ = $4;
- if (dialog.ex == NULL)
- rcparse_warning (_("BEDIT requires DIALOGEX"));
- res_string_to_id (&$$->class, "BEDIT");
- }
- | CHECKBOX optresidc
- {
- default_style = BS_CHECKBOX | WS_TABSTOP;
- base_style = BS_CHECKBOX | WS_TABSTOP;
- class.named = 0;
- class.u.id = CTL_BUTTON;
- res_text_field = $2;
- }
- control_params
- {
- $$ = $4;
- }
- | COMBOBOX
- {
- /* This is as per MSDN documentation. With some (???)
- versions of MS rc.exe their is no default style. */
- default_style = CBS_SIMPLE | WS_TABSTOP;
- base_style = 0;
- class.named = 0;
- class.u.id = CTL_COMBOBOX;
- res_text_field = res_null_text;
- }
- control_params
- {
- $$ = $3;
- }
- | CONTROL optresidc numexpr cresid control_styleexpr cnumexpr
- cnumexpr cnumexpr cnumexpr optcnumexpr opt_control_data
- {
- $$ = define_control ($2, $3, $6, $7, $8, $9, $4, style, $10);
- if ($11 != NULL)
- {
- if (dialog.ex == NULL)
- rcparse_warning (_("control data requires DIALOGEX"));
- $$->data = $11;
- }
- }
- | CONTROL optresidc numexpr cresid control_styleexpr cnumexpr
- cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
- {
- $$ = define_control ($2, $3, $6, $7, $8, $9, $4, style, $10);
- if (dialog.ex == NULL)
- rcparse_warning (_("help ID requires DIALOGEX"));
- $$->help = $11;
- $$->data = $12;
- }
- | CTEXT optresidc
- {
- default_style = SS_CENTER | WS_GROUP;
- base_style = SS_CENTER;
- class.named = 0;
- class.u.id = CTL_STATIC;
- res_text_field = $2;
- }
- control_params
- {
- $$ = $4;
- }
- | DEFPUSHBUTTON optresidc
- {
- default_style = BS_DEFPUSHBUTTON | WS_TABSTOP;
- base_style = BS_DEFPUSHBUTTON | WS_TABSTOP;
- class.named = 0;
- class.u.id = CTL_BUTTON;
- res_text_field = $2;
- }
- control_params
- {
- $$ = $4;
- }
- | EDITTEXT
- {
- default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
- base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
- class.named = 0;
- class.u.id = CTL_EDIT;
- res_text_field = res_null_text;
- }
- control_params
- {
- $$ = $3;
- }
- | GROUPBOX optresidc
- {
- default_style = BS_GROUPBOX;
- base_style = BS_GROUPBOX;
- class.named = 0;
- class.u.id = CTL_BUTTON;
- res_text_field = $2;
- }
- control_params
- {
- $$ = $4;
- }
- | HEDIT optresidc
- {
- default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
- base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
- class.named = 0;
- class.u.id = CTL_EDIT;
- res_text_field = $2;
- }
- control_params
- {
- $$ = $4;
- if (dialog.ex == NULL)
- rcparse_warning (_("IEDIT requires DIALOGEX"));
- res_string_to_id (&$$->class, "HEDIT");
- }
- | ICON resref numexpr cnumexpr cnumexpr opt_control_data
- {
- $$ = define_icon_control ($2, $3, $4, $5, 0, 0, 0, $6,
- dialog.ex);
- }
- | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
- opt_control_data
- {
- $$ = define_icon_control ($2, $3, $4, $5, 0, 0, 0, $8,
- dialog.ex);
- }
- | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
- icon_styleexpr optcnumexpr opt_control_data
- {
- $$ = define_icon_control ($2, $3, $4, $5, style, $9, 0, $10,
- dialog.ex);
- }
- | ICON resref numexpr cnumexpr cnumexpr cnumexpr cnumexpr
- icon_styleexpr cnumexpr cnumexpr opt_control_data
- {
- $$ = define_icon_control ($2, $3, $4, $5, style, $9, $10, $11,
- dialog.ex);
- }
- | IEDIT optresidc
- {
- default_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
- base_style = ES_LEFT | WS_BORDER | WS_TABSTOP;
- class.named = 0;
- class.u.id = CTL_EDIT;
- res_text_field = $2;
- }
- control_params
- {
- $$ = $4;
- if (dialog.ex == NULL)
- rcparse_warning (_("IEDIT requires DIALOGEX"));
- res_string_to_id (&$$->class, "IEDIT");
- }
- | LISTBOX
- {
- default_style = LBS_NOTIFY | WS_BORDER;
- base_style = LBS_NOTIFY | WS_BORDER;
- class.named = 0;
- class.u.id = CTL_LISTBOX;
- res_text_field = res_null_text;
- }
- control_params
- {
- $$ = $3;
- }
- | LTEXT optresidc
- {
- default_style = SS_LEFT | WS_GROUP;
- base_style = SS_LEFT;
- class.named = 0;
- class.u.id = CTL_STATIC;
- res_text_field = $2;
- }
- control_params
- {
- $$ = $4;
- }
- | PUSHBOX optresidc
- {
- default_style = BS_PUSHBOX | WS_TABSTOP;
- base_style = BS_PUSHBOX;
- class.named = 0;
- class.u.id = CTL_BUTTON;
- }
- control_params
- {
- $$ = $4;
- }
- | PUSHBUTTON optresidc
- {
- default_style = BS_PUSHBUTTON | WS_TABSTOP;
- base_style = BS_PUSHBUTTON | WS_TABSTOP;
- class.named = 0;
- class.u.id = CTL_BUTTON;
- res_text_field = $2;
- }
- control_params
- {
- $$ = $4;
- }
- | RADIOBUTTON optresidc
- {
- default_style = BS_RADIOBUTTON | WS_TABSTOP;
- base_style = BS_RADIOBUTTON;
- class.named = 0;
- class.u.id = CTL_BUTTON;
- res_text_field = $2;
- }
- control_params
- {
- $$ = $4;
- }
- | RTEXT optresidc
- {
- default_style = SS_RIGHT | WS_GROUP;
- base_style = SS_RIGHT;
- class.named = 0;
- class.u.id = CTL_STATIC;
- res_text_field = $2;
- }
- control_params
- {
- $$ = $4;
- }
- | SCROLLBAR
- {
- default_style = SBS_HORZ;
- base_style = 0;
- class.named = 0;
- class.u.id = CTL_SCROLLBAR;
- res_text_field = res_null_text;
- }
- control_params
- {
- $$ = $3;
- }
- | STATE3 optresidc
- {
- default_style = BS_3STATE | WS_TABSTOP;
- base_style = BS_3STATE;
- class.named = 0;
- class.u.id = CTL_BUTTON;
- res_text_field = $2;
- }
- control_params
- {
- $$ = $4;
- }
- | USERBUTTON resref numexpr ',' numexpr ',' numexpr ','
- numexpr ',' numexpr ','
- { style = WS_CHILD | WS_VISIBLE; }
- styleexpr optcnumexpr
- {
- rc_res_id cid;
- cid.named = 0;
- cid.u.id = CTL_BUTTON;
- $$ = define_control ($2, $3, $5, $7, $9, $11, cid,
- style, $15);
- }
- ;
- /* Parameters for a control. The static variables DEFAULT_STYLE,
- BASE_STYLE, and CLASS must be initialized before this nonterminal
- is used. DEFAULT_STYLE is the style to use if no style expression
- is specified. BASE_STYLE is the base style to use if a style
- expression is specified; the style expression modifies the base
- style. CLASS is the class of the control. */
- control_params:
- numexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
- {
- $$ = define_control (res_text_field, $1, $2, $3, $4, $5, class,
- default_style | WS_CHILD | WS_VISIBLE, 0);
- if ($6 != NULL)
- {
- if (dialog.ex == NULL)
- rcparse_warning (_("control data requires DIALOGEX"));
- $$->data = $6;
- }
- }
- | numexpr cnumexpr cnumexpr cnumexpr cnumexpr
- control_params_styleexpr optcnumexpr opt_control_data
- {
- $$ = define_control (res_text_field, $1, $2, $3, $4, $5, class, style, $7);
- if ($8 != NULL)
- {
- if (dialog.ex == NULL)
- rcparse_warning (_("control data requires DIALOGEX"));
- $$->data = $8;
- }
- }
- | numexpr cnumexpr cnumexpr cnumexpr cnumexpr
- control_params_styleexpr cnumexpr cnumexpr opt_control_data
- {
- $$ = define_control (res_text_field, $1, $2, $3, $4, $5, class, style, $7);
- if (dialog.ex == NULL)
- rcparse_warning (_("help ID requires DIALOGEX"));
- $$->help = $8;
- $$->data = $9;
- }
- ;
- cresid:
- ',' resid
- {
- if ($2.named)
- res_unistring_to_id (&$$, $2.u.n.name);
- else
- $$=$2;
- }
- ;
- optresidc:
- /* empty */
- {
- res_string_to_id (&$$, "");
- }
- | resid ',' { $$=$1; }
- ;
- resid:
- posnumexpr
- {
- $$.named = 0;
- $$.u.id = $1;
- }
- | res_unicode_string_concat
- {
- $$.named = 1;
- $$.u.n.name = $1;
- $$.u.n.length = unichar_len ($1);
- }
- ;
- opt_control_data:
- /* empty */
- {
- $$ = NULL;
- }
- | BEG optrcdata_data END
- {
- $$ = $2.first;
- }
- ;
- /* These only exist to parse a reduction out of a common case. */
- control_styleexpr:
- ','
- { style = WS_CHILD | WS_VISIBLE; }
- styleexpr
- ;
- icon_styleexpr:
- ','
- { style = SS_ICON | WS_CHILD | WS_VISIBLE; }
- styleexpr
- ;
- control_params_styleexpr:
- ','
- { style = base_style | WS_CHILD | WS_VISIBLE; }
- styleexpr
- ;
- /* Font resources. */
- font:
- id FONT memflags_move_discard file_name
- {
- define_font ($1, &$3, $4);
- if (yychar != YYEMPTY)
- YYERROR;
- rcparse_discard_strings ();
- }
- ;
- /* Icon resources. */
- icon:
- id ICON memflags_move_discard file_name
- {
- define_icon ($1, &$3, $4);
- if (yychar != YYEMPTY)
- YYERROR;
- rcparse_discard_strings ();
- }
- ;
- /* Language command. This changes the static variable language, which
- affects all subsequent resources. */
- language:
- LANGUAGE numexpr cnumexpr
- {
- language = $2 | ($3 << SUBLANG_SHIFT);
- }
- ;
- /* Menu resources. */
- menu:
- id MENU suboptions BEG menuitems END
- {
- define_menu ($1, &$3, $5);
- if (yychar != YYEMPTY)
- YYERROR;
- rcparse_discard_strings ();
- }
- ;
- menuitems:
- /* empty */
- {
- $$ = NULL;
- }
- | menuitems menuitem
- {
- if ($1 == NULL)
- $$ = $2;
- else
- {
- rc_menuitem **pp;
- for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
- ;
- *pp = $2;
- $$ = $1;
- }
- }
- ;
- menuitem:
- MENUITEM res_unicode_string_concat cnumexpr menuitem_flags
- {
- $$ = define_menuitem ($2, $3, $4, 0, 0, NULL);
- }
- | MENUITEM SEPARATOR
- {
- $$ = define_menuitem (NULL, 0, 0, 0, 0, NULL);
- }
- | POPUP res_unicode_string_concat menuitem_flags BEG menuitems END
- {
- $$ = define_menuitem ($2, 0, $3, 0, 0, $5);
- }
- ;
- menuitem_flags:
- /* empty */
- {
- $$ = 0;
- }
- | menuitem_flags ',' menuitem_flag
- {
- $$ = $1 | $3;
- }
- | menuitem_flags menuitem_flag
- {
- $$ = $1 | $2;
- }
- ;
- menuitem_flag:
- CHECKED
- {
- $$ = MENUITEM_CHECKED;
- }
- | GRAYED
- {
- $$ = MENUITEM_GRAYED;
- }
- | HELP
- {
- $$ = MENUITEM_HELP;
- }
- | INACTIVE
- {
- $$ = MENUITEM_INACTIVE;
- }
- | MENUBARBREAK
- {
- $$ = MENUITEM_MENUBARBREAK;
- }
- | MENUBREAK
- {
- $$ = MENUITEM_MENUBREAK;
- }
- ;
- /* Menuex resources. */
- menuex:
- id MENUEX suboptions BEG menuexitems END
- {
- define_menu ($1, &$3, $5);
- if (yychar != YYEMPTY)
- YYERROR;
- rcparse_discard_strings ();
- }
- ;
- menuexitems:
- /* empty */
- {
- $$ = NULL;
- }
- | menuexitems menuexitem
- {
- if ($1 == NULL)
- $$ = $2;
- else
- {
- rc_menuitem **pp;
- for (pp = &$1->next; *pp != NULL; pp = &(*pp)->next)
- ;
- *pp = $2;
- $$ = $1;
- }
- }
- ;
- menuexitem:
- MENUITEM res_unicode_string_concat
- {
- $$ = define_menuitem ($2, 0, 0, 0, 0, NULL);
- }
- | MENUITEM res_unicode_string_concat cnumexpr
- {
- $$ = define_menuitem ($2, $3, 0, 0, 0, NULL);
- }
- | MENUITEM res_unicode_string_concat cnumexpr cnumexpr optcnumexpr
- {
- $$ = define_menuitem ($2, $3, $4, $5, 0, NULL);
- }
- | MENUITEM SEPARATOR
- {
- $$ = define_menuitem (NULL, 0, 0, 0, 0, NULL);
- }
- | POPUP res_unicode_string_concat BEG menuexitems END
- {
- $$ = define_menuitem ($2, 0, 0, 0, 0, $4);
- }
- | POPUP res_unicode_string_concat cnumexpr BEG menuexitems END
- {
- $$ = define_menuitem ($2, $3, 0, 0, 0, $5);
- }
- | POPUP res_unicode_string_concat cnumexpr cnumexpr BEG menuexitems END
- {
- $$ = define_menuitem ($2, $3, $4, 0, 0, $6);
- }
- | POPUP res_unicode_string_concat cnumexpr cnumexpr cnumexpr optcnumexpr
- BEG menuexitems END
- {
- $$ = define_menuitem ($2, $3, $4, $5, $6, $8);
- }
- ;
- /* Messagetable resources. */
- messagetable:
- id MESSAGETABLE memflags_move file_name
- {
- define_messagetable ($1, &$3, $4);
- if (yychar != YYEMPTY)
- YYERROR;
- rcparse_discard_strings ();
- }
- ;
- /* We use a different lexing algorithm, because rcdata strings may
- contain embedded null bytes, and we need to know the length to use. */
- optrcdata_data:
- {
- rcparse_rcdata ();
- }
- optrcdata_data_int
- {
- rcparse_normal ();
- $$ = $2;
- }
- ;
- optrcdata_data_int:
- /* empty */
- {
- $$.first = NULL;
- $$.last = NULL;
- }
- | rcdata_data
- {
- $$ = $1;
- }
- ;
- rcdata_data:
- sizedstring
- {
- rc_rcdata_item *ri;
- ri = define_rcdata_string ($1.s, $1.length);
- $$.first = ri;
- $$.last = ri;
- }
- | sizedunistring
- {
- rc_rcdata_item *ri;
- ri = define_rcdata_unistring ($1.s, $1.length);
- $$.first = ri;
- $$.last = ri;
- }
- | sizednumexpr
- {
- rc_rcdata_item *ri;
- ri = define_rcdata_number ($1.val, $1.dword);
- $$.first = ri;
- $$.last = ri;
- }
- | rcdata_data ',' sizedstring
- {
- rc_rcdata_item *ri;
- ri = define_rcdata_string ($3.s, $3.length);
- $$.first = $1.first;
- $1.last->next = ri;
- $$.last = ri;
- }
- | rcdata_data ',' sizedunistring
- {
- rc_rcdata_item *ri;
- ri = define_rcdata_unistring ($3.s, $3.length);
- $$.first = $1.first;
- $1.last->next = ri;
- $$.last = ri;
- }
- | rcdata_data ',' sizednumexpr
- {
- rc_rcdata_item *ri;
- ri = define_rcdata_number ($3.val, $3.dword);
- $$.first = $1.first;
- $1.last->next = ri;
- $$.last = ri;
- }
- | rcdata_data ','
- {
- $$=$1;
- }
- ;
- /* Stringtable resources. */
- stringtable:
- STRINGTABLE suboptions BEG
- { sub_res_info = $2; rcparse_rcdata (); }
- string_data END { rcparse_normal (); }
- ;
- string_data:
- /* empty */
- | string_data numexpr res_unicode_sizedstring_concat
- {
- define_stringtable (&sub_res_info, $2, $3.s, $3.length);
- rcparse_discard_strings ();
- }
- | string_data numexpr ',' res_unicode_sizedstring_concat
- {
- define_stringtable (&sub_res_info, $2, $4.s, $4.length);
- rcparse_discard_strings ();
- }
- | string_data error
- {
- rcparse_warning (_("invalid stringtable resource."));
- abort ();
- }
- ;
- rcdata_id:
- id
- {
- $$=$1;
- }
- | HTML
- {
- $$.named = 0;
- $$.u.id = 23;
- }
- | RCDATA
- {
- $$.named = 0;
- $$.u.id = RT_RCDATA;
- }
- | MANIFEST
- {
- $$.named = 0;
- $$.u.id = RT_MANIFEST;
- }
- | PLUGPLAY
- {
- $$.named = 0;
- $$.u.id = RT_PLUGPLAY;
- }
- | VXD
- {
- $$.named = 0;
- $$.u.id = RT_VXD;
- }
- | DLGINCLUDE
- {
- $$.named = 0;
- $$.u.id = RT_DLGINCLUDE;
- }
- | DLGINIT
- {
- $$.named = 0;
- $$.u.id = RT_DLGINIT;
- }
- | ANICURSOR
- {
- $$.named = 0;
- $$.u.id = RT_ANICURSOR;
- }
- | ANIICON
- {
- $$.named = 0;
- $$.u.id = RT_ANIICON;
- }
- ;
- /* User defined resources. We accept general suboptions in the
- file_name case to keep the parser happy. */
- user:
- id rcdata_id suboptions BEG optrcdata_data END
- {
- define_user_data ($1, $2, &$3, $5.first);
- if (yychar != YYEMPTY)
- YYERROR;
- rcparse_discard_strings ();
- }
- | id rcdata_id suboptions file_name
- {
- define_user_file ($1, $2, &$3, $4);
- if (yychar != YYEMPTY)
- YYERROR;
- rcparse_discard_strings ();
- }
- ;
- toolbar:
- id TOOLBAR suboptions numexpr cnumexpr BEG toolbar_data END
- {
- define_toolbar ($1, &$3, $4, $5, $7);
- }
- ;
- toolbar_data: /* empty */ { $$= NULL; }
- | toolbar_data BUTTON id
- {
- rc_toolbar_item *c,*n;
- c = $1;
- n= (rc_toolbar_item *)
- res_alloc (sizeof (rc_toolbar_item));
- if (c != NULL)
- while (c->next != NULL)
- c = c->next;
- n->prev = c;
- n->next = NULL;
- if (c != NULL)
- c->next = n;
- n->id = $3;
- if ($1 == NULL)
- $$ = n;
- else
- $$ = $1;
- }
- | toolbar_data SEPARATOR
- {
- rc_toolbar_item *c,*n;
- c = $1;
- n= (rc_toolbar_item *)
- res_alloc (sizeof (rc_toolbar_item));
- if (c != NULL)
- while (c->next != NULL)
- c = c->next;
- n->prev = c;
- n->next = NULL;
- if (c != NULL)
- c->next = n;
- n->id.named = 0;
- n->id.u.id = 0;
- if ($1 == NULL)
- $$ = n;
- else
- $$ = $1;
- }
- ;
- /* Versioninfo resources. */
- versioninfo:
- id VERSIONINFO fixedverinfo BEG verblocks END
- {
- define_versioninfo ($1, language, $3, $5);
- if (yychar != YYEMPTY)
- YYERROR;
- rcparse_discard_strings ();
- }
- ;
- fixedverinfo:
- /* empty */
- {
- $$ = ((rc_fixed_versioninfo *)
- res_alloc (sizeof (rc_fixed_versioninfo)));
- memset ($$, 0, sizeof (rc_fixed_versioninfo));
- }
- | fixedverinfo FILEVERSION numexpr optcnumexpr optcnumexpr
- optcnumexpr
- {
- $1->file_version_ms = ($3 << 16) | ($4 & 0xffff);
- $1->file_version_ls = ($5 << 16) | ($6 & 0xffff);
- $$ = $1;
- }
- | fixedverinfo PRODUCTVERSION numexpr optcnumexpr optcnumexpr
- optcnumexpr
- {
- $1->product_version_ms = ($3 << 16) | ($4 & 0xffff);
- $1->product_version_ls = ($5 << 16) | ($6 & 0xffff);
- $$ = $1;
- }
- | fixedverinfo FILEFLAGSMASK numexpr
- {
- $1->file_flags_mask = $3;
- $$ = $1;
- }
- | fixedverinfo FILEFLAGS numexpr
- {
- $1->file_flags = $3;
- $$ = $1;
- }
- | fixedverinfo FILEOS numexpr
- {
- $1->file_os = $3;
- $$ = $1;
- }
- | fixedverinfo FILETYPE numexpr
- {
- $1->file_type = $3;
- $$ = $1;
- }
- | fixedverinfo FILESUBTYPE numexpr
- {
- $1->file_subtype = $3;
- $$ = $1;
- }
- ;
- /* To handle verblocks successfully, the lexer handles BLOCK
- specially. A BLOCK "StringFileInfo" is returned as
- BLOCKSTRINGFILEINFO. A BLOCK "VarFileInfo" is returned as
- BLOCKVARFILEINFO. A BLOCK with some other string returns BLOCK
- with the string as the value. */
- verblocks:
- /* empty */
- {
- $$ = NULL;
- }
- | verblocks BLOCKSTRINGFILEINFO BEG verstringtables END
- {
- $$ = append_ver_stringfileinfo ($1, $4);
- }
- | verblocks BLOCKVARFILEINFO BEG VALUE res_unicode_string_concat vertrans END
- {
- $$ = append_ver_varfileinfo ($1, $5, $6);
- }
- ;
- verstringtables:
- /* empty */
- {
- $$ = NULL;
- }
- | verstringtables BLOCK BEG vervals END
- {
- $$ = append_ver_stringtable ($1, $2, $4);
- }
- ;
- vervals:
- /* empty */
- {
- $$ = NULL;
- }
- | vervals VALUE res_unicode_string_concat ',' res_unicode_string_concat
- {
- $$ = append_verval ($1, $3, $5);
- }
- ;
- vertrans:
- /* empty */
- {
- $$ = NULL;
- }
- | vertrans cnumexpr cnumexpr
- {
- $$ = append_vertrans ($1, $2, $3);
- }
- ;
- /* A resource ID. */
- id:
- posnumexpr
- {
- $$.named = 0;
- $$.u.id = $1;
- }
- | resname
- {
- res_unistring_to_id (&$$, $1);
- }
- ;
- /* A resource reference. */
- resname:
- res_unicode_string
- {
- $$ = $1;
- }
- | STRING
- {
- unichar *h = NULL;
- unicode_from_ascii ((rc_uint_type *) NULL, &h, $1);
- $$ = h;
- }
- ;
- resref:
- posnumexpr ','
- {
- $$.named = 0;
- $$.u.id = $1;
- }
- | resname
- {
- res_unistring_to_id (&$$, $1);
- }
- | resname ','
- {
- res_unistring_to_id (&$$, $1);
- }
- ;
- /* Generic suboptions. These may appear before the BEGIN in any
- multiline statement. */
- suboptions:
- /* empty */
- {
- memset (&$$, 0, sizeof (rc_res_res_info));
- $$.language = language;
- /* FIXME: Is this the right default? */
- $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_PURE | MEMFLAG_DISCARDABLE;
- }
- | suboptions memflag
- {
- $$ = $1;
- $$.memflags |= $2.on;
- $$.memflags &=~ $2.off;
- }
- | suboptions CHARACTERISTICS numexpr
- {
- $$ = $1;
- $$.characteristics = $3;
- }
- | suboptions LANGUAGE numexpr cnumexpr
- {
- $$ = $1;
- $$.language = $3 | ($4 << SUBLANG_SHIFT);
- }
- | suboptions VERSIONK numexpr
- {
- $$ = $1;
- $$.version = $3;
- }
- ;
- /* Memory flags which default to MOVEABLE and DISCARDABLE. */
- memflags_move_discard:
- /* empty */
- {
- memset (&$$, 0, sizeof (rc_res_res_info));
- $$.language = language;
- $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_DISCARDABLE;
- }
- | memflags_move_discard memflag
- {
- $$ = $1;
- $$.memflags |= $2.on;
- $$.memflags &=~ $2.off;
- }
- ;
- /* Memory flags which default to MOVEABLE. */
- memflags_move:
- /* empty */
- {
- memset (&$$, 0, sizeof (rc_res_res_info));
- $$.language = language;
- $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_PURE | MEMFLAG_DISCARDABLE;
- }
- | memflags_move memflag
- {
- $$ = $1;
- $$.memflags |= $2.on;
- $$.memflags &=~ $2.off;
- }
- ;
- /* Memory flags. This returns a struct with two integers, because we
- sometimes want to set bits and we sometimes want to clear them. */
- memflag:
- MOVEABLE
- {
- $$.on = MEMFLAG_MOVEABLE;
- $$.off = 0;
- }
- | FIXED
- {
- $$.on = 0;
- $$.off = MEMFLAG_MOVEABLE;
- }
- | PURE
- {
- $$.on = MEMFLAG_PURE;
- $$.off = 0;
- }
- | IMPURE
- {
- $$.on = 0;
- $$.off = MEMFLAG_PURE;
- }
- | PRELOAD
- {
- $$.on = MEMFLAG_PRELOAD;
- $$.off = 0;
- }
- | LOADONCALL
- {
- $$.on = 0;
- $$.off = MEMFLAG_PRELOAD;
- }
- | DISCARDABLE
- {
- $$.on = MEMFLAG_DISCARDABLE;
- $$.off = 0;
- }
- ;
- /* A file name. */
- file_name:
- QUOTEDSTRING
- {
- $$ = $1;
- }
- | STRING
- {
- $$ = $1;
- }
- ;
- /* Concat string */
- res_unicode_string_concat:
- res_unicode_string
- {
- $$ = $1;
- }
- |
- res_unicode_string_concat res_unicode_string
- {
- rc_uint_type l1 = unichar_len ($1);
- rc_uint_type l2 = unichar_len ($2);
- unichar *h = (unichar *) res_alloc ((l1 + l2 + 1) * sizeof (unichar));
- if (l1 != 0)
- memcpy (h, $1, l1 * sizeof (unichar));
- if (l2 != 0)
- memcpy (h + l1, $2, l2 * sizeof (unichar));
- h[l1 + l2] = 0;
- $$ = h;
- }
- ;
- res_unicode_string:
- QUOTEDUNISTRING
- {
- $$ = unichar_dup ($1);
- }
- | QUOTEDSTRING
- {
- unichar *h = NULL;
- unicode_from_ascii ((rc_uint_type *) NULL, &h, $1);
- $$ = h;
- }
- ;
- res_unicode_sizedstring:
- sizedunistring
- {
- $$ = $1;
- }
- | sizedstring
- {
- unichar *h = NULL;
- rc_uint_type l = 0;
- unicode_from_ascii_len (&l, &h, $1.s, $1.length);
- $$.s = h;
- $$.length = l;
- }
- ;
- /* Concat string */
- res_unicode_sizedstring_concat:
- res_unicode_sizedstring
- {
- $$ = $1;
- }
- |
- res_unicode_sizedstring_concat res_unicode_sizedstring
- {
- rc_uint_type l1 = $1.length;
- rc_uint_type l2 = $2.length;
- unichar *h = (unichar *) res_alloc ((l1 + l2 + 1) * sizeof (unichar));
- if (l1 != 0)
- memcpy (h, $1.s, l1 * sizeof (unichar));
- if (l2 != 0)
- memcpy (h + l1, $2.s, l2 * sizeof (unichar));
- h[l1 + l2] = 0;
- $$.length = l1 + l2;
- $$.s = h;
- }
- ;
- sizedstring:
- SIZEDSTRING
- {
- $$ = $1;
- }
- | sizedstring SIZEDSTRING
- {
- rc_uint_type l = $1.length + $2.length;
- char *h = (char *) res_alloc (l);
- memcpy (h, $1.s, $1.length);
- memcpy (h + $1.length, $2.s, $2.length);
- $$.s = h;
- $$.length = l;
- }
- ;
- sizedunistring:
- SIZEDUNISTRING
- {
- $$ = $1;
- }
- | sizedunistring SIZEDUNISTRING
- {
- rc_uint_type l = $1.length + $2.length;
- unichar *h = (unichar *) res_alloc (l * sizeof (unichar));
- memcpy (h, $1.s, $1.length * sizeof (unichar));
- memcpy (h + $1.length, $2.s, $2.length * sizeof (unichar));
- $$.s = h;
- $$.length = l;
- }
- ;
- /* A style expression. This changes the static variable STYLE. We do
- it this way because rc appears to permit a style to be set to
- something like
- WS_GROUP | NOT WS_TABSTOP
- to mean that a default of WS_TABSTOP should be removed. Anything
- which wants to accept a style must first set STYLE to the default
- value. The styleexpr nonterminal will change STYLE as specified by
- the user. Note that we do not accept arbitrary expressions here,
- just numbers separated by '|'. */
- styleexpr:
- parennumber
- {
- style |= $1;
- }
- | NOT parennumber
- {
- style &=~ $2;
- }
- | styleexpr '|' parennumber
- {
- style |= $3;
- }
- | styleexpr '|' NOT parennumber
- {
- style &=~ $4;
- }
- ;
- parennumber:
- NUMBER
- {
- $$ = $1.val;
- }
- | '(' numexpr ')'
- {
- $$ = $2;
- }
- ;
- /* An optional expression with a leading comma. */
- optcnumexpr:
- /* empty */
- {
- $$ = 0;
- }
- | cnumexpr
- {
- $$ = $1;
- }
- ;
- /* An expression with a leading comma. */
- cnumexpr:
- ',' numexpr
- {
- $$ = $2;
- }
- ;
- /* A possibly negated numeric expression. */
- numexpr:
- sizednumexpr
- {
- $$ = $1.val;
- }
- ;
- /* A possibly negated expression with a size. */
- sizednumexpr:
- NUMBER
- {
- $$ = $1;
- }
- | '(' sizednumexpr ')'
- {
- $$ = $2;
- }
- | '~' sizednumexpr %prec '~'
- {
- $$.val = ~ $2.val;
- $$.dword = $2.dword;
- }
- | '-' sizednumexpr %prec NEG
- {
- $$.val = - $2.val;
- $$.dword = $2.dword;
- }
- | sizednumexpr '*' sizednumexpr
- {
- $$.val = $1.val * $3.val;
- $$.dword = $1.dword || $3.dword;
- }
- | sizednumexpr '/' sizednumexpr
- {
- $$.val = $1.val / ($3.val ? $3.val : 1);
- $$.dword = $1.dword || $3.dword;
- }
- | sizednumexpr '%' sizednumexpr
- {
- $$.val = $1.val % ($3.val ? $3.val : 1);
- $$.dword = $1.dword || $3.dword;
- }
- | sizednumexpr '+' sizednumexpr
- {
- $$.val = $1.val + $3.val;
- $$.dword = $1.dword || $3.dword;
- }
- | sizednumexpr '-' sizednumexpr
- {
- $$.val = $1.val - $3.val;
- $$.dword = $1.dword || $3.dword;
- }
- | sizednumexpr '&' sizednumexpr
- {
- $$.val = $1.val & $3.val;
- $$.dword = $1.dword || $3.dword;
- }
- | sizednumexpr '^' sizednumexpr
- {
- $$.val = $1.val ^ $3.val;
- $$.dword = $1.dword || $3.dword;
- }
- | sizednumexpr '|' sizednumexpr
- {
- $$.val = $1.val | $3.val;
- $$.dword = $1.dword || $3.dword;
- }
- ;
- /* An expression with a leading comma which does not use unary
- negation. */
- cposnumexpr:
- ',' posnumexpr
- {
- $$ = $2;
- }
- ;
- /* An expression which does not use unary negation. */
- posnumexpr:
- sizedposnumexpr
- {
- $$ = $1.val;
- }
- ;
- /* An expression which does not use unary negation. We separate unary
- negation to avoid parsing conflicts when two numeric expressions
- appear consecutively. */
- sizedposnumexpr:
- NUMBER
- {
- $$ = $1;
- }
- | '(' sizednumexpr ')'
- {
- $$ = $2;
- }
- | '~' sizednumexpr %prec '~'
- {
- $$.val = ~ $2.val;
- $$.dword = $2.dword;
- }
- | sizedposnumexpr '*' sizednumexpr
- {
- $$.val = $1.val * $3.val;
- $$.dword = $1.dword || $3.dword;
- }
- | sizedposnumexpr '/' sizednumexpr
- {
- $$.val = $1.val / ($3.val ? $3.val : 1);
- $$.dword = $1.dword || $3.dword;
- }
- | sizedposnumexpr '%' sizednumexpr
- {
- /* PR 17512: file: 89105a25. */
- $$.val = $1.val % ($3.val ? $3.val : 1);
- $$.dword = $1.dword || $3.dword;
- }
- | sizedposnumexpr '+' sizednumexpr
- {
- $$.val = $1.val + $3.val;
- $$.dword = $1.dword || $3.dword;
- }
- | sizedposnumexpr '-' sizednumexpr
- {
- $$.val = $1.val - $3.val;
- $$.dword = $1.dword || $3.dword;
- }
- | sizedposnumexpr '&' sizednumexpr
- {
- $$.val = $1.val & $3.val;
- $$.dword = $1.dword || $3.dword;
- }
- | sizedposnumexpr '^' sizednumexpr
- {
- $$.val = $1.val ^ $3.val;
- $$.dword = $1.dword || $3.dword;
- }
- | sizedposnumexpr '|' sizednumexpr
- {
- $$.val = $1.val | $3.val;
- $$.dword = $1.dword || $3.dword;
- }
- ;
- %%
- /* Set the language from the command line. */
- void
- rcparse_set_language (int lang)
- {
- language = lang;
- }
|