bt_parse.y (122a1b33) bt_parse.y (b005393a)
1/* $OpenBSD: bt_parse.y,v 1.43 2021/09/09 12:09:11 mpi Exp $ */
1/* $OpenBSD: bt_parse.y,v 1.44 2021/10/03 22:01:48 dv Exp $ */
2
3/*
4 * Copyright (c) 2019-2021 Martin Pieuchot <mpi@openbsd.org>
5 * Copyright (c) 2019 Tobias Heider <tobhe@openbsd.org>
6 * Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
7 *
8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above

--- 103 unchanged lines hidden (view full) ---

113%}
114
115%token <v.i> ERROR ENDFILT
116%token <v.i> OP_EQ OP_NE OP_LE OP_LT OP_GE OP_GT OP_LAND OP_LOR
117/* Builtins */
118%token <v.i> BUILTIN BEGIN END HZ IF
119/* Functions and Map operators */
120%token <v.i> F_DELETE F_PRINT
2
3/*
4 * Copyright (c) 2019-2021 Martin Pieuchot <mpi@openbsd.org>
5 * Copyright (c) 2019 Tobias Heider <tobhe@openbsd.org>
6 * Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
7 *
8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above

--- 103 unchanged lines hidden (view full) ---

113%}
114
115%token <v.i> ERROR ENDFILT
116%token <v.i> OP_EQ OP_NE OP_LE OP_LT OP_GE OP_GT OP_LAND OP_LOR
117/* Builtins */
118%token <v.i> BUILTIN BEGIN END HZ IF
119/* Functions and Map operators */
120%token <v.i> F_DELETE F_PRINT
121%token <v.i> MFUNC FUNC0 FUNC1 FUNCN OP1 OP4 MOP0 MOP1
121%token <v.i> MFUNC FUNC0 FUNC1 FUNCN OP1 OP2 OP4 MOP0 MOP1
122%token <v.string> STRING CSTRING
123%token <v.number> NUMBER
124
125%type <v.string> gvar lvar
126%type <v.i> beginend
127%type <v.probe> plist probe pname
128%type <v.filter> filter
129%type <v.stmt> action stmt stmtblck stmtlist block
130%type <v.arg> pat vargs mentry mpat pargs staticv
122%token <v.string> STRING CSTRING
123%token <v.number> NUMBER
124
125%type <v.string> gvar lvar
126%type <v.i> beginend
127%type <v.probe> plist probe pname
128%type <v.filter> filter
129%type <v.stmt> action stmt stmtblck stmtlist block
130%type <v.arg> pat vargs mentry mpat pargs staticv
131%type <v.arg> expr term fterm variable factor
131%type <v.arg> expr term fterm variable factor func
132%%
133
134grammar : /* empty */
135 | grammar '\n'
136 | grammar rule
137 | grammar error
138 ;
139

--- 76 unchanged lines hidden (view full) ---

216 ;
217
218factor : '(' expr ')' { $$ = $2; }
219 | NUMBER { $$ = ba_new($1, B_AT_LONG); }
220 | BUILTIN { $$ = ba_new(NULL, $1); }
221 | staticv
222 | variable
223 | mentry
132%%
133
134grammar : /* empty */
135 | grammar '\n'
136 | grammar rule
137 | grammar error
138 ;
139

--- 76 unchanged lines hidden (view full) ---

216 ;
217
218factor : '(' expr ')' { $$ = $2; }
219 | NUMBER { $$ = ba_new($1, B_AT_LONG); }
220 | BUILTIN { $$ = ba_new(NULL, $1); }
221 | staticv
222 | variable
223 | mentry
224 | func
224 ;
225
225 ;
226
227func : STR '(' staticv ')' { $$ = ba_new($3, B_AT_FN_STR); }
228 | STR '(' staticv ',' pat ')' { $$ = ba_op(B_AT_FN_STR, $3, $5); }
229 ;
226
227vargs : pat
228 | vargs ',' pat { $$ = ba_append($1, $3); }
229 ;
230
231pargs : expr
232 | gvar ',' pat { $$ = ba_append(bg_find($1), $3); }
233 ;

--- 475 unchanged lines hidden (view full) ---

709 { "lhist", OP4, 0 },
710 { "max", MOP1, B_AT_MF_MAX },
711 { "min", MOP1, B_AT_MF_MIN },
712 { "nsecs", BUILTIN, B_AT_BI_NSECS },
713 { "pid", BUILTIN, B_AT_BI_PID },
714 { "print", F_PRINT, B_AC_PRINT },
715 { "printf", FUNCN, B_AC_PRINTF },
716 { "retval", BUILTIN, B_AT_BI_RETVAL },
230
231vargs : pat
232 | vargs ',' pat { $$ = ba_append($1, $3); }
233 ;
234
235pargs : expr
236 | gvar ',' pat { $$ = ba_append(bg_find($1), $3); }
237 ;

--- 475 unchanged lines hidden (view full) ---

713 { "lhist", OP4, 0 },
714 { "max", MOP1, B_AT_MF_MAX },
715 { "min", MOP1, B_AT_MF_MIN },
716 { "nsecs", BUILTIN, B_AT_BI_NSECS },
717 { "pid", BUILTIN, B_AT_BI_PID },
718 { "print", F_PRINT, B_AC_PRINT },
719 { "printf", FUNCN, B_AC_PRINTF },
720 { "retval", BUILTIN, B_AT_BI_RETVAL },
721 { "str", STR, B_AT_FN_STR },
717 { "sum", MOP1, B_AT_MF_SUM },
718 { "tid", BUILTIN, B_AT_BI_TID },
719 { "time", FUNC1, B_AC_TIME },
720 { "ustack", BUILTIN, B_AT_BI_USTACK },
721 { "zero", MFUNC, B_AC_ZERO },
722 };
723
724 return bsearch(s, kws, nitems(kws), sizeof(kws[0]), kw_cmp);

--- 302 unchanged lines hidden ---
722 { "sum", MOP1, B_AT_MF_SUM },
723 { "tid", BUILTIN, B_AT_BI_TID },
724 { "time", FUNC1, B_AC_TIME },
725 { "ustack", BUILTIN, B_AT_BI_USTACK },
726 { "zero", MFUNC, B_AC_ZERO },
727 };
728
729 return bsearch(s, kws, nitems(kws), sizeof(kws[0]), kw_cmp);

--- 302 unchanged lines hidden ---