scan.l revision 1.1
11.1Such%{ 21.1Such/* $NetBSD: scan.l,v 1.1 2001/01/28 02:52:25 uch 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.1Suchchar *getstr __P((char*)); 451.1Suchvoid getcomment __P((void)); 461.1Such 471.1Such#define yywrap() 1 481.1Such 491.1Such%} 501.1Such 511.1Such%% 521.1Such\"([^"]|\\\")*\" { yylval.str = getstr(yytext); return NAME; } 531.1Such[a-zA-Z][0-9a-zA-Z]* { yylval.str = strdup(yytext); return FSYM; } 541.1Such[a-zA-Z][_0-9a-zA-Z]* { yylval.str = strdup(yytext); return MOD; } 551.1Such[0-9a-zA-Z]+ { yylval.str = strdup(yytext); return SYM; } 561.1Such\n { yyline++; } 571.1Such"/*" { getcomment(); } 581.1Such[ \t]+ { /* ignored */; } 591.1Such. { return yytext[0]; } 601.1Such 611.1Such%% 621.1Such 631.1Suchchar* 641.1Suchgetstr(char*s) 651.1Such{ 661.1Such char *res, *p, *p2; 671.1Such res = strdup(s + 1); 681.1Such for (p = p2 = res; *p != '\"'; p++) { 691.1Such if (*p == '\\') { 701.1Such *p2++ = *++p; 711.1Such } else { 721.1Such *p2++ = *p; 731.1Such } 741.1Such } 751.1Such *p2 = '\0'; 761.1Such return (res); 771.1Such} 781.1Such 791.1Suchvoid 801.1Suchgetcomment() 811.1Such{ 821.1Such int c; 831.1Such 841.1Such for ( ; ; ) { 851.1Such while ( (c = input()) != '*' && c != EOF ) { 861.1Such if (c == '\n') yyline++; 871.1Such } 881.1Such if (c == '\n') yyline++; 891.1Such 901.1Such if ( c == '*' ) { 911.1Such while ( (c = input()) == '*' ) { 921.1Such if (c == '\n') yyline++; 931.1Such } 941.1Such if (c == '\n') yyline++; 951.1Such if ( c == '/' ) 961.1Such break; /* found the end */ 971.1Such } 981.1Such 991.1Such if ( c == EOF ) { 1001.1Such yyerror( "EOF in comment" ); 1011.1Such break; 1021.1Such } 1031.1Such } 1041.1Such} 1051.1Such 1061.1Suchread_def() 1071.1Such{ 1081.1Such yyline = 1; 1091.1Such def_tree = NULL; 1101.1Such return yyparse(); 1111.1Such} 112