home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / octave-1.1.1p1-base.tgz / octave-1.1.1p1-base.tar / fsf / octave / src / tree-base.h < prev    next >
C/C++ Source or Header  |  1995-01-03  |  2KB  |  90 lines

  1. // tree-base.h                                           -*- C++ -*-
  2. /*
  3.  
  4. Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton
  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.  
  24. #if !defined (octave_tree_base_h)
  25. #define octave_tree_base_h 1
  26.  
  27. class ostream;
  28.  
  29. // How to print the code that the trees represent.
  30.  
  31. class
  32. tree_print_code
  33. {
  34. public:
  35.   virtual ~tree_print_code (void) { }
  36.  
  37.   virtual void print_code (ostream& os) = 0;
  38.  
  39.   void reset_indent_level (void)
  40.     { curr_print_indent_level = 0; }
  41.  
  42.   void increment_indent_level (void)
  43.     { curr_print_indent_level += 2; }
  44.  
  45.   void decrement_indent_level (void)
  46.     { curr_print_indent_level -= 2; }
  47.  
  48.   void print_code_new_line (ostream& os);
  49.  
  50.   void print_code_indent (ostream& os);
  51.  
  52.   void print_code_reset (void);
  53.  
  54. private:
  55.   static int curr_print_indent_level;
  56.   static int beginning_of_line;
  57. };
  58.  
  59. // Base class for the parse tree.
  60.  
  61. class
  62. tree : public tree_print_code
  63. {
  64. public:
  65.   tree (int l = -1, int c = -1)
  66.     {
  67.       line_num = l;
  68.       column_num = c;
  69.     }
  70.  
  71.   virtual int line (void) const
  72.     { return line_num; }
  73.  
  74.   virtual int column (void) const
  75.     { return column_num; }
  76.  
  77. private:
  78.   int line_num;
  79.   int column_num;
  80. };
  81.  
  82. #endif
  83.  
  84. /*
  85. ;;; Local Variables: ***
  86. ;;; mode: C++ ***
  87. ;;; page-delimiter: "^/\\*" ***
  88. ;;; End: ***
  89. */
  90.