📄 rcos2.y
字号:
/***************************************************************************
* OS/2 Resource Compiler Grammar
* Worked out with much blood, sweat & tears, no thanks to IBM's atrocious
* "documentation". Reverse engineering rules.
***************************************************************************/
/*** error tokens ***/
%token Y_SCAN_ERROR
/*** non-keyword tokens ***/
%token <string> Y_NAME
%token <intinfo> Y_INTEGER
%token <string> Y_STRING
%token <string> Y_DOS_FILENAME
/*** operator tokens ***/
%token Y_POUND_SIGN /* this token is intercepted by yylex */
%token Y_LPAREN
%token Y_RPAREN
%token Y_LBRACE
%token Y_RBRACE
%token Y_LSQ_BRACKET
%token Y_RSQ_BRACKET
%token Y_PLUS
%token Y_MINUS
%token Y_BITNOT
%token Y_NOT
%token Y_TIMES
%token Y_DIVIDE
%token Y_MOD
%token Y_SHIFTL
%token Y_SHIFTR
%token Y_GT
%token Y_LT
%token Y_GE
%token Y_LE
%token Y_EQ
%token Y_SINGLE_EQ
%token Y_NE
%token Y_BITAND
%token Y_BITXOR
%token Y_BITOR
%token Y_AND
%token Y_OR
%token Y_QUESTION
%token Y_COLON
%token Y_COMMA
/*** keywords tokens ***/
%token Y_ACCELTABLE
%token Y_ALT
%token Y_ASSOCTABLE
%token Y_AUTOCHECKBOX
%token Y_AUTORADIOBUTTON
%token Y_BEGIN
%token Y_BITMAP
%token Y_CHAR
%token Y_CHARTABLE
%token Y_CHECKBOX
%token Y_CODEPAGE
%token Y_COMBOBOX
%token Y_CONTAINER
%token Y_CONTROL
%token Y_CTEXT
%token Y_CTLDATA
%token Y_CURSOR
%token Y_DEFAULTICON
%token Y_DEFPUSHBUTTON
%token Y_DIALOG
%token Y_DISCARDABLE
%token Y_DLGINCLUDE
%token Y_DLGTEMPLATE
%token Y_EDITTEXT
%token Y_END
%token Y_ENTRYFIELD
%token Y_FIXED
%token Y_FKAITEM
%token Y_FKALONG
%token Y_FKAROW
%token Y_FKASHORT
%token Y_FONT
%token Y_FONTDIR
%token Y_FRAME
%token Y_GROUPBOX
%token Y_HELP
%token Y_HELPITEM
%token Y_HELPSUBITEM
%token Y_HELPSUBTABLE
%token Y_HELPTABLE
%token Y_ICON
%token Y_IMPURE
%token Y_KEYTABLE
%token Y_LISTBOX
%token Y_LOADONCALL
%token Y_LONEKEY
%token Y_LTEXT
%token Y_MENU
%token Y_MENUITEM
%token Y_MESSAGETABLE
%token Y_MLE
%token Y_MOVEABLE
%token Y_NONSHARED
%token Y_NOT_KEYWORD
%token Y_NOTEBOOK
%token Y_POINTER
%token Y_POUND_PRAGMA
%token Y_PRELOAD
%token Y_PRESPARAMS
%token Y_PSZ
%token Y_PURE
%token Y_PUSHBUTTON
%token Y_RADIOBUTTON
%token Y_RCDATA
%token Y_RCINCLUDE /* This is an old keyword that should no */
/* longer be used, but is used in the sample files*/
/* so may be used in some old .RC files. */
/* It is intercepted by the scanner */
%token Y_RESOURCE
%token Y_RTEXT
%token Y_SCANCODE
%token Y_SEGALIGN
%token Y_SEPARATOR
%token Y_SHARED
%token Y_SHIFT
%token Y_SLIDER
%token Y_SPINBUTTON
%token Y_STRINGTABLE
%token Y_SUBITEMSIZE
%token Y_SUBMENU
%token Y_SYSCOMMAND
%token Y_VALUESET
%token Y_VIRTUALKEY
%token Y_VKEYTABLE
%token Y_WINDOW
%token Y_WINDOWTEMPLATE
%type <maskint> constant-expression
%type <maskint> conditional-exp
%type <maskint> log-or-exp
%type <maskint> log-and-exp
%type <maskint> bit-or-exp
%type <maskint> bit-xor-exp
%type <maskint> bit-and-exp
%type <maskint> equality-exp
%type <maskint> relational-exp
%type <maskint> shift-exp
%type <maskint> additive-exp
%type <maskint> multiplicative-exp
%type <maskint> unary-exp
%type <maskint> primary-exp
%type <token> keyword-name
%type <resid> name-id
%type <resid> type-id
%type <integral> id-value
%type <fullresflags> resource-options
%type <maskint> resource-option
%type <string> file-name
%type <acceltable> acc-section
%type <accevent> acc-event
%type <integral> acc-cmd
%type <accflags> acc-item-option
%type <accflags> acc-item-options
%type <accelfullentry> acc-item
%type <acceltable> acc-items
%type <helptable> help-table-section
%type <helptable> help-items
%type <helpfullentry> help-item
%type <helpsubtable> help-subitems
%type <helpsubtable> help-subtable-section
%type <dataelem> help-subitem
%type <menuflags> menu-item-options
%type <token> menu-item-option
%type <menuptr> menu-section
%type <menuptr> submenu-section
%type <menuptr> menu-items
%type <menufull> menu-item
%type <menuitem> menu-entry-stmt
%type <menuitem> menu-entry-defn
%type <menufull> submenu-entry-stmt
%type <string> menu-text
%type <integral> size-x
%type <integral> size-y
%type <integral> size-w
%type <integral> size-h
%type <sizeinfo> size-info
%type <string> string-constant
%type <string> string-group
%type <diagopts> menu-stmt
%type <diagopts> font-stmt
%type <diagopts> diag-options-stmt
%type <token> dialogtemplate
%type <dataelem> diag-data-elements
%type <nameorord> ctl-class-name
%type <token> dialog-or-frame
%type <diagctrllist> diag-control-section
%type <diagctrllist> diag-control-stmts
%type <diagctrl> diag-control-stmt
%type <diagctrl> dialog-stmt
%type <diagctrlopts> cntl-text-options
%type <diagctrlopts> cntl-options
%type <diagctrlopts> icon-parms
%type <presparams> presparam-stmt
%type <presparamlist> presparam-list
%type <diagctrl> autocheckbox-stmt
%type <diagctrl> autoradiobutton-stmt
%type <diagctrl> checkbox-stmt
%type <diagctrl> combobox-stmt
%type <diagctrl> container-stmt
%type <diagctrl> ctext-stmt
%type <diagctrl> defpushbutton-stmt
%type <diagctrl> edittext-stmt
%type <diagctrl> groupbox-stmt
%type <diagctrl> listbox-stmt
%type <diagctrl> ltext-stmt
%type <diagctrl> mle-stmt
%type <diagctrl> notebook-stmt
%type <diagctrl> pushbutton-stmt
%type <diagctrl> radiobutton-stmt
%type <diagctrl> rtext-stmt
%type <diagctrl> slider-stmt
%type <diagctrl> spinbutton-stmt
%type <diagctrl> valueset-stmt
%type <diagctrl> icon-stmt
%type <diagctrl> control-stmt
%type <nameorord> control-name
%type <nameorord> presparam-name
%type <integral> cntl-id
%type <resid> cntl-text
%type <maskint> cntl-style
%type <maskint> frame-style
%type <integral> string-id
%type <stritem> string-item
%type <strtable> string-items
%type <strtable> string-section
%type <rawitem> raw-data-item
%type <rawitem> raw-numeric-data-item
%type <rawitem> rc-data-item
%type <resloc> user-defined-data
%type <resloc> rc-data
%type <token> resource-type
%type <dataelem> control-data-section
%type <dataelem> raw-data-section
%type <dataelem> raw-data-items
%type <dataelem> raw-numeric-data-items
%type <dataelem> rc-data-items
%type <dataelem> rc-data-section
%type <integral> menu-id
%type <integral> menuitem-style
%type <integral> menuitem-attrib
%start goal-symbol
%%
goal-symbol
: resources
| /* nothing */
;
resources
: resource
| resources resource
;
resource
: normal-resource
| string-table-resource
| message-table-resource
| pragma-statment
| codepage-statement
;
normal-resource
: single-line-resource
| rcdata-resource
| user-defined-resource
| menu-resource
| accel-table-resource
| help-table-resource
| help-subtable-resource
| dlg-template
| dlginclude-resource
;
name-id
: Y_NAME
{ $$ = WResIDFromStr( $1.string ); RcMemFree( $1.string ); }
| string-constant
{ $$ = WResIDFromStr( $1.string ); RcMemFree( $1.string ); }
| constant-expression
{
$$ = WResIDFromNum( $1.Value );
if( $$ == NULL ) {
$$ = WResIDFromNum( 0 );
RcError( ERR_BAD_RES_ID, $1.Value );
ErrorHasOccured = TRUE;
}
}
| keyword-name
{ $$ = WResIDFromStr( SemOS2TokenToString( $1 ) ); }
;
type-id
: Y_NAME
{ $$ = WResIDFromStr( $1.string ); RcMemFree( $1.string ); }
| string-constant
{ $$ = WResIDFromStr( $1.string ); RcMemFree( $1.string ); }
| constant-expression
{ $$ = WResIDFromNum( $1.Value ); }
;
pragma-statment
: Y_POUND_PRAGMA Y_CODEPAGE Y_LPAREN constant-expression Y_RPAREN
{ SemOS2SetCodepage( $4.Value ); }
;
codepage-statement
: Y_CODEPAGE constant-expression
{ SemOS2SetCodepage( $2.Value ); }
;
keyword-name
: Y_ACCELTABLE
{ $$ = Y_ACCELTABLE; }
| Y_ALT
{ $$ = Y_ALT; }
| Y_ASSOCTABLE
{ $$ = Y_ASSOCTABLE; }
| Y_AUTOCHECKBOX
{ $$ = Y_AUTOCHECKBOX; }
| Y_AUTORADIOBUTTON
{ $$ = Y_AUTORADIOBUTTON; }
| Y_BEGIN
{ $$ = Y_BEGIN; }
| Y_BITMAP
{ $$ = Y_BITMAP; }
| Y_CHAR
{ $$ = Y_CHAR; }
| Y_CHARTABLE
{ $$ = Y_CHARTABLE; }
| Y_CHECKBOX
{ $$ = Y_CHECKBOX; }
| Y_CODEPAGE
{ $$ = Y_CODEPAGE; }
| Y_COMBOBOX
{ $$ = Y_COMBOBOX; }
| Y_CONTAINER
{ $$ = Y_CONTAINER; }
| Y_CONTROL
{ $$ = Y_CONTROL; }
| Y_CTEXT
{ $$ = Y_CTEXT; }
| Y_CTLDATA
{ $$ = Y_CTLDATA; }
| Y_CURSOR
{ $$ = Y_CURSOR; }
| Y_DEFAULTICON
{ $$ = Y_DEFAULTICON; }
| Y_DEFPUSHBUTTON
{ $$ = Y_DEFPUSHBUTTON; }
| Y_DIALOG
{ $$ = Y_DIALOG; }
| Y_DISCARDABLE
{ $$ = Y_DISCARDABLE; }
| Y_DLGINCLUDE
{ $$ = Y_DLGINCLUDE; }
| Y_DLGTEMPLATE
{ $$ = Y_DLGTEMPLATE; }
| Y_EDITTEXT
{ $$ = Y_EDITTEXT; }
| Y_END
{ $$ = Y_END; }
| Y_ENTRYFIELD
{ $$ = Y_ENTRYFIELD; }
| Y_FIXED
{ $$ = Y_FIXED; }
| Y_FKAITEM
{ $$ = Y_FKAITEM; }
| Y_FKALONG
{ $$ = Y_FKALONG; }
| Y_FKAROW
{ $$ = Y_FKASHORT; }
| Y_FKASHORT
{ $$ = Y_FKASHORT; }
| Y_FONT
{ $$ = Y_FONT; }
| Y_FONTDIR
{ $$ = Y_FONTDIR; }
| Y_FRAME
{ $$ = Y_FRAME; }
| Y_GROUPBOX
{ $$ = Y_GROUPBOX; }
| Y_HELP
{ $$ = Y_HELP; }
| Y_HELPITEM
{ $$ = Y_HELPITEM; }
| Y_HELPSUBITEM
{ $$ = Y_HELPSUBITEM; }
| Y_HELPTABLE
{ $$ = Y_HELPTABLE; }
| Y_ICON
{ $$ = Y_ICON; }
| Y_IMPURE
{ $$ = Y_IMPURE; }
| Y_KEYTABLE
{ $$ = Y_KEYTABLE; }
| Y_LISTBOX
{ $$ = Y_LISTBOX; }
| Y_LOADONCALL
{ $$ = Y_LOADONCALL; }
| Y_LONEKEY
{ $$ = Y_LONEKEY; }
| Y_LTEXT
{ $$ = Y_LTEXT; }
| Y_MENU
{ $$ = Y_MENU; }
| Y_MENUITEM
{ $$ = Y_MENUITEM; }
| Y_MESSAGETABLE
{ $$ = Y_MESSAGETABLE; }
| Y_MLE
{ $$ = Y_MLE; }
| Y_MOVEABLE
{ $$ = Y_MOVEABLE; }
| Y_NONSHARED
{ $$ = Y_NONSHARED; }
| Y_NOTEBOOK
{ $$ = Y_NOTEBOOK; }
| Y_POINTER
{ $$ = Y_POINTER; }
| Y_PRELOAD
{ $$ = Y_PRELOAD; }
| Y_PRESPARAMS
{ $$ = Y_PRESPARAMS; }
| Y_PURE
{ $$ = Y_PURE; }
| Y_PUSHBUTTON
{ $$ = Y_PUSHBUTTON; }
| Y_RADIOBUTTON
{ $$ = Y_RADIOBUTTON; }
| Y_RCDATA
{ $$ = Y_RCDATA; }
| Y_RCINCLUDE
{ $$ = Y_RCINCLUDE; }
| Y_RESOURCE
{ $$ = Y_RESOURCE; }
| Y_RTEXT
{ $$ = Y_RTEXT; }
| Y_SCANCODE
{ $$ = Y_SCANCODE; }
| Y_SEGALIGN
{ $$ = Y_SEGALIGN; }
| Y_SEPARATOR
{ $$ = Y_SEPARATOR; }
| Y_SHARED
{ $$ = Y_SHARED; }
| Y_SHIFT
{ $$ = Y_SHIFT; }
| Y_SLIDER
{ $$ = Y_SLIDER; }
| Y_SPINBUTTON
{ $$ = Y_SPINBUTTON; }
| Y_STRINGTABLE
{ $$ = Y_STRINGTABLE; }
| Y_SUBITEMSIZE
{ $$ = Y_SUBITEMSIZE; }
| Y_SUBMENU
{ $$ = Y_SUBMENU; }
| Y_SYSCOMMAND
{ $$ = Y_SYSCOMMAND; }
| Y_VALUESET
{ $$ = Y_VALUESET; }
| Y_VIRTUALKEY
{ $$ = Y_VIRTUALKEY; }
| Y_VKEYTABLE
{ $$ = Y_VKEYTABLE; }
| Y_WINDOW
{ $$ = Y_WINDOW; }
| Y_WINDOWTEMPLATE
{ $$ = Y_WINDOWTEMPLATE; }
;
comma-opt
: Y_COMMA
| /* nothing */
;
dlginclude-resource
: Y_DLGINCLUDE name-id file-name
{ SemOS2AddDlgincResource( $2, $3.string ); }
;
single-line-resource
: resource-type name-id file-name
{ SemOS2AddSingleLineResource( $2, $1, NULL, $3.string ); }
| resource-type name-id resource-options file-name
{ SemOS2AddSingleLineResource( $2, $1, &($3), $4.string ); }
| Y_DEFAULTICON file-name
{ SemOS2AddSingleLineResource( NULL, Y_DEFAULTICON, NULL, $2.string ); }
| Y_DEFAULTICON resource-options file-name
{ SemOS2AddSingleLineResource( NULL, Y_DEFAULTICON, &($2), $3.string ); }
;
resource-options
: resource-option
{ $$ = SemOS2AddFirstResOption( $1.Mask, $1.Value ); }
| resource-options resource-option
{ $$ = SemOS2AddResOption( $1, $2.Mask, $2.Value ); }
;
resource-option
: Y_PRELOAD
{ $$.Mask = Y_PRELOAD; }
| Y_LOADONCALL
{ $$.Mask = Y_LOADONCALL; }
| Y_FIXED
{ $$.Mask = Y_FIXED; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -