26#if ! defined (octave_token_h)
27#define octave_token_h 1
29#include "octave-config.h"
77 : m_type_tag (invalid_token)
81 : m_beg_pos (beg_pos), m_end_pos (end_pos), m_tok_id (id), m_leading_comments (lst)
85 : m_beg_pos (beg_pos), m_end_pos (end_pos), m_tok_id (id), m_type_tag (is_kw ? keyword_token : generic_token), m_leading_comments (lst)
89 : m_beg_pos (beg_pos), m_end_pos (end_pos), m_tok_id (id), m_type_tag (string_token), m_tok_info (s), m_leading_comments (lst)
93 : m_beg_pos (beg_pos), m_end_pos (end_pos), m_tok_id (id), m_type_tag (string_token), m_tok_info (s), m_leading_comments (lst)
97 : m_beg_pos (beg_pos), m_end_pos (end_pos), m_tok_id (id), m_type_tag (numeric_token), m_tok_info (val), m_orig_text (s), m_leading_comments (lst)
101 : m_beg_pos (beg_pos), m_end_pos (end_pos), m_tok_id (id), m_type_tag (ettype_token), m_tok_info (t), m_leading_comments (lst)
105 : m_beg_pos (beg_pos), m_end_pos (end_pos), m_tok_id (id), m_type_tag (scls_name_token), m_tok_info (meth, cls), m_leading_comments (lst)
108 OCTAVE_DEFAULT_COPY_MOVE_DELETE (
token)
110 void mark_may_be_command () { m_maybe_cmd =
true; }
116 operator bool ()
const {
return m_type_tag != invalid_token; }
120 bool token_is (
int id)
const {
return m_tok_id == id; }
123 return tok ? token_is (tok->
token_id ()) :
false;
139 int line ()
const {
return m_beg_pos.line (); }
140 int column ()
const {
return m_beg_pos.column (); }
144 return m_type_tag == keyword_token || m_type_tag == ettype_token;
147 bool isstring ()
const {
return m_type_tag == string_token; }
149 std::string
text ()
const {
return m_tok_info.text (); }
157 std::string
text_rep ()
const {
return m_orig_text; }
161 class superclass_info
165 superclass_info (
const std::string& meth,
const std::string& cls)
166 : m_method_name (meth), m_class_name (cls)
169 OCTAVE_DEFAULT_COPY_MOVE_DELETE (superclass_info)
171 std::string method_name ()
const {
return m_method_name; }
173 std::string class_name ()
const {
return m_class_name; }
181 std::string m_method_name;
185 std::string m_class_name;
192 tok_info (
const char *s) : m_value (std::string (s)) { }
194 tok_info (
const std::string& str) : m_value (str) { }
198 tok_info (end_tok_type et) : m_value (et) { }
200 tok_info (
const std::string& meth,
const std::string& cls) : m_value (superclass_info (meth, cls)) { }
202 OCTAVE_DEFAULT_CONSTRUCT_COPY_MOVE_DELETE (tok_info)
204 std::string text ()
const
206 panic_unless (std::holds_alternative<std::string> (m_value));
207 return std::get<std::string> (m_value);
212 panic_unless (std::holds_alternative<octave_value> (m_value));
213 return std::get<octave_value> (m_value);
218 panic_unless (std::holds_alternative<end_tok_type> (m_value));
219 return std::get<end_tok_type> (m_value);
223 superclass_method_name ()
const
225 panic_unless (std::holds_alternative<superclass_info> (m_value));
226 return std::get<superclass_info> (m_value).method_name ();
230 superclass_class_name ()
const
232 panic_unless (std::holds_alternative<superclass_info> (m_value));
233 return std::get<superclass_info> (m_value).class_name ();
238 std::variant<std::string, octave_value, end_tok_type, superclass_info> m_value;
243 bool m_maybe_cmd {
false};
252 token_type m_type_tag {generic_token};
256 std::string m_orig_text;
266OCTAVE_END_NAMESPACE(octave)
void trailing_comments(const comment_list &lst)
std::string text_rep() const
std::string superclass_class_name() const
token(int id, bool is_kw, const filepos &beg_pos, const filepos &end_pos, const comment_list &lst=comment_list())
comment_list leading_comments() const
void mark_trailing_space()
void leading_comments(const comment_list &lst)
token(int id, const octave_value &val, const std::string &s, const filepos &beg_pos, const filepos &end_pos, const comment_list &lst=comment_list())
bool token_is(const token *tok) const
token(int id, const std::string &s, const filepos &beg_pos, const filepos &end_pos, const comment_list &lst=comment_list())
void end_pos(const filepos &pos)
std::string superclass_method_name() const
end_tok_type ettype() const
comment_list trailing_comments() const
token(int id, end_tok_type t, const filepos &beg_pos, const filepos &end_pos, const comment_list &lst=comment_list())
void beg_pos(const filepos &pos)
token(int id, const std::string &meth, const std::string &cls, const filepos &beg_pos, const filepos &end_pos, const comment_list &lst=comment_list())
token(int id, const char *s, const filepos &beg_pos, const filepos &end_pos, const comment_list &lst=comment_list())
token(int id, const filepos &beg_pos, const filepos &end_pos, const comment_list &lst=comment_list())
bool token_is(int id) const
bool may_be_command() const
octave_value number() const
bool space_follows_token() const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define panic_unless(cond)