diff src/lex.l @ 4930:bdb307dc8613

[project @ 2004-08-05 04:55:26 by jwe]
author jwe
date Thu, 05 Aug 2004 04:55:26 +0000
parents b11223097ad4
children ec98115062d1
line wrap: on
line diff
--- a/src/lex.l	Tue Aug 03 20:45:34 2004 +0000
+++ b/src/lex.l	Thu Aug 05 04:55:26 2004 +0000
@@ -603,8 +603,13 @@
 // Function handles.
 %}
 
-@{IDENT} {
-    TOK_PUSH_AND_RETURN (&yytext[1], FCN_HANDLE);
+"@" {
+    current_input_column++;
+    lexer_flags.quote_is_transpose = false;
+    lexer_flags.cant_be_identifier = false;
+    lexer_flags.convert_spaces_to_comma = false;
+    lexer_flags.looking_at_function_handle++;
+    COUNT_TOK_AND_RETURN ('@');
   }
 
 %{
@@ -2480,12 +2485,24 @@
       return STRUCT_ELT;
     }
 
+  int kw_token = is_keyword_token (tok);
+
+  if (lexer_flags.looking_at_function_handle)
+    {
+      if (kw_token)
+	{
+	  error ("function handles may not refer to keywords");
+
+	  return LEXICAL_ERROR;
+	}
+      else
+	TOK_PUSH_AND_RETURN (tok, FCN_HANDLE);
+    }
+
   // If we have a regular keyword, or a plot STYLE, return it.
   // Keywords can be followed by identifiers (TOK_RETURN handles
   // that).
 
-  int kw_token = is_keyword_token (tok);
-
   if (kw_token)
     {
       if (kw_token < 0)
@@ -2630,6 +2647,9 @@
   parsed_function_name = false;
   parsing_nested_function = 0;
 
+  // Not initiallly looking at a function handle.
+  looking_at_function_handle = 0;
+
   // Not parsing a function return or parameter list.
   looking_at_return_list = false;
   looking_at_parameter_list = false;