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

Subversion Repositories sc2v

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

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 39 vasiliev
.pos\(\)                if(!includefound & !linecomment & !multilinecomment) return POS;
50 11 jcastillo
sensitive_neg           if(!includefound & !linecomment & !multilinecomment) return SENSITIVE_NEG;
51
sensitive               if(!includefound & !linecomment & !multilinecomment) return SENSITIVE;
52
"<<"                    if(!includefound & !linecomment & !multilinecomment) return SENSIBLE;
53
sc_in                   if(!includefound & !linecomment & !multilinecomment) return SC_IN;
54
sc_out                  if(!includefound & !linecomment & !multilinecomment) return SC_OUT;
55
sc_signal               if(!includefound & !linecomment & !multilinecomment) return SC_SIGNAL;
56
"bool"                  if(!includefound & !linecomment & !multilinecomment) return BOOL;
57
"<"                     if(!includefound & !linecomment & !multilinecomment) return MENOR;
58
">"                     if(!includefound & !linecomment & !multilinecomment) return MAYOR;
59 35 jcastillo
sc_int                  if(!includefound & !linecomment & !multilinecomment) return SC_SGNREG;
60
sc_uint                if(!includefound & !linecomment & !multilinecomment) return SC_REG;
61
sc_bigint               if(!includefound & !linecomment & !multilinecomment) return SC_SGNREG;
62 16 jcastillo
sc_biguint              if(!includefound & !linecomment & !multilinecomment) return SC_REG;
63 11 jcastillo
\(                      if(!includefound & !linecomment & !multilinecomment) return OPENPAR;
64
\)                      if(!includefound & !linecomment & !multilinecomment) return CLOSEPAR;
65
;                       if(!includefound & !linecomment & !multilinecomment) return SEMICOLON;
66
"enum"                  if(!includefound & !linecomment & !multilinecomment) return ENUM;
67
","                     if(!includefound & !linecomment & !multilinecomment) return COLON;
68
"{"                     if(!includefound & !linecomment & !multilinecomment) return OPENKEY;
69
"}"                     if(!includefound & !linecomment & !multilinecomment) return CLOSEKEY;
70
"->"                    if(!includefound & !linecomment & !multilinecomment) return ARROW;
71
"="                     if(!includefound & !linecomment & !multilinecomment) return EQUALS;
72
"new"                   if(!includefound & !linecomment & !multilinecomment) return NEW;
73
"\""                    if(!includefound & !linecomment & !multilinecomment) return QUOTE;
74
[a-zA-Z][a-z_A-Z0-9]*   if(!includefound & !linecomment & !multilinecomment) {
75
                           yylval=(int)strdup(yytext);
76
                           return WORD;
77
                        }
78 20 jcastillo
"["                     if(!includefound & !linecomment & !multilinecomment) {
79
                           yylval=(int)strdup(yytext);
80
                           return OPENCORCH;
81
                        }
82
"]"                     if(!includefound & !linecomment & !multilinecomment) {
83
                           yylval=(int)strdup(yytext);
84
                           return CLOSECORCH;
85
                        }
86
 
87 11 jcastillo
"*"                     if(!includefound & !linecomment & !multilinecomment) return ASTERISCO;
88 15 jcastillo
"\n"                    includefound = 0; linecomment = 0; lineno++;
89
"\\\n"                  lineno++;/* no new line */
90 11 jcastillo
"$"                     /* ignore */
91
"."                     /* ignore */
92
":"                     /* ignore */
93 39 vasiliev
"#include"                          includefound = 1;
94
"#ifdef"                            if (!multilinecomment) linecomment = 1;
95
"#define"                           if (!multilinecomment) linecomment = 1;
96
"#ifndef"                           if (!multilinecomment) linecomment = 1;
97
"#else"                             if (!multilinecomment) linecomment = 1;
98
"#endif"                            if (!multilinecomment) linecomment = 1;
99 11 jcastillo
"//"                    if (!multilinecomment) linecomment = 1;
100
"/*"                    if (!linecomment) multilinecomment = 1;
101
"*/"                    if (multilinecomment) multilinecomment = 0;
102
"-"
103 32 jcastillo
[.:~@#^!%/+'*_"&""?""|""\\"]
104 11 jcastillo
 
105 22 jcastillo
"("[ ]*"sc_uint"[ ]*"<"[ ]*[0-9]+[ ]*">"[ ]*")"
106
"("[ ]*"sc_biguint"[ ]*"<"[ ]*[0-9]+[ ]*">"[ ]*")"
107
"("[ ]*"sc_int"[ ]*"<"[ ]*[0-9]+[ ]*">"[ ]*")"
108
"("[ ]*"sc_bigint"[ ]*"<"[ ]*[0-9]+[ ]*">"[ ]*")"
109
"("[ ]*"int"[ ]*")"
110
 
111 11 jcastillo
"//"[ ]*[tT][rR][aA][nN][sS][lL][aA][tT][eE][ ]*[oO][fF][fF]  return TRANSLATEOFF;  /*Translate directive*/
112
"//"[ ]*[tT][rR][aA][nN][sS][lL][aA][tT][eE][ ]*[oO][nN]      return TRANSLATEON;  /*Translate directive*/
113
%%

powered by: WebSVN 2.1.0

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