-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathfin.l
84 lines (75 loc) · 2.08 KB
/
fin.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
%{
#include <stdio.h>
#include "fin.tab.h" // to get the token types from Bison
extern int finlex();
int lineNum = 1;
%}
%option noyywrap
%option outfile="lex.fin.c"
%option prefix="fin"
DIGIT [0-9]
UDIGIT 0x[0-9a-f]{8}
CHAR [a-zA-Z]
UCHAR 0x[0-9a-f]{2}
LABEL [a-z]{1,3}
ULABEL 0x[0-9a-f]{4}
NETCON [0-9]{1,3}"."[0-9]{1,3}"."[0-9]{1,3}"."[0-9]{1,3}":"[0-9]{1,5}":"("tcp")
%%
[ \t] ;
"//".* ;
\n { lineNum++; }
peekn { return PEEKN; }
peekc { return PEEKC; }
header { return HEADER; }
footer { return FOOTER; }
stack { return STACK_IMP; }
arith { return ARITH_IMP; }
heap { return HEAP_IMP; }
flow { return FLOW_IMP; }
ioa { return IOA_IMP; }
ioc { return IOC_IMP; }
netcon { return NETCON_IMP; }
FIN { return END_PRGM; }
push { return STACK_PUSH; }
dup { return STACK_DUP; }
swap { return STACK_SWAP; }
discard { return STACK_DEL; }
add { return ADD; }
sub { return SUB; }
mult { return MULT; }
div { return DIV; }
mod { return MOD; }
store { return HEAP_STORE; }
retrieve { return HEAP_RETR; }
mark { return MARK; }
call { return CALL; }
jumpu { return JUMPU; }
jumpz { return JUMPZ; }
jumpn { return JUMPN; }
return { return RETURN; }
outc { return OUTC; }
outn { return OUTN; }
inc { return INC; }
inn { return INN; }
fileio { return IOC_FILE; }
stdio { return IOC_STD; }
connect { return CONNECT; }
close { return CLOSE; }
send { return SEND; }
recv { return RECV; }
{DIGIT}+ { finlval.ival = atoi(fintext);
return NUM; }
{UDIGIT} { finlval.sval = strdup(fintext);
return UNUM; }
{CHAR} { finlval.cval = fintext[0];
return CHAR; }
{UCHAR} { finlval.sval = strdup(fintext);
return UCHAR; }
{LABEL} { finlval.sval = strdup(fintext);
return LABEL; }
{ULABEL} { finlval.sval = strdup(fintext);
return ULABEL; }
{NETCON} { finlval.sval = strdup(fintext);
return NETCON; }
. ;
%%