-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpass1.l
46 lines (43 loc) · 1.21 KB
/
pass1.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
%{
#include "y.tab.h"
#include<stdio.h>
%}
%%
"START" { return START; }
"END" { return END; }
[0-9]+ {
yylval.number = atoi(yytext);
return NUMBER;
}
(ADD|STL|CLEAR|COMP|DIV|JSUB|COMPR|LDL|MUL|SUB|WORD|RESW|RESB|BYTE) {
yylval.string = strdup(yytext);
return OPCODE;
}
"+JSUB" {
yylval.string = strdup(yytext);
return OPCODE;
}
"RSUB" {
yylval.string = strdup(yytext);
return RSUB;
}
(FIX|HIO) {
yylval.string = strdup(yytext);
return FORMAT1;
}
[,a-zA-Z]+ {
yylval.string = strdup(yytext);
return LABEL;
}
# { return yytext[0]; }
(SIC-XE) {}
%%
int yywrap()
{
return 1;
}
void file_setup()
{
yyin = fopen("input.txt","r");
yyout = fopen("output.txt","w");
}