aboutsummaryrefslogtreecommitdiffstats
path: root/parse.y
diff options
context:
space:
mode:
authorokan2021-12-24 16:00:47 +0000
committerWolfgang Müller2022-01-17 17:04:50 +0100
commit16c9a10b1bee63300a3fa68cc03e08c6c693008c (patch)
tree40d3e9bfd4e50e07017102f4cf69bba15d2fcf8e /parse.y
parentba370fed0e18e09a856df10ec2560b20e1f83a1b (diff)
downloadcwm-16c9a10b1bee63300a3fa68cc03e08c6c693008c.tar.gz
Allow bare numbers for key and mouse bindings; taken from similar support in other parse.y's; from Leon Fischer <lfischer@airmail.cc>.
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y23
1 files changed, 17 insertions, 6 deletions
diff --git a/parse.y b/parse.y
index 1e10568..4423a2a 100644
--- a/parse.y
+++ b/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.74 2021/11/22 00:51:54 okan Exp $ */
+/* $OpenBSD: parse.y,v 1.75 2021/12/24 16:00:47 okan Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -81,7 +81,7 @@ typedef struct {
%token <v.string> STRING
%token <v.number> NUMBER
%type <v.number> yesno
-%type <v.string> string
+%type <v.string> string numberstring
%%
grammar : /* empty */
@@ -104,6 +104,17 @@ string : string STRING {
| STRING
;
+numberstring : NUMBER {
+ char *s;
+ if (asprintf(&s, "%lld", $1) == -1) {
+ yyerror("string: asprintf");
+ YYERROR;
+ }
+ $$ = s;
+ }
+ | STRING
+ ;
+
yesno : YES { $$ = 1; }
| NO { $$ = 0; }
;
@@ -209,7 +220,7 @@ main : FONTNAME STRING {
conf->gap.left = $4;
conf->gap.right = $5;
}
- | BINDKEY STRING string {
+ | BINDKEY numberstring string {
if (!conf_bind_key(conf, $2, $3)) {
yyerror("invalid bind-key: %s %s", $2, $3);
free($2);
@@ -219,7 +230,7 @@ main : FONTNAME STRING {
free($2);
free($3);
}
- | UNBINDKEY STRING {
+ | UNBINDKEY numberstring {
if (!conf_bind_key(conf, $2, NULL)) {
yyerror("invalid unbind-key: %s", $2);
free($2);
@@ -227,7 +238,7 @@ main : FONTNAME STRING {
}
free($2);
}
- | BINDMOUSE STRING string {
+ | BINDMOUSE numberstring string {
if (!conf_bind_mouse(conf, $2, $3)) {
yyerror("invalid bind-mouse: %s %s", $2, $3);
free($2);
@@ -237,7 +248,7 @@ main : FONTNAME STRING {
free($2);
free($3);
}
- | UNBINDMOUSE STRING {
+ | UNBINDMOUSE numberstring {
if (!conf_bind_mouse(conf, $2, NULL)) {
yyerror("invalid unbind-mouse: %s", $2);
free($2);