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 / token.h < prev    next >
C/C++ Source or Header  |  1995-01-03  |  2KB  |  103 lines

  1. // token.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_token_h)
  25. #define octave_token_h 1
  26.  
  27. class symbol_record;
  28.  
  29. class
  30. token
  31. {
  32. public:
  33.   enum token_type
  34.     {
  35.       generic_token,
  36.       string_token,
  37.       double_token,
  38.       ettype_token,
  39.       pttype_token,
  40.       sym_rec_token,
  41.     };
  42.  
  43.   enum end_tok_type
  44.     {
  45.       simple_end,
  46.       for_end,
  47.       function_end,
  48.       if_end,
  49.       while_end,
  50.       unwind_protect_end,
  51.     };
  52.  
  53.   enum plot_tok_type
  54.     {
  55.       replot = 1,
  56.       two_dee = 2,
  57.       three_dee = 3,
  58.     };
  59.  
  60.   token (int l = -1, int c = -1);
  61.   token (char *s, int l = -1, int c = -1);
  62.   token (double d, char *s = 0, int l = -1, int c = -1);
  63.   token (end_tok_type t, int l = -1, int c = -1);
  64.   token (plot_tok_type t, int l = -1, int c = -1);
  65.   token (symbol_record *s, int l = -1, int c = -1);
  66.  
  67.  ~token (void);
  68.  
  69.   int line (void);
  70.   int column (void);
  71.  
  72.   char *string (void);
  73.   double number (void);
  74.   end_tok_type ettype (void);
  75.   plot_tok_type pttype (void);
  76.   symbol_record *sym_rec (void);
  77.  
  78.   char *text_rep (void);
  79.  
  80. private:
  81.   int line_num;
  82.   int column_num;
  83.   token_type type_tag;
  84.   union
  85.     {
  86.       char *str;
  87.       double num;
  88.       end_tok_type et;
  89.       plot_tok_type pt;
  90.       symbol_record *sr;
  91.     };
  92.   char *orig_text;
  93. };
  94.  
  95. #endif
  96.  
  97. /*
  98. ;;; Local Variables: ***
  99. ;;; mode: C++ ***
  100. ;;; page-delimiter: "^/\\*" ***
  101. ;;; End: ***
  102. */
  103.