17c478bd9Sstevel@tonic-gate %{ 27c478bd9Sstevel@tonic-gate /* 37c478bd9Sstevel@tonic-gate * CDDL HEADER START 47c478bd9Sstevel@tonic-gate * 57c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 68a40a695Sgavinm * Common Development and Distribution License (the "License"). 78a40a695Sgavinm * You may not use this file except in compliance with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate * 22*b0daa853SStephen Hanson * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate * 257c478bd9Sstevel@tonic-gate * escparse.y -- parser for esc 267c478bd9Sstevel@tonic-gate * 277c478bd9Sstevel@tonic-gate * this is the yacc-based parser for Eversholt. the syntax is simple 287c478bd9Sstevel@tonic-gate * and is defined by the LALR(1) grammar described by this file. there 297c478bd9Sstevel@tonic-gate * should be no shift/reduce or reduce/reduce messages when building this 307c478bd9Sstevel@tonic-gate * file. 317c478bd9Sstevel@tonic-gate * 327c478bd9Sstevel@tonic-gate * as the input is parsed, a parse tree is built by calling the 337c478bd9Sstevel@tonic-gate * tree_X() functions defined in tree.c. any syntax errors cause 347c478bd9Sstevel@tonic-gate * us to skip to the next semicolon, achieved via the "error" clause 357c478bd9Sstevel@tonic-gate * in the stmt rule below. the yacc state machine code will call 367c478bd9Sstevel@tonic-gate * yyerror() in esclex.c and that will keep count of the errors and 377c478bd9Sstevel@tonic-gate * display the filename, line number, and current input stream of tokens 387c478bd9Sstevel@tonic-gate * to help the user figure out the problem. the -Y flag to this program 397c478bd9Sstevel@tonic-gate * turns on the yacc debugging output which is quite large. you probably 407c478bd9Sstevel@tonic-gate * only need to do that if you're debugging the grammar below. 417c478bd9Sstevel@tonic-gate * 427c478bd9Sstevel@tonic-gate */ 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate #include <stdio.h> 457c478bd9Sstevel@tonic-gate #include <ctype.h> 467c478bd9Sstevel@tonic-gate #include <string.h> 477c478bd9Sstevel@tonic-gate #include <stdlib.h> 487c478bd9Sstevel@tonic-gate #include <unistd.h> 497c478bd9Sstevel@tonic-gate #include <time.h> 507c478bd9Sstevel@tonic-gate #include <sys/time.h> 517c478bd9Sstevel@tonic-gate #include "out.h" 527c478bd9Sstevel@tonic-gate #include "stable.h" 537c478bd9Sstevel@tonic-gate #include "literals.h" 547c478bd9Sstevel@tonic-gate #include "lut.h" 557c478bd9Sstevel@tonic-gate #include "esclex.h" 567c478bd9Sstevel@tonic-gate #include "tree.h" 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate %} 597c478bd9Sstevel@tonic-gate %union { 607c478bd9Sstevel@tonic-gate struct tokstr tok; 617c478bd9Sstevel@tonic-gate struct node *np; 627c478bd9Sstevel@tonic-gate } 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate %right '=' 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate /* 677c478bd9Sstevel@tonic-gate * make sure ':' comes immediately after '?' in precedence declarations 687c478bd9Sstevel@tonic-gate */ 697c478bd9Sstevel@tonic-gate %right '?' 707c478bd9Sstevel@tonic-gate %nonassoc ':' 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate %left OR 737c478bd9Sstevel@tonic-gate %left AND 747c478bd9Sstevel@tonic-gate %left '|' 757c478bd9Sstevel@tonic-gate %left '^' 767c478bd9Sstevel@tonic-gate %left '&' 777c478bd9Sstevel@tonic-gate %left EQ NE 787c478bd9Sstevel@tonic-gate %left LE GE '<' '>' 797c478bd9Sstevel@tonic-gate %left LSHIFT RSHIFT 807c478bd9Sstevel@tonic-gate %left '-' '+' 817c478bd9Sstevel@tonic-gate %left '*' '%' DIV '/' 827c478bd9Sstevel@tonic-gate %right '!' '~' 837c478bd9Sstevel@tonic-gate %left '.' 847c478bd9Sstevel@tonic-gate 857aec1d6eScindi %token <tok> PROP MASK ARROW EVENT ENGINE ASRU FRU COUNT CONFIG 867c478bd9Sstevel@tonic-gate %token <tok> ID QUOTE NUMBER IF PATHFUNC 877c478bd9Sstevel@tonic-gate %type <tok> enameid 887c478bd9Sstevel@tonic-gate %type <np> root stmtlist stmt nvpairlist nvpair nvname nvexpr 897c478bd9Sstevel@tonic-gate %type <np> exprlist expr iterid ename pname epname eexprlist ipname iname 90837416c3Scy152378 %type <np> numexpr cexpr func pfunc parglist parg 917c478bd9Sstevel@tonic-gate %type <np> eventlist event nork norkexpr globid propbody 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate %% 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate root : stmtlist 967c478bd9Sstevel@tonic-gate { (void)tree_root($1); } 977c478bd9Sstevel@tonic-gate ; 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate stmtlist : /*empty*/ 1007c478bd9Sstevel@tonic-gate { $$ = NULL; } 1017c478bd9Sstevel@tonic-gate | stmtlist stmt 1027c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_LIST, $1, $2); } 1037c478bd9Sstevel@tonic-gate ; 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate stmt : error ';' 1067c478bd9Sstevel@tonic-gate { $$ = tree_nothing(); } 1077c478bd9Sstevel@tonic-gate | IF '(' expr ')' stmt 1087c478bd9Sstevel@tonic-gate { $$ = $5; } 1097c478bd9Sstevel@tonic-gate | IF '(' expr ')' '{' stmtlist '}' 1107c478bd9Sstevel@tonic-gate { $$ = $6; } 1117c478bd9Sstevel@tonic-gate | EVENT event nvpairlist ';' 1127c478bd9Sstevel@tonic-gate { $$ = tree_decl(T_EVENT, $2, $3, $1.file, $1.line); } 1137c478bd9Sstevel@tonic-gate | ENGINE event nvpairlist ';' 1147c478bd9Sstevel@tonic-gate { $$ = tree_decl(T_ENGINE, $2, $3, $1.file, $1.line); } 1157c478bd9Sstevel@tonic-gate | PROP propbody ';' 1167c478bd9Sstevel@tonic-gate { 1177c478bd9Sstevel@tonic-gate $$ = tree_stmt(T_PROP, $2, $1.file, $1.line); 1187c478bd9Sstevel@tonic-gate } 1197c478bd9Sstevel@tonic-gate | MASK propbody ';' 1207c478bd9Sstevel@tonic-gate { 1217c478bd9Sstevel@tonic-gate $$ = tree_stmt(T_MASK, $2, $1.file, $1.line); 1227c478bd9Sstevel@tonic-gate } 1237c478bd9Sstevel@tonic-gate | ASRU pname nvpairlist ';' 1247c478bd9Sstevel@tonic-gate { 1257c478bd9Sstevel@tonic-gate $$ = tree_decl(T_ASRU, $2, $3, $1.file, $1.line); 1267c478bd9Sstevel@tonic-gate } 1277c478bd9Sstevel@tonic-gate | FRU pname nvpairlist ';' 1287c478bd9Sstevel@tonic-gate { 1297c478bd9Sstevel@tonic-gate $$ = tree_decl(T_FRU, $2, $3, $1.file, $1.line); 1307c478bd9Sstevel@tonic-gate } 1317c478bd9Sstevel@tonic-gate | CONFIG ipname nvpairlist ';' 1327c478bd9Sstevel@tonic-gate { 1337c478bd9Sstevel@tonic-gate $$ = tree_decl(T_CONFIG, $2, $3, $1.file, $1.line); 1347c478bd9Sstevel@tonic-gate } 1357c478bd9Sstevel@tonic-gate | /*superfluous semicolons are ignored*/ ';' 1367c478bd9Sstevel@tonic-gate { $$ = tree_nothing(); } 1377c478bd9Sstevel@tonic-gate ; 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate propbody: eventlist nork ARROW nork eventlist 1407c478bd9Sstevel@tonic-gate { 1417c478bd9Sstevel@tonic-gate $$ = tree_arrow($1, $2, $4, $5); 1427c478bd9Sstevel@tonic-gate } 1437c478bd9Sstevel@tonic-gate | propbody nork ARROW nork eventlist 1447c478bd9Sstevel@tonic-gate { 1457c478bd9Sstevel@tonic-gate $$ = tree_arrow($1, $2, $4, $5); 1467c478bd9Sstevel@tonic-gate } 1477c478bd9Sstevel@tonic-gate ; 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate nork : /* empty */ 1507c478bd9Sstevel@tonic-gate { $$ = NULL; } 1517c478bd9Sstevel@tonic-gate | '(' norkexpr ')' 1527c478bd9Sstevel@tonic-gate { $$ = $2; } 1537c478bd9Sstevel@tonic-gate ; 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate norkexpr: NUMBER 1567c478bd9Sstevel@tonic-gate { $$ = tree_num($1.s, $1.file, $1.line); } 1577c478bd9Sstevel@tonic-gate | ID 1587c478bd9Sstevel@tonic-gate /* really can only be 'A', enforced by check_arrow() later */ 1597c478bd9Sstevel@tonic-gate { $$ = tree_name($1.s, IT_NONE, $1.file, $1.line); } 1607c478bd9Sstevel@tonic-gate | '(' norkexpr ')' 1617c478bd9Sstevel@tonic-gate { $$ = $2; } 1627c478bd9Sstevel@tonic-gate | norkexpr '-' norkexpr 1637c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_SUB, $1, $3); } 1647c478bd9Sstevel@tonic-gate | norkexpr '+' norkexpr 1657c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_ADD, $1, $3); } 1667c478bd9Sstevel@tonic-gate | norkexpr '*' norkexpr 1677c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_MUL, $1, $3); } 1687c478bd9Sstevel@tonic-gate | norkexpr DIV norkexpr 1697c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_DIV, $1, $3); } 1707c478bd9Sstevel@tonic-gate | norkexpr '%' norkexpr 1717c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_MOD, $1, $3); } 1727c478bd9Sstevel@tonic-gate ; 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate nvpairlist: /* empty */ 1757c478bd9Sstevel@tonic-gate { $$ = NULL; } 1767c478bd9Sstevel@tonic-gate | nvpair 1777c478bd9Sstevel@tonic-gate | nvpairlist ',' nvpair 1787c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_LIST, $1, $3); } 1797c478bd9Sstevel@tonic-gate ; 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate nvpair : nvname '=' nvexpr 1827c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_NVPAIR, $1, $3); } 1837c478bd9Sstevel@tonic-gate | ENGINE '=' nvexpr 1847c478bd9Sstevel@tonic-gate /* "engine" is a reserved word, but a valid property name */ 1857c478bd9Sstevel@tonic-gate { 1867c478bd9Sstevel@tonic-gate $$ = tree_expr(T_NVPAIR, 1877c478bd9Sstevel@tonic-gate tree_name($1.s, IT_NONE, $1.file, $1.line), $3); 1887c478bd9Sstevel@tonic-gate } 1897aec1d6eScindi | COUNT '=' nvexpr 1907aec1d6eScindi /* "count" is a reserved word, but a valid property name */ 1917aec1d6eScindi { 1927aec1d6eScindi $$ = tree_expr(T_NVPAIR, 1937aec1d6eScindi tree_name($1.s, IT_NONE, $1.file, $1.line), $3); 1947aec1d6eScindi } 1957c478bd9Sstevel@tonic-gate ; 1967c478bd9Sstevel@tonic-gate 1977c478bd9Sstevel@tonic-gate nvname : ID 1987c478bd9Sstevel@tonic-gate { $$ = tree_name($1.s, IT_NONE, $1.file, $1.line); } 1997c478bd9Sstevel@tonic-gate | nvname '-' ID 2007c478bd9Sstevel@tonic-gate { 2017c478bd9Sstevel@tonic-gate /* hack to allow dashes in property names */ 2027c478bd9Sstevel@tonic-gate $$ = tree_name_repairdash($1, $3.s); 2037c478bd9Sstevel@tonic-gate } 2047c478bd9Sstevel@tonic-gate ; 2057c478bd9Sstevel@tonic-gate 2067c478bd9Sstevel@tonic-gate /* the RHS of an nvpair can be a value, or an ename, or an ename@pname */ 2077c478bd9Sstevel@tonic-gate nvexpr : numexpr 2087c478bd9Sstevel@tonic-gate | ename epname 2097c478bd9Sstevel@tonic-gate { $$ = tree_event($1, $2, NULL); } 2107c478bd9Sstevel@tonic-gate | pname 2117aec1d6eScindi | globid 2127aec1d6eScindi | func 2137c478bd9Sstevel@tonic-gate | NUMBER ID 2147c478bd9Sstevel@tonic-gate /* 2157c478bd9Sstevel@tonic-gate * ID must be timevals only ("ms", "us", etc.). 2167c478bd9Sstevel@tonic-gate * enforced by tree_timeval(). 2177c478bd9Sstevel@tonic-gate */ 2187c478bd9Sstevel@tonic-gate { $$ = tree_timeval($1.s, $2.s, $1.file, $1.line); } 2197c478bd9Sstevel@tonic-gate | QUOTE 2207c478bd9Sstevel@tonic-gate { $$ = tree_quote($1.s, $1.file, $1.line); } 2217c478bd9Sstevel@tonic-gate ; 2227c478bd9Sstevel@tonic-gate 2237c478bd9Sstevel@tonic-gate /* arithmetic operations, no variables or symbols */ 2247c478bd9Sstevel@tonic-gate numexpr : numexpr '-' numexpr 2257c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_SUB, $1, $3); } 2267c478bd9Sstevel@tonic-gate | numexpr '+' numexpr 2277c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_ADD, $1, $3); } 2287c478bd9Sstevel@tonic-gate | numexpr '*' numexpr 2297c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_MUL, $1, $3); } 2307c478bd9Sstevel@tonic-gate | numexpr DIV numexpr 2317c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_DIV, $1, $3); } 2327c478bd9Sstevel@tonic-gate | numexpr '/' numexpr 2337c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_DIV, $1, $3); } 2347c478bd9Sstevel@tonic-gate | numexpr '%' numexpr 2357c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_MOD, $1, $3); } 2367c478bd9Sstevel@tonic-gate | '(' numexpr ')' 2377c478bd9Sstevel@tonic-gate { $$ = $2; } 2387c478bd9Sstevel@tonic-gate | NUMBER 2397c478bd9Sstevel@tonic-gate { $$ = tree_num($1.s, $1.file, $1.line); } 2407c478bd9Sstevel@tonic-gate ; 2417c478bd9Sstevel@tonic-gate 2427c478bd9Sstevel@tonic-gate eventlist: event 2437c478bd9Sstevel@tonic-gate | eventlist ',' event 2447c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_LIST, $1, $3); } 2457c478bd9Sstevel@tonic-gate ; 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate event : ename epname eexprlist 2487c478bd9Sstevel@tonic-gate { $$ = tree_event($1, $2, $3); } 2497c478bd9Sstevel@tonic-gate ; 2507c478bd9Sstevel@tonic-gate 2517c478bd9Sstevel@tonic-gate epname : /* empty */ 2527c478bd9Sstevel@tonic-gate { $$ = NULL; } 2537c478bd9Sstevel@tonic-gate | '@' pname 2547c478bd9Sstevel@tonic-gate { $$ = $2; } 2557c478bd9Sstevel@tonic-gate ; 2567c478bd9Sstevel@tonic-gate 2577c478bd9Sstevel@tonic-gate eexprlist: /* empty */ 2587c478bd9Sstevel@tonic-gate { $$ = NULL; } 2597c478bd9Sstevel@tonic-gate | '{' exprlist '}' 2607c478bd9Sstevel@tonic-gate { $$ = $2; } 2617c478bd9Sstevel@tonic-gate ; 2627c478bd9Sstevel@tonic-gate 2637c478bd9Sstevel@tonic-gate exprlist: expr 2647c478bd9Sstevel@tonic-gate | exprlist ',' expr 2657c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_LIST, $1, $3); } 2667c478bd9Sstevel@tonic-gate ; 2677c478bd9Sstevel@tonic-gate 2687c478bd9Sstevel@tonic-gate /* 2697c478bd9Sstevel@tonic-gate * note that expr does not include pname, to avoid reduce/reduce 2707c478bd9Sstevel@tonic-gate * conflicts between cexpr and iterid involving the use of ID 2717c478bd9Sstevel@tonic-gate */ 2727c478bd9Sstevel@tonic-gate expr : cexpr 2737c478bd9Sstevel@tonic-gate | NUMBER ID 2747c478bd9Sstevel@tonic-gate /* 2757c478bd9Sstevel@tonic-gate * ID must be timevals only ("ms", "us", etc.). 2767c478bd9Sstevel@tonic-gate * enforced by tree_timeval(). 2777c478bd9Sstevel@tonic-gate */ 2787c478bd9Sstevel@tonic-gate { $$ = tree_timeval($1.s, $2.s, $1.file, $1.line); } 2797c478bd9Sstevel@tonic-gate ; 2807c478bd9Sstevel@tonic-gate 2817c478bd9Sstevel@tonic-gate cexpr : cexpr '=' cexpr 2827c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_ASSIGN, $1, $3); } 2837c478bd9Sstevel@tonic-gate | cexpr '?' cexpr 2847c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_CONDIF, $1, $3); } 2857c478bd9Sstevel@tonic-gate | cexpr ':' cexpr 2867c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_CONDELSE, $1, $3); } 2877c478bd9Sstevel@tonic-gate | cexpr OR cexpr 2887c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_OR, $1, $3); } 2897c478bd9Sstevel@tonic-gate | cexpr AND cexpr 2907c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_AND, $1, $3); } 2917c478bd9Sstevel@tonic-gate | cexpr '|' cexpr 2927c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_BITOR, $1, $3); } 2937c478bd9Sstevel@tonic-gate | cexpr '^' cexpr 2947c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_BITXOR, $1, $3); } 2957c478bd9Sstevel@tonic-gate | cexpr '&' cexpr 2967c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_BITAND, $1, $3); } 2977c478bd9Sstevel@tonic-gate | cexpr EQ cexpr 2987c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_EQ, $1, $3); } 2997c478bd9Sstevel@tonic-gate | cexpr NE cexpr 3007c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_NE, $1, $3); } 3017c478bd9Sstevel@tonic-gate | cexpr '<' cexpr 3027c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_LT, $1, $3); } 3037c478bd9Sstevel@tonic-gate | cexpr LE cexpr 3047c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_LE, $1, $3); } 3057c478bd9Sstevel@tonic-gate | cexpr '>' cexpr 3067c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_GT, $1, $3); } 3077c478bd9Sstevel@tonic-gate | cexpr GE cexpr 3087c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_GE, $1, $3); } 3097c478bd9Sstevel@tonic-gate | cexpr LSHIFT cexpr 3107c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_LSHIFT, $1, $3); } 3117c478bd9Sstevel@tonic-gate | cexpr RSHIFT cexpr 3127c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_RSHIFT, $1, $3); } 3137c478bd9Sstevel@tonic-gate | cexpr '-' cexpr 3147c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_SUB, $1, $3); } 3157c478bd9Sstevel@tonic-gate | cexpr '+' cexpr 3167c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_ADD, $1, $3); } 3177c478bd9Sstevel@tonic-gate | cexpr '*' cexpr 3187c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_MUL, $1, $3); } 3197c478bd9Sstevel@tonic-gate | cexpr DIV cexpr 3207c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_DIV, $1, $3); } 3217c478bd9Sstevel@tonic-gate | cexpr '/' cexpr 3227c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_DIV, $1, $3); } 3237c478bd9Sstevel@tonic-gate | cexpr '%' cexpr 3247c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_MOD, $1, $3); } 3257c478bd9Sstevel@tonic-gate | '!' cexpr 3267c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_NOT, $2, NULL); } 3277c478bd9Sstevel@tonic-gate | '~' cexpr 3287c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_BITNOT, $2, NULL); } 3297c478bd9Sstevel@tonic-gate | '(' cexpr ')' 3307c478bd9Sstevel@tonic-gate { $$ = $2; } 3317c478bd9Sstevel@tonic-gate | func 3327c478bd9Sstevel@tonic-gate | NUMBER 3337c478bd9Sstevel@tonic-gate { $$ = tree_num($1.s, $1.file, $1.line); } 3347c478bd9Sstevel@tonic-gate | ID 3357c478bd9Sstevel@tonic-gate { 3367c478bd9Sstevel@tonic-gate /* iteration variable */ 3377c478bd9Sstevel@tonic-gate $$ = tree_name($1.s, IT_NONE, $1.file, $1.line); 3387c478bd9Sstevel@tonic-gate } 3397c478bd9Sstevel@tonic-gate | globid 3407c478bd9Sstevel@tonic-gate | QUOTE 3417c478bd9Sstevel@tonic-gate { $$ = tree_quote($1.s, $1.file, $1.line); } 3427c478bd9Sstevel@tonic-gate ; 3437c478bd9Sstevel@tonic-gate 3447c478bd9Sstevel@tonic-gate func : ID '(' ')' 3457c478bd9Sstevel@tonic-gate { $$ = tree_func($1.s, NULL, $1.file, $1.line); } 3467c478bd9Sstevel@tonic-gate | ID '(' exprlist ')' 3477c478bd9Sstevel@tonic-gate { $$ = tree_func($1.s, $3, $1.file, $1.line); } 3487c478bd9Sstevel@tonic-gate | PATHFUNC '(' parglist ')' 3497c478bd9Sstevel@tonic-gate { $$ = tree_func($1.s, $3, $1.file, $1.line); } 3507c478bd9Sstevel@tonic-gate | pfunc 3517c478bd9Sstevel@tonic-gate ; 3527c478bd9Sstevel@tonic-gate 3537c478bd9Sstevel@tonic-gate parglist: parg 3547c478bd9Sstevel@tonic-gate | parglist ',' parg 3557c478bd9Sstevel@tonic-gate { $$ = tree_expr(T_LIST, $1, $3); } 3567c478bd9Sstevel@tonic-gate ; 3577c478bd9Sstevel@tonic-gate 3587c478bd9Sstevel@tonic-gate parg : pfunc 3597c478bd9Sstevel@tonic-gate | pname 3607c478bd9Sstevel@tonic-gate { $$ = tree_pname($1); } 3617c478bd9Sstevel@tonic-gate | QUOTE 3627c478bd9Sstevel@tonic-gate { $$ = tree_quote($1.s, $1.file, $1.line); } 363*b0daa853SStephen Hanson | ID '(' exprlist ')' 364*b0daa853SStephen Hanson { $$ = tree_func($1.s, $3, $1.file, $1.line); } 3657c478bd9Sstevel@tonic-gate ; 3667c478bd9Sstevel@tonic-gate 3677aec1d6eScindi /* 3687aec1d6eScindi * these functions are in the grammar so we can force the arg to be 3697aec1d6eScindi * a path or an event. they show up as functions in the parse tree. 3707aec1d6eScindi */ 3717c478bd9Sstevel@tonic-gate pfunc : ASRU '(' pname ')' 3727c478bd9Sstevel@tonic-gate { $$ = tree_func($1.s, tree_pname($3), $1.file, $1.line); } 3737c478bd9Sstevel@tonic-gate | FRU '(' pname ')' 3747c478bd9Sstevel@tonic-gate { $$ = tree_func($1.s, tree_pname($3), $1.file, $1.line); } 3757aec1d6eScindi | COUNT '(' event ')' 3767aec1d6eScindi { $$ = tree_func($1.s, $3, $1.file, $1.line); } 3777c478bd9Sstevel@tonic-gate ; 3787c478bd9Sstevel@tonic-gate 3797c478bd9Sstevel@tonic-gate globid : '$' ID 3807c478bd9Sstevel@tonic-gate { $$ = tree_globid($2.s, $2.file, $2.line); } 3817c478bd9Sstevel@tonic-gate ; 3827c478bd9Sstevel@tonic-gate 3837c478bd9Sstevel@tonic-gate iterid : ID 3847c478bd9Sstevel@tonic-gate { $$ = tree_name($1.s, IT_VERTICAL, $1.file, $1.line); } 3857c478bd9Sstevel@tonic-gate | ID '[' ']' 3867c478bd9Sstevel@tonic-gate { $$ = tree_name($1.s, IT_VERTICAL, $1.file, $1.line); } 3877c478bd9Sstevel@tonic-gate | ID '[' cexpr ']' 3887c478bd9Sstevel@tonic-gate { 3897c478bd9Sstevel@tonic-gate $$ = tree_name_iterator( 3907c478bd9Sstevel@tonic-gate tree_name($1.s, IT_VERTICAL, $1.file, $1.line), $3); 3917c478bd9Sstevel@tonic-gate } 3927c478bd9Sstevel@tonic-gate | ID '<' '>' 3937c478bd9Sstevel@tonic-gate { $$ = tree_name($1.s, IT_HORIZONTAL, $1.file, $1.line); } 3947c478bd9Sstevel@tonic-gate | ID '<' ID '>' 3957c478bd9Sstevel@tonic-gate { 3967c478bd9Sstevel@tonic-gate $$ = tree_name_iterator( 3977c478bd9Sstevel@tonic-gate tree_name($1.s, IT_HORIZONTAL, $1.file, $1.line), 3987c478bd9Sstevel@tonic-gate tree_name($3.s, IT_NONE, $3.file, $3.line)); 3997c478bd9Sstevel@tonic-gate } 4008a40a695Sgavinm | ID '-' iterid 4018a40a695Sgavinm { 4028a40a695Sgavinm /* hack to allow dashes in path name components */ 4038a40a695Sgavinm $$ = tree_name_repairdash2($1.s, $3); 4048a40a695Sgavinm } 4057c478bd9Sstevel@tonic-gate ; 4067c478bd9Sstevel@tonic-gate 4077c478bd9Sstevel@tonic-gate /* iname is an ID where we can peel numbers off the end */ 4087c478bd9Sstevel@tonic-gate iname : ID 4097c478bd9Sstevel@tonic-gate { $$ = tree_iname($1.s, $1.file, $1.line); } 4107c478bd9Sstevel@tonic-gate ; 4117c478bd9Sstevel@tonic-gate 4127c478bd9Sstevel@tonic-gate /* base case of ID.ID instead of just ID requires ename to contain one dot */ 4137c478bd9Sstevel@tonic-gate ename : ID '.' enameid 4147c478bd9Sstevel@tonic-gate { 4157c478bd9Sstevel@tonic-gate $$ = tree_name_append( 4167c478bd9Sstevel@tonic-gate tree_name($1.s, IT_ENAME, $1.file, $1.line), 4177c478bd9Sstevel@tonic-gate tree_name($3.s, IT_NONE, $3.file, $3.line)); 4187c478bd9Sstevel@tonic-gate } 4197c478bd9Sstevel@tonic-gate | ename '.' enameid 4207c478bd9Sstevel@tonic-gate { 4217c478bd9Sstevel@tonic-gate $$ = tree_name_append($1, 4227c478bd9Sstevel@tonic-gate tree_name($3.s, IT_NONE, $3.file, $3.line)); 4237c478bd9Sstevel@tonic-gate } 4247c478bd9Sstevel@tonic-gate | ename '-' enameid 4257c478bd9Sstevel@tonic-gate { 4267c478bd9Sstevel@tonic-gate /* 4277c478bd9Sstevel@tonic-gate * hack to allow dashes in class names. when we 4287c478bd9Sstevel@tonic-gate * detect the dash here, we know we're in a class 4297c478bd9Sstevel@tonic-gate * name because the left recursion of this rule 4307c478bd9Sstevel@tonic-gate * means we've already matched at least: 4317c478bd9Sstevel@tonic-gate * ID '.' ID 4327c478bd9Sstevel@tonic-gate * so the ename here has an incomplete final 4337c478bd9Sstevel@tonic-gate * component (because the lexer stopped at the 4347c478bd9Sstevel@tonic-gate * dash). so we repair that final component here. 4357c478bd9Sstevel@tonic-gate */ 4367c478bd9Sstevel@tonic-gate $$ = tree_name_repairdash($1, $3.s); 4377c478bd9Sstevel@tonic-gate } 4387c478bd9Sstevel@tonic-gate ; 4397c478bd9Sstevel@tonic-gate 4407c478bd9Sstevel@tonic-gate /* like an ID, but we let reserved words act unreserved in enames */ 4417c478bd9Sstevel@tonic-gate enameid : ID 4427c478bd9Sstevel@tonic-gate | PROP 4437c478bd9Sstevel@tonic-gate | MASK 4447c478bd9Sstevel@tonic-gate | EVENT 4457c478bd9Sstevel@tonic-gate | ENGINE 4467c478bd9Sstevel@tonic-gate | ASRU 4477c478bd9Sstevel@tonic-gate | FRU 4487c478bd9Sstevel@tonic-gate | CONFIG 4497c478bd9Sstevel@tonic-gate | IF 4507c478bd9Sstevel@tonic-gate ; 4517c478bd9Sstevel@tonic-gate 4527c478bd9Sstevel@tonic-gate /* pname is a pathname, like x/y, x<i>/y[0], etc */ 4537c478bd9Sstevel@tonic-gate pname : iterid 4547c478bd9Sstevel@tonic-gate | pname '/' iterid 4557c478bd9Sstevel@tonic-gate { $$ = tree_name_append($1, $3); } 4567c478bd9Sstevel@tonic-gate ; 4577c478bd9Sstevel@tonic-gate 4587c478bd9Sstevel@tonic-gate /* ipname is an "instanced" pathname, like x0/y1 */ 4597c478bd9Sstevel@tonic-gate ipname : iname 4607c478bd9Sstevel@tonic-gate | ipname '/' iname 4617c478bd9Sstevel@tonic-gate { $$ = tree_name_append($1, $3); } 4627c478bd9Sstevel@tonic-gate ; 4637c478bd9Sstevel@tonic-gate 4647c478bd9Sstevel@tonic-gate %% 465