changeset 14292:d1810b2ca809

iskeyword: don't consider get and set as keywords * lex.ll (is_keyword): Don't recognize get and set as keywords. (Fiskeyword): Don't include get and set in the list of keywords. * grammar.txi: Remove get and set from the list of keywords.
author John W. Eaton <jwe@octave.org>
date Mon, 30 Jan 2012 23:03:00 -0500
parents 2633baa831e2
children 71a198cca35b
files src/lex.ll
diffstat 1 files changed, 21 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lex.ll	Mon Jan 30 08:22:32 2012 -0500
+++ b/src/lex.ll	Mon Jan 30 23:03:00 2012 -0500
@@ -3451,7 +3451,14 @@
 bool
 is_keyword (const std::string& s)
 {
-  return octave_kw_hash::in_word_set (s.c_str (), s.length ()) != 0;
+  // Parsing function names like "set.property_name" inside
+  // classdef-style class definitions is simplified by handling the
+  // "set" and "get" portions of the names using the same mechanism as
+  // is used for keywords.  However, they are not really keywords in
+  // the language, so omit them from the list of possible keywords.
+
+  return (octave_kw_hash::in_word_set (s.c_str (), s.length ()) != 0
+          && ! (s == "set" || s == "get"));
 }
 
 DEFUN (iskeyword, args, ,
@@ -3474,10 +3481,22 @@
 
   if (argc == 1)
     {
+      // Neither set and get are keywords.  See the note in the
+      // is_keyword function for additional details.
+
       string_vector lst (TOTAL_KEYWORDS);
 
+      int j = 0;
+
       for (int i = 0; i < TOTAL_KEYWORDS; i++)
-        lst[i] = wordlist[i].name;
+        {
+          std::string tmp = wordlist[i].name;
+
+          if (! (tmp == "set" || tmp == "get"))
+            lst[j++] = tmp;
+        }
+
+      lst.resize (j);
 
       retval = Cell (lst.sort ());
     }