Changeset 3426 for trunk/tools/wrc/parser.y
- Timestamp:
- Apr 19, 2000, 4:46:07 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/wrc/parser.y
r882 r3426 3 3 * Copyright Martin von Loewis, 1994 4 4 * Copyright 1998 Bertho A. Stultiens (BS) 5 * 1999 Juergen Schmied (JS) 5 6 * 7 * 6-Nov-1999 JS - see CHANGES 8 * 6 9 * 29-Dec-1998 AdH - Grammar and function extensions. 7 10 * grammar: TOOLBAR resources, Named ICONs in … … 104 107 #include "preproc.h" 105 108 #include "parser.h" 109 #include "windef.h" 110 #include "wingdi.h" 106 111 #include "winuser.h" 107 112 … … 110 115 #endif 111 116 112 DWORD andmask; /* Used to parse 'NOT NUMBER' expressions */113 117 int indialog = 0; /* Signal flex that we're parsing a dialog */ 114 118 int want_rscname = 0; /* Set when a resource's name is required */ … … 158 162 dialogex_t *dialogex_font(font_id_t *f, dialogex_t *dlg); 159 163 dialogex_t *dialogex_caption(string_t *s, dialogex_t *dlg); 160 dialogex_t *dialogex_exstyle( intst, dialogex_t *dlg);161 dialogex_t *dialogex_style( intst, dialogex_t *dlg);164 dialogex_t *dialogex_exstyle(style_t *st, dialogex_t *dlg); 165 dialogex_t *dialogex_style(style_t *st, dialogex_t *dlg); 162 166 name_id_t *convert_ctlclass(name_id_t *cls); 163 control_t *ins_ctrl(int type, int s tyle, control_t *ctrl, control_t *prev);167 control_t *ins_ctrl(int type, int special_style, control_t *ctrl, control_t *prev); 164 168 dialog_t *dialog_version(version_t *v, dialog_t *dlg); 165 169 dialog_t *dialog_characteristics(characts_t *c, dialog_t *dlg); … … 169 173 dialog_t *dialog_font(font_id_t *f, dialog_t *dlg); 170 174 dialog_t *dialog_caption(string_t *s, dialog_t *dlg); 171 dialog_t *dialog_exstyle( intst, dialog_t *dlg);172 dialog_t *dialog_style( intst, dialog_t *dlg);175 dialog_t *dialog_exstyle(style_t * st, dialog_t *dlg); 176 dialog_t *dialog_style(style_t * st, dialog_t *dlg); 173 177 resource_t *build_stt_resources(stringtable_t *stthead); 174 178 stringtable_t *find_stringtable(lvc_t *lvc); … … 218 222 dlginit_t *dginit; 219 223 style_pair_t *styles; 224 style_t *style; 220 225 } 221 226 … … 264 269 %type <dlg> dialog dlg_attributes 265 270 %type <ctl> ctrls gen_ctrl lab_ctrl ctrl_desc iconinfo 266 %type <iptr> optional_stylehelpid271 %type <iptr> helpid 267 272 %type <dlgex> dialogex dlgex_attribs 268 273 %type <ctl> exctrls gen_exctrl lab_exctrl exctrl_desc … … 289 294 %type <chars> opt_characts 290 295 %type <ver> opt_version 291 %type <num> expr xpr dummy296 %type <num> expr xpr 292 297 %type <iptr> e_expr 293 298 %type <iptr> pp_expr pp_constant … … 297 302 %type <styles> optional_style_pair 298 303 %type <num> any_num 304 %type <style> optional_style 305 %type <style> style 299 306 300 307 %% … … 389 396 /* C ignore stuff */ 390 397 cjunk : tTYPEDEF { strip_til_semicolon(); } 391 | tEXTERN { strip_ til_semicolon(); }398 | tEXTERN { strip_extern(); } 392 399 | IDENT IDENT { strip_til_semicolon(); } 393 400 | IDENT '(' { strip_til_parenthesis(); } … … 434 441 */ 435 442 nameid : expr { 443 if($1 > 65535 || $1 < -32768) 444 yyerror("Resource's ID out of range (%d)", $1); 436 445 $$ = new_name_id(); 437 446 $$->type = name_ord; … … 672 681 if(!$$->gotstyle) 673 682 { 674 $$->style = WS_POPUP;683 $$->style->or_mask = WS_POPUP; 675 684 $$->gotstyle = TRUE; 676 685 } 677 686 if($$->title) 678 $$->style |= WS_CAPTION;687 $$->style->or_mask |= WS_CAPTION; 679 688 if($$->font) 680 $$->style |= DS_SETFONT; 689 $$->style->or_mask |= DS_SETFONT; 690 691 $$->style->or_mask &= ~($$->style->and_mask); 692 $$->style->and_mask = 0; 693 681 694 indialog = FALSE; 682 695 if(!$$->lvc.language) … … 687 700 dlg_attributes 688 701 : /* Empty */ { $$=new_dialog(); } 689 | dlg_attributes STYLE expr{ $$=dialog_style($3,$1); }690 | dlg_attributes EXSTYLE expr{ $$=dialog_exstyle($3,$1); }702 | dlg_attributes STYLE style { $$=dialog_style($3,$1); } 703 | dlg_attributes EXSTYLE style { $$=dialog_exstyle($3,$1); } 691 704 | dlg_attributes CAPTION tSTRING { $$=dialog_caption($3,$1); } 692 705 | dlg_attributes opt_font { $$=dialog_font($2,$1); } … … 718 731 | ctrls RTEXT lab_ctrl { $$=ins_ctrl(CT_STATIC, SS_RIGHT, $3, $1); } 719 732 /* special treatment for icons, as the extent is optional */ 720 | ctrls ICON nameid_s ','expr ',' expr ',' expr iconinfo {733 | ctrls ICON nameid_s opt_comma expr ',' expr ',' expr iconinfo { 721 734 $10->title = $3; 722 735 $10->id = $5; … … 728 741 729 742 lab_ctrl 730 : tSTRING ','expr ',' expr ',' expr ',' expr ',' expr optional_style {743 : tSTRING opt_comma expr ',' expr ',' expr ',' expr ',' expr optional_style { 731 744 $$=new_control(); 732 745 $$->title = new_name_id(); … … 740 753 if($12) 741 754 { 742 $$->style = *($12);755 $$->style = $12; 743 756 $$->gotstyle = TRUE; 744 free($12);745 757 } 746 758 } … … 757 769 if($10) 758 770 { 759 $$->style = *($10);771 $$->style = $10; 760 772 $$->gotstyle = TRUE; 761 free($10);762 773 } 763 774 } … … 772 783 $$->height = $4; 773 784 } 774 | ',' expr ',' expr ',' expr{785 | ',' expr ',' expr ',' style { 775 786 $$ = new_control(); 776 787 $$->width = $2; … … 779 790 $$->gotstyle = TRUE; 780 791 } 781 | ',' expr ',' expr ',' expr ',' expr{792 | ',' expr ',' expr ',' style ',' style { 782 793 $$ = new_control(); 783 794 $$->width = $2; … … 790 801 ; 791 802 792 gen_ctrl: nameid_s ',' expr ',' ctlclass ',' expr ',' expr ',' expr ',' expr ',' expr ',' expr{803 gen_ctrl: nameid_s opt_comma expr ',' ctlclass ',' style ',' expr ',' expr ',' expr ',' expr ',' style { 793 804 $$=new_control(); 794 805 $$->title = $1; … … 804 815 $$->gotexstyle = TRUE; 805 816 } 806 | nameid_s ',' expr ',' ctlclass ',' expr',' expr ',' expr ',' expr ',' expr {817 | nameid_s opt_comma expr ',' ctlclass ',' style ',' expr ',' expr ',' expr ',' expr { 807 818 $$=new_control(); 808 819 $$->title = $1; … … 822 833 ; 823 834 835 /* ------------------------------ style flags ------------------------------ */ 824 836 optional_style /* Abbused once to get optional ExStyle */ 825 837 : /* Empty */ { $$ = NULL; } 826 | ',' expr { $$ = new_int($2); }838 | ',' style { $$ = $2; } 827 839 ; 828 840 829 841 optional_style_pair 830 : /* Enpty */ { $$ = NULL; } 831 | ',' expr { $$ = new_style_pair($2, 0); } 832 | ',' expr ',' expr { $$ = new_style_pair($2, $4); } 833 ; 842 : /* Empty */ { $$ = NULL; } 843 | ',' style { $$ = new_style_pair($2, 0); } 844 | ',' style ',' style { $$ = new_style_pair($2, $4); } 845 ; 846 847 style 848 : style '|' style { $$ = new_style($1->or_mask | $3->or_mask, $1->and_mask | $3->and_mask); free($1); free($3);} 849 | '(' style ')' { $$ = $2; } 850 | any_num { $$ = new_style($1, 0); } 851 | NOT any_num { $$ = new_style(0, $2); } 852 ; 834 853 835 854 ctlclass … … 870 889 $11->controls = get_control_head($13); 871 890 $$ = $11; 891 892 assert($$->style != NULL); 872 893 if(!$$->gotstyle) 873 894 { 874 $$->style = WS_POPUP;895 $$->style->or_mask = WS_POPUP; 875 896 $$->gotstyle = TRUE; 876 897 } 877 898 if($$->title) 878 $$->style |= WS_CAPTION;899 $$->style->or_mask |= WS_CAPTION; 879 900 if($$->font) 880 $$->style |= DS_SETFONT; 901 $$->style->or_mask |= DS_SETFONT; 902 903 $$->style->or_mask &= ~($$->style->and_mask); 904 $$->style->and_mask = 0; 905 881 906 indialog = FALSE; 882 907 if(!$$->lvc.language) … … 887 912 dlgex_attribs 888 913 : /* Empty */ { $$=new_dialogex(); } 889 | dlgex_attribs STYLE expr{ $$=dialogex_style($3,$1); }890 | dlgex_attribs EXSTYLE expr{ $$=dialogex_exstyle($3,$1); }914 | dlgex_attribs STYLE style { $$=dialogex_style($3,$1); } 915 | dlgex_attribs EXSTYLE style { $$=dialogex_exstyle($3,$1); } 891 916 | dlgex_attribs CAPTION tSTRING { $$=dialogex_caption($3,$1); } 892 917 | dlgex_attribs opt_font { $$=dialogex_font($2,$1); } … … 919 944 | exctrls RTEXT lab_exctrl { $$=ins_ctrl(CT_STATIC, SS_RIGHT, $3, $1); } 920 945 /* special treatment for icons, as the extent is optional */ 921 | exctrls ICON nameid_s ','expr ',' expr ',' expr iconinfo {946 | exctrls ICON nameid_s opt_comma expr ',' expr ',' expr iconinfo { 922 947 $10->title = $3; 923 948 $10->id = $5; … … 929 954 930 955 gen_exctrl 931 : nameid_s ',' expr ',' ctlclass ',' expr',' expr ',' expr ',' expr ','932 expr ',' e_exprhelpid opt_data {956 : nameid_s opt_comma expr ',' ctlclass ',' style ',' expr ',' expr ',' expr ',' 957 expr ',' style helpid opt_data { 933 958 $$=new_control(); 934 959 $$->title = $1; … … 943 968 if($17) 944 969 { 945 $$->exstyle = *($17);970 $$->exstyle = $17; 946 971 $$->gotexstyle = TRUE; 947 free($17);948 972 } 949 973 if($18) … … 955 979 $$->extra = $19; 956 980 } 957 | nameid_s ',' expr ',' ctlclass ',' expr',' expr ',' expr ',' expr ',' expr opt_data {981 | nameid_s opt_comma expr ',' ctlclass ',' style ',' expr ',' expr ',' expr ',' expr opt_data { 958 982 $$=new_control(); 959 983 $$->title = $1; … … 971 995 972 996 lab_exctrl 973 : tSTRING ','expr ',' expr ',' expr ',' expr ',' expr optional_style_pair opt_data {997 : tSTRING opt_comma expr ',' expr ',' expr ',' expr ',' expr optional_style_pair opt_data { 974 998 $$=new_control(); 975 999 $$->title = new_name_id(); … … 1071 1095 item_definitions 1072 1096 : /* Empty */ {$$ = NULL;} 1073 | item_definitions MENUITEM tSTRING ','expr item_options {1097 | item_definitions MENUITEM tSTRING opt_comma expr item_options { 1074 1098 $$=new_menu_item(); 1075 1099 $$->prev = $1; … … 1306 1330 int i; 1307 1331 assert(tagstt != NULL); 1332 if($2 > 65535 || $2 < -32768) 1333 yyerror("Stringtable entry's ID out of range (%d)", $2); 1308 1334 /* Search for the ID */ 1309 1335 for(i = 0; i < tagstt->nentries; i++) … … 1598 1624 | expr { $$ = new_int($1); } 1599 1625 ; 1600 expr : dummy xpr { $$ = ($2) & andmask; } 1601 ; 1602 1603 dummy : /* Empty */ { $$ = 0; andmask = -1; } 1626 expr : xpr { $$ = ($1); } 1604 1627 ; 1605 1628 … … 1615 1638 | '(' xpr ')' { $$ = $2; } 1616 1639 | any_num { $$ = $1; want_rscname = 0; } 1617 | NOT any_num { $$ = 0; andmask &=~($2); }1640 | NOT any_num { $$ = ~($2); } 1618 1641 ; 1619 1642 … … 1624 1647 %% 1625 1648 /* Dialog specific functions */ 1626 dialog_t *dialog_style(int st, dialog_t *dlg) 1627 { 1628 DWORD s = 0; 1649 dialog_t *dialog_style(style_t * st, dialog_t *dlg) 1650 { 1629 1651 assert(dlg != NULL); 1652 if(dlg->style == NULL) 1653 { 1654 dlg->style = new_style(0,0); 1655 } 1656 1630 1657 if(dlg->gotstyle) 1631 1658 { 1632 1659 yywarning("Style already defined, or-ing together"); 1633 s = dlg->style; 1634 } 1635 dlg->style = st | s; 1660 } 1661 else 1662 { 1663 dlg->style->or_mask = 0; 1664 dlg->style->and_mask = 0; 1665 } 1666 dlg->style->or_mask |= st->or_mask; 1667 dlg->style->and_mask |= st->and_mask; 1636 1668 dlg->gotstyle = TRUE; 1669 free(st); 1637 1670 return dlg; 1638 1671 } 1639 1672 1640 dialog_t *dialog_exstyle(int st, dialog_t *dlg) 1641 { 1642 DWORD s = 0; 1673 dialog_t *dialog_exstyle(style_t *st, dialog_t *dlg) 1674 { 1643 1675 assert(dlg != NULL); 1676 if(dlg->exstyle == NULL) 1677 { 1678 dlg->exstyle = new_style(0,0); 1679 } 1680 1644 1681 if(dlg->gotexstyle) 1645 1682 { 1646 1683 yywarning("ExStyle already defined, or-ing together"); 1647 s = dlg->style; 1648 } 1649 dlg->exstyle = st | s; 1684 } 1685 else 1686 { 1687 dlg->exstyle->or_mask = 0; 1688 dlg->exstyle->and_mask = 0; 1689 } 1690 dlg->exstyle->or_mask |= st->or_mask; 1691 dlg->exstyle->and_mask |= st->and_mask; 1650 1692 dlg->gotexstyle = TRUE; 1693 free(st); 1651 1694 return dlg; 1652 1695 } … … 1716 1759 1717 1760 /* Controls specific functions */ 1718 control_t *ins_ctrl(int type, int style, control_t *ctrl, control_t *prev) 1719 { 1761 control_t *ins_ctrl(int type, int special_style, control_t *ctrl, control_t *prev) 1762 { 1763 /* Hm... this seems to be jammed in at all time... */ 1764 int defaultstyle = WS_CHILD | WS_VISIBLE; 1765 1720 1766 assert(ctrl != NULL); 1721 1767 ctrl->prev = prev; 1768 1722 1769 if(prev) 1723 1770 prev->next = ctrl; 1771 1724 1772 if(type != -1) 1725 1773 { … … 1729 1777 } 1730 1778 1731 /* Hm... this seems to be jammed in at all time... */1732 ctrl->style |= WS_CHILD | WS_VISIBLE;1733 1779 switch(type) 1734 1780 { 1735 1781 case CT_BUTTON: 1736 ctrl->style |= style; 1737 if(style != BS_GROUPBOX && style != BS_RADIOBUTTON) 1738 ctrl->style |= WS_TABSTOP; 1782 if(special_style != BS_GROUPBOX && special_style != BS_RADIOBUTTON) 1783 defaultstyle |= WS_TABSTOP; 1739 1784 break; 1740 1785 case CT_EDIT: 1741 ctrl->style |= WS_TABSTOP | WS_BORDER;1786 defaultstyle |= WS_TABSTOP | WS_BORDER; 1742 1787 break; 1743 1788 case CT_LISTBOX: 1744 ctrl->style |= LBS_NOTIFY | WS_BORDER;1789 defaultstyle |= LBS_NOTIFY | WS_BORDER; 1745 1790 break; 1746 1791 case CT_COMBOBOX: 1747 ctrl->style |= CBS_SIMPLE;1792 defaultstyle |= CBS_SIMPLE; 1748 1793 break; 1749 1794 case CT_STATIC: 1750 ctrl->style |= style; 1751 if(style == SS_CENTER || style == SS_LEFT || style == SS_RIGHT) 1752 ctrl->style |= WS_GROUP; 1795 if(special_style == SS_CENTER || special_style == SS_LEFT || special_style == SS_RIGHT) 1796 defaultstyle |= WS_GROUP; 1753 1797 break; 1754 1798 } … … 1759 1803 { 1760 1804 case CT_EDIT: 1761 ctrl->style |= ES_LEFT;1805 defaultstyle |= ES_LEFT; 1762 1806 break; 1763 1807 case CT_LISTBOX: 1764 ctrl->style |= LBS_NOTIFY;1808 defaultstyle |= LBS_NOTIFY; 1765 1809 break; 1766 1810 case CT_COMBOBOX: 1767 ctrl->style |= CBS_SIMPLE | WS_TABSTOP;1811 defaultstyle |= CBS_SIMPLE | WS_TABSTOP; 1768 1812 break; 1769 1813 case CT_SCROLLBAR: 1770 ctrl->style |= SBS_HORZ;1814 defaultstyle |= SBS_HORZ; 1771 1815 break; 1772 1816 case CT_BUTTON: 1773 switch(s tyle)1817 switch(special_style) 1774 1818 { 1775 1819 case BS_CHECKBOX: … … 1782 1826 case BS_3STATE: 1783 1827 case BS_AUTOCHECKBOX: 1784 ctrl->style |= WS_TABSTOP;1828 defaultstyle |= WS_TABSTOP; 1785 1829 break; 1786 1830 default: 1787 yywarning("Unknown default button control-style 0x%08x", s tyle);1831 yywarning("Unknown default button control-style 0x%08x", special_style); 1788 1832 case BS_RADIOBUTTON: 1789 1833 break; … … 1792 1836 1793 1837 case CT_STATIC: 1794 switch(s tyle)1838 switch(special_style) 1795 1839 { 1796 1840 case SS_LEFT: 1797 1841 case SS_RIGHT: 1798 1842 case SS_CENTER: 1799 ctrl->style |= WS_GROUP;1843 defaultstyle |= WS_GROUP; 1800 1844 break; 1801 1845 case SS_ICON: /* Special case */ 1802 1846 break; 1803 1847 default: 1804 yywarning("Unknown default static control-style 0x%08x", s tyle);1848 yywarning("Unknown default static control-style 0x%08x", special_style); 1805 1849 break; 1806 1850 } … … 1815 1859 1816 1860 /* The SS_ICON flag is always forced in for icon controls */ 1817 if(type == CT_STATIC && style == SS_ICON) 1818 ctrl->style |= SS_ICON; 1819 1861 if(type == CT_STATIC && special_style == SS_ICON) 1862 defaultstyle |= SS_ICON; 1863 1864 if (!ctrl->gotstyle) 1865 ctrl->style = new_style(0,0); 1866 1867 /* combine all styles */ 1868 ctrl->style->or_mask = ctrl->style->or_mask | defaultstyle | special_style; 1820 1869 ctrl->gotstyle = TRUE; 1821 1870 byebye: 1871 /* combine with NOT mask */ 1872 if (ctrl->gotstyle) 1873 { 1874 ctrl->style->or_mask &= ~(ctrl->style->and_mask); 1875 ctrl->style->and_mask = 0; 1876 } 1877 if (ctrl->gotexstyle) 1878 { 1879 ctrl->exstyle->or_mask &= ~(ctrl->exstyle->and_mask); 1880 ctrl->exstyle->and_mask = 0; 1881 } 1822 1882 return ctrl; 1823 1883 } … … 1861 1921 1862 1922 /* DialogEx specific functions */ 1863 dialogex_t *dialogex_style(int st, dialogex_t *dlg) 1864 { 1865 DWORD s = 0; 1923 dialogex_t *dialogex_style(style_t * st, dialogex_t *dlg) 1924 { 1866 1925 assert(dlg != NULL); 1926 if(dlg->style == NULL) 1927 { 1928 dlg->style = new_style(0,0); 1929 } 1930 1867 1931 if(dlg->gotstyle) 1868 1932 { 1869 1933 yywarning("Style already defined, or-ing together"); 1870 s = dlg->style; 1871 } 1872 dlg->style = st | s; 1934 } 1935 else 1936 { 1937 dlg->style->or_mask = 0; 1938 dlg->style->and_mask = 0; 1939 } 1940 dlg->style->or_mask |= st->or_mask; 1941 dlg->style->and_mask |= st->and_mask; 1873 1942 dlg->gotstyle = TRUE; 1943 free(st); 1874 1944 return dlg; 1875 1945 } 1876 1946 1877 dialogex_t *dialogex_exstyle(int st, dialogex_t *dlg) 1878 { 1879 DWORD s = 0; 1947 dialogex_t *dialogex_exstyle(style_t * st, dialogex_t *dlg) 1948 { 1880 1949 assert(dlg != NULL); 1950 if(dlg->exstyle == NULL) 1951 { 1952 dlg->exstyle = new_style(0,0); 1953 } 1954 1881 1955 if(dlg->gotexstyle) 1882 1956 { 1883 1957 yywarning("ExStyle already defined, or-ing together"); 1884 s = dlg->exstyle; 1885 } 1886 dlg->exstyle = st | s; 1958 } 1959 else 1960 { 1961 dlg->exstyle->or_mask = 0; 1962 dlg->exstyle->and_mask = 0; 1963 } 1964 dlg->exstyle->or_mask |= st->or_mask; 1965 dlg->exstyle->and_mask |= st->and_mask; 1887 1966 dlg->gotexstyle = TRUE; 1967 free(st); 1888 1968 return dlg; 1889 1969 }
Note:
See TracChangeset
for help on using the changeset viewer.