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

Subversion Repositories sc2v

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

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

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

powered by: WebSVN 2.1.0

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