1995-01-19 22:27:58 +00:00
|
|
|
%{
|
1995-01-19 21:30:25 +00:00
|
|
|
/*
|
|
|
|
* Copyright 1987, 1988 by MIT Student Information Processing Board.
|
|
|
|
*
|
|
|
|
* For copyright info, see copyright.h.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
1996-06-02 17:22:01 +00:00
|
|
|
#include "y.tab.h"
|
1995-01-19 21:30:25 +00:00
|
|
|
#include "copyright.h"
|
|
|
|
|
|
|
|
extern char *last_token, *ds();
|
|
|
|
|
1996-07-12 19:08:36 +00:00
|
|
|
static int l_command_table()
|
1995-01-19 21:30:25 +00:00
|
|
|
{
|
|
|
|
last_token = "command_table";
|
|
|
|
return COMMAND_TABLE;
|
|
|
|
}
|
|
|
|
|
1996-07-12 19:08:36 +00:00
|
|
|
static int l_request()
|
1995-01-19 21:30:25 +00:00
|
|
|
{
|
|
|
|
last_token = "request";
|
|
|
|
return REQUEST;
|
|
|
|
}
|
|
|
|
|
1996-07-12 19:08:36 +00:00
|
|
|
static int l_unimplemented()
|
1995-01-19 21:30:25 +00:00
|
|
|
{
|
|
|
|
last_token = "unimplemented";
|
|
|
|
return UNIMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
1996-07-12 19:08:36 +00:00
|
|
|
static int l_end()
|
1995-01-19 21:30:25 +00:00
|
|
|
{
|
|
|
|
last_token = "end";
|
|
|
|
return END;
|
|
|
|
}
|
|
|
|
|
1996-07-12 19:08:36 +00:00
|
|
|
static int l_quoted_string()
|
1995-01-19 21:30:25 +00:00
|
|
|
{
|
|
|
|
register char *p;
|
|
|
|
yylval.dynstr = ds(yytext+1);
|
1996-07-12 19:08:36 +00:00
|
|
|
if ( (p=rindex(yylval.dynstr, '"')) )
|
1995-01-19 21:30:25 +00:00
|
|
|
*p='\0';
|
|
|
|
last_token = ds(yylval.dynstr);
|
|
|
|
return STRING;
|
|
|
|
}
|
|
|
|
|
1996-07-12 19:08:36 +00:00
|
|
|
static int l_string()
|
1995-01-19 21:30:25 +00:00
|
|
|
{
|
|
|
|
yylval.dynstr = ds(yytext);
|
|
|
|
last_token = ds(yylval.dynstr);
|
|
|
|
return STRING;
|
|
|
|
}
|
1995-01-19 22:27:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
%}
|
|
|
|
|
|
|
|
N [0-9]
|
|
|
|
PC [^\"]
|
|
|
|
AN [A-Z_a-z0-9]
|
|
|
|
%%
|
|
|
|
|
|
|
|
command_table return l_command_table();
|
|
|
|
request return l_request();
|
|
|
|
unimplemented return l_unimplemented();
|
|
|
|
end return l_end();
|
|
|
|
|
|
|
|
[\t\n ] ;
|
|
|
|
|
|
|
|
\"{PC}*\" return l_quoted_string();
|
|
|
|
|
|
|
|
{AN}* return l_string();
|
|
|
|
|
|
|
|
#.*\n ;
|
|
|
|
|
|
|
|
. return (*yytext);
|
|
|
|
|
|
|
|
%%
|
|
|
|
|