summaryrefslogtreecommitdiff
path: root/other/gramble/input.l
blob: caebf4b51f314f0218d4c25e90bc5f0a3d9c47fb (plain)
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
/* gramble - gammar ramble
 *
 * team teso
 *
 * grammar lexer
 */

%{
#undef	yywrap

#include <string.h>
#include "y.tab.h"
#include "input.h"

#undef	ECHO
#undef	YY_INPUT
#define	YY_INPUT(b, r, ms) (r = in_yyinput (b, ms))

%}

%%

[\n\t ]+ ;

\"[^\"]*\" {
	yylval.str = strdup (yytext + 1);
	yylval.str[strlen (yylval.str) - 1] = '\0';

	return (TERM);
}

[0-9]+ {
	sscanf (yytext, "%u", &yylval.uint);

	return (NUM);
}

0x[0-9abcdef]+ {
	sscanf (yytext, "0x%x", &yylval.uint);

	return (NUM);
}

[^\/]/\/ {
	yylval.str = strdup (yytext);

	return (NSSTR);
}

filter {
	return (FILTER);
}

\~filter {
	return (NEGFILTER);
}

size {
	return (SIZE);
}