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