File: scan.l

package info (click to toggle)
idled 1.16-8
  • links: PTS
  • area: non-free
  • in suites: hamm
  • size: 364 kB
  • ctags: 390
  • sloc: ansic: 2,886; yacc: 318; makefile: 149; lex: 69; sh: 26
file content (69 lines) | stat: -rw-r--r-- 1,414 bytes parent folder | download | duplicates (3)
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
%{

/**************************************************************************
 *  Lex grammer to scan input file for idled                              *
 **************************************************************************/

#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;

[/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);
			}