5 * The contents of this file are subject to the terms of the
6 * Common Development and Distribution License, Version 1.0 only
7 * (the "License"). You may not use this file except in compliance
10 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 * or http://www.opensolaris.org/os/licensing.
12 * See the License for the specific language governing permissions
13 * and limitations under the License.
15 * When distributing Covered Code, include this CDDL HEADER in each
16 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 * If applicable, add the following below this CDDL HEADER, with the
18 * fields enclosed by brackets "[]" replaced with your own identifying
19 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
36 #include <inj_string.h>
37 #include <inj_event.h>
38 #include <inj_grammar.h>
46 * S0 is for normal input processing. SCOMMENT is used to process comments.
47 * We need a separate state for comments to prevent the lex regexp engine from
48 * overflowing its own buffers as it searches for the end of comments.
52 RGX_IMM_SEQ -?([0-9]+|0[xX][0-9A-Fa-f]+)
53 RGX_STR_SEQ ([^"\\\n]|\\[^"\n]|\\\")*
54 RGX_IDENT [a-zA-Z][a-zA-Z0-9\-_]*
58 <S0>"/*" { BEGIN(SCOMMENT); }
59 <SCOMMENT>.|\n ; /* discard */
60 <SCOMMENT>"*/" { BEGIN(S0); }
62 <S0>evdef { return (INJ_TOK_EVDEF); }
63 <S0>fmridef { return (INJ_TOK_FMRIDEF); }
64 <S0>authdef { return (INJ_TOK_AUTHDEF); }
65 <S0>listdef { return (INJ_TOK_LISTDEF); }
67 <S0>int8_t { return (INJ_TOK_INT8); }
68 <S0>int16_t { return (INJ_TOK_INT16); }
69 <S0>int32_t { return (INJ_TOK_INT32); }
70 <S0>int64_t { return (INJ_TOK_INT64); }
71 <S0>uint8_t { return (INJ_TOK_UINT8); }
72 <S0>uint16_t { return (INJ_TOK_UINT16); }
73 <S0>uint32_t { return (INJ_TOK_UINT32); }
74 <S0>uint64_t { return (INJ_TOK_UINT64); }
75 <S0>boolean { return (INJ_TOK_BOOLEAN); }
76 <S0>boolean_t { return (INJ_TOK_BOOLEAN); }
77 <S0>string { return (INJ_TOK_STRING); }
78 <S0>enum { return (INJ_TOK_ENUM); }
80 <S0>event { return (INJ_TOK_EVENT); }
81 <S0>fmri { return (INJ_TOK_FMRI); }
82 <S0>auth { return (INJ_TOK_AUTH); }
83 <S0>list { return (INJ_TOK_LIST); }
85 <S0>addhrtime { return (INJ_TOK_ADDHRT); }
86 <S0>endhrtime { return (INJ_TOK_ENDHRT); }
87 <S0>sleep { return (INJ_TOK_SLEEP); }
88 <S0>repeat { return (INJ_TOK_REPEAT); }
89 <S0>randomize { return (INJ_TOK_RANDOMIZE); }
91 <S0>\"{RGX_STR_SEQ}$ { yyerror("syntax error: \" unmatched"); }
93 <S0>\"{RGX_STR_SEQ}\" {
95 yylval.l_string = inj_strndup(yytext + 1, yyleng - 2);
96 return (INJ_TOK_QSTRING);
99 <S0>{RGX_IDENT}("."{RGX_IDENT})+ {
100 yylval.l_string = inj_strdup(yytext);
101 return (INJ_TOK_FMACLASS);
105 yylval.l_string = inj_strdup(yytext);
106 return (INJ_TOK_IDENT);
110 yylval.l_string = inj_strdup(yytext);
111 return (INJ_TOK_IMM);
114 <S0>[ \t\n] ; /* Ignore whitespace */
116 . { return (yytext[0]); }
121 yyerror(const char *format, ...)
127 /* Don't print the line number if the message begins with a space */
128 if (*format == ' ') {
129 (void) fprintf(stderr, "%s: ", yyinname, yylineno);
132 (void) fprintf(stderr, "%s: %d: ", yyinname, yylineno);
134 va_start(ap, format);
135 (void) vfprintf(stderr, format, ap);
138 if (strchr(format, '\n') == NULL)
139 (void) fprintf(stderr, " near \"%s\"\n", yytext);