author | Mario de Sousa <msousa@fe.up.pt> |
Thu, 08 Nov 2012 17:31:50 +0000 | |
changeset 721 | 5dc33058e041 |
parent 678 | 01e33dc2a255 |
child 725 | bfbe4aca6b77 |
permissions | -rw-r--r-- |
678
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1 |
/* |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
2 |
* matiec - a compiler for the programming languages defined in IEC 61131-3 |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
3 |
* Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt) |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
4 |
* Copyright (C) 2007-2011 Laurent Bessard and Edouard Tisserant |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
5 |
* |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
6 |
* This program is free software: you can redistribute it and/or modify |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
7 |
* it under the terms of the GNU General Public License as published by |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
8 |
* the Free Software Foundation, either version 3 of the License, or |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
9 |
* (at your option) any later version. |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
10 |
* |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
11 |
* This program is distributed in the hope that it will be useful, |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
14 |
* GNU General Public License for more details. |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
15 |
* |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
16 |
* You should have received a copy of the GNU General Public License |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
17 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
18 |
* |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
19 |
* |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
20 |
* This code is made available on the understanding that it will not be |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
21 |
* used in safety-critical situations without a full and competent review. |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
22 |
*/ |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
23 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
24 |
/* |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
25 |
* An IEC 61131-3 compiler. |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
26 |
* |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
27 |
* Based on the |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
28 |
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
29 |
* |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
30 |
*/ |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
31 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
32 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
33 |
/* |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
34 |
* Some classes to help with debuging. |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
35 |
* |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
36 |
* These classes will print out the current state of a symbol or a portion of the Abstract Syntax Tree. |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
37 |
*/ |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
38 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
39 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
40 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
41 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
42 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
43 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
44 |
#include "../absyntax/visitor.hh" |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
45 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
46 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
47 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
48 |
class print_symbol_c: public fcall_visitor_c { |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
49 |
public: |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
50 |
static void print(symbol_c *symbol); |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
51 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
52 |
protected: |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
53 |
void fcall(symbol_c *symbol); |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
54 |
/* AST symbols with extra data have their own specialised methods for printing that data */ |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
55 |
void *visit(il_instruction_c *symbol); |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
56 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
57 |
private: |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
58 |
static print_symbol_c *singleton; |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
59 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
60 |
void dump_symbol(symbol_c* symbol); |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
61 |
}; |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
62 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
63 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
64 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
65 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
66 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
67 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
68 |
class print_ast_c: public fcall_iterator_visitor_c { |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
69 |
public: |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
70 |
static void print(symbol_c *symbol); |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
71 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
72 |
protected: |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
73 |
void prefix_fcall(symbol_c *symbol); |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
74 |
void suffix_fcall(symbol_c *symbol); |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
75 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
76 |
private: |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
77 |
static print_ast_c *singleton; |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
78 |
}; |
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
79 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
80 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
81 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
82 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
83 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
84 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
85 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
86 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
87 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
88 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
89 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
90 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
91 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
92 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
93 |
|
01e33dc2a255
Add classes to print status of AST (use only for debugging!)
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
94 |