* $Id: fsi_lex.l,v 5.2.1.2 90/12/21 16:41:55 jsp Alpha $
* Copyright (c) 1989 Jan-Simon Pendry
* Copyright (c) 1989 Imperial College of Science, Technology & Medicine
* Copyright (c) 1989 The Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* Jan-Simon Pendry at Imperial College, London.
* Redistribution and use in source and binary forms are permitted provided
* that: (1) source distributions retain this entire copyright notice and
* comment, and (2) distributions including binaries display the following
* acknowledgement: ``This product includes software developed by the
* University of California, Berkeley and its contributors'' in the
* documentation or other materials provided with the distribution and in
* all advertising materials mentioning features or use of this software.
* Neither the name of the University nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
* @(#)fsi_lex.l 5.1 (Berkeley) %G%
* Lexical analyzer for fsinfo.
/* Flex support with help from Vern Paxson <vern@helios.ee.lbl.gov> */
#define YY_INPUT(buf,result,max_size) \
for (i = 0; i < max_size; i++) { \
int ch = xinput(i == 0); \
switch ((yy_start - 1) / 2) { \
#define unput(ch) xunput(ch)
#define input() xinput(1)
switch (yybgin - yysvec - 1) { \
#endif /* FLEX_SCANNER */
#include "../fsinfo/fsinfo.h"
static unsigned char ibuf[64];
static unsigned char *iptr = ibuf;
static int lastch, nextch = '\n';
{ "automount", tAUTOMOUNT },
{ "exportfs", tEXPORTFS },
{ "localhost", tLOCALHOST },
#define NRES_WORDS (sizeof(rr)/sizeof(rr[0])-1)
INIT_STATE; /* witchcraft */
<F>[^ \t\n"={}]+ { return find_resword(yytext); }
<F>[={}] { return *yytext; }
<F>\" { BEGIN Q; optr = ostr; quoted = 1; }
<Q>\n { yylineno++; yyerror("\" expected"); BEGIN F; }
<Q>\\b { *optr++ = '\b'; /* escape */ }
<Q>\\t { *optr++ = '\t'; /* escape */ }
<Q>\\\" { *optr++ = '\"'; /* escape */ }
<Q>\\\\ { *optr++ = '\\'; /* escape */ }
<Q>\\\n { yylineno++; /* continue */ }
<Q>\\r { *optr++ = '\r'; /* escape */ }
<Q>\\n { *optr++ = '\n'; /* escape */ }
<Q>\\f { *optr++ = '\f'; /* escape */ }
<Q>\\. { yyerror("Unknown \\ sequence"); }
<Q>([ \t]|"\\\n"){2,} { char *p = yytext-1; while (p = strchr(p+1, '\n')) yylineno++; }
<Q>"\\ " { *optr++ = ' '; /* force space */ }
<Q>\" { BEGIN F; quoted = 0;
<Q>. { *optr++ = *yytext; }
static int find_resword(s)
int l = 0, m = NRES_WORDS/2, h = NRES_WORDS-1;
#define FSTRCMP(p, q) ((*(p) == *(q)) ? strcmp((p)+1, (q)+1) : *(p) - *(q))
while ((l <= h) && (rc = FSTRCMP(s, rr[m].rw))) {
/*fprintf(stderr, "failed to cmp(%s, %s), %d, %d, %d\n", s, rr[m].rw, l, m, h);*/
int yyerror(s, s1, s2, s3, s4)
fprintf(stderr, "%s:%d: ", filename ? filename : "/dev/stdin", yylineno);
fprintf(stderr, s, s1, s2, s3, s4);
ioloc *current_location()
ioloc *ip = ALLOC(ioloc);
strcpy(prog, "for file in ");
if (access(*g_argv, 4) < 0) {
error("\"%s\": Cannot open for reading", *g_argv);
strcat(prog, "; do /lib/cpp ");
strcat(prog, " -DHOSTNAME=\'");
strcat(prog, "\' \"$file\"; done");
/*if (filename) free(filename);*/
filename = strdup("unknown");
if (!first && yyin && pclose(yyin) != 0)
#define xgetc(fp) ((iptr > ibuf) ? (*--iptr) : (lastch = nextch, nextch = getc(fp), (nextch == EOF ? nextch = lastch, EOF : nextch)))
static int c_comment = 0;
/* fprintf(stderr, "ch = %c, %#x, %d\n", ch, ibuf,iptr-ibuf); */
} while (ch2 != '*' && ch2 != EOF);
} while (ch2 != '/' && ch2 != EOF);
/*log("lastch = '%c' (%#x)", lastch, lastch);*/
} while (ch2 != EOF && ch2 != '\n' && !isdigit(ch2));
/* Read in line number */
yylineno = atoi(fname) - 1;
while (ch2 != EOF && ch2 != '\"' && ch2 != '\n')
while (ch2 != '\"' && ch2 != EOF && ch2 != EOF) {
log("Setting filename to \"%s\"", fname);
/*if (filename) free(filename);*/
filename = strdup(fname);
while (ch2 != '\n' && ch2 != EOF)
} while (ch2 != '\n' && ch2 != EOF);
} while (ch2 != '\n' && ch2 != EOF);
error("End of file within comment");
if (iptr == ibuf + sizeof(ibuf) - 1)
fatal("Out of space in lexical pushback");