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

Subversion Repositories sc2v

[/] [sc2v/] [trunk/] [src/] [sc2v_step3.y] - Blame information for rev 14

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

Line No. Rev Author Line
1 4 jcastillo
/* -----------------------------------------------------------------------------
2
 *
3 14 jcastillo
 *  SystemC to Verilog Translator v0.3
4 4 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
%{
26
#include 
27
#include 
28
 
29 12 jcastillo
  int module_found = 0;
30
  int concat_found = 0;
31
  int opened_pars;
32
  int *concat_par_num;
33
  int concats_found = 0;
34
  char *aux;
35
  void yyerror (const char *str)
36
  {
37
    fprintf (stderr, "error: %s\n", str);
38
  }
39 4 jcastillo
 
40 12 jcastillo
  int yywrap ()
41
  {
42
    return 1;
43
  }
44 4 jcastillo
 
45 12 jcastillo
  main ()
46
  {
47
    concat_par_num = (int *) malloc (16 * sizeof (int));
48
    *concat_par_num = 0;
49
    yyparse ();
50 4 jcastillo
 
51 12 jcastillo
  }
52
 
53 4 jcastillo
%}
54
 
55
%token WORD
56
%token OPENPAR CLOSEPAR
57 12 jcastillo
%token MODULE
58 4 jcastillo
 
59 12 jcastillo
%% commands:
60
/* empty */
61
|commands command;
62 4 jcastillo
 
63
 
64
command:
65 12 jcastillo
module
66
|
67
closepar
68
|
69
concat
70
|
71
openpar;
72 4 jcastillo
 
73
module:
74 12 jcastillo
MODULE
75
{
76
  module_found = 1;
77
  opened_pars++;
78
  printf ("%s", (char *) $1);
79
};
80
 
81 4 jcastillo
openpar:
82 12 jcastillo
OPENPAR
83
{
84
  printf ("(");
85
  opened_pars++;
86
};
87 4 jcastillo
 
88
closepar:
89 12 jcastillo
CLOSEPAR
90
{
91
  if (module_found)
92
    {
93
      printf (")");
94
      opened_pars--;
95
      module_found = 0;
96
    }
97
  else if (concat_found)
98
    {
99
      if (opened_pars == *(concat_par_num + concats_found))
100 4 jcastillo
        {
101 12 jcastillo
          printf ("}");
102
          concats_found--;
103
          if (concats_found == 0)
104
            {
105
              concat_found = 0;
106
            }
107
        }
108
      else
109
        {
110
          printf (")");
111
        }
112
      opened_pars--;
113
    }
114
  else
115
    {
116
      opened_pars--;
117
      printf (")");
118
    }
119
};
120 4 jcastillo
 
121
concat:
122 12 jcastillo
WORD
123
{
124
  aux = (char *) $1;
125
  aux++;
126
  printf ("{%s", aux);
127
  concat_found = 1;
128
  opened_pars++;
129
  concats_found++;
130
  *(concat_par_num + concats_found) = opened_pars;
131
};

powered by: WebSVN 2.1.0

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