142
|
1 // token.h -*- C++ -*- |
|
2 /* |
|
3 |
1009
|
4 Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton |
142
|
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 |
1315
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
142
|
21 |
|
22 */ |
|
23 |
383
|
24 #if !defined (octave_token_h) |
|
25 #define octave_token_h 1 |
142
|
26 |
1297
|
27 #if defined (__GNUG__) |
|
28 #pragma interface |
|
29 #endif |
|
30 |
142
|
31 class symbol_record; |
|
32 |
453
|
33 class |
|
34 token |
142
|
35 { |
|
36 public: |
|
37 enum token_type |
|
38 { |
|
39 generic_token, |
|
40 string_token, |
|
41 double_token, |
|
42 ettype_token, |
|
43 pttype_token, |
|
44 sym_rec_token, |
|
45 }; |
|
46 |
|
47 enum end_tok_type |
|
48 { |
|
49 simple_end, |
|
50 for_end, |
|
51 function_end, |
|
52 if_end, |
|
53 while_end, |
1489
|
54 try_catch_end, |
915
|
55 unwind_protect_end, |
142
|
56 }; |
|
57 |
|
58 enum plot_tok_type |
|
59 { |
476
|
60 replot = 1, |
142
|
61 two_dee = 2, |
|
62 three_dee = 3, |
|
63 }; |
|
64 |
|
65 token (int l = -1, int c = -1); |
|
66 token (char *s, int l = -1, int c = -1); |
581
|
67 token (double d, char *s = 0, int l = -1, int c = -1); |
142
|
68 token (end_tok_type t, int l = -1, int c = -1); |
|
69 token (plot_tok_type t, int l = -1, int c = -1); |
|
70 token (symbol_record *s, int l = -1, int c = -1); |
|
71 |
|
72 ~token (void); |
|
73 |
|
74 int line (void); |
|
75 int column (void); |
|
76 |
|
77 char *string (void); |
|
78 double number (void); |
|
79 end_tok_type ettype (void); |
|
80 plot_tok_type pttype (void); |
|
81 symbol_record *sym_rec (void); |
|
82 |
581
|
83 char *text_rep (void); |
|
84 |
142
|
85 private: |
1288
|
86 token (const token& tok); |
|
87 token& operator = (const token& tok); |
|
88 |
142
|
89 int line_num; |
|
90 int column_num; |
|
91 token_type type_tag; |
|
92 union |
|
93 { |
|
94 char *str; |
|
95 double num; |
|
96 end_tok_type et; |
|
97 plot_tok_type pt; |
|
98 symbol_record *sr; |
|
99 }; |
581
|
100 char *orig_text; |
142
|
101 }; |
|
102 |
|
103 #endif |
|
104 |
|
105 /* |
|
106 ;;; Local Variables: *** |
|
107 ;;; mode: C++ *** |
|
108 ;;; page-delimiter: "^/\\*" *** |
|
109 ;;; End: *** |
|
110 */ |