Mercurial > hg > octave-lyh
diff libinterp/parse-tree/lex.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 | a89cf57ba3a5 |
children | b28062b977fd db7f07b22b9b |
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.h +++ b/libinterp/parse-tree/lex.h @@ -188,15 +188,36 @@ } // Direct access. - token *at (size_t n) { return buffer.at (n); } - const token *at (size_t n) const { return buffer.at (n); } + token *at (size_t n) + { + return empty () ? 0 : buffer.at (n); + } + + const token *at (size_t n) const + { + return empty () ? 0 : buffer.at (n); + } // Most recently pushed. - token *front (void) { return buffer.front (); } - const token *front (void) const { return buffer.front (); } + token *front (void) + { + return empty () ? 0 : buffer.front (); + } + + const token *front (void) const + { + return empty () ? 0 : buffer.front (); + } - token *back (void) { return buffer.back (); } - const token *back (void) const { return buffer.back (); } + token *back (void) + { + return empty () ? 0 : buffer.back (); + } + + const token *back (void) const + { + return empty () ? 0 : buffer.back (); + } // Number of elements currently in the buffer, max of sz. size_t size (void) const { return buffer.size (); } @@ -253,6 +274,14 @@ void reset (void); + int previous_token_value (void) const; + + bool previous_token_value_is (int tok_val) const; + + void mark_previous_token_trailing_space (void); + + bool space_follows_previous_token (void) const; + // true means that we have encountered eof on the input stream. bool end_of_input;