-
Notifications
You must be signed in to change notification settings - Fork 1
/
scan.l
70 lines (57 loc) · 1.41 KB
/
scan.l
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
%{
/**************************************************************************
* Lex grammer to scan input file for doinkd *
**************************************************************************/
#include <stdio.h>
#include "y.tab.h"
#define makestr(Z) ((char *)strcpy((char *)malloc(strlen(Z)+1),Z))
int linenum = 1; /* current line number for error messages */
%}
%%
all return ALL;
default return DEFAULT;
exempt return EXEMPT;
group return GROUP;
host return HOST;
idle return IDLE;
idlemethod return IDLEMETHOD;
conswins return CONSWINS;
login return LOGIN;
multiple return MULTIPLE;
multiples return MULTIPLES;
refuse return REFUSE;
session return SESSION;
sleep return SLEEP;
warn return WARN;
threshold return THRESHOLD;
timeout return TIMEOUT;
tty return TTY;
normal return NORMAL;
off return OFF;
userinput return USERINPUT;
inputoutput return INPUTOUTPUT;
file return FILECOM;
maxuser return MAXUSER;
[/A-Za-z][/A-Za-z0-9._:]* {
yylval.sb = makestr(yytext);
return NAME;
}
[0-9]+ {
yylval.nb = atoi(yytext);
return NUM;
}
-[0-9]+ {
yylval.nb = atoi(yytext);
return NUM;
}
"#".* ;
"\n" {
linenum++;
return NL;
}
[ \t]* ;
. {
static char errormsg[] = "Illegal character ' '.";
errormsg[19] = yytext[0];
yyerror(errormsg);
}