xref: /onnv-gate/usr/src/cmd/sgs/librtld_db/demo/common/lex.l (revision 12927:a27c46eb192b)
1*12927SRod.Evans@Sun.COM %{
2*12927SRod.Evans@Sun.COM /*
3*12927SRod.Evans@Sun.COM  * CDDL HEADER START
4*12927SRod.Evans@Sun.COM  *
5*12927SRod.Evans@Sun.COM  * The contents of this file are subject to the terms of the
6*12927SRod.Evans@Sun.COM  * Common Development and Distribution License (the "License").
7*12927SRod.Evans@Sun.COM  * You may not use this file except in compliance with the License.
8*12927SRod.Evans@Sun.COM  *
9*12927SRod.Evans@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*12927SRod.Evans@Sun.COM  * or http://www.opensolaris.org/os/licensing.
11*12927SRod.Evans@Sun.COM  * See the License for the specific language governing permissions
12*12927SRod.Evans@Sun.COM  * and limitations under the License.
13*12927SRod.Evans@Sun.COM  *
14*12927SRod.Evans@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
15*12927SRod.Evans@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*12927SRod.Evans@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
17*12927SRod.Evans@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
18*12927SRod.Evans@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
19*12927SRod.Evans@Sun.COM  *
20*12927SRod.Evans@Sun.COM  * CDDL HEADER END
21*12927SRod.Evans@Sun.COM  */
22*12927SRod.Evans@Sun.COM 
23*12927SRod.Evans@Sun.COM /*
24*12927SRod.Evans@Sun.COM  * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
25*12927SRod.Evans@Sun.COM  */
26*12927SRod.Evans@Sun.COM 
27*12927SRod.Evans@Sun.COM #include <stdlib.h>
28*12927SRod.Evans@Sun.COM #include <string.h>
29*12927SRod.Evans@Sun.COM #include <sys/types.h>
30*12927SRod.Evans@Sun.COM 
31*12927SRod.Evans@Sun.COM #include "gram.h"
32*12927SRod.Evans@Sun.COM #include "rdb.h"
33*12927SRod.Evans@Sun.COM %}
34*12927SRod.Evans@Sun.COM 
35*12927SRod.Evans@Sun.COM ws		[ \t]+
36*12927SRod.Evans@Sun.COM nl		\n
37*12927SRod.Evans@Sun.COM symbol		[_a-zA-Z][_a-zA-Z0-9]*
38*12927SRod.Evans@Sun.COM varstring	\$[_a-zA-Z][_a-zA-Z0-9]*	/* $<name> */
39*12927SRod.Evans@Sun.COM hexnumber	0[xX][0-9a-zA-Z]+
40*12927SRod.Evans@Sun.COM decnumber	[0-9]+
41*12927SRod.Evans@Sun.COM qstring		\"[^\"\n]*[\"\n]
42*12927SRod.Evans@Sun.COM 
43*12927SRod.Evans@Sun.COM %%
44*12927SRod.Evans@Sun.COM \#[^\n]*		;	/* ignore comments */
45*12927SRod.Evans@Sun.COM \\\n			;	/* perform line continuation... */
46*12927SRod.Evans@Sun.COM {ws}			;	/* ignore whitespace */
47*12927SRod.Evans@Sun.COM {hexnumber}		{yylval.addr = hexstr_to_num(yytext); return (NUMBER);}
48*12927SRod.Evans@Sun.COM {decnumber}		{yylval.addr = atoi(yytext); return (NUMBER);}
49*12927SRod.Evans@Sun.COM \+			{return (PLUS);}
50*12927SRod.Evans@Sun.COM ^{ws}*break		{return (BREAK);}
51*12927SRod.Evans@Sun.COM ^{ws}*cont		{return (CONT);}
52*12927SRod.Evans@Sun.COM ^{ws}*echo		{return (ECHO_OUT);}
53*12927SRod.Evans@Sun.COM ^{ws}*event		{return (EVENT);}
54*12927SRod.Evans@Sun.COM ^{ws}*delete		{return (DELETE);}
55*12927SRod.Evans@Sun.COM ^{ws}*dis		{return (DIS);}
56*12927SRod.Evans@Sun.COM ^{ws}*getmaps		{return (GETMAPS);}
57*12927SRod.Evans@Sun.COM ^{ws}*help		{return (HELP);}
58*12927SRod.Evans@Sun.COM ^{ws}*linkmaps		{return (LINKMAPS);}
59*12927SRod.Evans@Sun.COM ^{ws}*maps		{return (MAPS);}
60*12927SRod.Evans@Sun.COM ^{ws}*objpad		{return (OBJPAD);}
61*12927SRod.Evans@Sun.COM ^{ws}*pltskip		{return (PLTSKIP);}
62*12927SRod.Evans@Sun.COM ^{ws}*print		{return (PRINT);}
63*12927SRod.Evans@Sun.COM ^{ws}*step		{return (STEP);}
64*12927SRod.Evans@Sun.COM ^{ws}*value		{return (VALUE);}
65*12927SRod.Evans@Sun.COM ^{ws}*where		{return (WHERE);}
66*12927SRod.Evans@Sun.COM {symbol}		{yylval.str = strdup(yytext); return (SYMBOL);}
67*12927SRod.Evans@Sun.COM {varstring}		{
68*12927SRod.Evans@Sun.COM 				yylval.str = strdup(yytext + 1);
69*12927SRod.Evans@Sun.COM 				return (VARSTRING);
70*12927SRod.Evans@Sun.COM 			}
71*12927SRod.Evans@Sun.COM {qstring}		{
72*12927SRod.Evans@Sun.COM 				yylval.str = strdup(yytext + 1);
73*12927SRod.Evans@Sun.COM 				if (yylval.str[yyleng - 2] == '"')
74*12927SRod.Evans@Sun.COM 					yylval.str[yyleng - 2] = '\0';
75*12927SRod.Evans@Sun.COM 				return (QSTRING);
76*12927SRod.Evans@Sun.COM 			}
77*12927SRod.Evans@Sun.COM {nl}			{return (NEWLINE);}
78*12927SRod.Evans@Sun.COM %%
79