-
Notifications
You must be signed in to change notification settings - Fork 0
/
huelle.l
94 lines (73 loc) · 1 KB
/
huelle.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* SPDX-License-Identifier: GPL-3.0-or-later
* Author: bluewww */
%{
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include "huelle.tab.h"
%}
DIGIT [0-9]
OPERATION [+*\(\)]
WORD [a-zA-Z0-9\-\.\/]+
%option reentrant
%option noyywrap
%option bison-bridge
%option bison-locations
%option noyywrap
%option nounput
%option noinput
%%
[ \t] {
}
\n {
return NEWL;
}
"<&" {
return LESSAND;
}
">" {
return GREATER;
}
"<" {
return LESS;
}
">&" {
return GREATAND;
}
">>" {
return DGREAT;
}
"<>" {
return LESSGREAT;
}
">|" {
return CLOBBER;
}
"<<" {
return DLESS;
}
"<<-" {
return DLESSDASH;
}
"|" {
return PIPE;
}
{DIGIT}+/(>|<) {
yylval->num = atoi(yytext); /* TODO: error checking */
#ifdef HUL_DEBUG
fprintf(stderr, "io:`%d'\n", yylval->num);
#endif
return IO_NUMBER;
}
{WORD} {
yylval->str = strdup(yytext); /* TODO: xstrdup */
#ifdef HUL_DEBUG
fprintf(stderr, "str:`%s'\n", yytext);
#endif
return WORD;
}
. {
fprintf(stderr, "undefined token:`%s'\n", yytext);
return YYUNDEF;
}
%%