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, |
915
|
54 unwind_protect_end, |
142
|
55 }; |
|
56 |
|
57 enum plot_tok_type |
|
58 { |
476
|
59 replot = 1, |
142
|
60 two_dee = 2, |
|
61 three_dee = 3, |
|
62 }; |
|
63 |
|
64 token (int l = -1, int c = -1); |
|
65 token (char *s, int l = -1, int c = -1); |
581
|
66 token (double d, char *s = 0, int l = -1, int c = -1); |
142
|
67 token (end_tok_type t, int l = -1, int c = -1); |
|
68 token (plot_tok_type t, int l = -1, int c = -1); |
|
69 token (symbol_record *s, int l = -1, int c = -1); |
|
70 |
|
71 ~token (void); |
|
72 |
|
73 int line (void); |
|
74 int column (void); |
|
75 |
|
76 char *string (void); |
|
77 double number (void); |
|
78 end_tok_type ettype (void); |
|
79 plot_tok_type pttype (void); |
|
80 symbol_record *sym_rec (void); |
|
81 |
581
|
82 char *text_rep (void); |
|
83 |
142
|
84 private: |
1288
|
85 token (const token& tok); |
|
86 token& operator = (const token& tok); |
|
87 |
142
|
88 int line_num; |
|
89 int column_num; |
|
90 token_type type_tag; |
|
91 union |
|
92 { |
|
93 char *str; |
|
94 double num; |
|
95 end_tok_type et; |
|
96 plot_tok_type pt; |
|
97 symbol_record *sr; |
|
98 }; |
581
|
99 char *orig_text; |
142
|
100 }; |
|
101 |
|
102 #endif |
|
103 |
|
104 /* |
|
105 ;;; Local Variables: *** |
|
106 ;;; mode: C++ *** |
|
107 ;;; page-delimiter: "^/\\*" *** |
|
108 ;;; End: *** |
|
109 */ |