diff src/parse.y @ 8150:283989f2da9b

make null assignment matlab compatible
author Jaroslav Hajek <highegg@gmail.com>
date Fri, 26 Sep 2008 11:52:01 -0400
parents 4f1ebb704545
children 47a3d2f829e4
line wrap: on
line diff
--- a/src/parse.y	Thu Sep 25 13:44:51 2008 -0400
+++ b/src/parse.y	Fri Sep 26 11:52:01 2008 -0400
@@ -65,6 +65,7 @@
 #include "oct-map.h"
 #include "ov-fcn-handle.h"
 #include "ov-usr-fcn.h"
+#include "ov-null-mat.h"
 #include "toplev.h"
 #include "pager.h"
 #include "parse.h"
@@ -577,13 +578,19 @@
 
 matrix		: '[' ']'
 		  {
-		    $$ = new tree_constant (octave_value (Matrix ()));
+		    $$ = new tree_constant (octave_null_matrix::instance);
 		    lexer_flags.looking_at_matrix_or_assign_lhs = false;
 		    lexer_flags.pending_local_variables.clear ();
 		  }
 		| '[' ';' ']'
 		  {
-		    $$ = new tree_constant (octave_value (Matrix ()));
+		    $$ = new tree_constant (octave_null_matrix::instance);
+		    lexer_flags.looking_at_matrix_or_assign_lhs = false;
+		    lexer_flags.pending_local_variables.clear ();
+		  }
+		| '[' ',' ']'
+		  {
+		    $$ = new tree_constant (octave_null_matrix::instance);
 		    lexer_flags.looking_at_matrix_or_assign_lhs = false;
 		    lexer_flags.pending_local_variables.clear ();
 		  }
@@ -1721,9 +1728,17 @@
       {
 	std::string txt = tok_val->text ();
 
-	char delim = op == DQ_STRING ? '"' : '\'';
-
-	octave_value tmp (txt, delim);
+        char delim = op == DQ_STRING ? '"' : '\'';
+        octave_value tmp (txt, delim);
+
+        if (txt.empty ())
+          {
+            if (op == DQ_STRING)
+              tmp = octave_null_str::instance;
+            else
+              tmp = octave_null_sq_str::instance;
+          }
+
 	retval = new tree_constant (tmp, l, c);
 
 	if (op == DQ_STRING)