142
|
1 // token.h -*- C++ -*- |
|
2 /* |
|
3 |
383
|
4 Copyright (C) 1992, 1993, 1994 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 |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
383
|
24 #if !defined (octave_token_h) |
|
25 #define octave_token_h 1 |
142
|
26 |
453
|
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, |
|
54 }; |
|
55 |
|
56 enum plot_tok_type |
|
57 { |
|
58 two_dee = 2, |
|
59 three_dee = 3, |
|
60 }; |
|
61 |
|
62 token (int l = -1, int c = -1); |
|
63 token (char *s, int l = -1, int c = -1); |
|
64 token (double d, int l = -1, int c = -1); |
|
65 token (end_tok_type t, int l = -1, int c = -1); |
|
66 token (plot_tok_type t, int l = -1, int c = -1); |
|
67 token (symbol_record *s, int l = -1, int c = -1); |
|
68 |
|
69 ~token (void); |
|
70 |
|
71 int line (void); |
|
72 int column (void); |
|
73 |
|
74 char *string (void); |
|
75 double number (void); |
|
76 end_tok_type ettype (void); |
|
77 plot_tok_type pttype (void); |
|
78 symbol_record *sym_rec (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 }; |
|
93 |
|
94 #endif |
|
95 |
|
96 /* |
|
97 ;;; Local Variables: *** |
|
98 ;;; mode: C++ *** |
|
99 ;;; page-delimiter: "^/\\*" *** |
|
100 ;;; End: *** |
|
101 */ |