diff 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
line wrap: on
line diff
--- a/libinterp/parse-tree/token.h
+++ b/libinterp/parse-tree/token.h
@@ -61,26 +61,32 @@
       unwind_protect_end
     };
 
-  token (int l = -1, int c = -1);
-  token (const std::string& s, int l = -1, int c = -1);
-  token (double d, const std::string& s = std::string (),
+  token (int tv, int l = -1, int c = -1);
+  token (int tv, const std::string& s, int l = -1, int c = -1);
+  token (int tv, double d, const std::string& s = std::string (),
          int l = -1, int c = -1);
-  token (end_tok_type t, int l = -1, int c = -1);
-  token (symbol_table::symbol_record *s, int l = -1, int c = -1);
-  token (symbol_table::symbol_record *cls,
+  token (int tv, end_tok_type t, int l = -1, int c = -1);
+  token (int tv, symbol_table::symbol_record *s, int l = -1, int c = -1);
+  token (int tv, symbol_table::symbol_record *cls,
          symbol_table::symbol_record *pkg, int l = -1, int c = -1);
-  token (symbol_table::symbol_record *mth,
+  token (int tv, symbol_table::symbol_record *mth,
          symbol_table::symbol_record *cls,
          symbol_table::symbol_record *pkg, int l = -1, int c = -1);
 
   ~token (void);
 
-  int line (void) { return line_num; }
-  int column (void) { return column_num; }
+  void mark_trailing_space (void) { tspc = true; }
+  bool space_follows_token (void) const { return tspc; }
+
+  int token_value (void) const { return tok_val; }
+  bool token_value_is (int tv) const { return tv == tok_val; }
 
-  std::string text (void);
-  double number (void);
-  end_tok_type ettype (void);
+  int line (void) const { return line_num; }
+  int column (void) const { return column_num; }
+
+  std::string text (void) const;
+  double number (void) const;
+  end_tok_type ettype (void) const;
   symbol_table::symbol_record *sym_rec (void);
 
   symbol_table::symbol_record *method_rec (void);
@@ -100,8 +106,10 @@
 
   token& operator = (const token& tok);
 
+  bool tspc;
   int line_num;
   int column_num;
+  int tok_val;
   token_type type_tag;
   union
     {