5 * The contents of this file are subject to the terms of the
6 * Common Development and Distribution License, Version 1.0 only
7 * (the "License"). You may not use this file except in compliance
10 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 * or http://www.opensolaris.org/os/licensing.
12 * See the License for the specific language governing permissions
13 * and limitations under the License.
15 * When distributing Covered Code, include this CDDL HEADER in each
16 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 * If applicable, add the following below this CDDL HEADER, with the
18 * fields enclosed by brackets "[]" replaced with your own identifying
19 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
31 #define OP1(op, c) dt_node_op1(op, c)
32 #define OP2(op, l, r) dt_node_op2(op, l, r)
33 #define OP3(x, y, z) dt_node_op3(x, y, z)
34 #define LINK(l, r) dt_node_link(l, r)
35 #define DUP(s) strdup(s)
47 %token DT_TOK_COMMA DT_TOK_ELLIPSIS
48 %token DT_TOK_ASGN DT_TOK_ADD_EQ DT_TOK_SUB_EQ DT_TOK_MUL_EQ
49 %token DT_TOK_DIV_EQ DT_TOK_MOD_EQ DT_TOK_AND_EQ DT_TOK_XOR_EQ DT_TOK_OR_EQ
50 %token DT_TOK_LSH_EQ DT_TOK_RSH_EQ DT_TOK_QUESTION DT_TOK_COLON
51 %token DT_TOK_LOR DT_TOK_LXOR DT_TOK_LAND
52 %token DT_TOK_BOR DT_TOK_XOR DT_TOK_BAND DT_TOK_EQU DT_TOK_NEQ
53 %token DT_TOK_LT DT_TOK_LE DT_TOK_GT DT_TOK_GE DT_TOK_LSH DT_TOK_RSH
54 %token DT_TOK_ADD DT_TOK_SUB DT_TOK_MUL DT_TOK_DIV DT_TOK_MOD
55 %token DT_TOK_LNEG DT_TOK_BNEG DT_TOK_ADDADD DT_TOK_SUBSUB
56 %token DT_TOK_PREINC DT_TOK_POSTINC DT_TOK_PREDEC DT_TOK_POSTDEC
57 %token DT_TOK_IPOS DT_TOK_INEG DT_TOK_DEREF DT_TOK_ADDROF
58 %token DT_TOK_OFFSETOF DT_TOK_SIZEOF DT_TOK_STRINGOF DT_TOK_XLATE
59 %token DT_TOK_LPAR DT_TOK_RPAR DT_TOK_LBRAC DT_TOK_RBRAC DT_TOK_PTR DT_TOK_DOT
61 %token <l_str> DT_TOK_STRING
62 %token <l_str> DT_TOK_IDENT
63 %token <l_str> DT_TOK_PSPEC
64 %token <l_str> DT_TOK_AGG
65 %token <l_str> DT_TOK_TNAME
66 %token <l_int> DT_TOK_INT
73 %token DT_KEY_CONTINUE
90 %token DT_KEY_PROVIDER
91 %token DT_KEY_REGISTER
92 %token DT_KEY_RESTRICT
102 %token DT_KEY_TYPEDEF
104 %token DT_KEY_UNSIGNED
106 %token DT_KEY_VOLATILE
117 %right DT_TOK_ASGN DT_TOK_ADD_EQ DT_TOK_SUB_EQ DT_TOK_MUL_EQ DT_TOK_DIV_EQ
118 DT_TOK_MOD_EQ DT_TOK_AND_EQ DT_TOK_XOR_EQ DT_TOK_OR_EQ DT_TOK_LSH_EQ
120 %left DT_TOK_QUESTION DT_TOK_COLON
127 %left DT_TOK_EQU DT_TOK_NEQ
128 %left DT_TOK_LT DT_TOK_LE DT_TOK_GT DT_TOK_GE
129 %left DT_TOK_LSH DT_TOK_RSH
130 %left DT_TOK_ADD DT_TOK_SUB
131 %left DT_TOK_MUL DT_TOK_DIV DT_TOK_MOD
132 %right DT_TOK_LNEG DT_TOK_BNEG DT_TOK_ADDADD DT_TOK_SUBSUB
133 DT_TOK_IPOS DT_TOK_INEG
134 %right DT_TOK_DEREF DT_TOK_ADDROF DT_TOK_SIZEOF DT_TOK_STRINGOF DT_TOK_XLATE
135 %left DT_TOK_LPAR DT_TOK_RPAR DT_TOK_LBRAC DT_TOK_RBRAC DT_TOK_PTR DT_TOK_DOT
137 %type <l_node> d_expression
138 %type <l_node> d_program
139 %type <l_node> d_type
141 %type <l_node> translation_unit
142 %type <l_node> external_declaration
143 %type <l_node> inline_definition
144 %type <l_node> translator_definition
145 %type <l_node> translator_member_list
146 %type <l_node> translator_member
147 %type <l_node> provider_definition
148 %type <l_node> provider_probe_list
149 %type <l_node> provider_probe
150 %type <l_node> probe_definition
151 %type <l_node> probe_specifiers
152 %type <l_node> probe_specifier_list
153 %type <l_node> probe_specifier
154 %type <l_node> statement_list
155 %type <l_node> statement
156 %type <l_node> declaration
157 %type <l_node> init_declarator_list
158 %type <l_node> init_declarator
160 %type <l_decl> type_specifier
161 %type <l_decl> type_qualifier
162 %type <l_decl> struct_or_union_specifier
163 %type <l_decl> specifier_qualifier_list
164 %type <l_decl> enum_specifier
165 %type <l_decl> declarator
166 %type <l_decl> direct_declarator
167 %type <l_decl> pointer
168 %type <l_decl> type_qualifier_list
169 %type <l_decl> type_name
170 %type <l_decl> abstract_declarator
171 %type <l_decl> direct_abstract_declarator
173 %type <l_node> parameter_type_list
174 %type <l_node> parameter_list
175 %type <l_node> parameter_declaration
178 %type <l_node> array_parameters
179 %type <l_node> function
180 %type <l_node> function_parameters
182 %type <l_node> expression
183 %type <l_node> assignment_expression
184 %type <l_node> conditional_expression
185 %type <l_node> constant_expression
186 %type <l_node> logical_or_expression
187 %type <l_node> logical_xor_expression
188 %type <l_node> logical_and_expression
189 %type <l_node> inclusive_or_expression
190 %type <l_node> exclusive_or_expression
191 %type <l_node> and_expression
192 %type <l_node> equality_expression
193 %type <l_node> relational_expression
194 %type <l_node> shift_expression
195 %type <l_node> additive_expression
196 %type <l_node> multiplicative_expression
197 %type <l_node> cast_expression
198 %type <l_node> unary_expression
199 %type <l_node> postfix_expression
200 %type <l_node> primary_expression
201 %type <l_node> argument_expression_list
203 %type <l_tok> assignment_operator
204 %type <l_tok> unary_operator
205 %type <l_tok> struct_or_union
207 %type <l_str> dtrace_keyword_ident
211 dtrace_program: d_expression DT_TOK_EOF { return (dt_node_root($1)); }
212 | d_program DT_TOK_EOF { return (dt_node_root($1)); }
213 | d_type DT_TOK_EOF { return (dt_node_root($1)); }
216 d_expression: DT_CTX_DEXPR { $$ = NULL; }
217 | DT_CTX_DEXPR expression { $$ = $2; }
220 d_program: DT_CTX_DPROG { $$ = dt_node_program(NULL); }
221 | DT_CTX_DPROG translation_unit { $$ = dt_node_program($2); }
224 d_type: DT_CTX_DTYPE { $$ = NULL; }
225 | DT_CTX_DTYPE type_name { $$ = (dt_node_t *)$2; }
230 | translation_unit external_declaration { $$ = LINK($1, $2); }
233 external_declaration:
235 | translator_definition
236 | provider_definition
242 DT_KEY_INLINE declaration_specifiers declarator
243 { dt_scope_push(NULL, CTF_ERR); } DT_TOK_ASGN
244 assignment_expression ';' {
246 * We push a new declaration scope before shifting the
247 * assignment_expression in order to preserve ds_class
248 * and ds_ident for use in dt_node_inline(). Once the
249 * entire inline_definition rule is matched, pop the
250 * scope and construct the inline using the saved decl.
253 $$ = dt_node_inline($6);
257 translator_definition:
258 DT_KEY_XLATOR type_name DT_TOK_LT type_name
259 DT_TOK_IDENT DT_TOK_GT '{' translator_member_list '}' ';' {
260 $$ = dt_node_xlator($2, $4, $5, $8);
262 | DT_KEY_XLATOR type_name DT_TOK_LT type_name
263 DT_TOK_IDENT DT_TOK_GT '{' '}' ';' {
264 $$ = dt_node_xlator($2, $4, $5, NULL);
268 translator_member_list:
270 | translator_member_list translator_member { $$ = LINK($1,$2); }
274 DT_TOK_IDENT DT_TOK_ASGN assignment_expression ';' {
275 $$ = dt_node_member(NULL, $1, $3);
280 DT_KEY_PROVIDER DT_TOK_IDENT '{' provider_probe_list '}' ';' {
281 $$ = dt_node_provider($2, $4);
283 | DT_KEY_PROVIDER DT_TOK_IDENT '{' '}' ';' {
284 $$ = dt_node_provider($2, NULL);
290 | provider_probe_list provider_probe { $$ = LINK($1, $2); }
294 DT_KEY_PROBE DT_TOK_IDENT function DT_TOK_COLON function ';' {
295 $$ = dt_node_probe($2, 2, $3, $5);
297 | DT_KEY_PROBE DT_TOK_IDENT function ';' {
298 $$ = dt_node_probe($2, 1, $3, NULL);
306 * If the input stream is a file, do not permit a probe
307 * specification without / <pred> / or { <act> } after
308 * it. This can only occur if the next token is EOF or
309 * an ambiguous predicate was slurped up as a comment.
310 * We cannot perform this check if input() is a string
311 * because dtrace(1M) [-fmnP] also use the compiler and
312 * things like dtrace -n BEGIN have to be accepted.
314 if (yypcb->pcb_fileptr != NULL) {
315 dnerror($1, D_SYNTAX, "expected predicate and/"
316 "or actions following probe description\n");
318 $$ = dt_node_clause($1, NULL, NULL);
320 | probe_specifiers '{' statement_list '}' {
321 $$ = dt_node_clause($1, NULL, $3);
323 | probe_specifiers DT_TOK_DIV expression DT_TOK_EPRED {
324 dnerror($3, D_SYNTAX, "expected actions { } following "
325 "probe description and predicate\n");
327 | probe_specifiers DT_TOK_DIV expression DT_TOK_EPRED
328 '{' statement_list '}' {
329 $$ = dt_node_clause($1, $3, $6);
334 probe_specifier_list { yybegin(YYS_EXPR); $$ = $1; }
337 probe_specifier_list:
339 | probe_specifier_list DT_TOK_COMMA probe_specifier {
345 DT_TOK_PSPEC { $$ = dt_node_pdesc_by_name($1); }
346 | DT_TOK_INT { $$ = dt_node_pdesc_by_id($1); }
349 statement_list: statement { $$ = $1; }
350 | statement_list ';' statement { $$ = LINK($1, $3); }
353 statement: /* empty */ { $$ = NULL; }
354 | expression { $$ = dt_node_statement($1); }
357 argument_expression_list:
358 assignment_expression
359 | argument_expression_list DT_TOK_COMMA assignment_expression {
365 DT_TOK_IDENT { $$ = dt_node_ident($1); }
366 | DT_TOK_AGG { $$ = dt_node_ident($1); }
367 | DT_TOK_INT { $$ = dt_node_int($1); }
368 | DT_TOK_STRING { $$ = dt_node_string($1); }
369 | DT_KEY_SELF { $$ = dt_node_ident(DUP("self")); }
370 | DT_KEY_THIS { $$ = dt_node_ident(DUP("this")); }
371 | DT_TOK_LPAR expression DT_TOK_RPAR { $$ = $2; }
377 DT_TOK_LBRAC argument_expression_list DT_TOK_RBRAC {
378 $$ = OP2(DT_TOK_LBRAC, $1, $3);
380 | postfix_expression DT_TOK_LPAR DT_TOK_RPAR {
381 $$ = dt_node_func($1, NULL);
384 DT_TOK_LPAR argument_expression_list DT_TOK_RPAR {
385 $$ = dt_node_func($1, $3);
387 | postfix_expression DT_TOK_DOT DT_TOK_IDENT {
388 $$ = OP2(DT_TOK_DOT, $1, dt_node_ident($3));
390 | postfix_expression DT_TOK_DOT DT_TOK_TNAME {
391 $$ = OP2(DT_TOK_DOT, $1, dt_node_ident($3));
393 | postfix_expression DT_TOK_DOT dtrace_keyword_ident {
394 $$ = OP2(DT_TOK_DOT, $1, dt_node_ident($3));
396 | postfix_expression DT_TOK_PTR DT_TOK_IDENT {
397 $$ = OP2(DT_TOK_PTR, $1, dt_node_ident($3));
399 | postfix_expression DT_TOK_PTR DT_TOK_TNAME {
400 $$ = OP2(DT_TOK_PTR, $1, dt_node_ident($3));
402 | postfix_expression DT_TOK_PTR dtrace_keyword_ident {
403 $$ = OP2(DT_TOK_PTR, $1, dt_node_ident($3));
405 | postfix_expression DT_TOK_ADDADD {
406 $$ = OP1(DT_TOK_POSTINC, $1);
408 | postfix_expression DT_TOK_SUBSUB {
409 $$ = OP1(DT_TOK_POSTDEC, $1);
411 | DT_TOK_OFFSETOF DT_TOK_LPAR type_name DT_TOK_COMMA
412 DT_TOK_IDENT DT_TOK_RPAR {
413 $$ = dt_node_offsetof($3, $5);
415 | DT_TOK_OFFSETOF DT_TOK_LPAR type_name DT_TOK_COMMA
416 DT_TOK_TNAME DT_TOK_RPAR {
417 $$ = dt_node_offsetof($3, $5);
419 | DT_TOK_OFFSETOF DT_TOK_LPAR type_name DT_TOK_COMMA
420 dtrace_keyword_ident DT_TOK_RPAR {
421 $$ = dt_node_offsetof($3, $5);
423 | DT_TOK_XLATE DT_TOK_LT type_name DT_TOK_GT
424 DT_TOK_LPAR expression DT_TOK_RPAR {
425 $$ = OP2(DT_TOK_XLATE, dt_node_type($3), $6);
431 | DT_TOK_ADDADD unary_expression { $$ = OP1(DT_TOK_PREINC, $2); }
432 | DT_TOK_SUBSUB unary_expression { $$ = OP1(DT_TOK_PREDEC, $2); }
433 | unary_operator cast_expression { $$ = OP1($1, $2); }
434 | DT_TOK_SIZEOF unary_expression { $$ = OP1(DT_TOK_SIZEOF, $2); }
435 | DT_TOK_SIZEOF DT_TOK_LPAR type_name DT_TOK_RPAR {
436 $$ = OP1(DT_TOK_SIZEOF, dt_node_type($3));
438 | DT_TOK_STRINGOF unary_expression {
439 $$ = OP1(DT_TOK_STRINGOF, $2);
443 unary_operator: DT_TOK_BAND { $$ = DT_TOK_ADDROF; }
444 | DT_TOK_MUL { $$ = DT_TOK_DEREF; }
445 | DT_TOK_ADD { $$ = DT_TOK_IPOS; }
446 | DT_TOK_SUB { $$ = DT_TOK_INEG; }
447 | DT_TOK_BNEG { $$ = DT_TOK_BNEG; }
448 | DT_TOK_LNEG { $$ = DT_TOK_LNEG; }
453 | DT_TOK_LPAR type_name DT_TOK_RPAR cast_expression {
454 $$ = OP2(DT_TOK_LPAR, dt_node_type($2), $4);
458 multiplicative_expression:
460 | multiplicative_expression DT_TOK_MUL cast_expression {
461 $$ = OP2(DT_TOK_MUL, $1, $3);
463 | multiplicative_expression DT_TOK_DIV cast_expression {
464 $$ = OP2(DT_TOK_DIV, $1, $3);
466 | multiplicative_expression DT_TOK_MOD cast_expression {
467 $$ = OP2(DT_TOK_MOD, $1, $3);
472 multiplicative_expression
473 | additive_expression DT_TOK_ADD multiplicative_expression {
474 $$ = OP2(DT_TOK_ADD, $1, $3);
476 | additive_expression DT_TOK_SUB multiplicative_expression {
477 $$ = OP2(DT_TOK_SUB, $1, $3);
483 | shift_expression DT_TOK_LSH additive_expression {
484 $$ = OP2(DT_TOK_LSH, $1, $3);
486 | shift_expression DT_TOK_RSH additive_expression {
487 $$ = OP2(DT_TOK_RSH, $1, $3);
491 relational_expression:
493 | relational_expression DT_TOK_LT shift_expression {
494 $$ = OP2(DT_TOK_LT, $1, $3);
496 | relational_expression DT_TOK_GT shift_expression {
497 $$ = OP2(DT_TOK_GT, $1, $3);
499 | relational_expression DT_TOK_LE shift_expression {
500 $$ = OP2(DT_TOK_LE, $1, $3);
502 | relational_expression DT_TOK_GE shift_expression {
503 $$ = OP2(DT_TOK_GE, $1, $3);
508 relational_expression
509 | equality_expression DT_TOK_EQU relational_expression {
510 $$ = OP2(DT_TOK_EQU, $1, $3);
512 | equality_expression DT_TOK_NEQ relational_expression {
513 $$ = OP2(DT_TOK_NEQ, $1, $3);
519 | and_expression DT_TOK_BAND equality_expression {
520 $$ = OP2(DT_TOK_BAND, $1, $3);
524 exclusive_or_expression:
526 | exclusive_or_expression DT_TOK_XOR and_expression {
527 $$ = OP2(DT_TOK_XOR, $1, $3);
531 inclusive_or_expression:
532 exclusive_or_expression
533 | inclusive_or_expression DT_TOK_BOR exclusive_or_expression {
534 $$ = OP2(DT_TOK_BOR, $1, $3);
538 logical_and_expression:
539 inclusive_or_expression
540 | logical_and_expression DT_TOK_LAND inclusive_or_expression {
541 $$ = OP2(DT_TOK_LAND, $1, $3);
545 logical_xor_expression:
546 logical_and_expression
547 | logical_xor_expression DT_TOK_LXOR logical_and_expression {
548 $$ = OP2(DT_TOK_LXOR, $1, $3);
552 logical_or_expression:
553 logical_xor_expression
554 | logical_or_expression DT_TOK_LOR logical_xor_expression {
555 $$ = OP2(DT_TOK_LOR, $1, $3);
559 constant_expression: conditional_expression
562 conditional_expression:
563 logical_or_expression
564 | logical_or_expression DT_TOK_QUESTION expression DT_TOK_COLON
565 conditional_expression { $$ = OP3($1, $3, $5); }
568 assignment_expression:
569 conditional_expression
570 | unary_expression assignment_operator assignment_expression {
571 $$ = OP2($2, $1, $3);
576 DT_TOK_ASGN { $$ = DT_TOK_ASGN; }
577 | DT_TOK_MUL_EQ { $$ = DT_TOK_MUL_EQ; }
578 | DT_TOK_DIV_EQ { $$ = DT_TOK_DIV_EQ; }
579 | DT_TOK_MOD_EQ { $$ = DT_TOK_MOD_EQ; }
580 | DT_TOK_ADD_EQ { $$ = DT_TOK_ADD_EQ; }
581 | DT_TOK_SUB_EQ { $$ = DT_TOK_SUB_EQ; }
582 | DT_TOK_LSH_EQ { $$ = DT_TOK_LSH_EQ; }
583 | DT_TOK_RSH_EQ { $$ = DT_TOK_RSH_EQ; }
584 | DT_TOK_AND_EQ { $$ = DT_TOK_AND_EQ; }
585 | DT_TOK_XOR_EQ { $$ = DT_TOK_XOR_EQ; }
586 | DT_TOK_OR_EQ { $$ = DT_TOK_OR_EQ; }
589 expression: assignment_expression
590 | expression DT_TOK_COMMA assignment_expression {
591 $$ = OP2(DT_TOK_COMMA, $1, $3);
595 declaration: declaration_specifiers ';' {
597 dt_decl_free(dt_decl_pop());
600 | declaration_specifiers init_declarator_list ';' {
602 dt_decl_free(dt_decl_pop());
607 declaration_specifiers:
608 d_storage_class_specifier
609 | d_storage_class_specifier declaration_specifiers
611 | type_specifier declaration_specifiers
613 | type_qualifier declaration_specifiers
616 parameter_declaration_specifiers:
617 storage_class_specifier
618 | storage_class_specifier declaration_specifiers
620 | type_specifier declaration_specifiers
622 | type_qualifier declaration_specifiers
625 storage_class_specifier:
626 DT_KEY_AUTO { dt_decl_class(DT_DC_AUTO); }
627 | DT_KEY_REGISTER { dt_decl_class(DT_DC_REGISTER); }
628 | DT_KEY_STATIC { dt_decl_class(DT_DC_STATIC); }
629 | DT_KEY_EXTERN { dt_decl_class(DT_DC_EXTERN); }
630 | DT_KEY_TYPEDEF { dt_decl_class(DT_DC_TYPEDEF); }
633 d_storage_class_specifier:
634 storage_class_specifier
635 | DT_KEY_SELF { dt_decl_class(DT_DC_SELF); }
636 | DT_KEY_THIS { dt_decl_class(DT_DC_THIS); }
639 type_specifier: DT_KEY_VOID { $$ = dt_decl_spec(CTF_K_INTEGER, DUP("void")); }
640 | DT_KEY_CHAR { $$ = dt_decl_spec(CTF_K_INTEGER, DUP("char")); }
641 | DT_KEY_SHORT { $$ = dt_decl_attr(DT_DA_SHORT); }
642 | DT_KEY_INT { $$ = dt_decl_spec(CTF_K_INTEGER, DUP("int")); }
643 | DT_KEY_LONG { $$ = dt_decl_attr(DT_DA_LONG); }
644 | DT_KEY_FLOAT { $$ = dt_decl_spec(CTF_K_FLOAT, DUP("float")); }
645 | DT_KEY_DOUBLE { $$ = dt_decl_spec(CTF_K_FLOAT, DUP("double")); }
646 | DT_KEY_SIGNED { $$ = dt_decl_attr(DT_DA_SIGNED); }
647 | DT_KEY_UNSIGNED { $$ = dt_decl_attr(DT_DA_UNSIGNED); }
649 $$ = dt_decl_spec(CTF_K_TYPEDEF, DUP("string"));
651 | DT_TOK_TNAME { $$ = dt_decl_spec(CTF_K_TYPEDEF, $1); }
652 | struct_or_union_specifier
656 type_qualifier: DT_KEY_CONST { $$ = dt_decl_attr(DT_DA_CONST); }
657 | DT_KEY_RESTRICT { $$ = dt_decl_attr(DT_DA_RESTRICT); }
658 | DT_KEY_VOLATILE { $$ = dt_decl_attr(DT_DA_VOLATILE); }
661 struct_or_union_specifier:
662 struct_or_union_definition struct_declaration_list '}' {
665 | struct_or_union DT_TOK_IDENT { $$ = dt_decl_spec($1, $2); }
666 | struct_or_union DT_TOK_TNAME { $$ = dt_decl_spec($1, $2); }
669 struct_or_union_definition:
670 struct_or_union '{' { dt_decl_sou($1, NULL); }
671 | struct_or_union DT_TOK_IDENT '{' { dt_decl_sou($1, $2); }
672 | struct_or_union DT_TOK_TNAME '{' { dt_decl_sou($1, $2); }
676 DT_KEY_STRUCT { $$ = CTF_K_STRUCT; }
677 | DT_KEY_UNION { $$ = CTF_K_UNION; }
680 struct_declaration_list:
682 | struct_declaration_list struct_declaration
685 init_declarator_list:
687 | init_declarator_list DT_TOK_COMMA init_declarator {
700 specifier_qualifier_list struct_declarator_list ';' {
701 dt_decl_free(dt_decl_pop());
705 specifier_qualifier_list:
707 | type_specifier specifier_qualifier_list { $$ = $2; }
709 | type_qualifier specifier_qualifier_list { $$ = $2; }
712 struct_declarator_list:
714 | struct_declarator_list DT_TOK_COMMA struct_declarator
718 declarator { dt_decl_member(NULL); }
719 | DT_TOK_COLON constant_expression { dt_decl_member($2); }
720 | declarator DT_TOK_COLON constant_expression {
726 enum_definition enumerator_list '}' { $$ = dt_scope_pop(); }
727 | DT_KEY_ENUM DT_TOK_IDENT { $$ = dt_decl_spec(CTF_K_ENUM, $2); }
728 | DT_KEY_ENUM DT_TOK_TNAME { $$ = dt_decl_spec(CTF_K_ENUM, $2); }
732 DT_KEY_ENUM '{' { dt_decl_enum(NULL); }
733 | DT_KEY_ENUM DT_TOK_IDENT '{' { dt_decl_enum($2); }
734 | DT_KEY_ENUM DT_TOK_TNAME '{' { dt_decl_enum($2); }
739 | enumerator_list DT_TOK_COMMA enumerator
742 enumerator: DT_TOK_IDENT { dt_decl_enumerator($1, NULL); }
743 | DT_TOK_IDENT DT_TOK_ASGN expression {
744 dt_decl_enumerator($1, $3);
748 declarator: direct_declarator
749 | pointer direct_declarator
753 DT_TOK_IDENT { $$ = dt_decl_ident($1); }
754 | lparen declarator DT_TOK_RPAR { $$ = $2; }
755 | direct_declarator array { dt_decl_array($2); }
756 | direct_declarator function { dt_decl_func($1, $2); }
759 lparen: DT_TOK_LPAR { dt_decl_top()->dd_attr |= DT_DA_PAREN; }
762 pointer: DT_TOK_MUL { $$ = dt_decl_ptr(); }
763 | DT_TOK_MUL type_qualifier_list { $$ = dt_decl_ptr(); }
764 | DT_TOK_MUL pointer { $$ = dt_decl_ptr(); }
765 | DT_TOK_MUL type_qualifier_list pointer { $$ = dt_decl_ptr(); }
770 | type_qualifier_list type_qualifier { $$ = $2; }
775 | DT_TOK_ELLIPSIS { $$ = dt_node_vatype(); }
776 | parameter_list DT_TOK_COMMA DT_TOK_ELLIPSIS {
777 $$ = LINK($1, dt_node_vatype());
781 parameter_list: parameter_declaration
782 | parameter_list DT_TOK_COMMA parameter_declaration {
787 parameter_declaration:
788 parameter_declaration_specifiers {
789 $$ = dt_node_type(NULL);
791 | parameter_declaration_specifiers declarator {
792 $$ = dt_node_type(NULL);
794 | parameter_declaration_specifiers abstract_declarator {
795 $$ = dt_node_type(NULL);
799 type_name: specifier_qualifier_list {
802 | specifier_qualifier_list abstract_declarator {
809 | direct_abstract_declarator
810 | pointer direct_abstract_declarator
813 direct_abstract_declarator:
814 lparen abstract_declarator DT_TOK_RPAR { $$ = $2; }
815 | direct_abstract_declarator array { dt_decl_array($2); }
816 | array { dt_decl_array($1); $$ = NULL; }
817 | direct_abstract_declarator function { dt_decl_func($1, $2); }
818 | function { dt_decl_func(NULL, $1); }
821 array: DT_TOK_LBRAC { dt_scope_push(NULL, CTF_ERR); }
822 array_parameters DT_TOK_RBRAC {
829 /* empty */ { $$ = NULL; }
830 | constant_expression { $$ = $1; }
831 | parameter_type_list { $$ = $1; }
834 function: DT_TOK_LPAR { dt_scope_push(NULL, CTF_ERR); }
835 function_parameters DT_TOK_RPAR {
842 /* empty */ { $$ = NULL; }
843 | parameter_type_list { $$ = $1; }
846 dtrace_keyword_ident:
847 DT_KEY_PROBE { $$ = DUP("probe"); }
848 | DT_KEY_PROVIDER { $$ = DUP("provider"); }
849 | DT_KEY_SELF { $$ = DUP("self"); }
850 | DT_KEY_STRING { $$ = DUP("string"); }
851 | DT_TOK_STRINGOF { $$ = DUP("stringof"); }
852 | DT_KEY_USERLAND { $$ = DUP("userland"); }
853 | DT_TOK_XLATE { $$ = DUP("xlate"); }
854 | DT_KEY_XLATOR { $$ = DUP("translator"); }