comparison libinterp/parse-tree/token.cc @ 15195:2fc554ffbc28

split libinterp from src * libinterp: New directory. Move all files from src directory here except Makefile.am, main.cc, main-cli.cc, mkoctfile.in.cc, mkoctfilr.in.sh, octave-config.in.cc, octave-config.in.sh. * libinterp/Makefile.am: New file, extracted from src/Makefile.am. * src/Makefile.am: Delete everything except targets and definitions needed to build and link main and utility programs. * Makefile.am (SUBDIRS): Include libinterp in the list. * autogen.sh: Run config-module.sh in libinterp/dldfcn directory, not src/dldfcn directory. * configure.ac (AC_CONFIG_SRCDIR): Use libinterp/octave.cc, not src/octave.cc. (DL_LDFLAGS, LIBOCTINTERP): Use libinterp, not src. (AC_CONFIG_FILES): Include libinterp/Makefile in the list. * find-docstring-files.sh: Look in libinterp, not src. * gui/src/Makefile.am (liboctgui_la_CPPFLAGS): Find header files in libinterp, not src.
author John W. Eaton <jwe@octave.org>
date Sat, 18 Aug 2012 16:23:39 -0400
parents src/parse-tree/token.cc@909a2797935b
children 947cf10c94da 12bf6a3f8c45
comparison
equal deleted inserted replaced
15194:0f0b795044c3 15195:2fc554ffbc28
1 /*
2
3 Copyright (C) 1993-2012 John W. Eaton
4
5 This file is part of Octave.
6
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20
21 */
22
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27 #include <cassert>
28
29 #include "error.h"
30 #include "oct-obj.h"
31 #include "symtab.h"
32 #include "token.h"
33 #include "utils.h"
34
35 token::token (int l, int c)
36 {
37 line_num = l;
38 column_num = c;
39 type_tag = generic_token;
40 }
41
42 token::token (const std::string& s, int l, int c)
43 {
44 line_num = l;
45 column_num = c;
46 type_tag = string_token;
47 str = new std::string (s);
48 }
49
50 token::token (double d, const std::string& s, int l, int c)
51 {
52 line_num = l;
53 column_num = c;
54 type_tag = double_token;
55 num = d;
56 orig_text = s;
57 }
58
59 token::token (end_tok_type t, int l, int c)
60 {
61 line_num = l;
62 column_num = c;
63 type_tag = ettype_token;
64 et = t;
65 }
66
67 token::token (symbol_table::symbol_record *s, int l, int c)
68 {
69 line_num = l;
70 column_num = c;
71 type_tag = sym_rec_token;
72 sr = s;
73 }
74
75 token::token (symbol_table::symbol_record *cls,
76 symbol_table::symbol_record *pkg, int l, int c)
77 {
78 line_num = l;
79 column_num = c;
80 type_tag = meta_rec_token;
81 mc.cr = cls;
82 mc.pr = pkg;
83 }
84
85 token::token (symbol_table::symbol_record *mth,
86 symbol_table::symbol_record *cls,
87 symbol_table::symbol_record *pkg, int l, int c)
88 {
89 line_num = l;
90 column_num = c;
91 type_tag = scls_rec_token;
92 sc.mr = mth;
93 sc.cr = cls;
94 sc.pr = pkg;
95 }
96
97 token::~token (void)
98 {
99 if (type_tag == string_token)
100 delete str;
101 }
102
103 std::string
104 token::text (void)
105 {
106 assert (type_tag == string_token);
107 return *str;
108 }
109
110 double
111 token::number (void)
112 {
113 assert (type_tag == double_token);
114 return num;
115 }
116
117 token::end_tok_type
118 token::ettype (void)
119 {
120 assert (type_tag == ettype_token);
121 return et;
122 }
123
124 symbol_table::symbol_record *
125 token::sym_rec (void)
126 {
127 assert (type_tag == sym_rec_token);
128 return sr;
129 }
130
131 symbol_table::symbol_record *
132 token::method_rec (void)
133 {
134 assert (type_tag == scls_rec_token);
135 return sc.mr;
136 }
137
138 symbol_table::symbol_record *
139 token::class_rec (void)
140 {
141 assert (type_tag == scls_rec_token);
142 return sc.cr;
143 }
144
145 symbol_table::symbol_record *
146 token::package_rec (void)
147 {
148 assert (type_tag == scls_rec_token);
149 return sc.pr;
150 }
151
152 symbol_table::symbol_record *
153 token::meta_class_rec (void)
154 {
155 assert (type_tag == meta_rec_token);
156 return mc.cr;
157 }
158
159 symbol_table::symbol_record *
160 token::meta_package_rec (void)
161 {
162 assert (type_tag == meta_rec_token);
163 return mc.pr;
164 }
165
166 std::string
167 token::text_rep (void)
168 {
169 return orig_text;
170 }