11.1Such%{
21.6Snonaka/*	$NetBSD: scan.l,v 1.6 2011/09/23 14:14:38 nonaka Exp $	*/
31.1Such
41.1Such/*-
51.1Such * Copyright (c) 1999
61.1Such *         Shin Takemura and PocketBSD Project. All rights reserved.
71.1Such *
81.1Such * Redistribution and use in source and binary forms, with or without
91.1Such * modification, are permitted provided that the following conditions
101.1Such * are met:
111.1Such * 1. Redistributions of source code must retain the above copyright
121.1Such *    notice, this list of conditions and the following disclaimer.
131.1Such * 2. Redistributions in binary form must reproduce the above copyright
141.1Such *    notice, this list of conditions and the following disclaimer in the
151.1Such *    documentation and/or other materials provided with the distribution.
161.1Such * 3. All advertising materials mentioning features or use of this software
171.1Such *    must display the following acknowledgement:
181.1Such *	This product includes software developed by the PocketBSD project
191.1Such *	and its contributors.
201.1Such * 4. Neither the name of the project nor the names of its contributors
211.1Such *    may be used to endorse or promote products derived from this software
221.1Such *    without specific prior written permission.
231.1Such *
241.1Such * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
251.1Such * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
261.1Such * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
271.1Such * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
281.1Such * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
291.1Such * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
301.1Such * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
311.1Such * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
321.1Such * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
331.1Such * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
341.1Such * SUCH DAMAGE.
351.1Such *
361.1Such */
371.1Such
381.1Such#include <strings.h>
391.1Such#include "gram.h"
401.1Such
411.1Such#include "platid_gen.h"
421.1Such
431.1Suchint	yyline;
441.4Speterchar	*getstr(char *);
451.4Spetervoid	getcomment(void);
461.6Snonakaint	yyparse(void);
471.6Snonakavoid	yyerror(const char *);
481.5Snonaka%}
491.1Such
501.5Snonaka%option	noyywrap
511.1Such
521.1Such%%
531.3Stakemura#[^\n]*\n		{ yylval.str = strdup(yytext); yyline++; return DIRECTIVE; }
541.1Such\"([^"]|\\\")*\"	{ yylval.str = getstr(yytext); return NAME; }
551.1Such[a-zA-Z][0-9a-zA-Z]*	{ yylval.str = strdup(yytext); return FSYM; }
561.1Such[a-zA-Z][_0-9a-zA-Z]*	{ yylval.str = strdup(yytext); return MOD; }
571.1Such[0-9a-zA-Z]+	{ yylval.str = strdup(yytext); return SYM; }
581.1Such\n		{ yyline++; }
591.1Such"/*"		{ getcomment(); }
601.1Such[ \t]+		{ /* ignored */; }
611.1Such.		{ return yytext[0]; }
621.1Such
631.1Such%%
641.1Such
651.1Suchchar*
661.1Suchgetstr(char*s)
671.1Such{
681.1Such	char *res, *p, *p2;
691.1Such	res = strdup(s + 1);
701.1Such	for (p = p2 = res; *p != '\"'; p++) {
711.1Such		if (*p == '\\') {
721.1Such			*p2++ = *++p;
731.1Such		} else {
741.1Such			*p2++ = *p;
751.1Such		}
761.1Such	}
771.1Such	*p2 = '\0';
781.1Such	return (res);
791.1Such}
801.1Such
811.1Suchvoid
821.1Suchgetcomment()
831.1Such{
841.1Such	int c;
851.1Such
861.1Such	for ( ; ; ) {
871.1Such		while ( (c = input()) != '*' && c != EOF ) {
881.1Such			if (c == '\n') yyline++;
891.1Such		}
901.1Such		if (c == '\n') yyline++;
911.1Such
921.1Such		if ( c == '*' ) {
931.1Such			while ( (c = input()) == '*' ) {
941.1Such				if (c == '\n') yyline++;
951.1Such			}
961.1Such			if (c == '\n') yyline++;
971.1Such			if ( c == '/' )
981.1Such				break;    /* found the end */
991.1Such		}
1001.1Such
1011.1Such		if ( c == EOF ) {
1021.1Such			yyerror( "EOF in comment" );
1031.1Such			break;
1041.1Such		}
1051.1Such	}
1061.1Such}
1071.1Such
1081.6Snonakaint
1091.1Suchread_def()
1101.1Such{
1111.1Such	yyline = 1;
1121.1Such	def_tree = NULL;
1131.1Such	return yyparse();
1141.1Such}
115