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

Subversion Repositories sc2v

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

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 35 jcastillo
sc_int                              if(!includefound & !linecomment & !multilinecomment) return SC_SIGREG; else {yylval=(int)strdup(yytext);} return COMMENT;
46 28 jcastillo
sc_uint                             if(!includefound & !linecomment & !multilinecomment) return SC_REG; else {yylval=(int)strdup(yytext);} return COMMENT;
47 35 jcastillo
sc_bigint                           if(!includefound & !linecomment & !multilinecomment) return SC_SIGREG; else {yylval=(int)strdup(yytext);} return COMMENT;
48 28 jcastillo
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 33 jcastillo
"struct"                            if(!includefound & !linecomment & !multilinecomment) return STRUCT; else {yylval=(int)strdup(yytext);} return COMMENT;
61 28 jcastillo
"switch"                            if(!includefound & !linecomment & !multilinecomment) return SWITCH; else {yylval=(int)strdup(yytext);} return COMMENT;
62
"case"                              if(!includefound & !linecomment & !multilinecomment) return CASE; else {yylval=(int)strdup(yytext);} return COMMENT;
63
"default"                           if(!includefound & !linecomment & !multilinecomment) return DEFAULT; else {yylval=(int)strdup(yytext);} return COMMENT;
64
"break"                             if(!includefound & !linecomment & !multilinecomment) return BREAK; else {yylval=(int)strdup(yytext);} return COMMENT;
65
".read"                             if(!includefound & !linecomment & !multilinecomment) return READ; else {yylval=(int)strdup(yytext);} return COMMENT;
66
".range"                            if(!includefound & !linecomment & !multilinecomment) return RANGE; else {yylval=(int)strdup(yytext);} return COMMENT;
67
[a-zA-Z][_a-zA-Z0-9]*               yylval=(int)strdup(yytext); if(!includefound & !linecomment & !multilinecomment) return WORD; else return COMMENT;
68 33 jcastillo
[:^!%/+*_"&""?""|""\\"]             yylval=(int)strdup(yytext); if(!includefound & !linecomment & !multilinecomment) return SYMBOL; else return COMMENT;
69 28 jcastillo
"<="                                yylval=(int)strdup(yytext); if(!includefound & !linecomment & !multilinecomment) return MINEQ; else return COMMENT;
70
"="                                 yylval=(int)strdup(yytext); if(!includefound & !linecomment & !multilinecomment) return EQUALS; else  return COMMENT;
71
"++"                                yylval=(int)strdup(yytext); if(!includefound & !linecomment & !multilinecomment) return INC; else return COMMENT;
72
"--"                                yylval=(int)strdup(yytext); if(!includefound & !linecomment & !multilinecomment) return DEC; 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 SYMBOL; else  return COMMENT;
76
","                                 yylval=(int)strdup(yytext); if(!includefound & !linecomment & !multilinecomment) return COLON; else  return COMMENT;
77
";"                                 yylval=(int)strdup(yytext); if(!includefound & !linecomment & !multilinecomment) return SEMICOLON; else  return COMMENT;
78 33 jcastillo
"."                                 yylval=(int)strdup(yytext); if(!includefound & !linecomment & !multilinecomment) return DOT; else  return COMMENT;
79 11 jcastillo
[" "]+                              /*Ignore white spaces*/
80
"\t"                                return TAB; /*Ignore Tab*/
81 15 jcastillo
"\n"                                lineno++; if (linecomment) linecomment=0; else if(includefound) includefound=0; return NEWLINE;
82
"\\\n"                              lineno++; /* no new line */
83 28 jcastillo
"0x"                                if(!includefound & !linecomment & !multilinecomment) return HEXA; else {yylval=(int)strdup(yytext);} return COMMENT;
84
"$"                                 if(!includefound & !linecomment & !multilinecomment) return DOLLAR; else {yylval=(int)strdup(yytext);} return COMMENT;/* Ignore if(!includefound & !linecomment & !multilinecomment) $ */
85
"#define"                           if(!includefound & !linecomment & !multilinecomment) return DEFINE; else {yylval=(int)strdup(yytext);} return COMMENT;
86 11 jcastillo
"#include"                          includefound = 1;
87 28 jcastillo
"#ifdef"                            if(!includefound & !linecomment & !multilinecomment) return PIFDEF; else {yylval=(int)strdup(yytext);} return COMMENT;
88
"#ifndef"                           if(!includefound & !linecomment & !multilinecomment) return PIFNDEF; else {yylval=(int)strdup(yytext);} return COMMENT;
89
"#else"                             if(!includefound & !linecomment & !multilinecomment) return PELSE; else {yylval=(int)strdup(yytext);} return COMMENT;
90
"#endif"                            if(!includefound & !linecomment & !multilinecomment) return PENDDEF; else {yylval=(int)strdup(yytext);} return COMMENT;
91
"//"                                if (!multilinecomment) linecomment = 1; yylval=(int)strdup(yytext); return COMMENT;
92
"/*"                                if (!linecomment) multilinecomment = 1; yylval=(int)strdup(yytext); return COMMENT;
93
"*/"                                if (multilinecomment) multilinecomment = 0; yylval=(int)strdup(yytext); return COMMENT;
94 11 jcastillo
 
95 22 jcastillo
"("[ ]*"sc_uint"[ ]*"<"[ ]*[0-9]+[ ]*">"[ ]*")"
96
"("[ ]*"sc_biguint"[ ]*"<"[ ]*[0-9]+[ ]*">"[ ]*")"
97
"("[ ]*"sc_int"[ ]*"<"[ ]*[0-9]+[ ]*">"[ ]*")"
98
"("[ ]*"sc_bigint"[ ]*"<"[ ]*[0-9]+[ ]*">"[ ]*")"
99 19 jcastillo
"("[ ]*"int"[ ]*")"
100 11 jcastillo
 
101 19 jcastillo
 
102 11 jcastillo
"//"[ ]*[tT][rR][aA][nN][sS][lL][aA][tT][eE][ ]*[oO][fF][fF]  return TRANSLATEOFF;  /*Translate directive*/
103
"//"[ ]*[tT][rR][aA][nN][sS][lL][aA][tT][eE][ ]*[oO][nN]      return TRANSLATEON;   /*Translate directive*/
104
"/*"[ ]*[vV][eE][rR][iI][lL][oO][gG][ ]*[bB][eE][gG][iI][nN]  return VERILOGBEGIN;
105
[vV][eE][rR][iI][lL][oO][gG][ ]*[eE][nN][dD]"*/"              return VERILOGEND;
106
 
107
%%

powered by: WebSVN 2.1.0

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