OpenCores
URL https://opencores.org/ocsvn/sc2v/sc2v/trunk

Subversion Repositories sc2v

[/] [sc2v/] [trunk/] [src/] [sc2v_step1.l] - Blame information for rev 14

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 jcastillo
/* -----------------------------------------------------------------------------
2
 *
3 14 jcastillo
 *  SystemC to Verilog Translator v0.3
4 11 jcastillo
 *  Provided by OpenSoc Design
5
 *
6
 *  www.opensocdesign.com
7
 *
8
 * -----------------------------------------------------------------------------
9
 *  This program is free software; you can redistribute it and/or modify
10
 *  it under the terms of the GNU General Public License as published by
11
 *  the Free Software Foundation; either version 2 of the License, or
12
 *  (at your option) any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU Library General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU General Public License
20
 *  along with this program; if not, write to the Free Software
21
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
 */
23
 
24
 
25
%{
26
#include 
27
#include "y.tab.h"
28
 
29
extern int yylval;
30
 
31
int includefound = 0;
32
int linecomment = 0;
33
int multilinecomment = 0;
34
%}
35
 
36 10 jcastillo
%%
37 11 jcastillo
"void"                              if(!includefound & !linecomment & !multilinecomment) return VOID; else {yylval=(int)strdup(yytext);} return WORD;
38
"true"                              if(!includefound & !linecomment & !multilinecomment) return TTRUE; else {yylval=(int)strdup(yytext);} return WORD;
39
"false"                             if(!includefound & !linecomment & !multilinecomment) return TFALSE; else {yylval=(int)strdup(yytext);} return WORD;
40
[0-9]+                              yylval=atoi(yytext); return NUMBER;
41
"::"                                if(!includefound & !linecomment & !multilinecomment) return TWODOUBLEPOINTS; else {yylval=(int)strdup(yytext);} return WORD;
42
sc_int                              if(!includefound & !linecomment & !multilinecomment) return SC_INT; else {yylval=(int)strdup(yytext);} return WORD;
43
sc_uint                             if(!includefound & !linecomment & !multilinecomment) return SC_UINT; else {yylval=(int)strdup(yytext);} return WORD;
44
sc_bigint                           if(!includefound & !linecomment & !multilinecomment) return SC_BIGINT; else {yylval=(int)strdup(yytext);} return WORD;
45
sc_biguint                          if(!includefound & !linecomment & !multilinecomment) return SC_BIGUINT; else {yylval=(int)strdup(yytext);} return WORD;
46
bool                                if(!includefound & !linecomment & !multilinecomment) return BOOL; else {yylval=(int)strdup(yytext);} return WORD;
47
">"                                 if(!includefound & !linecomment & !multilinecomment) return BIGGER; else {yylval=(int)strdup(yytext);} return WORD;
48
"<"                                 if(!includefound & !linecomment & !multilinecomment) return LOWER; else {yylval=(int)strdup(yytext);} return WORD;
49
"{"                                 if(!includefound & !linecomment & !multilinecomment) return OPENKEY; else {yylval=(int)strdup(yytext);} return WORD;
50
"}"                                 if(!includefound & !linecomment & !multilinecomment) return CLOSEKEY; else {yylval=(int)strdup(yytext);} return WORD;
51
"("                                 if(!includefound & !linecomment & !multilinecomment) return OPENPAR; else {yylval=(int)strdup(yytext);} return WORD;
52
")"                                 if(!includefound & !linecomment & !multilinecomment) return CLOSEPAR; else {yylval=(int)strdup(yytext);} return WORD;
53
"["                                 if(!includefound & !linecomment & !multilinecomment) return OPENCORCH; else {yylval=(int)strdup(yytext);} return WORD;
54
"]"                                 if(!includefound & !linecomment & !multilinecomment) return CLOSECORCH; else {yylval=(int)strdup(yytext);} return WORD;
55
".write"                            if(!includefound & !linecomment & !multilinecomment) return WRITE; else {yylval=(int)strdup(yytext);} return WORD;
56
"switch"                            if(!includefound & !linecomment & !multilinecomment) return SWITCH; else {yylval=(int)strdup(yytext);} return WORD;
57
"case"                              if(!includefound & !linecomment & !multilinecomment) return CASE; else {yylval=(int)strdup(yytext);} return WORD;
58
"default"                           if(!includefound & !linecomment & !multilinecomment) return DEFAULT; else {yylval=(int)strdup(yytext);} return WORD;
59
"break"                             if(!includefound & !linecomment & !multilinecomment) return BREAK; else {yylval=(int)strdup(yytext);} return WORD;
60
".read"                             if(!includefound & !linecomment & !multilinecomment) return READ; else {yylval=(int)strdup(yytext);} return WORD;
61
".range"                            if(!includefound & !linecomment & !multilinecomment) return RANGE; else {yylval=(int)strdup(yytext);} return WORD;
62
[a-zA-Z][_a-zA-Z0-9]*               yylval=(int)strdup(yytext); return WORD;
63
[.:"^"!%()=/+*_"&""?""|""\\"]       yylval=(int)strdup(yytext); return SYMBOL;
64
"-"                                 yylval=(int)strdup(yytext); return SYMBOL;
65
"~"                                 yylval=(int)strdup(yytext); return SYMBOL;
66
"@"                                 yylval=(int)strdup(yytext); return SYMBOL;
67
","                                 if(!includefound & !linecomment & !multilinecomment) return COLON; else {yylval=(int)strdup(yytext);} return WORD;
68
";"                                 if(!includefound & !linecomment & !multilinecomment) return SEMICOLON; else {yylval=(int)strdup(yytext);} return WORD;
69
[" "]+                              /*Ignore white spaces*/
70
"\t"                                return TAB; /*Ignore Tab*/
71
"\n"                                if (linecomment) linecomment=0; else if(includefound) includefound=0; return NEWLINE;
72
"\\\n"                               /* no new line */
73
"0x"                                if(!includefound & !linecomment & !multilinecomment) return HEXA; else {yylval=(int)strdup(yytext);} return WORD;
74
"$"                                 if(!includefound & !linecomment & !multilinecomment) return DOLLAR; else {yylval=(int)strdup(yytext);} return WORD;/* Ignore if(!includefound & !linecomment & !multilinecomment) $ */
75
"(int)"                             if(!includefound & !linecomment & !multilinecomment) return INTCONV; else {yylval=(int)strdup(yytext);} return WORD;/* Ignore int type if(!includefound & !linecomment & !multilinecomment) conversions*/
76
 
77
"#define"                           if(!includefound & !linecomment & !multilinecomment) return DEFINE; else {yylval=(int)strdup(yytext);} return WORD;
78
"#include"                          includefound = 1;
79
"#ifdef"                            if(!includefound & !linecomment & !multilinecomment) return PIFDEF; else {yylval=(int)strdup(yytext);} return WORD;
80
"#else"                             if(!includefound & !linecomment & !multilinecomment) return PELSE; else {yylval=(int)strdup(yytext);} return WORD;
81
"#endif"                            if(!includefound & !linecomment & !multilinecomment) return PENDDEF; else {yylval=(int)strdup(yytext);} return WORD;
82
 
83
"//"                    if (!multilinecomment) linecomment = 1; yylval=(int)strdup(yytext); return WORD;
84
"/*"                    if (!linecomment) multilinecomment = 1; yylval=(int)strdup(yytext); return WORD;
85
"*/"                    if (multilinecomment) multilinecomment = 0; yylval=(int)strdup(yytext); return WORD;
86
 
87
"("[ ]*"sc_uint"[ ]*"<"[ ]*[0-9+][ ]*">"[ ]*")"
88
"("[ ]*"sc_biguint"[ ]*"<"[ ]*[0-9+][ ]*">"[ ]*")"
89
"("[ ]*"sc_int"[ ]*"<"[ ]*[0-9+][ ]*">"[ ]*")"
90
"("[ ]*"sc_bigint"[ ]*"<"[ ]*[0-9+][ ]*">"[ ]*")"
91
 
92
"//"[ ]*[tT][rR][aA][nN][sS][lL][aA][tT][eE][ ]*[oO][fF][fF]  return TRANSLATEOFF;  /*Translate directive*/
93
"//"[ ]*[tT][rR][aA][nN][sS][lL][aA][tT][eE][ ]*[oO][nN]      return TRANSLATEON;   /*Translate directive*/
94
"/*"[ ]*[vV][eE][rR][iI][lL][oO][gG][ ]*[bB][eE][gG][iI][nN]  return VERILOGBEGIN;
95
[vV][eE][rR][iI][lL][oO][gG][ ]*[eE][nN][dD]"*/"              return VERILOGEND;
96
 
97
%%

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.