tab2vmem_scan.l
1.8 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
/* tab2vmem_scan.l - Tokenizer for register level simulation */
%p 6500
%a 4200
%o 4700
digit [0-9]
hexdigit [0-9a-fA-F]
alpha [a-z_A-Z]
dot [.]
blank [ ]
underscore [_]
percent [%]
colon [:]
lbrk [\[]
rbrk [\]]
lpar [\(]
rpar [\)]
number {digit}+
hex 0x{hexdigit}+
input [@][Ii]
output [@][Oo]
bidir [@][Bb]
tri [@][Tt]
edge [@][Ee]
strobe [@][Ss]
clock [@][Cc]
valid [@][Vv]
ident ({alpha}|{dot}|{underscore})*{alpha}({alpha}|{digit}|{dot}|{underscore})*
comment #[^\n]*\n
quote [\"]
endofline [\n]
skip [ \t]
backslash [\\]
%%
{number} { install_number(yytext, 10); return (tNUMBER); }
{hex} { install_number(yytext, 16); return (tHEX); }
{input} { return (tINPUT); }
{output} { return (tOUTPUT); }
{bidir} { return (tBIDIR); }
{tri} { return (tTRI); }
{edge} { return (tEDGE); }
{strobe} { return (tSTROBE); }
{clock} { return (tCLOCK); }
{valid} { return (tVALID); }
{quote} { return (tQUOTE); }
{colon} { return (tCOLON); }
{percent} { return (tPERCENT); }
{lbrk} { return (tLBRACK); }
{rbrk} { return (tRBRACK); }
{lpar} { return (tLPAREN); }
{rpar} { return (tRPAREN); }
{ident} { install(yytext); return (tIDENT); }
{backslash} { int c; while ( (c = input()) != '\n' &&
c != EOF )
; /* eat up input til next line */
}
{endofline} { line_num++; return (tEOL); }
{comment} ;
{skip} ;
. { return (tJUNK); }
%%
int yywrap()
{
return(1);
}
void install_number(char *str, int base)
{
if(!VectorPhase)
yylval.ival = strtol(str, NULL, base);
else
{
(void) strncpy(yylval.name, str, TOKENSIZ-1);
yylval.name[TOKENSIZ-1] = '\0';
}
}
void install(char *str)
{
(void) strncpy(yylval.name, str, TOKENSIZ-1);
yylval.name[TOKENSIZ-1] = '\0';
}
void
yyerror(str)
char *str;
{
fprintf(stderr,"******* Error line: %d *********\n", line_num);
}