-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshell.l
More file actions
42 lines (37 loc) · 805 Bytes
/
Copy pathshell.l
File metadata and controls
42 lines (37 loc) · 805 Bytes
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
%{
#include <stdlib.h>
#include "y.tab.h"
#include "shell.h"
char* str;
char* envstr;
int str_length;
void yyerror(char*);
%}
%%
"setenv" return SETENV;
"printenv" return PRINTENV;
"unsetenv" return UNSETENV;
"cd" return CD;
"alias" return ALIAS;
"unalias" return UNALIAS;
"clear" return CLEAR;
"bye" return BYE;
"\"" return QUOTE;
"<" return LT;
">" return GT;
"|" return VERT;
"\\" return WACK;
"&" return AMP;
"*" return STAR;
"?" return QUEST;
"2" return STDERR;
"&1" return STDOUT;
\033 printf("ESC\n");
[ \t]+ ;
\n return END;
[a-zA-Z0-9_:./~-]*"${"[a-zA-Z0-9]+"}"[a-zA-Z0-9_:./~-]* {str = yytext; str_length = yyleng; return ENVSTR;}
[a-zA-Z0-9_:./~*?-]+ {str = yytext; str_length = yyleng; return WORD;}
%%
int yywrap(void) {
return 1;
}