Adding new source file faustio.ml, including class waveio and class csvio.
[Faustine.git] / interpretor / faust-0.9.47mr3 / compiler / errors / errormsg.cpp
1 /************************************************************************
2 ************************************************************************
3 FAUST compiler
4 Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale
5 ---------------------------------------------------------------------
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 ************************************************************************
20 ************************************************************************/
21
22
23
24 #include "errormsg.hh"
25 #include "boxes.hh"
26 #include "ppbox.hh"
27 #include <iostream>
28 using namespace std;
29
30 const char* yyfilename = "????";
31 int gErrorCount = 0;
32 Tree DEFLINEPROP = tree(symbol("DefLineProp"));
33
34 void yyerror(char* msg)
35 {
36 fprintf(stderr, "%s:%d:%s\n", yyfilename, yylineno, msg);
37 gErrorCount++;
38 }
39
40 void evalerror(const char* filename, int linenum, const char* msg, Tree exp)
41 {
42 fprintf(stderr, "%s:%d: ERROR: %s ", filename, linenum, msg);
43 print(exp,stderr); fprintf(stderr, "\n");
44 gErrorCount++;
45 }
46
47 void evalerrorbox(const char* filename, int linenum, const char* msg, Tree exp)
48 {
49 cerr << filename << ':' << linenum << ": ERROR: " << msg << " : " << boxpp(exp) << endl;
50 gErrorCount++;
51 }
52
53 void evalwarning(const char* filename, int linenum, const char* msg, Tree exp)
54 {
55 fprintf(stderr, "%s:%d: WARNING: %s ", filename, linenum, msg);
56 print(exp,stderr); fprintf(stderr, "\n");
57 }
58
59 void evalremark(const char* filename, int linenum, const char* msg, Tree exp)
60 {
61 fprintf(stderr, "%s:%d: REMARK: %s ", filename, linenum, msg);
62 print(exp,stderr); fprintf(stderr, "\n");
63 }
64
65
66 void setDefProp(Tree sym, const char* filename, int lineno)
67 {
68 setProperty(sym, DEFLINEPROP, cons(tree(filename), tree(lineno)));
69 }
70
71
72 const char* getDefFileProp(Tree sym)
73 {
74 Tree n;
75 if (getProperty(sym, DEFLINEPROP, n)) {
76 return name(hd(n)->node().getSym());
77 } else {
78 return "????";
79 }
80 }
81
82 int getDefLineProp(Tree sym)
83 {
84 Tree n;
85 if (getProperty(sym, DEFLINEPROP, n)) {
86 return tl(n)->node().getInt();
87 } else {
88 return -1;
89 }
90 }