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