Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Oct 2014 21:52:41 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r272671 - head/cddl/contrib/opensolaris/lib/libdtrace/common
Message-ID:  <201410062152.s96LqfYP033439@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Mon Oct  6 21:52:40 2014
New Revision: 272671
URL: https://svnweb.freebsd.org/changeset/base/272671

Log:
  Treat D keywords as identifiers in certain postfix expressions. This allows
  one to, for example, access the "provider" field of a struct g_consumer,
  even though "provider" is a D keyword.
  
  PR:		169657
  MFC after:	2 months
  Discussed with:	Bryan Cantrill
  Sponsored by:	EMC / Isilon Storage Division

Modified:
  head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_grammar.y

Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_grammar.y
==============================================================================
--- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_grammar.y	Mon Oct  6 20:48:01 2014	(r272670)
+++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_grammar.y	Mon Oct  6 21:52:40 2014	(r272671)
@@ -207,6 +207,8 @@
 %type	<l_tok>		unary_operator
 %type	<l_tok>		struct_or_union
 
+%type	<l_str>		dtrace_keyword_ident
+
 %%
 
 dtrace_program: d_expression DT_TOK_EOF { return (dt_node_root($1)); }
@@ -391,12 +393,18 @@ postfix_expression:
 	|	postfix_expression DT_TOK_DOT DT_TOK_TNAME {
 			$$ = OP2(DT_TOK_DOT, $1, dt_node_ident($3));
 		}
+	|	postfix_expression DT_TOK_DOT dtrace_keyword_ident {
+			$$ = 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_PTR dtrace_keyword_ident {
+			$$ = OP2(DT_TOK_PTR, $1, dt_node_ident($3));
+		}
 	|	postfix_expression DT_TOK_ADDADD {
 			$$ = OP1(DT_TOK_POSTINC, $1);
 		}
@@ -411,6 +419,10 @@ postfix_expression:
 		    DT_TOK_TNAME DT_TOK_RPAR {
 			$$ = dt_node_offsetof($3, $5);
 		}
+	|	DT_TOK_OFFSETOF DT_TOK_LPAR type_name DT_TOK_COMMA
+		    dtrace_keyword_ident 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);
@@ -835,4 +847,15 @@ function_parameters:
 	|	parameter_type_list	{ $$ = $1; }
 	;
 
+dtrace_keyword_ident:
+	  DT_KEY_PROBE { $$ = DUP("probe"); }
+	| DT_KEY_PROVIDER { $$ = DUP("provider"); }
+	| DT_KEY_SELF { $$ = DUP("self"); }
+	| DT_KEY_STRING { $$ = DUP("string"); }
+	| DT_TOK_STRINGOF { $$ = DUP("stringof"); }
+	| DT_KEY_USERLAND { $$ = DUP("userland"); }
+	| DT_TOK_XLATE { $$ = DUP("xlate"); }
+	| DT_KEY_XLATOR { $$ = DUP("translator"); }
+	;
+
 %%



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201410062152.s96LqfYP033439>