comparison libinterp/parse-tree/token.h @ 16255:12bf6a3f8c45

store more info in token value class * token.h, token.cc: Store token ID and trailing space info * lex.h, lex.ll (lexical_feedback::token_cache): Handle storing and retrieving extra info in the lexer.
author John W. Eaton <jwe@octave.org>
date Mon, 11 Mar 2013 14:08:50 -0400
parents ec9c6222ef5a
children b28062b977fd db7f07b22b9b
comparison
equal deleted inserted replaced
16253:a89cf57ba3a5 16255:12bf6a3f8c45
59 while_end, 59 while_end,
60 try_catch_end, 60 try_catch_end,
61 unwind_protect_end 61 unwind_protect_end
62 }; 62 };
63 63
64 token (int l = -1, int c = -1); 64 token (int tv, int l = -1, int c = -1);
65 token (const std::string& s, int l = -1, int c = -1); 65 token (int tv, const std::string& s, int l = -1, int c = -1);
66 token (double d, const std::string& s = std::string (), 66 token (int tv, double d, const std::string& s = std::string (),
67 int l = -1, int c = -1); 67 int l = -1, int c = -1);
68 token (end_tok_type t, int l = -1, int c = -1); 68 token (int tv, end_tok_type t, int l = -1, int c = -1);
69 token (symbol_table::symbol_record *s, int l = -1, int c = -1); 69 token (int tv, symbol_table::symbol_record *s, int l = -1, int c = -1);
70 token (symbol_table::symbol_record *cls, 70 token (int tv, symbol_table::symbol_record *cls,
71 symbol_table::symbol_record *pkg, int l = -1, int c = -1); 71 symbol_table::symbol_record *pkg, int l = -1, int c = -1);
72 token (symbol_table::symbol_record *mth, 72 token (int tv, symbol_table::symbol_record *mth,
73 symbol_table::symbol_record *cls, 73 symbol_table::symbol_record *cls,
74 symbol_table::symbol_record *pkg, int l = -1, int c = -1); 74 symbol_table::symbol_record *pkg, int l = -1, int c = -1);
75 75
76 ~token (void); 76 ~token (void);
77 77
78 int line (void) { return line_num; } 78 void mark_trailing_space (void) { tspc = true; }
79 int column (void) { return column_num; } 79 bool space_follows_token (void) const { return tspc; }
80 80
81 std::string text (void); 81 int token_value (void) const { return tok_val; }
82 double number (void); 82 bool token_value_is (int tv) const { return tv == tok_val; }
83 end_tok_type ettype (void); 83
84 int line (void) const { return line_num; }
85 int column (void) const { return column_num; }
86
87 std::string text (void) const;
88 double number (void) const;
89 end_tok_type ettype (void) const;
84 symbol_table::symbol_record *sym_rec (void); 90 symbol_table::symbol_record *sym_rec (void);
85 91
86 symbol_table::symbol_record *method_rec (void); 92 symbol_table::symbol_record *method_rec (void);
87 symbol_table::symbol_record *class_rec (void); 93 symbol_table::symbol_record *class_rec (void);
88 symbol_table::symbol_record *package_rec (void); 94 symbol_table::symbol_record *package_rec (void);
98 104
99 token (const token& tok); 105 token (const token& tok);
100 106
101 token& operator = (const token& tok); 107 token& operator = (const token& tok);
102 108
109 bool tspc;
103 int line_num; 110 int line_num;
104 int column_num; 111 int column_num;
112 int tok_val;
105 token_type type_tag; 113 token_type type_tag;
106 union 114 union
107 { 115 {
108 std::string *str; 116 std::string *str;
109 double num; 117 double num;