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