summaryrefslogtreecommitdiff
path: root/usr.sbin/btrace/bt_parse.y
diff options
context:
space:
mode:
authorDave Voutila <dv@cvs.openbsd.org>2023-08-13 13:19:24 +0000
committerDave Voutila <dv@cvs.openbsd.org>2023-08-13 13:19:24 +0000
commit9c61022e8e6952706a3a24be045f660260bb1304 (patch)
treeda68f0bc93f7b8d7c451d4bda6131334eab2abc1 /usr.sbin/btrace/bt_parse.y
parente22513034e17b668951192c36f1250cf86fff1fc (diff)
btrace(8): fix yacc reduce conflicts and undefined symbol warnings.
Define the STR symbol, used for the str function. Tune the grammar, simplifying the 'pat' rule to 'expr'. Resolves the reduce conflicts related to 'pat' and 'factor' both matching a lone CSTRING token. ok mpi@
Diffstat (limited to 'usr.sbin/btrace/bt_parse.y')
-rw-r--r--usr.sbin/btrace/bt_parse.y30
1 files changed, 13 insertions, 17 deletions
diff --git a/usr.sbin/btrace/bt_parse.y b/usr.sbin/btrace/bt_parse.y
index 12bfdef9528..959f6e4a44c 100644
--- a/usr.sbin/btrace/bt_parse.y
+++ b/usr.sbin/btrace/bt_parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: bt_parse.y,v 1.49 2022/12/28 21:30:16 jmc Exp $ */
+/* $OpenBSD: bt_parse.y,v 1.50 2023/08/13 13:19:23 dv Exp $ */
/*
* Copyright (c) 2019-2021 Martin Pieuchot <mpi@openbsd.org>
@@ -115,7 +115,7 @@ static int pflag;
%token <v.i> ERROR ENDFILT
%token <v.i> OP_EQ OP_NE OP_LE OP_LT OP_GE OP_GT OP_LAND OP_LOR
/* Builtins */
-%token <v.i> BUILTIN BEGIN END HZ IF
+%token <v.i> BUILTIN BEGIN END HZ IF STR
/* Functions and Map operators */
%token <v.i> F_DELETE F_PRINT
%token <v.i> MFUNC FUNC0 FUNC1 FUNCN OP1 OP2 OP4 MOP0 MOP1
@@ -127,7 +127,7 @@ static int pflag;
%type <v.probe> plist probe pname
%type <v.filter> filter
%type <v.stmt> action stmt stmtblck stmtlist block
-%type <v.arg> pat vargs mentry mpat pargs staticv
+%type <v.arg> vargs mentry mpat pargs staticv
%type <v.arg> expr term fterm variable factor func
%%
@@ -169,11 +169,7 @@ mentry : gvar '[' vargs ']' { $$ = bm_find($1, $3); }
;
mpat : MOP0 '(' ')' { $$ = ba_new(NULL, $1); }
- | MOP1 '(' pat ')' { $$ = ba_new($3, $1); }
- | pat
- ;
-
-pat : CSTRING { $$ = ba_new($1, B_AT_STR); }
+ | MOP1 '(' expr ')' { $$ = ba_new($3, $1); }
| expr
;
@@ -226,15 +222,15 @@ factor : '(' expr ')' { $$ = $2; }
;
func : STR '(' staticv ')' { $$ = ba_new($3, B_AT_FN_STR); }
- | STR '(' staticv ',' pat ')' { $$ = ba_op(B_AT_FN_STR, $3, $5); }
+ | STR '(' staticv ',' expr ')' { $$ = ba_op(B_AT_FN_STR, $3, $5); }
;
-vargs : pat
- | vargs ',' pat { $$ = ba_append($1, $3); }
+vargs : expr
+ | vargs ',' expr { $$ = ba_append($1, $3); }
;
pargs : expr
- | gvar ',' pat { $$ = ba_append(bg_find($1), $3); }
+ | gvar ',' expr { $$ = ba_append(bg_find($1), $3); }
;
NL : /* empty */
@@ -242,17 +238,17 @@ NL : /* empty */
;
stmt : ';' NL { $$ = NULL; }
- | gvar '=' pat { $$ = bg_store($1, $3); }
- | lvar '=' pat { $$ = bl_store($1, $3); }
+ | gvar '=' expr { $$ = bg_store($1, $3); }
+ | lvar '=' expr { $$ = bl_store($1, $3); }
| gvar '[' vargs ']' '=' mpat { $$ = bm_insert($1, $3, $6); }
| FUNCN '(' vargs ')' { $$ = bs_new($1, $3, NULL); }
- | FUNC1 '(' pat ')' { $$ = bs_new($1, $3, NULL); }
+ | FUNC1 '(' expr ')' { $$ = bs_new($1, $3, NULL); }
| MFUNC '(' variable ')' { $$ = bs_new($1, $3, NULL); }
| FUNC0 '(' ')' { $$ = bs_new($1, NULL, NULL); }
| F_DELETE '(' mentry ')' { $$ = bm_op($1, $3, NULL); }
| F_PRINT '(' pargs ')' { $$ = bs_new($1, $3, NULL); }
- | gvar '=' OP1 '(' pat ')' { $$ = bh_inc($1, $5, NULL); }
- | gvar '=' OP4 '(' pat ',' vargs ')' { $$ = bh_inc($1, $5, $7); }
+ | gvar '=' OP1 '(' expr ')' { $$ = bh_inc($1, $5, NULL); }
+ | gvar '=' OP4 '(' expr ',' vargs ')' { $$ = bh_inc($1, $5, $7); }
;
stmtblck: IF '(' expr ')' block { $$ = bt_new($3, $5); }