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