-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.l
37 lines (30 loc) · 775 Bytes
/
test.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
/* -*- indented-text -*- */
%{
#include "test.tab.h"
#include <string.h>
#include <FlexLexer.h>
extern "C" int yylex (void);
#ifdef DOESNT_HAVE_STRDUP
#warning DOESNT_HAVE_STRDUP
char *strdup(const char *s);
#endif
#define ECHO
%}
NL [\n]
PIPE [|]
OUTPUT_REDIR [>]
INPUT_REDIR [<]
BG [&]
CHAR [0-9a-zA-Z_/\-\*\.]
SPACE [\032]
%%
exit { ECHO; return EXIT; }
{NL} { ECHO; return 0; }
{BG} { ECHO; return BACKGROUND; }
{PIPE} { ECHO; return PIPE;}
{OUTPUT_REDIR} { ECHO; return OUTPUT_REDIR; }
{INPUT_REDIR} { ECHO; return INPUT_REDIR; }
{CHAR}+ { ECHO; yylval.string = strdup(yytext); return STRING; }
. ;
%%
int yywrap (void) {return 1;}