xref: /illumos-gate/usr/src/cmd/sgs/demo_rdb/common/lex.l (revision d9328cd4)
17c478bd9Sstevel@tonic-gate %{
27c478bd9Sstevel@tonic-gate /*
37c478bd9Sstevel@tonic-gate  * CDDL HEADER START
47c478bd9Sstevel@tonic-gate  *
57c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
620c1c355SRod Evans  * Common Development and Distribution License (the "License").
720c1c355SRod Evans  * You may not use this file except in compliance with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate 
2320c1c355SRod Evans /*
2420c1c355SRod Evans  * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
2520c1c355SRod Evans  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #include <stdlib.h>
287c478bd9Sstevel@tonic-gate #include <string.h>
297c478bd9Sstevel@tonic-gate #include <sys/types.h>
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #include "gram.h"
327c478bd9Sstevel@tonic-gate #include "rdb.h"
337c478bd9Sstevel@tonic-gate %}
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate ws		[ \t]+
367c478bd9Sstevel@tonic-gate nl		\n
377c478bd9Sstevel@tonic-gate symbol		[_a-zA-Z][_a-zA-Z0-9]*
387c478bd9Sstevel@tonic-gate varstring	\$[_a-zA-Z][_a-zA-Z0-9]*	/* $<name> */
397c478bd9Sstevel@tonic-gate hexnumber	0[xX][0-9a-zA-Z]+
407c478bd9Sstevel@tonic-gate decnumber	[0-9]+
417c478bd9Sstevel@tonic-gate qstring		\"[^\"\n]*[\"\n]
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate %%
4420c1c355SRod Evans \#[^\n]*		;	/* ignore comments */
457c478bd9Sstevel@tonic-gate \\\n			;	/* perform line continuation... */
467c478bd9Sstevel@tonic-gate {ws}			;	/* ignore whitespace */
477c478bd9Sstevel@tonic-gate {hexnumber}		{yylval.addr = hexstr_to_num(yytext); return (NUMBER);}
487c478bd9Sstevel@tonic-gate {decnumber}		{yylval.addr = atoi(yytext); return (NUMBER);}
497c478bd9Sstevel@tonic-gate \+			{return (PLUS);}
507c478bd9Sstevel@tonic-gate ^{ws}*break		{return (BREAK);}
517c478bd9Sstevel@tonic-gate ^{ws}*cont		{return (CONT);}
527c478bd9Sstevel@tonic-gate ^{ws}*echo		{return (ECHO_OUT);}
537c478bd9Sstevel@tonic-gate ^{ws}*event		{return (EVENT);}
547c478bd9Sstevel@tonic-gate ^{ws}*delete		{return (DELETE);}
557c478bd9Sstevel@tonic-gate ^{ws}*dis		{return (DIS);}
567c478bd9Sstevel@tonic-gate ^{ws}*getmaps		{return (GETMAPS);}
577c478bd9Sstevel@tonic-gate ^{ws}*help		{return (HELP);}
587c478bd9Sstevel@tonic-gate ^{ws}*linkmaps		{return (LINKMAPS);}
597c478bd9Sstevel@tonic-gate ^{ws}*maps		{return (MAPS);}
607c478bd9Sstevel@tonic-gate ^{ws}*objpad		{return (OBJPAD);}
617c478bd9Sstevel@tonic-gate ^{ws}*pltskip		{return (PLTSKIP);}
627c478bd9Sstevel@tonic-gate ^{ws}*print		{return (PRINT);}
637c478bd9Sstevel@tonic-gate ^{ws}*step		{return (STEP);}
647c478bd9Sstevel@tonic-gate ^{ws}*value		{return (VALUE);}
657c478bd9Sstevel@tonic-gate ^{ws}*where		{return (WHERE);}
667c478bd9Sstevel@tonic-gate {symbol}		{yylval.str = strdup(yytext); return (SYMBOL);}
677c478bd9Sstevel@tonic-gate {varstring}		{
687c478bd9Sstevel@tonic-gate 				yylval.str = strdup(yytext + 1);
697c478bd9Sstevel@tonic-gate 				return (VARSTRING);
707c478bd9Sstevel@tonic-gate 			}
717c478bd9Sstevel@tonic-gate {qstring}		{
727c478bd9Sstevel@tonic-gate 				yylval.str = strdup(yytext + 1);
737c478bd9Sstevel@tonic-gate 				if (yylval.str[yyleng - 2] == '"')
747c478bd9Sstevel@tonic-gate 					yylval.str[yyleng - 2] = '\0';
757c478bd9Sstevel@tonic-gate 				return (QSTRING);
767c478bd9Sstevel@tonic-gate 			}
777c478bd9Sstevel@tonic-gate {nl}			{return (NEWLINE);}
787c478bd9Sstevel@tonic-gate %%
79