From aa089e2a24987f551d50d2e6865b457adf563c7c Mon Sep 17 00:00:00 2001 From: Pierre Le Marre Date: Thu, 19 Dec 2024 16:23:05 +0100 Subject: [PATCH] symbols: Parse empty key The following syntax does not parse in xkbcommon, but it does in xkbcomp: ``` xkb_symbols "x" { key { }; }; ``` While the usefulness of such statement is debatable, the fact that it does parse in xkbcomp and that tools may generate such keymap entry make it relevant to handle. --- src/xkbcomp/parser.y | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/xkbcomp/parser.y b/src/xkbcomp/parser.y index 80420aae..95d1327d 100644 --- a/src/xkbcomp/parser.y +++ b/src/xkbcomp/parser.y @@ -210,7 +210,7 @@ resolve_keysym(struct parser_param *param, const char *name, xkb_keysym_t *sym_r %type MultiKeySymList KeySymList MultiActionList ActionList Action Coord CoordList %type OptExprList ExprList %type VarDecl SymbolsVarDecl -%type VarDeclList SymbolsBody +%type VarDeclList SymbolsBody OptSymbolsBody %type VModDef %type VModDefList VModDecl %type InterpretDecl InterpretMatch @@ -458,11 +458,15 @@ KeyTypeDecl : TYPE String OBRACE ; SymbolsDecl : KEY KEYNAME OBRACE - SymbolsBody + OptSymbolsBody CBRACE SEMI { $$ = SymbolsCreate($2, $4.head); } ; +OptSymbolsBody : SymbolsBody { $$ = $1; } + | { $$.head = $$.last = NULL; } + ; + SymbolsBody : SymbolsBody COMMA SymbolsVarDecl { $$.head = $1.head; $$.last->common.next = &$3->common; $$.last = $3; } | SymbolsVarDecl