⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dt_grammar.y

📁 Sun Solaris 10 中的 DTrace 组件的源代码。请参看: http://www.sun.com/software/solaris/observability.jsp
💻 Y
📖 第 1 页 / 共 2 页
字号:
%{/* * Copyright 2005 Sun Microsystems, Inc.  All rights reserved. * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only. * See the file usr/src/LICENSING.NOTICE in this distribution or * http://www.opensolaris.org/license/ for details. */#pragma ident	"@(#)dt_grammar.y	1.4	04/10/22 SMI"#include <dt_impl.h>#define	OP1(op, c)	dt_node_op1(op, c)#define	OP2(op, l, r)	dt_node_op2(op, l, r)#define	OP3(x, y, z)	dt_node_op3(x, y, z)#define	LINK(l, r)	dt_node_link(l, r)#define	DUP(s)		strdup(s)%}%union {	dt_node_t *l_node;	dt_decl_t *l_decl;	char *l_str;	uintmax_t l_int;	int l_tok;}%token	DT_TOK_COMMA DT_TOK_ELLIPSIS%token	DT_TOK_ASGN DT_TOK_ADD_EQ DT_TOK_SUB_EQ DT_TOK_MUL_EQ%token	DT_TOK_DIV_EQ DT_TOK_MOD_EQ DT_TOK_AND_EQ DT_TOK_XOR_EQ DT_TOK_OR_EQ%token	DT_TOK_LSH_EQ DT_TOK_RSH_EQ DT_TOK_QUESTION DT_TOK_COLON%token	DT_TOK_LOR DT_TOK_LXOR DT_TOK_LAND%token	DT_TOK_BOR DT_TOK_XOR DT_TOK_BAND DT_TOK_EQU DT_TOK_NEQ%token	DT_TOK_LT DT_TOK_LE DT_TOK_GT DT_TOK_GE DT_TOK_LSH DT_TOK_RSH%token	DT_TOK_ADD DT_TOK_SUB DT_TOK_MUL DT_TOK_DIV DT_TOK_MOD%token	DT_TOK_LNEG DT_TOK_BNEG DT_TOK_ADDADD DT_TOK_SUBSUB%token	DT_TOK_PREINC DT_TOK_POSTINC DT_TOK_PREDEC DT_TOK_POSTDEC%token	DT_TOK_IPOS DT_TOK_INEG DT_TOK_DEREF DT_TOK_ADDROF%token	DT_TOK_OFFSETOF DT_TOK_SIZEOF DT_TOK_STRINGOF DT_TOK_XLATE%token	DT_TOK_LPAR DT_TOK_RPAR DT_TOK_LBRAC DT_TOK_RBRAC DT_TOK_PTR DT_TOK_DOT%token <l_str>	DT_TOK_STRING%token <l_str>	DT_TOK_IDENT%token <l_str>	DT_TOK_PSPEC%token <l_str>	DT_TOK_AGG%token <l_str>	DT_TOK_TNAME%token <l_int>	DT_TOK_INT%token	DT_KEY_AUTO%token	DT_KEY_BREAK%token	DT_KEY_CASE%token	DT_KEY_CHAR%token	DT_KEY_CONST%token	DT_KEY_CONTINUE%token	DT_KEY_COUNTER%token	DT_KEY_DEFAULT%token	DT_KEY_DO%token	DT_KEY_DOUBLE%token	DT_KEY_ELSE%token	DT_KEY_ENUM%token	DT_KEY_EXTERN%token	DT_KEY_FLOAT%token	DT_KEY_FOR%token	DT_KEY_GOTO%token	DT_KEY_IF%token	DT_KEY_IMPORT%token	DT_KEY_INLINE%token	DT_KEY_INT%token	DT_KEY_LONG%token	DT_KEY_PROBE%token	DT_KEY_PROVIDER%token	DT_KEY_REGISTER%token	DT_KEY_RESTRICT%token	DT_KEY_RETURN%token	DT_KEY_SELF%token	DT_KEY_SHORT%token	DT_KEY_SIGNED%token	DT_KEY_STATIC%token	DT_KEY_STRING%token	DT_KEY_STRUCT%token	DT_KEY_SWITCH%token	DT_KEY_THIS%token	DT_KEY_TYPEDEF%token	DT_KEY_UNION%token	DT_KEY_UNSIGNED%token	DT_KEY_VOID%token	DT_KEY_VOLATILE%token	DT_KEY_WHILE%token	DT_KEY_XLATOR%token	DT_TOK_EPRED%token	DT_CTX_DEXPR%token	DT_CTX_DPROG%token	DT_TOK_EOF	0%left	DT_TOK_COMMA%right	DT_TOK_ASGN DT_TOK_ADD_EQ DT_TOK_SUB_EQ DT_TOK_MUL_EQ DT_TOK_DIV_EQ	DT_TOK_MOD_EQ DT_TOK_AND_EQ DT_TOK_XOR_EQ DT_TOK_OR_EQ DT_TOK_LSH_EQ	DT_TOK_RSH_EQ%left	DT_TOK_QUESTION DT_TOK_COLON%left	DT_TOK_LOR%left	DT_TOK_LXOR%left	DT_TOK_LAND%left	DT_TOK_BOR%left	DT_TOK_XOR%left	DT_TOK_BAND%left	DT_TOK_EQU DT_TOK_NEQ%left	DT_TOK_LT DT_TOK_LE DT_TOK_GT DT_TOK_GE%left	DT_TOK_LSH DT_TOK_RSH%left	DT_TOK_ADD DT_TOK_SUB%left	DT_TOK_MUL DT_TOK_DIV DT_TOK_MOD%right	DT_TOK_LNEG DT_TOK_BNEG DT_TOK_ADDADD DT_TOK_SUBSUB	DT_TOK_IPOS DT_TOK_INEG%right	DT_TOK_DEREF DT_TOK_ADDROF DT_TOK_SIZEOF DT_TOK_STRINGOF DT_TOK_XLATE%left	DT_TOK_LPAR DT_TOK_RPAR DT_TOK_LBRAC DT_TOK_RBRAC DT_TOK_PTR DT_TOK_DOT%type	<l_node>	d_expression%type	<l_node>	d_program%type	<l_node>	translation_unit%type	<l_node>	external_declaration%type	<l_node>	inline_definition%type	<l_node>	translator_definition%type	<l_node>	translator_member_list%type	<l_node>	translator_member%type	<l_node>	provider_definition%type	<l_node>	provider_probe_list%type	<l_node>	provider_probe%type	<l_node>	probe_definition%type	<l_node>	probe_specifiers%type	<l_node>	probe_specifier_list%type	<l_node>	probe_specifier%type	<l_node>	statement_list%type	<l_node>	statement%type	<l_node>	declaration%type	<l_node>	init_declarator_list%type	<l_node>	init_declarator%type	<l_decl>	type_specifier%type	<l_decl>	type_qualifier%type	<l_decl>	struct_or_union_specifier%type	<l_decl>	specifier_qualifier_list%type	<l_decl>	enum_specifier%type	<l_decl>	declarator%type	<l_decl>	direct_declarator%type	<l_decl>	pointer%type	<l_decl>	type_qualifier_list%type	<l_decl>	type_name%type	<l_decl>	abstract_declarator%type	<l_decl>	direct_abstract_declarator%type	<l_node>	parameter_type_list%type	<l_node>	parameter_list%type	<l_node>	parameter_declaration%type	<l_node>	array%type	<l_node>	function%type	<l_node>	expression%type	<l_node>	assignment_expression%type	<l_node>	conditional_expression%type	<l_node>	constant_expression%type	<l_node>	logical_or_expression%type	<l_node>	logical_xor_expression%type	<l_node>	logical_and_expression%type	<l_node>	inclusive_or_expression%type	<l_node>	exclusive_or_expression%type	<l_node>	and_expression%type	<l_node>	equality_expression%type	<l_node>	relational_expression%type	<l_node>	shift_expression%type	<l_node>	additive_expression%type	<l_node>	multiplicative_expression%type	<l_node>	cast_expression%type	<l_node>	unary_expression%type	<l_node>	postfix_expression%type	<l_node>	primary_expression%type	<l_node>	argument_expression_list%type	<l_tok>		assignment_operator%type	<l_tok>		unary_operator%type	<l_tok>		struct_or_union%%dtrace_program: d_expression DT_TOK_EOF { return (dt_node_root($1)); }	|	d_program DT_TOK_EOF { return (dt_node_root($1)); }	;d_expression:	DT_CTX_DEXPR { $$ = NULL; }	|	DT_CTX_DEXPR expression { $$ = $2; }	;d_program:	DT_CTX_DPROG { $$ = dt_node_program(NULL); }	|	DT_CTX_DPROG translation_unit { $$ = dt_node_program($2); }	;translation_unit:		external_declaration	|	translation_unit external_declaration { $$ = LINK($1, $2); }	;external_declaration:		inline_definition	|	translator_definition	|	provider_definition	|	probe_definition	|	declaration	;inline_definition:		DT_KEY_INLINE type_name DT_TOK_IDENT DT_TOK_ASGN		    assignment_expression ';' {			$$ = dt_node_inline($2, $3, $5);		}translator_definition:		DT_KEY_XLATOR type_name DT_TOK_LT type_name		    DT_TOK_IDENT DT_TOK_GT '{' translator_member_list '}' ';' {			$$ = dt_node_xlator($2, $4, $5, $8);		}	|	DT_KEY_XLATOR type_name DT_TOK_LT type_name		    DT_TOK_IDENT DT_TOK_GT '{' '}' ';' {			$$ = dt_node_xlator($2, $4, $5, NULL);		}	;translator_member_list:		translator_member	|	translator_member_list translator_member { $$ = LINK($1,$2); }	;translator_member:		DT_TOK_IDENT DT_TOK_ASGN assignment_expression ';' {			$$ = dt_node_member(NULL, $1, $3);		}	;provider_definition:		DT_KEY_PROVIDER DT_TOK_IDENT '{' provider_probe_list '}' ';' {			$$ = dt_node_provider($2, $4);		}	|	DT_KEY_PROVIDER DT_TOK_IDENT '{' '}' ';' {			$$ = dt_node_provider($2, NULL);		}	;provider_probe_list:		provider_probe	|	provider_probe_list provider_probe { $$ = LINK($1, $2); }	;provider_probe:		DT_KEY_PROBE DT_TOK_IDENT function DT_TOK_COLON function ';' {			$$ = dt_node_probe($2, $3, $5);		}	|	DT_KEY_PROBE DT_TOK_IDENT function ';' {			$$ = dt_node_probe($2, $3, NULL);		}	;	probe_definition:		probe_specifiers {			/*			 * If the input stream is a file, do not permit a probe			 * specification without / <pred> / or { <act> } after			 * it.  This can only occur if the next token is EOF or			 * an ambiguous predicate was slurped up as a comment.			 * We cannot perform this check if input() is a string			 * because dtrace(1M) [-fmnP] also use the compiler and			 * things like dtrace -n BEGIN have to be accepted.			 */			if (yypcb->pcb_fileptr != NULL) {				dnerror($1, D_SYNTAX, "expected predicate and/"				    "or actions following probe description\n");			}			$$ = dt_node_clause($1, NULL, NULL);		}	|	probe_specifiers '{' statement_list '}' {			$$ = dt_node_clause($1, NULL, $3);		}	|	probe_specifiers DT_TOK_DIV expression DT_TOK_EPRED {			dnerror($3, D_SYNTAX, "expected actions { } following "			    "probe description and predicate\n");		}	|	probe_specifiers DT_TOK_DIV expression DT_TOK_EPRED		    '{' statement_list '}' {			$$ = dt_node_clause($1, $3, $6);		}	;probe_specifiers:		probe_specifier_list { yybegin(YYS_EXPR); $$ = $1; }	;probe_specifier_list:		probe_specifier	|	probe_specifier_list DT_TOK_COMMA probe_specifier {			$$ = LINK($1, $3);		}	;probe_specifier:		DT_TOK_PSPEC { $$ = dt_node_pdesc_by_name($1); }	|	DT_TOK_INT   { $$ = dt_node_pdesc_by_id($1); }	;statement_list:	statement { $$ = $1; }	|	statement_list ';' statement { $$ = LINK($1, $3); }	;statement:	/* empty */ { $$ = NULL; }	|	expression { $$ = dt_node_statement($1); }	;argument_expression_list:		assignment_expression	|	argument_expression_list DT_TOK_COMMA assignment_expression {			$$ = LINK($1, $3);		}	;primary_expression:		DT_TOK_IDENT { $$ = dt_node_ident($1); }	|	DT_TOK_AGG { $$ = dt_node_ident($1); }	|	DT_TOK_INT { $$ = dt_node_int($1); }	|	DT_TOK_STRING { $$ = dt_node_string($1); }	|	DT_KEY_SELF { $$ = dt_node_ident(DUP("self")); }	|	DT_KEY_THIS { $$ = dt_node_ident(DUP("this")); }	|	DT_TOK_LPAR expression DT_TOK_RPAR { $$ = $2; }	;postfix_expression:		primary_expression	|	postfix_expression		    DT_TOK_LBRAC argument_expression_list DT_TOK_RBRAC {			$$ = OP2(DT_TOK_LBRAC, $1, $3);		}	|	postfix_expression DT_TOK_LPAR DT_TOK_RPAR {			$$ = dt_node_func($1, NULL);		}	|	postfix_expression		    DT_TOK_LPAR argument_expression_list DT_TOK_RPAR {			$$ = dt_node_func($1, $3);		}	|	postfix_expression DT_TOK_DOT DT_TOK_IDENT {			$$ = OP2(DT_TOK_DOT, $1, dt_node_ident($3));		}	|	postfix_expression DT_TOK_DOT DT_TOK_TNAME {			$$ = OP2(DT_TOK_DOT, $1, dt_node_ident($3));		}	|	postfix_expression DT_TOK_PTR DT_TOK_IDENT {			$$ = OP2(DT_TOK_PTR, $1, dt_node_ident($3));		}	|	postfix_expression DT_TOK_PTR DT_TOK_TNAME {			$$ = OP2(DT_TOK_PTR, $1, dt_node_ident($3));		}	|	postfix_expression DT_TOK_ADDADD {			$$ = OP1(DT_TOK_POSTINC, $1);		}	|	postfix_expression DT_TOK_SUBSUB {			$$ = OP1(DT_TOK_POSTDEC, $1);		}	|	DT_TOK_OFFSETOF DT_TOK_LPAR type_name DT_TOK_COMMA 		    DT_TOK_IDENT DT_TOK_RPAR {			$$ = dt_node_offsetof($3, $5);		}	|	DT_TOK_OFFSETOF DT_TOK_LPAR type_name DT_TOK_COMMA 		    DT_TOK_TNAME DT_TOK_RPAR {			$$ = dt_node_offsetof($3, $5);		}	|	DT_TOK_XLATE DT_TOK_LT type_name DT_TOK_GT		    DT_TOK_LPAR expression DT_TOK_RPAR {			$$ = OP2(DT_TOK_XLATE, dt_node_type($3), $6);		}	;unary_expression:		postfix_expression	|	DT_TOK_ADDADD unary_expression { $$ = OP1(DT_TOK_PREINC, $2); }	|	DT_TOK_SUBSUB unary_expression { $$ = OP1(DT_TOK_PREDEC, $2); }	|	unary_operator cast_expression { $$ = OP1($1, $2); }	|	DT_TOK_SIZEOF unary_expression { $$ = OP1(DT_TOK_SIZEOF, $2); }	|	DT_TOK_SIZEOF DT_TOK_LPAR type_name DT_TOK_RPAR {			$$ = OP1(DT_TOK_SIZEOF, dt_node_type($3));		}	|	DT_TOK_STRINGOF unary_expression {			$$ = OP1(DT_TOK_STRINGOF, $2);		}	;unary_operator:	DT_TOK_BAND { $$ = DT_TOK_ADDROF; }	|	DT_TOK_MUL { $$ = DT_TOK_DEREF; }	|	DT_TOK_ADD { $$ = DT_TOK_IPOS; }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -