-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtry.l
51 lines (40 loc) · 1.2 KB
/
try.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
%{
#define YYSTYPE char*
#include <stdio.h>
#include "trynext.tab.h"
void yyerror(char *s);
%}
%option yylineno
%option noyywrap
%x STR
%%
[-] return DEF;
[>] return RIGHTBR;
[<] return LEFTBR;
[*] return STAR;
[!] return SIGN;
[?] return QSIGN;
[+] return PLUS;
[=] return EQUALS;
[cC][rR][eE][aA][tT][eE] return CREATE;
[mM][aA][kK][eE] return MAKE;
[aA][dD][dD][aA][lL][lL] return ADDALL;
[cC][oO][pP][yY] return COPY;
[gG][oO][tT][oO] return GOTO;
[aA][dD][dD] return ADD;
[cC][oO][mM][pP][aA][rR][eE] return COMPARE;
[sS][oO][rR][tT] return SORT;
[rR][eE][nN][aA][mM][eE] return RENAME;
[lL][iI][sS][tT] return LST;
[dD][iI][rR] return DIR;
[pP][rR][iI][nN][tT] return PRINT;
[eE][nN][dD] return END;
[a-zA-Z.\/~][a-zA-Z0-9.\/]* yylval=strdup(yytext); return WORD;
[0-9]+ yylval=strdup(yytext); return NUMBER;
[ \n]
["] { yylval = strdup(""); BEGIN(STR); }
<STR>[^\\\n"]+ { yylval = (char*)realloc(yylval, 255); strcat(yylval, yytext); }
<STR>\\n { yylval = (char*)realloc(yylval, 255); strcat(yylval, yytext); }
<STR>\\["] yylval = strcat(yylval,"\"");
<STR>["] {BEGIN(INITIAL); return STRING; }
%%