Fix build problems introduced by r18788
[reactos.git] / reactos / tools / wrc / parser.y
index f9d3da8..e113390 100644 (file)
  *                     - Added extra comment about grammar
  */
 #include "config.h"
+#include "wine/port.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -251,6 +252,7 @@ static int rsrcid_to_token(int lookahead);
        fontdir_t       *fnd;
        menu_t          *men;
        menuex_t        *menex;
+       html_t          *html;
        rcdata_t        *rdt;
        stringtable_t   *stt;
        stt_entry_t     *stte;
@@ -285,7 +287,7 @@ static int rsrcid_to_token(int lookahead);
 %token <str> tSTRING tIDENT tFILENAME
 %token <raw> tRAWDATA
 %token tACCELERATORS tBITMAP tCURSOR tDIALOG tDIALOGEX tMENU tMENUEX tMESSAGETABLE
-%token tRCDATA tVERSIONINFO tSTRINGTABLE tFONT tFONTDIR tICON
+%token tRCDATA tVERSIONINFO tSTRINGTABLE tFONT tFONTDIR tICON tHTML
 %token tAUTO3STATE tAUTOCHECKBOX tAUTORADIOBUTTON tCHECKBOX tDEFPUSHBUTTON
 %token tPUSHBUTTON tRADIOBUTTON tSTATE3 /* PUSHBOX */
 %token tGROUPBOX tCOMBOBOX tLISTBOX tSCROLLBAR
@@ -323,6 +325,7 @@ static int rsrcid_to_token(int lookahead);
 %type <iptr>   helpid
 %type <dlgex>  dialogex dlgex_attribs
 %type <ctl>    exctrls gen_exctrl lab_exctrl exctrl_desc
+%type <html>   html
 %type <rdt>    rcdata
 %type <raw>    raw_data raw_elements opt_data file_raw
 %type <veri>   versioninfo fix_version
@@ -345,14 +348,13 @@ static int rsrcid_to_token(int lookahead);
 %type <lan>    opt_language
 %type <chars>  opt_characts
 %type <ver>    opt_version
-%type <num>    expr xpr
+%type <num>    expr xpr xpr_no_not
 %type <iptr>   e_expr
 %type <tlbar>  toolbar
 %type <tlbarItems>     toolbar_items
 %type <dginit>  dlginit
 %type <styles>  optional_style_pair
 %type <num>    any_num
-%type <style>   optional_style
 %type <style>   style
 %type <str>    filename
 
@@ -458,7 +460,7 @@ resources
         * for tNL. However, byacc already generates an error upon reading
         * the token instead of keeping it as a lookahead. The reason
         * lies in the lack of a $default transition in the "expr : xpr . "
-        * state (currently state 25). It is probably ommitted because tNL
+        * state (currently state 25). It is probably omitted because tNL
         * is a non-terminal and the state contains 2 s/r conflicts. The
         * state enumerates all possible transitions instead of using a
         * $default transition.
@@ -645,6 +647,7 @@ resource_definition
                        $$ = NULL;
                }
        | messagetable  { $$ = new_resource(res_msg, $1, WRC_MO_MOVEABLE | WRC_MO_DISCARDABLE, $1->data->lvc.language); }
+       | html          { $$ = new_resource(res_html, $1, $1->memopt, $1->data->lvc.language); }
        | rcdata        { $$ = new_resource(res_rdt, $1, $1->memopt, $1->data->lvc.language); }
        | toolbar       { $$ = new_resource(res_toolbar, $1, $1->memopt, $1->lvc.language); }
        | userres       { $$ = new_resource(res_usr, $1, $1->memopt, $1->data->lvc.language); }
@@ -725,6 +728,10 @@ messagetable
                }
        ;
 
+/* ------------------------------ HTML ------------------------------ */
+html   : tHTML loadmemopts file_raw    { $$ = new_html($3, $2); }
+       ;
+
 /* ------------------------------ RCData ------------------------------ */
 rcdata : tRCDATA loadmemopts file_raw  { $$ = new_rcdata($3, $2); }
        ;
@@ -735,11 +742,11 @@ dlginit   : tDLGINIT loadmemopts file_raw { $$ = new_dlginit($3, $2); }
 
 /* ------------------------------ UserType ------------------------------ */
 userres        : usertype loadmemopts file_raw         {
-               #ifdef WORDS_BIGENDIAN
+#ifdef WORDS_BIGENDIAN
                        if(pedantic && byteorder != WRC_BO_LITTLE)
-               #else
+#else
                        if(pedantic && byteorder == WRC_BO_BIG)
-               #endif
+#endif
                                yywarning("Byteordering is not little-endian and type cannot be interpreted");
                        $$ = new_user($1, $3, $2);
                }
@@ -889,7 +896,7 @@ ctrls       : /* Empty */                           { $$ = NULL; }
        ;
 
 lab_ctrl
-       : tSTRING opt_comma expr ',' expr ',' expr ',' expr ',' expr optional_style {
+       : tSTRING opt_comma expr ',' expr ',' expr ',' expr ',' expr optional_style_pair {
                $$=new_control();
                $$->title = new_name_id();
                $$->title->type = name_str;
@@ -901,14 +908,20 @@ lab_ctrl
                $$->height = $11;
                if($12)
                {
-                       $$->style = $12;
+                       $$->style = $12->style;
                        $$->gotstyle = TRUE;
+                       if ($12->exstyle)
+                       {
+                           $$->exstyle = $12->exstyle;
+                           $$->gotexstyle = TRUE;
+                       }
+                       free($12);
                }
                }
        ;
 
 ctrl_desc
-       : expr ',' expr ',' expr ',' expr ',' expr optional_style {
+       : expr ',' expr ',' expr ',' expr ',' expr optional_style_pair {
                $$ = new_control();
                $$->id = $1;
                $$->x = $3;
@@ -917,8 +930,14 @@ ctrl_desc
                $$->height = $9;
                if($10)
                {
-                       $$->style = $10;
+                       $$->style = $10->style;
                        $$->gotstyle = TRUE;
+                       if ($10->exstyle)
+                       {
+                           $$->exstyle = $10->exstyle;
+                           $$->gotexstyle = TRUE;
+                       }
+                       free($10);
                }
                }
        ;
@@ -982,11 +1001,6 @@ opt_font
        ;
 
 /* ------------------------------ style flags ------------------------------ */
-optional_style         /* Abbused once to get optional ExStyle */
-       : /* Empty */   { $$ = NULL; }
-       | ',' style     { $$ = $2; }
-       ;
-
 optional_style_pair
        : /* Empty */           { $$ = NULL; }
        | ',' style             { $$ = new_style_pair($2, 0); }
@@ -996,8 +1010,8 @@ optional_style_pair
 style
        : style '|' style       { $$ = new_style($1->or_mask | $3->or_mask, $1->and_mask | $3->and_mask); free($1); free($3);}
        | '(' style ')'         { $$ = $2; }
-        | xpr                  { $$ = new_style($1, 0); }
-        | tNOT xpr             { $$ = new_style(0, $2); }
+        | xpr_no_not           { $$ = new_style($1, 0); }
+        | tNOT xpr_no_not      { $$ = new_style(0, $2); }
         ;
 
 ctlclass
@@ -1277,12 +1291,12 @@ item_definitions
  */
 item_options
        : /* Empty */                           { $$ = 0; }
-       | ',' tCHECKED          item_options    { $$ = $3 | MF_CHECKED; }
-       | ',' tGRAYED           item_options    { $$ = $3 | MF_GRAYED; }
-       | ',' tHELP             item_options    { $$ = $3 | MF_HELP; }
-       | ',' tINACTIVE         item_options    { $$ = $3 | MF_DISABLED; }
-       | ',' tMENUBARBREAK     item_options    { $$ = $3 | MF_MENUBARBREAK; }
-       | ',' tMENUBREAK        item_options    { $$ = $3 | MF_MENUBREAK; }
+       | opt_comma tCHECKED            item_options    { $$ = $3 | MF_CHECKED; }
+       | opt_comma tGRAYED             item_options    { $$ = $3 | MF_GRAYED; }
+       | opt_comma tHELP               item_options    { $$ = $3 | MF_HELP; }
+       | opt_comma tINACTIVE           item_options    { $$ = $3 | MF_DISABLED; }
+       | opt_comma tMENUBARBREAK       item_options    { $$ = $3 | MF_MENUBARBREAK; }
+       | opt_comma tMENUBREAK  item_options    { $$ = $3 | MF_MENUBREAK; }
        ;
 
 /* ------------------------------ MenuEx ------------------------------ */
@@ -1817,18 +1831,22 @@ e_expr  : /* Empty */   { $$ = 0; }
 expr   : xpr   { $$ = ($1); }
        ;
 
-xpr    : xpr '+' xpr   { $$ = ($1) + ($3); }
-       | xpr '-' xpr   { $$ = ($1) - ($3); }
-       | xpr '|' xpr   { $$ = ($1) | ($3); }
-       | xpr '&' xpr   { $$ = ($1) & ($3); }
-       | xpr '*' xpr   { $$ = ($1) * ($3); }
-       | xpr '/' xpr   { $$ = ($1) / ($3); }
-       | xpr '^' xpr   { $$ = ($1) ^ ($3); }
-       | '~' xpr       { $$ = ~($2); }
-       | '-' xpr %prec pUPM    { $$ = -($2); }
-       | '+' xpr %prec pUPM    { $$ = $2; }
-       | '(' xpr ')'   { $$ = $2; }
-       | any_num       { $$ = $1; }
+xpr_no_not     : xpr '+' xpr   { $$ = ($1) + ($3); }
+               | xpr '-' xpr   { $$ = ($1) - ($3); }
+               | xpr '|' xpr   { $$ = ($1) | ($3); }
+               | xpr '&' xpr   { $$ = ($1) & ($3); }
+               | xpr '*' xpr   { $$ = ($1) * ($3); }
+               | xpr '/' xpr   { $$ = ($1) / ($3); }
+               | xpr '^' xpr   { $$ = ($1) ^ ($3); }
+               | '~' xpr       { $$ = ~($2); }
+               | '-' xpr %prec pUPM    { $$ = -($2); }
+               | '+' xpr %prec pUPM    { $$ = $2; }
+               | '(' xpr ')'   { $$ = $2; }
+               | any_num       { $$ = $1; }
+               ;
+
+
+xpr    : xpr_no_not    { $$ = ($1); }
        | tNOT any_num  { $$ = ~($2); }
        ;
 
@@ -2302,7 +2320,7 @@ static raw_data_t *load_file(string_t *filename, language_t *lang)
        if (codepage <= 0 && filename->type != str_char)
                yyerror("Cannot convert filename to ASCII string");
        name = convert_string( filename, str_char, codepage );
-       if (!(path = wpp_find_include(name->str.cstr, 1)))
+       if (!(path = wpp_find_include(name->str.cstr, input_name, 1)))
                yyerror("Cannot open file %s", name->str.cstr);
        if (!(fp = fopen( path, "rb" )))
                yyerror("Cannot open file %s", name->str.cstr);
@@ -2561,7 +2579,7 @@ static stringtable_t *find_stringtable(lvc_t *lvc)
 }
 
 /* qsort sorting function for string table entries */
-#define STE(p) ((stt_entry_t *)(p))
+#define STE(p) ((const stt_entry_t *)(p))
 static int sort_stt_entry(const void *e1, const void *e2)
 {
        return STE(e1)->id - STE(e2)->id;
@@ -3007,6 +3025,10 @@ static int rsrcid_to_token(int lookahead)
                type = "TOOLBAR";
                token = tTOOLBAR;
                break;
+       case WRC_RT_HTML:
+               type = "HTML";
+               token = tHTML;
+               break;
 
        case WRC_RT_STRING:
                type = "STRINGTABLE";
@@ -3022,7 +3044,6 @@ static int rsrcid_to_token(int lookahead)
        case WRC_RT_DLGINCLUDE:
        case WRC_RT_PLUGPLAY:
        case WRC_RT_VXD:
-       case WRC_RT_HTML:
                yywarning("Usertype uses reserved type ID %d, which is not supported by wrc yet", yylval.num);
        default:
                return lookahead;