%{
/*
....[@@@..[@@@..............[@.................. MUD++ is a written from
....[@..[@..[@..[@..[@..[@@@@@....[@......[@.... scratch multi-user swords and
....[@..[@..[@..[@..[@..[@..[@..[@@@@@..[@@@@@.. sorcery game written in C++.
....[@......[@..[@..[@..[@..[@....[@......[@.... This server is an ongoing
....[@......[@..[@@@@@..[@@@@@.................. development project. All
................................................ contributions are welcome.
....Copyright(C).1995.Melvin.Smith.............. Enjoy.
------------------------------------------------------------------------------
Melvin Smith (aka Fusion) msmith@hom.net
MUD++ development mailing list mudpp-list@mailhost.net
------------------------------------------------------------------------------
lex.l
Lexical analyzer for MUD++ Online Language (to be named)
*/
#include <stdio.h>
#include "sym.h"
#include "parse.h"
#include "yacc.tab.h"
extern char id[];
extern long line;
%}
D [0-9]
L [a-zA-Z_]
SC \"[^\"\n]*[\"\n]
%%
"void" { return(VOID); }
"int" { return(INT); }
"string" { return(STRING); }
"return" { return(RETURN); }
{L}({L}|{D})* {
yylval.sym_ptr = sym_lookup( yytext );
if( !yylval.sym_ptr )
yylval.sym_ptr = sym_add_id( yytext );
return(ID);
}
{D}+ { yylval.lval = atoi( yytext ); return(CONSTANT_INT); }
{SC} { if( yytext[yyleng-1] != '"' )
yyerror( "unterminated string" );
yytext[yyleng-1] = '\0';
yylval.sym_ptr = sym_add_const_str( yytext+1 );
return(STRING_LITERAL);
}
"," { return(','); }
":" { return(':'); }
";" { return(';'); }
"(" { return('('); }
")" { return(')'); }
"{" { return('{'); }
"}" { return('}'); }
"=" { return('='); }
"+" { return('+'); }
"-" { return('-'); }
"/" { return('/'); }
"*" { return('*'); }
"++" { return(INC_OP); }
"--" { return(DEC_OP); }
[\t\f ]+ ;
[\n] line++;
. { /* ignore */ }
%%
#ifdef yywrap
#undef yywrap
#endif
int yywrap()
{
/* Add code here to open next source file and start scanning
yywrap returns 0 if scanning is to continue
*/
return 1;
}