%{ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END * * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #include #include #include #include #include #include #include #include #include int yynerrors; const char *yyinname; %} /* * S0 is for normal input processing. SCOMMENT is used to process comments. * We need a separate state for comments to prevent the lex regexp engine from * overflowing its own buffers as it searches for the end of comments. */ %s S0 SCOMMENT RGX_IMM_SEQ -?([0-9]+|0[xX][0-9A-Fa-f]+) RGX_STR_SEQ ([^"\\\n]|\\[^"\n]|\\\")* RGX_IDENT [a-zA-Z][a-zA-Z0-9\-_]* %% "/*" { BEGIN(SCOMMENT); } .|\n ; /* discard */ "*/" { BEGIN(S0); } evdef { return (INJ_TOK_EVDEF); } fmridef { return (INJ_TOK_FMRIDEF); } authdef { return (INJ_TOK_AUTHDEF); } listdef { return (INJ_TOK_LISTDEF); } int8_t { return (INJ_TOK_INT8); } int16_t { return (INJ_TOK_INT16); } int32_t { return (INJ_TOK_INT32); } int64_t { return (INJ_TOK_INT64); } uint8_t { return (INJ_TOK_UINT8); } uint16_t { return (INJ_TOK_UINT16); } uint32_t { return (INJ_TOK_UINT32); } uint64_t { return (INJ_TOK_UINT64); } boolean { return (INJ_TOK_BOOLEAN); } boolean_t { return (INJ_TOK_BOOLEAN); } string { return (INJ_TOK_STRING); } enum { return (INJ_TOK_ENUM); } event { return (INJ_TOK_EVENT); } fmri { return (INJ_TOK_FMRI); } auth { return (INJ_TOK_AUTH); } list { return (INJ_TOK_LIST); } addhrtime { return (INJ_TOK_ADDHRT); } endhrtime { return (INJ_TOK_ENDHRT); } sleep { return (INJ_TOK_SLEEP); } repeat { return (INJ_TOK_REPEAT); } randomize { return (INJ_TOK_RANDOMIZE); } \"{RGX_STR_SEQ}$ { yyerror("syntax error: \" unmatched"); } \"{RGX_STR_SEQ}\" { /* Quoted string */ yylval.l_string = inj_strndup(yytext + 1, yyleng - 2); return (INJ_TOK_QSTRING); } {RGX_IDENT}("."{RGX_IDENT})+ { yylval.l_string = inj_strdup(yytext); return (INJ_TOK_FMACLASS); } {RGX_IDENT} { yylval.l_string = inj_strdup(yytext); return (INJ_TOK_IDENT); } {RGX_IMM_SEQ} { yylval.l_string = inj_strdup(yytext); return (INJ_TOK_IMM); } [ \t\n] ; /* Ignore whitespace */ . { return (yytext[0]); } %% void yyerror(const char *format, ...) { int err = errno; va_list ap; char *s; /* Don't print the line number if the message begins with a space */ if (*format == ' ') { (void) fprintf(stderr, "%s: ", yyinname, yylineno); format++; } else (void) fprintf(stderr, "%s: %d: ", yyinname, yylineno); va_start(ap, format); (void) vfprintf(stderr, format, ap); va_end(ap); if (strchr(format, '\n') == NULL) (void) fprintf(stderr, " near \"%s\"\n", yytext); yynerrors++; errno = err; } int yywrap(void) { return (1); } void yyreset(void) { BEGIN(S0); }