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

Subversion Repositories sc2v

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

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

powered by: WebSVN 2.1.0

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