2
/* SCCS Id: @(#)dgn_lex.c 3.4 2002/03/27 */
3
/* Copyright (c) 1989 by Jean-Christophe Collet */
4
/* Copyright (c) 1990 by M. Stephenson */
5
/* NetHack may be freely redistributed. See license for details. */
14
* Most of these don't exist in flex, yywrap is macro and
15
* yyunput is properly declared in flex.skel.
17
#if !defined(FLEX_SCANNER) && !defined(FLEXHACK_SCANNER)
18
int FDECL(yyback, (int *,int));
23
/* Traditional lexes let yyunput() and yyoutput() default to int;
24
* newer ones may declare them as void since they don't return
25
* values. For even more fun, the lex supplied as part of the
26
* newer unbundled compiler for SunOS 4.x adds the void declarations
27
* (under __STDC__ or _cplusplus ifdefs -- otherwise they remain
28
* int) while the bundled lex and the one with the older unbundled
29
* compiler do not. To detect this, we need help from outside --
30
* sys/unix/Makefile.utl.
32
* Digital UNIX is difficult and still has int in spite of all
35
# if defined(NeXT) || defined(SVR4) || defined(_AIX32)
38
# if !defined(VOIDYYPUT) && defined(POSIX_TYPES)
39
# if !defined(BOS) && !defined(HISX) && !defined(_M_UNIX) && !defined(VMS)
43
# if !defined(VOIDYYPUT) && defined(WEIRD_LEX)
44
# if defined(SUNOS4) && defined(__STDC__) && (WEIRD_LEX > 1)
48
# if defined(VOIDYYPUT) && defined(__osf__)
52
void FDECL(yyunput, (int));
53
void FDECL(yyoutput, (int));
55
int FDECL(yyunput, (int));
56
int FDECL(yyoutput, (int));
58
#endif /* !FLEX_SCANNER && !FLEXHACK_SCANNER */
61
#define YY_MALLOC_DECL \
62
genericptr_t FDECL(malloc, (size_t)); \
63
genericptr_t FDECL(realloc, (genericptr_t,size_t));
67
void FDECL(init_yyin, (FILE *));
68
void FDECL(init_yyout, (FILE *));
70
/* this doesn't always get put in dgn_comp.h
71
* (esp. when using older versions of bison)
74
extern YYSTYPE yylval;
80
DUNGEON return(A_DUNGEON);
81
up { yylval.i=1; return(UP_OR_DOWN); }
82
down { yylval.i=0; return(UP_OR_DOWN); }
86
no_down return(NO_DOWN);
87
portal return(PORTAL);
88
PROTOFILE return(PROTOFILE);
89
DESCRIPTION return(DESCRIPTION);
90
LEVELDESC return(LEVELDESC);
91
ALIGNMENT return(ALIGNMENT);
92
LEVALIGN return(LEVALIGN);
93
town { yylval.i=TOWN ; return(DESCRIPTOR); }
94
hellish { yylval.i=HELLISH ; return(DESCRIPTOR); }
95
mazelike { yylval.i=MAZELIKE ; return(DESCRIPTOR); }
96
roguelike { yylval.i=ROGUELIKE ; return(DESCRIPTOR); }
97
unaligned { yylval.i=D_ALIGN_NONE ; return(DESCRIPTOR); }
98
noalign { yylval.i=D_ALIGN_NONE ; return(DESCRIPTOR); }
99
lawful { yylval.i=D_ALIGN_LAWFUL ; return(DESCRIPTOR); }
100
neutral { yylval.i=D_ALIGN_NEUTRAL ; return(DESCRIPTOR); }
101
chaotic { yylval.i=D_ALIGN_CHAOTIC ; return(DESCRIPTOR); }
102
BRANCH return(BRANCH);
103
CHAINBRANCH return(CHBRANCH);
105
RNDLEVEL return(RNDLEVEL);
106
CHAINLEVEL return(CHLEVEL);
107
RNDCHLEVEL return(RNDCHLEVEL);
108
[-0-9]+ { yylval.i=atoi(yytext); return(INTEGER); }
109
\"[^"]*\" { yytext[yyleng-1] = 0; /* Discard the trailing \" */
110
yylval.str = (char *) alloc(strlen(yytext+1)+1);
111
Strcpy(yylval.str, yytext+1); /* Discard the first \" */
113
^#.*\n { line_number++; }
114
\r?\n { line_number++; }
115
[ \t]+ ; /* skip trailing tabs & spaces */
116
. { return yytext[0]; }
119
/* routine to switch to another input file; needed for flex */
120
void init_yyin( input_f )
123
#if defined(FLEX_SCANNER) || defined(FLEXHACK_SCANNER)
130
/* analogous routine (for completeness) */
131
void init_yyout( output_f )