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

Subversion Repositories sc2v

[/] [sc2v/] [trunk/] [src/] [sc2v_step2.l] - Blame information for rev 36

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
#include 
24
#include "y.tab.h"
25
 
26
extern int yylval;
27 15 jcastillo
extern FILE* yyin;
28
extern FILE* yyout;
29 11 jcastillo
 
30 15 jcastillo
extern int lineno;
31
 
32 11 jcastillo
int includefound = 0;
33
int linecomment = 0;
34
int multilinecomment = 0;
35
%}
36
 
37
%%
38
"\t"                    /* ignore whitespace */
39
" "                     /* ignore whitespace */
40
[0-9]+                  if(!includefound & !linecomment & !multilinecomment) {
41
                           yylval=atoi(yytext);
42
                           return NUMBER;
43
                         }
44
SC_MODULE               if(!includefound & !linecomment & !multilinecomment) return SC_MODULE;
45
SC_METHOD               if(!includefound & !linecomment & !multilinecomment) return SC_METHOD;
46 35 jcastillo
SC_CTOR                if(!includefound & !linecomment & !multilinecomment) return SC_CTOR;
47 11 jcastillo
"void"                  if(!includefound & !linecomment & !multilinecomment) return VOID;
48
sensitive_pos           if(!includefound & !linecomment & !multilinecomment) return SENSITIVE_POS;
49
sensitive_neg           if(!includefound & !linecomment & !multilinecomment) return SENSITIVE_NEG;
50
sensitive               if(!includefound & !linecomment & !multilinecomment) return SENSITIVE;
51
"<<"                    if(!includefound & !linecomment & !multilinecomment) return SENSIBLE;
52
sc_in                   if(!includefound & !linecomment & !multilinecomment) return SC_IN;
53
sc_out                  if(!includefound & !linecomment & !multilinecomment) return SC_OUT;
54
sc_signal               if(!includefound & !linecomment & !multilinecomment) return SC_SIGNAL;
55
"bool"                  if(!includefound & !linecomment & !multilinecomment) return BOOL;
56
"<"                     if(!includefound & !linecomment & !multilinecomment) return MENOR;
57
">"                     if(!includefound & !linecomment & !multilinecomment) return MAYOR;
58 35 jcastillo
sc_int                  if(!includefound & !linecomment & !multilinecomment) return SC_SGNREG;
59
sc_uint                if(!includefound & !linecomment & !multilinecomment) return SC_REG;
60
sc_bigint               if(!includefound & !linecomment & !multilinecomment) return SC_SGNREG;
61 16 jcastillo
sc_biguint              if(!includefound & !linecomment & !multilinecomment) return SC_REG;
62 11 jcastillo
\(                      if(!includefound & !linecomment & !multilinecomment) return OPENPAR;
63
\)                      if(!includefound & !linecomment & !multilinecomment) return CLOSEPAR;
64
;                       if(!includefound & !linecomment & !multilinecomment) return SEMICOLON;
65
"enum"                  if(!includefound & !linecomment & !multilinecomment) return ENUM;
66
","                     if(!includefound & !linecomment & !multilinecomment) return COLON;
67
"{"                     if(!includefound & !linecomment & !multilinecomment) return OPENKEY;
68
"}"                     if(!includefound & !linecomment & !multilinecomment) return CLOSEKEY;
69
"->"                    if(!includefound & !linecomment & !multilinecomment) return ARROW;
70
"="                     if(!includefound & !linecomment & !multilinecomment) return EQUALS;
71
"new"                   if(!includefound & !linecomment & !multilinecomment) return NEW;
72
"\""                    if(!includefound & !linecomment & !multilinecomment) return QUOTE;
73
[a-zA-Z][a-z_A-Z0-9]*   if(!includefound & !linecomment & !multilinecomment) {
74
                           yylval=(int)strdup(yytext);
75
                           return WORD;
76
                        }
77 20 jcastillo
"["                     if(!includefound & !linecomment & !multilinecomment) {
78
                           yylval=(int)strdup(yytext);
79
                           return OPENCORCH;
80
                        }
81
"]"                     if(!includefound & !linecomment & !multilinecomment) {
82
                           yylval=(int)strdup(yytext);
83
                           return CLOSECORCH;
84
                        }
85
 
86 11 jcastillo
"*"                     if(!includefound & !linecomment & !multilinecomment) return ASTERISCO;
87 15 jcastillo
"\n"                    includefound = 0; linecomment = 0; lineno++;
88
"\\\n"                  lineno++;/* no new line */
89 11 jcastillo
"$"                     /* ignore */
90
"."                     /* ignore */
91
":"                     /* ignore */
92
"#include"              includefound = 1;
93
"//"                    if (!multilinecomment) linecomment = 1;
94
"/*"                    if (!linecomment) multilinecomment = 1;
95
"*/"                    if (multilinecomment) multilinecomment = 0;
96
"-"
97 32 jcastillo
[.:~@#^!%/+'*_"&""?""|""\\"]
98 11 jcastillo
 
99 22 jcastillo
"("[ ]*"sc_uint"[ ]*"<"[ ]*[0-9]+[ ]*">"[ ]*")"
100
"("[ ]*"sc_biguint"[ ]*"<"[ ]*[0-9]+[ ]*">"[ ]*")"
101
"("[ ]*"sc_int"[ ]*"<"[ ]*[0-9]+[ ]*">"[ ]*")"
102
"("[ ]*"sc_bigint"[ ]*"<"[ ]*[0-9]+[ ]*">"[ ]*")"
103
"("[ ]*"int"[ ]*")"
104
 
105 11 jcastillo
"//"[ ]*[tT][rR][aA][nN][sS][lL][aA][tT][eE][ ]*[oO][fF][fF]  return TRANSLATEOFF;  /*Translate directive*/
106
"//"[ ]*[tT][rR][aA][nN][sS][lL][aA][tT][eE][ ]*[oO][nN]      return TRANSLATEON;  /*Translate directive*/
107
%%

powered by: WebSVN 2.1.0

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