ast: use a separate expr struct for action list Currently it's under UnaryExpr, which just doesn't make sense. Signed-off-by: Ran Benita <ran@unusedvar.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
diff --git a/src/xkbcomp/ast-build.c b/src/xkbcomp/ast-build.c
index d01aa24..64051c7 100644
--- a/src/xkbcomp/ast-build.c
+++ b/src/xkbcomp/ast-build.c
@@ -207,6 +207,16 @@ ExprCreateAction(xkb_atom_t name, ExprDef *args)
}
ExprDef *
+ExprCreateActionList(ExprDef *actions)
+{
+ ExprDef *expr = ExprCreate(EXPR_ACTION_LIST, EXPR_TYPE_ACTIONS, sizeof(ExprActionList));
+ if (!expr)
+ return NULL;
+ expr->actions.actions = actions;
+ return expr;
+}
+
+ExprDef *
ExprCreateKeysymList(xkb_keysym_t sym)
{
ExprDef *expr = ExprCreate(EXPR_KEYSYM_LIST, EXPR_TYPE_SYMBOLS, sizeof(ExprKeysymList));
@@ -592,7 +602,6 @@ FreeExpr(ExprDef *expr)
return;
switch (expr->expr.op) {
- case EXPR_ACTION_LIST:
case EXPR_NEGATE:
case EXPR_UNARY_PLUS:
case EXPR_NOT:
@@ -613,6 +622,10 @@ FreeExpr(ExprDef *expr)
FreeStmt((ParseCommon *) expr->action.args);
break;
+ case EXPR_ACTION_LIST:
+ FreeStmt((ParseCommon *) expr->actions.actions);
+ break;
+
case EXPR_ARRAY_REF:
FreeStmt((ParseCommon *) expr->array_ref.entry);
break;
@@ -812,6 +825,7 @@ static const char *expr_value_type_strings[_EXPR_TYPE_NUM_VALUES] = {
[EXPR_TYPE_FLOAT] = "float",
[EXPR_TYPE_STRING] = "string",
[EXPR_TYPE_ACTION] = "action",
+ [EXPR_TYPE_ACTIONS] = "actions",
[EXPR_TYPE_KEYNAME] = "keyname",
[EXPR_TYPE_SYMBOLS] = "symbols",
};
diff --git a/src/xkbcomp/ast-build.h b/src/xkbcomp/ast-build.h
index 6c76f38..46c7fbb 100644
--- a/src/xkbcomp/ast-build.h
+++ b/src/xkbcomp/ast-build.h
@@ -65,6 +65,9 @@ ExprDef *
ExprCreateAction(xkb_atom_t name, ExprDef *args);
ExprDef *
+ExprCreateActionList(ExprDef *actions);
+
+ExprDef *
ExprCreateMultiKeysymList(ExprDef *list);
ExprDef *
diff --git a/src/xkbcomp/ast.h b/src/xkbcomp/ast.h
index 49c5ada..ee61106 100644
--- a/src/xkbcomp/ast.h
+++ b/src/xkbcomp/ast.h
@@ -98,6 +98,7 @@ enum expr_value_type {
EXPR_TYPE_FLOAT,
EXPR_TYPE_STRING,
EXPR_TYPE_ACTION,
+ EXPR_TYPE_ACTIONS,
EXPR_TYPE_KEYNAME,
EXPR_TYPE_SYMBOLS,
@@ -230,6 +231,11 @@ typedef struct {
typedef struct {
ExprCommon expr;
+ ExprDef *actions;
+} ExprActionList;
+
+typedef struct {
+ ExprCommon expr;
darray(xkb_keysym_t) syms;
darray(unsigned int) symsMapIndex;
darray(unsigned int) symsNumEntries;
@@ -249,6 +255,7 @@ union ExprDef {
ExprFieldRef field_ref;
ExprArrayRef array_ref;
ExprAction action;
+ ExprActionList actions;
ExprKeysymList keysym_list;
};
diff --git a/src/xkbcomp/parser.y b/src/xkbcomp/parser.y
index f33a850..daf2cdd 100644
--- a/src/xkbcomp/parser.y
+++ b/src/xkbcomp/parser.y
@@ -454,7 +454,7 @@ SymbolsVarDecl : Lhs EQUALS Expr { $$ = VarCreate($1, $3); }
ArrayInit : OBRACKET OptKeySymList CBRACKET
{ $$ = $2; }
| OBRACKET ActionList CBRACKET
- { $$ = ExprCreateUnary(EXPR_ACTION_LIST, EXPR_TYPE_ACTION, $2); }
+ { $$ = ExprCreateActionList($2); }
;
GroupCompatDecl : GROUP Integer EQUALS Expr SEMI
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index f693bae..ffef6a4 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -753,7 +753,7 @@ AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
}
nActs = 0;
- for (act = value->unary.child; act; act = (ExprDef *) act->common.next)
+ for (act = value->actions.actions; act; act = (ExprDef *) act->common.next)
nActs++;
if (darray_size(groupi->levels) < nActs)
@@ -761,7 +761,7 @@ AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
groupi->defined |= GROUP_FIELD_ACTS;
- act = value->unary.child;
+ act = value->actions.actions;
for (unsigned i = 0; i < nActs; i++) {
union xkb_action *toAct = &darray_item(groupi->levels, i).action;