19 %type <n> expr optexpr
29 %token TU8 TU16 TU32 TU64
30 %token TS8 TS16 TS32 TS64
49 program: | program clause
51 clause: { clausebegin(); } probes optpredicate optaction { clauseend(); }
53 optpredicate: | TIF expr { addpred(codegen(exprcheck($2, 1))); }
58 addarg(node(OSYM, getsym("probe")));
62 stats: | stats0 | stats0 ';'
63 stats0: stat | stats0 ';' stat
65 stat: expr { addstat(STATEXPR, exprcheck($1, 0)); }
66 | TPRINT { addstat(STATPRINT); } pelist
67 | TPRINTF { addstat(STATPRINTF); } pelist
68 | '@' optsym '[' expr ']' '=' TSYM '(' optexpr ')' { addstat(STATAGG, $2, $4, $7, $9); }
69 optsym: TSYM | { $$ = nil; }
70 optexpr: expr | { $$ = nil; }
75 | '(' elist2 optcomma ')'
78 elist2: arg ',' arg | elist2 ',' arg
79 arg: expr { addarg(exprcheck($1, 0)); }
83 TSYM { $$ = node(OSYM, $1); }
84 | TNUM { $$ = node(ONUM, $1); }
85 | TSTR { $$ = node(OSTR, $1); }
86 | expr '+' expr { $$ = node(OBIN, OPADD, $1, $3); }
87 | expr '-' expr { $$ = node(OBIN, OPSUB, $1, $3); }
88 | expr '*' expr { $$ = node(OBIN, OPMUL, $1, $3); }
89 | expr '/' expr { $$ = node(OBIN, OPDIV, $1, $3); }
90 | expr '%' expr { $$ = node(OBIN, OPMOD, $1, $3); }
91 | expr '&' expr { $$ = node(OBIN, OPAND, $1, $3); }
92 | expr '|' expr { $$ = node(OBIN, OPOR, $1, $3); }
93 | expr '^' expr { $$ = node(OBIN, OPXOR, $1, $3); }
94 | expr TLSL expr { $$ = node(OBIN, OPLSH, $1, $3); }
95 | expr TLSR expr { $$ = node(OBIN, OPRSH, $1, $3); }
96 | expr TEQ expr { $$ = node(OBIN, OPEQ, $1, $3); }
97 | expr TNE expr { $$ = node(OBIN, OPNE, $1, $3); }
98 | expr '<' expr { $$ = node(OBIN, OPLT, $1, $3); }
99 | expr TLE expr { $$ = node(OBIN, OPLE, $1, $3); }
100 | expr '>' expr { $$ = node(OBIN, OPLT, $3, $1); }
101 | expr TGE expr { $$ = node(OBIN, OPLE, $3, $1); }
102 | expr TAND expr { $$ = node(OBIN, OPLAND, $1, $3); }
103 | expr TOR expr { $$ = node(OBIN, OPLOR, $1, $3); }
104 | '-' expr %prec unary { $$ = node(OBIN, OPSUB, node(ONUM, 0LL), $2); }
105 | '~' expr %prec unary { $$ = node(OBIN, OPXNOR, node(ONUM, 0LL), $2); }
106 | '!' expr %prec unary { $$ = node(OLNOT, $2); }
107 | '(' expr ')' { $$ = $2; }
108 | expr '?' expr ':' expr %prec '?' { $$ = node(OTERN, $1, $3, $5); }
109 | '(' type ')' expr %prec castprec { $$ = node(OCAST, $2, $4); }
112 TU8 { $$ = type(TYPINT, 1, 0); }
113 | TS8 { $$ = type(TYPINT, 1, 1); }
114 | TU16 { $$ = type(TYPINT, 2, 0); }
115 | TS16 { $$ = type(TYPINT, 2, 1); }
116 | TU32 { $$ = type(TYPINT, 4, 0); }
117 | TS32 { $$ = type(TYPINT, 4, 1); }
118 | TU64 { $$ = type(TYPINT, 8, 0); }
119 | TS64 { $$ = type(TYPINT, 8, 1); }
120 | TSTRING { $$ = type(TYPSTRING); }
123 probe { addprobe($1); }
124 | probes ',' probe { addprobe($3); }
127 TSYM { $$ = $1->name; }