parser: untabify

Run vim's :%retab and some resulting indention fixes.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2012-07-25 21:37:20 +03:00
parent 724f62c8e3
commit 01c81fa61e
2 changed files with 694 additions and 733 deletions

View File

@ -116,7 +116,9 @@ yyerror(struct YYLTYPE *loc, struct parser_param *param, const char *msg)
%left TIMES DIVIDE %left TIMES DIVIDE
%left EXCLAM INVERT %left EXCLAM INVERT
%left OPAREN %left OPAREN
%start XkbFile %start XkbFile
%union { %union {
int ival; int ival;
unsigned uval; unsigned uval;
@ -142,6 +144,7 @@ yyerror(struct YYLTYPE *loc, struct parser_param *param, const char *msg)
void *geom; void *geom;
XkbFile *file; XkbFile *file;
} }
%type <num> INTEGER FLOAT %type <num> INTEGER FLOAT
%type <str> IDENT STRING %type <str> IDENT STRING
%type <keyName> KEYNAME KeyName %type <keyName> KEYNAME KeyName
@ -170,58 +173,55 @@ yyerror(struct YYLTYPE *loc, struct parser_param *param, const char *msg)
%type <geom> DoodadDecl %type <geom> DoodadDecl
%type <file> XkbFile XkbMapConfigList XkbMapConfig XkbConfig %type <file> XkbFile XkbMapConfigList XkbMapConfig XkbConfig
%type <file> XkbCompositeMap XkbCompMapList %type <file> XkbCompositeMap XkbCompMapList
%% %%
XkbFile : XkbCompMapList XkbFile : XkbCompMapList
{ $$= param->rtrn= $1; } { $$ = param->rtrn = $1; }
| XkbMapConfigList | XkbMapConfigList
{ $$= param->rtrn= $1; } { $$ = param->rtrn = $1; }
| XkbConfig | XkbConfig
{ $$= param->rtrn= $1; } { $$ = param->rtrn = $1; }
; ;
XkbCompMapList : XkbCompMapList XkbCompositeMap XkbCompMapList : XkbCompMapList XkbCompositeMap
{ $$= (XkbFile *)AppendStmt(&$1->common,&$2->common); } { $$ = (XkbFile *)AppendStmt(&$1->common, &$2->common); }
| XkbCompositeMap | XkbCompositeMap
{ $$= $1; } { $$ = $1; }
; ;
XkbCompositeMap : OptFlags XkbCompositeType OptMapName OBRACE XkbCompositeMap : OptFlags XkbCompositeType OptMapName OBRACE
XkbMapConfigList XkbMapConfigList
CBRACE SEMI CBRACE SEMI
{ { $$ = CreateXKBFile(param->ctx, $2, $3, &$5->common, $1); }
$$ = CreateXKBFile(param->ctx, $2, $3,
&$5->common, $1);
}
; ;
XkbCompositeType: XKB_KEYMAP { $$= FILE_TYPE_KEYMAP; } XkbCompositeType: XKB_KEYMAP { $$ = FILE_TYPE_KEYMAP; }
| XKB_SEMANTICS { $$= FILE_TYPE_KEYMAP; } | XKB_SEMANTICS { $$ = FILE_TYPE_KEYMAP; }
| XKB_LAYOUT { $$= FILE_TYPE_KEYMAP; } | XKB_LAYOUT { $$ = FILE_TYPE_KEYMAP; }
; ;
XkbMapConfigList : XkbMapConfigList XkbMapConfig XkbMapConfigList : XkbMapConfigList XkbMapConfig
{ {
if (!$2) if (!$2)
$$= $1; $$ = $1;
else else
$$= (XkbFile *)AppendStmt(&$1->common,&$2->common); $$ = (XkbFile *)AppendStmt(&$1->common, &$2->common);
} }
| XkbMapConfig | XkbMapConfig
{ $$= $1; } { $$ = $1; }
; ;
XkbMapConfig : OptFlags FileType OptMapName OBRACE XkbMapConfig : OptFlags FileType OptMapName OBRACE
DeclList DeclList
CBRACE SEMI CBRACE SEMI
{ {
if ($2 == FILE_TYPE_GEOMETRY) if ($2 == FILE_TYPE_GEOMETRY) {
{
free($3); free($3);
FreeStmt($5); FreeStmt($5);
$$= NULL; $$ = NULL;
} }
else else {
{
$$ = CreateXKBFile(param->ctx, $2, $3, $5, $1); $$ = CreateXKBFile(param->ctx, $2, $3, $5, $1);
} }
} }
@ -229,369 +229,339 @@ XkbMapConfig : OptFlags FileType OptMapName OBRACE
XkbConfig : OptFlags FileType OptMapName DeclList XkbConfig : OptFlags FileType OptMapName DeclList
{ {
if ($2 == FILE_TYPE_GEOMETRY) if ($2 == FILE_TYPE_GEOMETRY) {
{
free($3); free($3);
FreeStmt($4); FreeStmt($4);
$$= NULL; $$ = NULL;
} }
else else {
{
$$ = CreateXKBFile(param->ctx, $2, $3, $4, $1); $$ = CreateXKBFile(param->ctx, $2, $3, $4, $1);
} }
} }
; ;
FileType : XKB_KEYCODES { $$= FILE_TYPE_KEYCODES; } FileType : XKB_KEYCODES { $$ = FILE_TYPE_KEYCODES; }
| XKB_TYPES { $$= FILE_TYPE_TYPES; } | XKB_TYPES { $$ = FILE_TYPE_TYPES; }
| XKB_COMPATMAP { $$= FILE_TYPE_COMPAT; } | XKB_COMPATMAP { $$ = FILE_TYPE_COMPAT; }
| XKB_SYMBOLS { $$= FILE_TYPE_SYMBOLS; } | XKB_SYMBOLS { $$ = FILE_TYPE_SYMBOLS; }
| XKB_GEOMETRY { $$= FILE_TYPE_GEOMETRY; } | XKB_GEOMETRY { $$ = FILE_TYPE_GEOMETRY; }
; ;
OptFlags : Flags { $$= $1; } OptFlags : Flags { $$ = $1; }
| { $$= 0; } | { $$ = 0; }
; ;
Flags : Flags Flag { $$= (($1)|($2)); } Flags : Flags Flag { $$ = ($1 | $2); }
| Flag { $$= $1; } | Flag { $$ = $1; }
; ;
Flag : PARTIAL { $$= XkbLC_Partial; } Flag : PARTIAL { $$ = XkbLC_Partial; }
| DEFAULT { $$= XkbLC_Default; } | DEFAULT { $$ = XkbLC_Default; }
| HIDDEN { $$= XkbLC_Hidden; } | HIDDEN { $$ = XkbLC_Hidden; }
| ALPHANUMERIC_KEYS { $$= XkbLC_AlphanumericKeys; } | ALPHANUMERIC_KEYS { $$ = XkbLC_AlphanumericKeys; }
| MODIFIER_KEYS { $$= XkbLC_ModifierKeys; } | MODIFIER_KEYS { $$ = XkbLC_ModifierKeys; }
| KEYPAD_KEYS { $$= XkbLC_KeypadKeys; } | KEYPAD_KEYS { $$ = XkbLC_KeypadKeys; }
| FUNCTION_KEYS { $$= XkbLC_FunctionKeys; } | FUNCTION_KEYS { $$ = XkbLC_FunctionKeys; }
| ALTERNATE_GROUP { $$= XkbLC_AlternateGroup; } | ALTERNATE_GROUP { $$ = XkbLC_AlternateGroup; }
; ;
DeclList : DeclList Decl DeclList : DeclList Decl
{ $$= AppendStmt($1,$2); } { $$ = AppendStmt($1, $2); }
| { $$= NULL; } | { $$ = NULL; }
; ;
Decl : OptMergeMode VarDecl Decl : OptMergeMode VarDecl
{ {
$2->merge= $1; $2->merge = $1;
$$= &$2->common; $$ = &$2->common;
} }
| OptMergeMode VModDecl | OptMergeMode VModDecl
{ {
$2->merge= $1; $2->merge = $1;
$$= &$2->common; $$ = &$2->common;
} }
| OptMergeMode InterpretDecl | OptMergeMode InterpretDecl
{ {
$2->merge= $1; $2->merge = $1;
$$= &$2->common; $$ = &$2->common;
} }
| OptMergeMode KeyNameDecl | OptMergeMode KeyNameDecl
{ {
$2->merge= $1; $2->merge = $1;
$$= &$2->common; $$ = &$2->common;
} }
| OptMergeMode KeyAliasDecl | OptMergeMode KeyAliasDecl
{ {
$2->merge= $1; $2->merge = $1;
$$= &$2->common; $$ = &$2->common;
} }
| OptMergeMode KeyTypeDecl | OptMergeMode KeyTypeDecl
{ {
$2->merge= $1; $2->merge = $1;
$$= &$2->common; $$ = &$2->common;
} }
| OptMergeMode SymbolsDecl | OptMergeMode SymbolsDecl
{ {
$2->merge= $1; $2->merge = $1;
$$= &$2->common; $$ = &$2->common;
} }
| OptMergeMode ModMapDecl | OptMergeMode ModMapDecl
{ {
$2->merge= $1; $2->merge = $1;
$$= &$2->common; $$ = &$2->common;
} }
| OptMergeMode GroupCompatDecl | OptMergeMode GroupCompatDecl
{ {
$2->merge= $1; $2->merge = $1;
$$= &$2->common; $$ = &$2->common;
} }
| OptMergeMode IndicatorMapDecl | OptMergeMode IndicatorMapDecl
{ {
$2->merge= $1; $2->merge = $1;
$$= &$2->common; $$ = &$2->common;
} }
| OptMergeMode IndicatorNameDecl | OptMergeMode IndicatorNameDecl
{ {
$2->merge= $1; $2->merge = $1;
$$= &$2->common; $$ = &$2->common;
}
| OptMergeMode ShapeDecl
{
}
| OptMergeMode SectionDecl
{
}
| OptMergeMode DoodadDecl
{
} }
| OptMergeMode ShapeDecl { }
| OptMergeMode SectionDecl { }
| OptMergeMode DoodadDecl { }
| MergeMode STRING | MergeMode STRING
{ {
$$= &IncludeCreate(param->ctx, $2, $1)->common; $$ = &IncludeCreate(param->ctx, $2, $1)->common;
free($2); free($2);
} }
; ;
VarDecl : Lhs EQUALS Expr SEMI VarDecl : Lhs EQUALS Expr SEMI
{ $$= VarCreate($1,$3); } { $$ = VarCreate($1, $3); }
| Ident SEMI | Ident SEMI
{ $$= BoolVarCreate($1,1); } { $$ = BoolVarCreate($1, 1); }
| EXCLAM Ident SEMI | EXCLAM Ident SEMI
{ $$= BoolVarCreate($2,0); } { $$ = BoolVarCreate($2, 0); }
; ;
KeyNameDecl : KeyName EQUALS KeyCode SEMI KeyNameDecl : KeyName EQUALS KeyCode SEMI
{ { $$ = KeycodeCreate($1, $3); }
$$ = KeycodeCreate($1, $3);
}
; ;
KeyAliasDecl : ALIAS KeyName EQUALS KeyName SEMI KeyAliasDecl : ALIAS KeyName EQUALS KeyName SEMI
{ { $$ = KeyAliasCreate($2, $4); }
$$= KeyAliasCreate($2,$4);
}
; ;
VModDecl : VIRTUAL_MODS VModDefList SEMI VModDecl : VIRTUAL_MODS VModDefList SEMI
{ $$= $2; } { $$ = $2; }
; ;
VModDefList : VModDefList COMMA VModDef VModDefList : VModDefList COMMA VModDef
{ $$= (VModDef *)AppendStmt(&$1->common,&$3->common); } { $$ = (VModDef *)AppendStmt(&$1->common, &$3->common); }
| VModDef | VModDef
{ $$= $1; } { $$ = $1; }
; ;
VModDef : Ident VModDef : Ident
{ $$= VModCreate($1,NULL); } { $$ = VModCreate($1, NULL); }
| Ident EQUALS Expr | Ident EQUALS Expr
{ $$= VModCreate($1,$3); } { $$ = VModCreate($1, $3); }
; ;
InterpretDecl : INTERPRET InterpretMatch OBRACE InterpretDecl : INTERPRET InterpretMatch OBRACE
VarDeclList VarDeclList
CBRACE SEMI CBRACE SEMI
{ { $2->def = $4; $$ = $2; }
$2->def= $4;
$$= $2;
}
; ;
InterpretMatch : KeySym PLUS Expr InterpretMatch : KeySym PLUS Expr
{ $$= InterpCreate($1, $3); } { $$ = InterpCreate($1, $3); }
| KeySym | KeySym
{ $$= InterpCreate($1, NULL); } { $$ = InterpCreate($1, NULL); }
; ;
VarDeclList : VarDeclList VarDecl VarDeclList : VarDeclList VarDecl
{ $$= (VarDef *)AppendStmt(&$1->common,&$2->common); } { $$ = (VarDef *)AppendStmt(&$1->common, &$2->common); }
| VarDecl | VarDecl
{ $$= $1; } { $$ = $1; }
; ;
KeyTypeDecl : TYPE String OBRACE KeyTypeDecl : TYPE String OBRACE
VarDeclList VarDeclList
CBRACE SEMI CBRACE SEMI
{ $$= KeyTypeCreate($2,$4); } { $$ = KeyTypeCreate($2, $4); }
; ;
SymbolsDecl : KEY KeyName OBRACE SymbolsDecl : KEY KeyName OBRACE
SymbolsBody SymbolsBody
CBRACE SEMI CBRACE SEMI
{ $$= SymbolsCreate($2,(ExprDef *)$4); } { $$ = SymbolsCreate($2, (ExprDef *)$4); }
; ;
SymbolsBody : SymbolsBody COMMA SymbolsVarDecl SymbolsBody : SymbolsBody COMMA SymbolsVarDecl
{ $$= (VarDef *)AppendStmt(&$1->common,&$3->common); } { $$ = (VarDef *)AppendStmt(&$1->common, &$3->common); }
| SymbolsVarDecl | SymbolsVarDecl
{ $$= $1; } { $$ = $1; }
| { $$= NULL; } | { $$ = NULL; }
; ;
SymbolsVarDecl : Lhs EQUALS Expr SymbolsVarDecl : Lhs EQUALS Expr { $$ = VarCreate($1, $3); }
{ $$= VarCreate($1,$3); } | Lhs EQUALS ArrayInit { $$ = VarCreate($1, $3); }
| Lhs EQUALS ArrayInit | Ident { $$ = BoolVarCreate($1, 1); }
{ $$= VarCreate($1,$3); } | EXCLAM Ident { $$ = BoolVarCreate($2, 0); }
| Ident | ArrayInit { $$ = VarCreate(NULL, $1); }
{ $$= BoolVarCreate($1,1); }
| EXCLAM Ident
{ $$= BoolVarCreate($2,0); }
| ArrayInit
{ $$= VarCreate(NULL,$1); }
; ;
ArrayInit : OBRACKET OptKeySymList CBRACKET ArrayInit : OBRACKET OptKeySymList CBRACKET
{ $$= $2; } { $$ = $2; }
| OBRACKET ActionList CBRACKET | OBRACKET ActionList CBRACKET
{ $$= ExprCreateUnary(EXPR_ACTION_LIST, EXPR_TYPE_ACTION, $2); } { $$ = ExprCreateUnary(EXPR_ACTION_LIST, EXPR_TYPE_ACTION, $2); }
; ;
GroupCompatDecl : GROUP Integer EQUALS Expr SEMI GroupCompatDecl : GROUP Integer EQUALS Expr SEMI
{ $$= GroupCompatCreate($2,$4); } { $$ = GroupCompatCreate($2, $4); }
; ;
ModMapDecl : MODIFIER_MAP Ident OBRACE ExprList CBRACE SEMI ModMapDecl : MODIFIER_MAP Ident OBRACE ExprList CBRACE SEMI
{ $$= ModMapCreate($2,$4); } { $$ = ModMapCreate($2, $4); }
; ;
IndicatorMapDecl: INDICATOR String OBRACE VarDeclList CBRACE SEMI IndicatorMapDecl: INDICATOR String OBRACE VarDeclList CBRACE SEMI
{ $$= IndicatorMapCreate($2,$4); } { $$ = IndicatorMapCreate($2, $4); }
; ;
IndicatorNameDecl: INDICATOR Integer EQUALS Expr SEMI IndicatorNameDecl: INDICATOR Integer EQUALS Expr SEMI
{ $$= IndicatorNameCreate($2,$4,false); } { $$ = IndicatorNameCreate($2, $4, false); }
| VIRTUAL INDICATOR Integer EQUALS Expr SEMI | VIRTUAL INDICATOR Integer EQUALS Expr SEMI
{ $$= IndicatorNameCreate($3,$5,true); } { $$ = IndicatorNameCreate($3, $5, true); }
; ;
ShapeDecl : SHAPE String OBRACE OutlineList CBRACE SEMI ShapeDecl : SHAPE String OBRACE OutlineList CBRACE SEMI
{ $$= NULL; } { $$ = NULL; }
| SHAPE String OBRACE CoordList CBRACE SEMI | SHAPE String OBRACE CoordList CBRACE SEMI
{ $$= NULL; } { $$ = NULL; }
; ;
SectionDecl : SECTION String OBRACE SectionBody CBRACE SEMI SectionDecl : SECTION String OBRACE SectionBody CBRACE SEMI
{ $$= NULL; } { $$ = NULL; }
; ;
SectionBody : SectionBody SectionBodyItem SectionBody : SectionBody SectionBodyItem { $$ = NULL;}
{ $$= NULL;} | SectionBodyItem { $$ = NULL; }
| SectionBodyItem
{ $$= NULL; }
; ;
SectionBodyItem : ROW OBRACE RowBody CBRACE SEMI SectionBodyItem : ROW OBRACE RowBody CBRACE SEMI
{ $$= NULL; } { $$ = NULL; }
| VarDecl | VarDecl
{ FreeStmt(&$1->common); $$= NULL; } { FreeStmt(&$1->common); $$ = NULL; }
| DoodadDecl | DoodadDecl
{ $$= NULL; } { $$ = NULL; }
| IndicatorMapDecl | IndicatorMapDecl
{ FreeStmt(&$1->common); $$= NULL; } { FreeStmt(&$1->common); $$ = NULL; }
| OverlayDecl | OverlayDecl
{ $$= NULL; } { $$ = NULL; }
; ;
RowBody : RowBody RowBodyItem RowBody : RowBody RowBodyItem { $$ = NULL;}
{ $$= NULL;} | RowBodyItem { $$ = NULL; }
| RowBodyItem
{ $$= NULL; }
; ;
RowBodyItem : KEYS OBRACE Keys CBRACE SEMI RowBodyItem : KEYS OBRACE Keys CBRACE SEMI { $$ = NULL; }
{ $$= NULL; }
| VarDecl | VarDecl
{ FreeStmt(&$1->common); $$= NULL; } { FreeStmt(&$1->common); $$ = NULL; }
; ;
Keys : Keys COMMA Key Keys : Keys COMMA Key { $$ = NULL; }
{ $$= NULL; } | Key { $$ = NULL; }
| Key
{ $$= NULL; }
; ;
Key : KeyName Key : KeyName
{ $$= NULL; } { $$ = NULL; }
| OBRACE ExprList CBRACE | OBRACE ExprList CBRACE
{ FreeStmt(&$2->common); $$= NULL; } { FreeStmt(&$2->common); $$ = NULL; }
; ;
OverlayDecl : OVERLAY String OBRACE OverlayKeyList CBRACE SEMI OverlayDecl : OVERLAY String OBRACE OverlayKeyList CBRACE SEMI
{ $$= NULL; } { $$ = NULL; }
; ;
OverlayKeyList : OverlayKeyList COMMA OverlayKey OverlayKeyList : OverlayKeyList COMMA OverlayKey { $$ = NULL; }
{ $$= NULL; } | OverlayKey { $$ = NULL; }
| OverlayKey
{ $$= NULL; }
; ;
OverlayKey : KeyName EQUALS KeyName OverlayKey : KeyName EQUALS KeyName { $$ = NULL; }
{ $$= NULL; }
; ;
OutlineList : OutlineList COMMA OutlineInList OutlineList : OutlineList COMMA OutlineInList
{ $$= NULL;} { $$ = NULL;}
| OutlineInList | OutlineInList
{ $$= NULL; } { $$ = NULL; }
; ;
OutlineInList : OBRACE CoordList CBRACE OutlineInList : OBRACE CoordList CBRACE
{ $$= NULL; } { $$ = NULL; }
| Ident EQUALS OBRACE CoordList CBRACE | Ident EQUALS OBRACE CoordList CBRACE
{ $$= NULL; } { $$ = NULL; }
| Ident EQUALS Expr | Ident EQUALS Expr
{ FreeStmt(&$3->common); $$= NULL; } { FreeStmt(&$3->common); $$ = NULL; }
; ;
CoordList : CoordList COMMA Coord CoordList : CoordList COMMA Coord
{ $$= NULL; } { $$ = NULL; }
| Coord | Coord
{ $$= NULL; } { $$ = NULL; }
; ;
Coord : OBRACKET SignedNumber COMMA SignedNumber CBRACKET Coord : OBRACKET SignedNumber COMMA SignedNumber CBRACKET
{ $$= NULL; } { $$ = NULL; }
; ;
DoodadDecl : DoodadType String OBRACE VarDeclList CBRACE SEMI DoodadDecl : DoodadType String OBRACE VarDeclList CBRACE SEMI
{ FreeStmt(&$4->common); $$= NULL; } { FreeStmt(&$4->common); $$ = NULL; }
; ;
DoodadType : TEXT { $$= 0; } DoodadType : TEXT { $$ = 0; }
| OUTLINE { $$= 0; } | OUTLINE { $$ = 0; }
| SOLID { $$= 0; } | SOLID { $$ = 0; }
| LOGO { $$= 0; } | LOGO { $$ = 0; }
; ;
FieldSpec : Ident { $$= $1; } FieldSpec : Ident { $$ = $1; }
| Element { $$= $1; } | Element { $$ = $1; }
; ;
Element : ACTION_TOK Element : ACTION_TOK
{ $$= xkb_atom_intern(param->ctx, "action"); } { $$ = xkb_atom_intern(param->ctx, "action"); }
| INTERPRET | INTERPRET
{ $$= xkb_atom_intern(param->ctx, "interpret"); } { $$ = xkb_atom_intern(param->ctx, "interpret"); }
| TYPE | TYPE
{ $$= xkb_atom_intern(param->ctx, "type"); } { $$ = xkb_atom_intern(param->ctx, "type"); }
| KEY | KEY
{ $$= xkb_atom_intern(param->ctx, "key"); } { $$ = xkb_atom_intern(param->ctx, "key"); }
| GROUP | GROUP
{ $$= xkb_atom_intern(param->ctx, "group"); } { $$ = xkb_atom_intern(param->ctx, "group"); }
| MODIFIER_MAP | MODIFIER_MAP
{$$= xkb_atom_intern(param->ctx, "modifier_map");} {$$ = xkb_atom_intern(param->ctx, "modifier_map");}
| INDICATOR | INDICATOR
{ $$= xkb_atom_intern(param->ctx, "indicator"); } { $$ = xkb_atom_intern(param->ctx, "indicator"); }
| SHAPE | SHAPE
{ $$= xkb_atom_intern(param->ctx, "shape"); } { $$ = xkb_atom_intern(param->ctx, "shape"); }
| ROW | ROW
{ $$= XKB_ATOM_NONE; } { $$ = XKB_ATOM_NONE; }
| SECTION | SECTION
{ $$= XKB_ATOM_NONE; } { $$ = XKB_ATOM_NONE; }
| TEXT | TEXT
{ $$= XKB_ATOM_NONE; } { $$ = XKB_ATOM_NONE; }
; ;
OptMergeMode : MergeMode { $$= $1; } OptMergeMode : MergeMode { $$ = $1; }
| { $$= MERGE_DEFAULT; } | { $$ = MERGE_DEFAULT; }
; ;
MergeMode : INCLUDE { $$= MERGE_DEFAULT; } MergeMode : INCLUDE { $$ = MERGE_DEFAULT; }
| AUGMENT { $$= MERGE_AUGMENT; } | AUGMENT { $$ = MERGE_AUGMENT; }
| OVERRIDE { $$= MERGE_OVERRIDE; } | OVERRIDE { $$ = MERGE_OVERRIDE; }
| REPLACE { $$= MERGE_REPLACE; } | REPLACE { $$ = MERGE_REPLACE; }
| ALTERNATE | ALTERNATE
{ {
/* /*
@ -602,195 +572,186 @@ MergeMode : INCLUDE { $$= MERGE_DEFAULT; }
} }
; ;
OptExprList : ExprList { $$= $1; } OptExprList : ExprList { $$ = $1; }
| { $$= NULL; } | { $$ = NULL; }
; ;
ExprList : ExprList COMMA Expr ExprList : ExprList COMMA Expr
{ $$= (ExprDef *)AppendStmt(&$1->common,&$3->common); } { $$ = (ExprDef *)AppendStmt(&$1->common, &$3->common); }
| Expr | Expr
{ $$= $1; } { $$ = $1; }
; ;
Expr : Expr DIVIDE Expr Expr : Expr DIVIDE Expr
{ $$= ExprCreateBinary(EXPR_DIVIDE,$1,$3); } { $$ = ExprCreateBinary(EXPR_DIVIDE, $1, $3); }
| Expr PLUS Expr | Expr PLUS Expr
{ $$= ExprCreateBinary(EXPR_ADD,$1,$3); } { $$ = ExprCreateBinary(EXPR_ADD, $1, $3); }
| Expr MINUS Expr | Expr MINUS Expr
{ $$= ExprCreateBinary(EXPR_SUBTRACT,$1,$3); } { $$ = ExprCreateBinary(EXPR_SUBTRACT, $1, $3); }
| Expr TIMES Expr | Expr TIMES Expr
{ $$= ExprCreateBinary(EXPR_MULTIPLY,$1,$3); } { $$ = ExprCreateBinary(EXPR_MULTIPLY, $1, $3); }
| Lhs EQUALS Expr | Lhs EQUALS Expr
{ $$= ExprCreateBinary(EXPR_ASSIGN,$1,$3); } { $$ = ExprCreateBinary(EXPR_ASSIGN, $1, $3); }
| Term | Term
{ $$= $1; } { $$ = $1; }
; ;
Term : MINUS Term Term : MINUS Term
{ $$= ExprCreateUnary(EXPR_NEGATE,$2->value_type,$2); } { $$ = ExprCreateUnary(EXPR_NEGATE, $2->value_type, $2); }
| PLUS Term | PLUS Term
{ $$= ExprCreateUnary(EXPR_UNARY_PLUS,$2->value_type,$2); } { $$ = ExprCreateUnary(EXPR_UNARY_PLUS, $2->value_type, $2); }
| EXCLAM Term | EXCLAM Term
{ $$= ExprCreateUnary(EXPR_NOT,EXPR_TYPE_BOOLEAN,$2); } { $$ = ExprCreateUnary(EXPR_NOT, EXPR_TYPE_BOOLEAN, $2); }
| INVERT Term | INVERT Term
{ $$= ExprCreateUnary(EXPR_INVERT,$2->value_type,$2); } { $$ = ExprCreateUnary(EXPR_INVERT, $2->value_type, $2); }
| Lhs | Lhs
{ $$= $1; } { $$ = $1; }
| FieldSpec OPAREN OptExprList CPAREN %prec OPAREN | FieldSpec OPAREN OptExprList CPAREN %prec OPAREN
{ $$= ActionCreate($1,$3); } { $$ = ActionCreate($1, $3); }
| Terminal | Terminal
{ $$= $1; } { $$ = $1; }
| OPAREN Expr CPAREN | OPAREN Expr CPAREN
{ $$= $2; } { $$ = $2; }
; ;
ActionList : ActionList COMMA Action ActionList : ActionList COMMA Action
{ $$= (ExprDef *)AppendStmt(&$1->common,&$3->common); } { $$ = (ExprDef *)AppendStmt(&$1->common, &$3->common); }
| Action | Action
{ $$= $1; } { $$ = $1; }
; ;
Action : FieldSpec OPAREN OptExprList CPAREN Action : FieldSpec OPAREN OptExprList CPAREN
{ $$= ActionCreate($1,$3); } { $$ = ActionCreate($1, $3); }
; ;
Lhs : FieldSpec Lhs : FieldSpec
{ {
ExprDef *expr; ExprDef *expr;
expr= ExprCreate(EXPR_IDENT, EXPR_TYPE_UNKNOWN); expr = ExprCreate(EXPR_IDENT, EXPR_TYPE_UNKNOWN);
expr->value.str= $1; expr->value.str = $1;
$$= expr; $$ = expr;
} }
| FieldSpec DOT FieldSpec | FieldSpec DOT FieldSpec
{ {
ExprDef *expr; ExprDef *expr;
expr= ExprCreate(EXPR_FIELD_REF,EXPR_TYPE_UNKNOWN); expr = ExprCreate(EXPR_FIELD_REF, EXPR_TYPE_UNKNOWN);
expr->value.field.element= $1; expr->value.field.element = $1;
expr->value.field.field= $3; expr->value.field.field = $3;
$$= expr; $$ = expr;
} }
| FieldSpec OBRACKET Expr CBRACKET | FieldSpec OBRACKET Expr CBRACKET
{ {
ExprDef *expr; ExprDef *expr;
expr= ExprCreate(EXPR_ARRAY_REF,EXPR_TYPE_UNKNOWN); expr = ExprCreate(EXPR_ARRAY_REF, EXPR_TYPE_UNKNOWN);
expr->value.array.element= XKB_ATOM_NONE; expr->value.array.element = XKB_ATOM_NONE;
expr->value.array.field= $1; expr->value.array.field = $1;
expr->value.array.entry= $3; expr->value.array.entry = $3;
$$= expr; $$ = expr;
} }
| FieldSpec DOT FieldSpec OBRACKET Expr CBRACKET | FieldSpec DOT FieldSpec OBRACKET Expr CBRACKET
{ {
ExprDef *expr; ExprDef *expr;
expr= ExprCreate(EXPR_ARRAY_REF,EXPR_TYPE_UNKNOWN); expr = ExprCreate(EXPR_ARRAY_REF, EXPR_TYPE_UNKNOWN);
expr->value.array.element= $1; expr->value.array.element = $1;
expr->value.array.field= $3; expr->value.array.field = $3;
expr->value.array.entry= $5; expr->value.array.entry = $5;
$$= expr; $$ = expr;
} }
; ;
Terminal : String Terminal : String
{ {
ExprDef *expr; ExprDef *expr;
expr= ExprCreate(EXPR_VALUE,EXPR_TYPE_STRING); expr = ExprCreate(EXPR_VALUE, EXPR_TYPE_STRING);
expr->value.str= $1; expr->value.str = $1;
$$= expr; $$ = expr;
} }
| Integer | Integer
{ {
ExprDef *expr; ExprDef *expr;
expr= ExprCreate(EXPR_VALUE,EXPR_TYPE_INT); expr = ExprCreate(EXPR_VALUE, EXPR_TYPE_INT);
expr->value.ival= $1; expr->value.ival = $1;
$$= expr; $$ = expr;
} }
| Float | Float
{ {
$$= NULL; $$ = NULL;
} }
| KeyName | KeyName
{ {
ExprDef *expr; ExprDef *expr;
expr= ExprCreate(EXPR_VALUE,EXPR_TYPE_KEYNAME); expr = ExprCreate(EXPR_VALUE, EXPR_TYPE_KEYNAME);
strncpy(expr->value.keyName,$1,4); strncpy(expr->value.keyName, $1, 4);
$$= expr; $$ = expr;
} }
; ;
OptKeySymList : KeySymList { $$= $1; } OptKeySymList : KeySymList { $$ = $1; }
| { $$= NULL; } | { $$ = NULL; }
; ;
KeySymList : KeySymList COMMA KeySym KeySymList : KeySymList COMMA KeySym
{ $$= AppendKeysymList($1,$3); } { $$ = AppendKeysymList($1, $3); }
| KeySymList COMMA KeySyms | KeySymList COMMA KeySyms
{ $$= AppendMultiKeysymList($1,$3); } { $$ = AppendMultiKeysymList($1, $3); }
| KeySym | KeySym
{ $$= CreateKeysymList($1); } { $$ = CreateKeysymList($1); }
| KeySyms | KeySyms
{ $$= CreateMultiKeysymList($1); } { $$ = CreateMultiKeysymList($1); }
; ;
KeySyms : OBRACE KeySymList CBRACE KeySyms : OBRACE KeySymList CBRACE
{ $$= $2; } { $$ = $2; }
; ;
KeySym : IDENT { $$= $1; } KeySym : IDENT { $$ = $1; }
| SECTION { $$= strdup("section"); } | SECTION { $$ = strdup("section"); }
| Integer | Integer
{ {
if ($1 < 10) { /* XK_0 .. XK_9 */ if ($1 < 10) { /* XK_0 .. XK_9 */
$$= malloc(2); $$ = malloc(2);
$$[0]= $1 + '0'; $$[0] = $1 + '0';
$$[1]= '\0'; $$[1] = '\0';
} }
else { else {
$$= malloc(17); $$ = malloc(17);
snprintf($$, 17, "0x%x", $1); snprintf($$, 17, "0x%x", $1);
} }
} }
; ;
SignedNumber : MINUS Number { $$= -$2; } SignedNumber : MINUS Number { $$ = -$2; }
| Number { $$= $1; } | Number { $$ = $1; }
; ;
Number : FLOAT { $$= $1; } Number : FLOAT { $$ = $1; }
| INTEGER { $$= $1*XkbGeomPtsPerMM; } | INTEGER { $$ = $1 * XkbGeomPtsPerMM; }
; ;
Float : FLOAT { $$= 0; } Float : FLOAT { $$ = 0; }
; ;
Integer : INTEGER { $$= $1; } Integer : INTEGER { $$ = $1; }
; ;
KeyCode : INTEGER { $$= $1; } KeyCode : INTEGER { $$ = $1; }
; ;
KeyName : KEYNAME { strncpy($$, $1, XkbKeyNameLength); } KeyName : KEYNAME { strncpy($$, $1, XkbKeyNameLength); }
; ;
Ident : IDENT Ident : IDENT { $$ = xkb_atom_steal(param->ctx, $1); }
{ | DEFAULT { $$ = xkb_atom_intern(param->ctx, "default"); }
$$ = xkb_atom_steal(param->ctx, $1);
}
| DEFAULT
{
$$ = xkb_atom_intern(param->ctx, "default");
}
; ;
String : STRING String : STRING { $$ = xkb_atom_steal(param->ctx, $1); }
{
$$ = xkb_atom_steal(param->ctx, $1);
}
; ;
OptMapName : MapName { $$= $1; } OptMapName : MapName { $$ = $1; }
| { $$= NULL; } | { $$ = NULL; }
; ;
MapName : STRING { $$= $1; } MapName : STRING { $$ = $1; }
; ;
%% %%