File: message.cc

package info (click to toggle)
freehdl 0.0.8-2.2
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 8,632 kB
  • ctags: 10,443
  • sloc: cpp: 45,275; sh: 11,405; yacc: 4,206; ansic: 2,026; lex: 486; perl: 430; makefile: 390; tcl: 100
file content (105 lines) | stat: -rw-r--r-- 2,919 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* printing errors and such

   Copyright (C) 1994-1997 University of Dortmund
   Department of Electrical Engineering, AG SIV

   VAUL is free software; you can redistribute it and/or modify it
   under the terms of the GNU Library General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.

   VAUL is distributed in the hope that it will be useful, but WITHOUT
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General
   Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with VAUL; see the file COPYING.LIB.  If not, write
   to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
   Boston, MA 02111-1307 USA.


*/

#include <freehdl/vaul-parser.h>
#include <freehdl/vaul-dunit.h>
#include <freehdl/vaul-printer.h>

void vaul_error_printer::info(const char *fmt, ...)
{
    va_list ap;
    va_start(ap, fmt);
    vinfo(fmt, ap);
    va_end(ap);
}

void vaul_error_printer::error(const char *fmt, ...)
{
    va_list ap;
    va_start(ap, fmt);
    vinfo(fmt, ap);
    va_end(ap);
    n_errors++;
}

void vaul_error_printer::vinfo(const char *fmt, va_list ap)
{
    vfprintf(log, fmt, ap);
    int l = strlen(fmt);
    if(l < 2 || fmt[l-2] != '%' || fmt[l-1] != '~')
	fprintf(log, "\n");
}

void vaul_parser::BisonError(const char *msg)
{
    error("%s %C", msg, lex);
    lex->stop();
}

void vaul_parser::vinfo(const char *fmt, va_list ap)
{
  if (announced_scope != cur_scope && cur_scope != NULL) 
    {
      pIIR_DeclarativeRegion s = cur_scope;
      while (s->declarator == NULL && s->continued)
	s = s->continued;
      while (s->declarator == NULL && s->declarative_region)
	s = s->declarative_region;
      if (announced_scope != s) 
	{
	  announced_scope = s;
	  if (s->is(VAUL_TOP_SCOPE))
	    vaul_error_printer::info ("%!at top level:", lex, 0);
	  else if (s->is(IR_ARCHITECTURE_DECLARATION))
	    vaul_error_printer::info ("%!in %n(%n):", lex, 0,
				      s->continued, s->declarator);
	  else
	    vaul_error_printer::info ("%!in %n:", lex, 0, s);
	}
    }
  if (fmt[0] != '%' || !strchr(":?!~", fmt[1]))
    fprintf (log, "%?", lex);
  if (strstr (fmt, "XXX"))
    XXX_seen = true;
  vaul_error_printer::vinfo (fmt, ap);
}

void
vaul_parser::print_node (FILE *f, tree_base_node *n)
{
  if (options.fullnames)
    {
      if (n && n->is(IR_DECLARATION)
	  && pIIR_Declaration(n)->declarative_region
	  && pIIR_Declaration(n)->declarative_region != announced_scope
	  && !pIIR_Declaration(n)->declarative_region->is(VAUL_TOP_SCOPE))
	{
	  pIIR_DeclarativeRegion as = announced_scope;
	  announced_scope = NULL;
	  fprintf (f, "%n::", pIIR_Declaration(n)->declarative_region);
	  announced_scope = as;
	}
    }

  vaul_printer::print_node (f, n);
}