📄 rcos2.y
字号:
| menu-text Y_COMMA menu-id Y_COMMA menuitem-style Y_COMMA menuitem-attrib
{
$$.ItemStyle = $5;
$$.ItemAttrs = $7;
$$.ItemCmd = $3;
$$.ItemText = $1.string;
}
;
menu-text
: string-constant
;
menu-item-options
: menu-item-option
{ $$ = SemOS2AddFirstMenuOption( $1 ); }
| menu-item-options comma-opt menu-item-option
{ $$ = SemOS2AddMenuOption( $1, $3 ); }
;
menu-item-option
: Y_BITMAP
{ $$ = Y_BITMAP; }
| Y_HELP
{ $$ = Y_HELP; }
;
dialogtemplate
: Y_DLGTEMPLATE
{ $$ = Y_DLGTEMPLATE; }
| Y_WINDOWTEMPLATE
{ $$ = Y_WINDOWTEMPLATE; }
;
dlg-template
: dialogtemplate name-id diag-control-section
{
SemOS2WriteDialogTemplate( $2,
MEMFLAG_PURE | MEMFLAG_MOVEABLE | MEMFLAG_DISCARDABLE,
SemOS2DefaultCodepage(), $3 );
}
| dialogtemplate name-id resource-options diag-control-section
{
SemOS2CheckResFlags( &($3), 0, MEMFLAG_MOVEABLE | MEMFLAG_DISCARDABLE,
MEMFLAG_PURE );
SemOS2WriteDialogTemplate( $2, $3.flags, $3.codePage, $4 );
}
;
size-info
: size-x comma-opt size-y comma-opt size-w comma-opt size-h
{ $$.x = $1; $$.y = $3; $$.width = $5; $$.height = $7; }
;
size-x
: constant-expression
{ $$ = $1.Value; }
;
size-y
: constant-expression
{ $$ = $1.Value; }
;
size-w
: constant-expression
{ $$ = $1.Value; }
;
size-h
: constant-expression
{ $$ = $1.Value; }
;
diag-options-stmt
: menu-stmt
| font-stmt
;
menu-stmt
: Y_MENU name-id
{
$$.token = Y_MENU;
$$.Opt.Name = WResIDToNameOrOrd( $2 );
RcMemFree( $2 );
}
;
ctl-class-name
: string-constant
{ $$ = ResStrToNameOrOrd( $1.string ); RcMemFree( $1.string ); }
| Y_PUSHBUTTON
{ $$ = ResStrToNameOrOrd( "PUSHBUTTON" ); }
| Y_COMBOBOX
{ $$ = ResStrToNameOrOrd( "COMBOBOX" ); }
| Y_ENTRYFIELD
{ $$ = ResStrToNameOrOrd( "ENTRYFIELD" ); }
| Y_LISTBOX
{ $$ = ResStrToNameOrOrd( "LISTBOX" ); }
| constant-expression
{ $$ = ResNumToNameOrOrd( $1.Value | 0x80 ); }
/* A little hack - OS/2 standard window classes are defined like this:
#define WC_BUTTON ((PSZ)0xffff0003L)
Since PSZ doesn't mean anything to wrc, it won't recognize the
constant. So we add a special case to get rid of the PSZ. Not very
clean but does the job.
*/
| Y_LPAREN Y_LPAREN Y_PSZ Y_RPAREN constant-expression Y_RPAREN
{ $$ = ResNumToNameOrOrd( $5.Value | 0x80 ); }
;
font-stmt
: Y_FONT comma-opt
{
$$.token = Y_FONT;
$$.Opt.Font.FontName = NULL;
$$.Opt.Font.FontItalic = 0;
$$.Opt.Font.FontExtra = 1;
}
;
diag-control-section
: Y_BEGIN diag-control-stmts Y_END
{ $$ = $2; }
| Y_LBRACE diag-control-stmts Y_RBRACE
{ $$ = $2; }
;
diag-data-elements
: control-data-section
| /* Nothing */
{ $$ = NULL; }
;
diag-control-stmts
: diag-control-stmt diag-data-elements
{ $$ = SemOS2NewDiagCtrlList( $1, $2, NULL ); }
| diag-control-stmts diag-control-stmt diag-data-elements
{ $$ = SemOS2AddDiagCtrlList( $1, $2, $3, NULL ); }
;
diag-control-stmt
: autocheckbox-stmt
| autoradiobutton-stmt
| checkbox-stmt
| combobox-stmt
| container-stmt
| ctext-stmt
| defpushbutton-stmt
| edittext-stmt
| groupbox-stmt
| icon-stmt
| listbox-stmt
| ltext-stmt
| mle-stmt
| notebook-stmt
| pushbutton-stmt
| radiobutton-stmt
| rtext-stmt
| slider-stmt
| spinbutton-stmt
| valueset-stmt
| control-stmt
| dialog-stmt
;
cntl-text-options
: string-constant cntl-options
{
$2.Text = ResStrToNameOrOrd( $1.string );
RcMemFree( $1.string );
$$ = $2;
}
;
cntl-options
: comma-opt cntl-id comma-opt size-info comma-opt
{
$$.ID = $2;
$$.Size = $4;
$$.Style.Mask = 0;
$$.Style.Value = 0;
$$.Text = NULL;
}
| comma-opt cntl-id comma-opt size-info comma-opt cntl-style
{
$$.ID = $2;
$$.Size = $4;
$$.Style = $6;
$$.Text = NULL;
}
;
cntl-style
: constant-expression
{ $$ = $1; }
;
frame-style
: constant-expression
{ $$ = $1; }
;
cntl-id
: constant-expression
{ $$ = $1.Value; }
;
autocheckbox-stmt
: Y_AUTOCHECKBOX cntl-text-options presparam-list
{ $$ = SemOS2NewDiagCtrl( Y_AUTOCHECKBOX, $2, $3 ); }
;
autoradiobutton-stmt
: Y_AUTORADIOBUTTON cntl-text-options presparam-list
{ $$ = SemOS2NewDiagCtrl( Y_AUTORADIOBUTTON, $2, $3 ); }
;
checkbox-stmt
: Y_CHECKBOX cntl-text-options presparam-list
{ $$ = SemOS2NewDiagCtrl( Y_CHECKBOX, $2, $3 ); }
;
combobox-stmt
: Y_COMBOBOX cntl-text-options presparam-list
{ $$ = SemOS2NewDiagCtrl( Y_COMBOBOX, $2, $3 ); }
;
container-stmt
: Y_CONTAINER cntl-options presparam-list
{ $$ = SemOS2NewDiagCtrl( Y_CONTAINER, $2, $3 ); }
;
ctext-stmt
: Y_CTEXT cntl-text-options presparam-list
{ $$ = SemOS2NewDiagCtrl( Y_CTEXT, $2, $3 ); }
;
defpushbutton-stmt
: Y_DEFPUSHBUTTON cntl-text-options presparam-list
{ $$ = SemOS2NewDiagCtrl( Y_DEFPUSHBUTTON, $2, $3 ); }
;
edittext-stmt
: Y_EDITTEXT cntl-text-options presparam-list
{ $$ = SemOS2NewDiagCtrl( Y_EDITTEXT, $2, $3 ); }
| Y_ENTRYFIELD cntl-text-options presparam-list
{ $$ = SemOS2NewDiagCtrl( Y_EDITTEXT, $2, $3 ); }
;
groupbox-stmt
: Y_GROUPBOX cntl-text-options presparam-list
{ $$ = SemOS2NewDiagCtrl( Y_GROUPBOX, $2, $3 ); }
;
listbox-stmt
: Y_LISTBOX cntl-options presparam-list
{ $$ = SemOS2NewDiagCtrl( Y_LISTBOX, $2, $3 ); }
;
ltext-stmt
: Y_LTEXT cntl-text-options presparam-list
{ $$ = SemOS2NewDiagCtrl( Y_LTEXT, $2, $3 ); }
;
mle-stmt
: Y_MLE cntl-text-options presparam-list
{ $$ = SemOS2NewDiagCtrl( Y_MLE, $2, $3 ); }
;
notebook-stmt
: Y_NOTEBOOK cntl-options presparam-list
{ $$ = SemOS2NewDiagCtrl( Y_NOTEBOOK, $2, $3 ); }
;
pushbutton-stmt
: Y_PUSHBUTTON cntl-text-options presparam-list
{ $$ = SemOS2NewDiagCtrl( Y_PUSHBUTTON, $2, $3 ); }
;
radiobutton-stmt
: Y_RADIOBUTTON cntl-text-options presparam-list
{ $$ = SemOS2NewDiagCtrl( Y_RADIOBUTTON, $2, $3 ); }
;
rtext-stmt
: Y_RTEXT cntl-text-options presparam-list
{ $$ = SemOS2NewDiagCtrl( Y_RTEXT, $2, $3 ); }
;
slider-stmt
: Y_SLIDER cntl-options presparam-list
{ $$ = SemOS2NewDiagCtrl( Y_SLIDER, $2, $3 ); }
;
spinbutton-stmt
: Y_SPINBUTTON cntl-options presparam-list
{ $$ = SemOS2NewDiagCtrl( Y_SPINBUTTON, $2, $3 ); }
;
valueset-stmt
: Y_VALUESET cntl-options presparam-list
{ $$ = SemOS2NewDiagCtrl( Y_VALUESET, $2, $3 ); }
;
icon-stmt
: Y_ICON control-name comma-opt cntl-id comma-opt icon-parms
{ $6.Text = $2; $6.ID = $4; $$ = SemOS2NewDiagCtrl( Y_ICON, $6, NULL ); }
;
icon-parms
: size-x comma-opt size-y comma-opt size-w comma-opt size-h
{
$$.Size.x = $1;
$$.Size.y = $3;
$$.Size.width = $5;
$$.Size.height = $7;
$$.Style.Mask = 0; /* no style given */
$$.Style.Value = 0;
}
| size-x comma-opt size-y comma-opt size-w comma-opt size-h comma-opt cntl-style
{
$$.Size.x = $1;
$$.Size.y = $3;
$$.Size.width = $5;
$$.Size.height = $7;
$$.Style = $9;
}
;
control-name
: name-id
{ $$ = WResIDToNameOrOrd( $1 ); RcMemFree( $1 ); }
;
control-stmt
: Y_CONTROL control-name comma-opt cntl-id comma-opt size-info comma-opt
ctl-class-name presparam-list
{
IntMask mask = {0};
$$ = SemOS2SetControlData( $2, $4, $6, $8, mask, NULL, $9 );
}
| Y_CONTROL control-name comma-opt cntl-id comma-opt size-info comma-opt
ctl-class-name comma-opt cntl-style presparam-list
{
$$ = SemOS2SetControlData( $2, $4, $6, $8, $10, NULL, $11 );
}
;
cntl-text
: name-id
;
dialog-or-frame
: Y_DIALOG
{ $$ = Y_DIALOG; }
| Y_FRAME
{ $$ = Y_FRAME; }
;
dialog-stmt
: dialog-or-frame cntl-text-options presparam-list
{
IntMask mask = {0};
$$ = SemOS2SetWindowData( $2, mask, $3, NULL, $1 );
}
| dialog-or-frame cntl-text-options Y_COMMA frame-style presparam-list
{
$$ = SemOS2SetWindowData( $2, $4, $5, NULL, $1 );
}
| dialog-or-frame cntl-text-options presparam-list diag-control-section
{
IntMask mask = {0};
$$ = SemOS2SetWindowData( $2, mask, $3, $4, $1 );
}
| dialog-or-frame cntl-text-options Y_COMMA frame-style presparam-list diag-control-section
{
$$ = SemOS2SetWindowData( $2, $4, $5, $6, $1 );
}
;
string-constant
: string-group
| Y_LSQ_BRACKET string-group Y_RSQ_BRACKET
{
$$ = $2;
}
;
string-group
: Y_STRING
| string-group Y_STRING
{
$$.lstring = ( $1.lstring | $2.lstring );
$$.length = $1.length + $2.length;
$$.string = RcMemMalloc( $$.length + 1 );
strcpy( $$.string, $1.string );
strcat( $$.string, $2.string );
RcMemFree( $1.string );
RcMemFree( $2.string );
}
;
constant-expression
: conditional-exp
;
conditional-exp
: log-or-exp
| log-or-exp Y_QUESTION constant-expression Y_COLON conditional-exp
{ $$ = $1.Value ? $3 : $5; }
;
log-or-exp
: log-and-exp
| log-or-exp Y_OR log-and-exp
{ $$.Value = $1.Value || $3.Value; $$.Mask = $1.Mask | $3.Mask; }
;
log-and-exp
: bit-or-exp
| log-and-exp Y_AND bit-or-exp
{ $$.Value = $1.Value && $3.Value; $$.Mask = $1.Mask | $3.Mask; }
;
bit-or-exp
: bit-xor-exp
| bit-or-exp Y_BITOR bit-xor-exp
{ $$.Value = $1.Value | $3.Value; $$.Mask = $1.Mask | $3.Mask; }
;
bit-xor-exp
: bit-and-exp
| bit-xor-exp Y_BITXOR bit-and-exp
{ $$.Value = $1.Value ^ $3.Value; $$.Mask = $1.Mask | $3.Mask; }
;
bit-and-exp
: equality-exp
| bit-and-exp Y_BITAND equality-exp
{ $$.Value = $1.Value & $3.Value; $$.Mask = $1.Mask | $3.Mask; }
;
equality-exp
: relational-exp
| equality-exp Y_EQ relational-exp
{ $$.Value = $1.Value == $3.Value; $$.Mask = $1.Mask | $3.Mask; }
| equality-exp Y_NE relational-exp
{ $$.Value = $1.Value != $3.Value; $$.Mask = $1.Mask | $3.Mask; }
;
relational-exp
: shift-exp
| relational-exp Y_GT shift-exp
{ $$.Value = $1.Value > $3.Value; $$.Mask = $1.Mask | $3.Mask; }
| relational-exp Y_LT shift-exp
{ $$.Value = $1.Value < $3.Value; $$.Mask = $1.Mask | $3.Mask; }
| relational-exp Y_GE shift-exp
{ $$.Value = $1.Value >= $3.Value; $$.Mask = $1.Mask | $3.Mask; }
| relational-exp Y_LE shift-exp
{ $$.Value = $1.Value <= $3.Value; $$.Mask = $1.Mask | $3.Mask; }
;
shift-exp
: additive-exp
| shift-exp Y_SHIFTL additive-exp
{ $$.Value = $1.Value << $3.Value; $$.Mask = $1.Mask | $3.Mask; }
| shift-exp Y_SHIFTR additive-exp
{ $$.Value = $1.Value >> $3.Value; $$.Mask = $1.Mask | $3.Mask; }
;
additive-exp
: multiplicative-exp
| additive-exp Y_PLUS multiplicative-exp
{ $$.Value = $1.Value + $3.Value; $$.Mask = $1.Mask | $3.Mask; }
| additive-exp Y_MINUS multiplicative-exp
{ $$.Value = $1.Value - $3.Value; $$.Mask = $1.Mask | $3.Mask; }
;
multiplicative-exp
: unary-exp
| multiplicative-exp Y_TIMES unary-exp
{ $$.Value = $1.Value * $3.Value; $$.Mask = $1.Mask | $3.Mask; }
| multiplicative-exp Y_DIVIDE unary-exp
{ $$.Value = $1.Value / $3.Value; $$.Mask = $1.Mask | $3.Mask; }
| multiplicative-exp Y_MOD unary-exp
{ $$.Value = $1.Value % $3.Value; $$.Mask = $1.Mask | $3.Mask; }
;
unary-exp
: primary-exp
| Y_MINUS unary-exp
{ $$.Value = - $2.Value; $$.Mask = $2.Mask; }
| Y_BITNOT unary-exp
{ $$.Value = ~ $2.Value; $$.Mask = $2.Mask; }
| Y_NOT unary-exp
{ $$.Value = ! $2.Value; $$.Mask = $2.Mask; }
| Y_NOT_KEYWORD unary-exp
{ $$.Value = ! $2.Value; $$.Mask = $2.Mask; }
;
primary-exp
: Y_INTEGER
{
$$.Mask = $1.val; $$.Value = $1.val;
$$.longVal = ($1.type & SCAN_INT_TYPE_LONG) != 0;
$$.unsgVal = ($1.type & SCAN_INT_TYPE_UNSIGNED) != 0;
}
| Y_LPAREN constant-expression Y_RPAREN
{ $$ = $2; }
;
%%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -