diff libinterp/parse-tree/lex.ll @ 22857:d90e0c79aa45

Backed out changeset d5b58e234c37
author John W. Eaton <jwe@octave.org>
date Fri, 02 Dec 2016 14:16:43 -0500
parents d5b58e234c37
children 551ac93c984c
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll	Fri Dec 02 14:52:09 2016 +0100
+++ b/libinterp/parse-tree/lex.ll	Fri Dec 02 14:16:43 2016 -0500
@@ -2145,26 +2145,30 @@
   int
   lexical_feedback::previous_token_value (void) const
   {
-    return tokens.empty () ? 0 : tokens.front ()->token_value ();
+    const token *tok = tokens.front ();
+    return tok ? tok->token_value () : 0;
   }
 
   bool
   lexical_feedback::previous_token_value_is (int tok_val) const
   {
-    return tokens.empty () ? false : tokens.front ()->token_value_is (tok_val);
+    const token *tok = tokens.front ();
+    return tok ? tok->token_value_is (tok_val) : false;
   }
 
   void
   lexical_feedback::mark_previous_token_trailing_space (void)
   {
-    if (! tokens.empty () && ! previous_token_value_is ('\n'))
-      tokens.front ()->mark_trailing_space ();
+    token *tok = tokens.front ();
+    if (tok && ! previous_token_value_is ('\n'))
+      tok->mark_trailing_space ();
   }
 
   bool
   lexical_feedback::space_follows_previous_token (void) const
   {
-    return tokens.empty () ? false : tokens.front ()->space_follows_token ();
+    const token *tok = tokens.front ();
+    return tok ? tok->space_follows_token () : false;
   }
 
   bool
@@ -2190,25 +2194,24 @@
   bool
   lexical_feedback::previous_token_is_keyword (void) const
   {
-    return tokens.empty () ? false : tokens.front ()->is_keyword ();
+    const token *tok = tokens.front ();
+    return tok ? tok->is_keyword () : false;
   }
 
   bool
   lexical_feedback::previous_token_may_be_command (void) const
   {
-    return tokens.empty () ? false : tokens.front ()->may_be_command ();
+    const token *tok = tokens.front ();
+    return tok ? tok->may_be_command () : false;
   }
 
   void
   lexical_feedback::maybe_mark_previous_token_as_variable (void)
   {
-    if (! tokens.empty ())
-    {
-      token *tok = tokens.front ();
-
-      if (tok->is_symbol ())
-        pending_local_variables.insert (tok->symbol_name ());
-    }
+    token *tok = tokens.front ();
+
+    if (tok && tok->is_symbol ())
+      pending_local_variables.insert (tok->symbol_name ());
   }
 
   void
@@ -3200,7 +3203,7 @@
   {
     YYSTYPE *lval = yyget_lval (scanner);
     lval->tok_val = tok;
-    tokens.push_front (tok);
+    tokens.push (tok);
   }
 
   token *