1
|
1 /* |
|
2 |
1827
|
3 Copyright (C) 1996 John W. Eaton |
1
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1
|
20 |
|
21 */ |
|
22 |
383
|
23 #if !defined (octave_tree_base_h) |
|
24 #define octave_tree_base_h 1 |
1
|
25 |
1297
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
581
|
30 class ostream; |
|
31 |
|
32 // How to print the code that the trees represent. |
|
33 |
|
34 class |
|
35 tree_print_code |
|
36 { |
|
37 public: |
|
38 virtual ~tree_print_code (void) { } |
|
39 |
|
40 virtual void print_code (ostream& os) = 0; |
|
41 |
|
42 void reset_indent_level (void) |
|
43 { curr_print_indent_level = 0; } |
|
44 |
|
45 void increment_indent_level (void) |
|
46 { curr_print_indent_level += 2; } |
1
|
47 |
581
|
48 void decrement_indent_level (void) |
|
49 { curr_print_indent_level -= 2; } |
|
50 |
|
51 void print_code_new_line (ostream& os); |
|
52 |
|
53 void print_code_indent (ostream& os); |
|
54 |
|
55 void print_code_reset (void); |
|
56 |
|
57 private: |
|
58 static int curr_print_indent_level; |
1827
|
59 static bool beginning_of_line; |
581
|
60 }; |
|
61 |
|
62 // Base class for the parse tree. |
|
63 |
1
|
64 class |
581
|
65 tree : public tree_print_code |
1
|
66 { |
|
67 public: |
578
|
68 tree (int l = -1, int c = -1) |
1
|
69 { |
578
|
70 line_num = l; |
|
71 column_num = c; |
|
72 } |
1
|
73 |
581
|
74 virtual int line (void) const |
|
75 { return line_num; } |
1
|
76 |
581
|
77 virtual int column (void) const |
|
78 { return column_num; } |
143
|
79 |
578
|
80 private: |
143
|
81 int line_num; |
|
82 int column_num; |
1
|
83 }; |
|
84 |
|
85 #endif |
|
86 |
|
87 /* |
|
88 ;;; Local Variables: *** |
|
89 ;;; mode: C++ *** |
|
90 ;;; End: *** |
|
91 */ |