GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
token.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1993-2017 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 #if ! defined (octave_token_h)
24 #define octave_token_h 1
25 
26 #include "octave-config.h"
27 
28 #include <string>
29 
30 #include "symtab.h"
31 
32 class
33 token
34 {
35 public:
36 
38  {
46  };
47 
49  {
64  };
65 
66  token (int tv, int l = -1, int c = -1);
67  token (int tv, bool is_keyword, int l = -1, int c = -1);
68  token (int tv, const char *s, int l = -1, int c = -1);
69  token (int tv, const std::string& s, int l = -1, int c = -1);
70  token (int tv, double d, const std::string& s = "",
71  int l = -1, int c = -1);
72  token (int tv, end_tok_type t, int l = -1, int c = -1);
73  token (int tv, symbol_table::symbol_record *s, int l = -1, int c = -1);
74  token (int tv, const std::string& mth, const std::string& cls,
75  int l = -1, int c = -1);
76 
77  ~token (void);
78 
79  void mark_may_be_command (void) { maybe_cmd = true; }
80  bool may_be_command (void) const { return maybe_cmd; }
81 
82  void mark_trailing_space (void) { tspc = true; }
83  bool space_follows_token (void) const { return tspc; }
84 
85  int token_value (void) const { return tok_val; }
86  bool token_value_is (int tv) const { return tv == tok_val; }
87 
88  int line (void) const { return line_num; }
89  int column (void) const { return column_num; }
90 
91  bool is_keyword (void) const
92  {
93  return type_tag == keyword_token || type_tag == ettype_token;
94  }
95 
96  bool is_symbol (void) const
97  {
98  return type_tag == sym_rec_token;
99  }
100 
101  std::string text (void) const;
102  std::string symbol_name (void) const;
103  double number (void) const;
104  token_type ttype (void) const;
105  end_tok_type ettype (void) const;
106  symbol_table::symbol_record *sym_rec (void);
107 
108  std::string superclass_method_name (void);
109  std::string superclass_class_name (void);
110 
111  std::string text_rep (void);
112 
113 private:
114 
115  // No copying!
116 
117  token (const token& tok);
118 
119  token& operator = (const token& tok);
120 
121  bool maybe_cmd;
122  bool tspc;
123  int line_num;
125  int tok_val;
127  union
128  {
130  double num;
133  struct
134  {
137  } sc;
138  };
140 };
141 
142 #endif
For example cd octave end example noindent changes the current working directory to an error message is printed and the working directory is not changed sc
Definition: dirfns.cc:120
bool token_value_is(int tv) const
Definition: token.h:86
int line_num
Definition: token.h:123
bool space_follows_token(void) const
Definition: token.h:83
token_type type_tag
Definition: token.h:126
int column(void) const
Definition: token.h:89
std::string orig_text
Definition: token.h:139
bool may_be_command(void) const
Definition: token.h:80
void mark_may_be_command(void)
Definition: token.h:79
int tok_val
Definition: token.h:125
OCTAVE_EXPORT octave_value_list any number nd example oindent prints the prompt xample Pick a number
Definition: input.cc:871
int line(void) const
Definition: token.h:88
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
Definition: ov-usr-fcn.cc:935
s
Definition: file-io.cc:2682
double num
Definition: token.h:130
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
end_tok_type
Definition: token.h:48
bool is_symbol(void) const
Definition: token.h:96
std::string * class_nm
Definition: token.h:136
bool is_keyword(void) const
Definition: token.h:91
bool is_keyword(const std::string &s)
Definition: lex.cc:4529
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
Definition: lu.cc:138
std::string * method_nm
Definition: token.h:135
int column_num
Definition: token.h:124
OCTAVE_EXPORT octave_value_list the first data row corresponds to an index of zero The a spreadsheet style form such as the file is read until end of file is reached The such as text
Definition: dlmread.cc:191
symbol_table::symbol_record * sr
Definition: token.h:132
void mark_trailing_space(void)
Definition: token.h:82
token_type
Definition: token.h:37
int token_value(void) const
Definition: token.h:85
bool tspc
Definition: token.h:122
std::string * str
Definition: token.h:129
bool maybe_cmd
Definition: token.h:121
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:854
end_tok_type et
Definition: token.h:131
Definition: token.h:32