comparison libinterp/parse-tree/pt-fcn-handle.cc @ 16681:d3619d4d267c

recognize character string at beginning of statement (bug #38926, #38958) * lex.ll ("'"): Always begin a character string if at the beginning of a statement. * oct-parse.in.yy (stmt_begin): New non-terminal. (anon_fcn_handle, if_cmd_list1, elseif_clause, switch_case, loop_command): Use it. * pt-fcn-handle.cc, for.tst, if.tst, switch.tst, while.tst: New tests.
author John W. Eaton <jwe@octave.org>
date Sat, 18 May 2013 16:21:32 -0400
parents 2fc554ffbc28
children d63878346099
comparison
equal deleted inserted replaced
16680:de79cdbbdf7c 16681:d3619d4d267c
157 %!test 157 %!test
158 %! h = @(x) sin (x); 158 %! h = @(x) sin (x);
159 %! g = @(f, x) h (x); 159 %! g = @(f, x) h (x);
160 %! f = @() g (@(x) h, pi); 160 %! f = @() g (@(x) h, pi);
161 %! assert (f () == sin (pi)); 161 %! assert (f () == sin (pi));
162
163 The next two tests are intended to test parsing of a character string
164 vs. hermitian operator at the beginning of an anonymous function
165 expression. The use of ' for the character string and the spacing is
166 intentional, so don't change it.
167
168 %!test
169 %! f = @() 'foo';
170 %! assert (f (), 'foo');
171
172 %!test
173 %! f = @()'foo';
174 %! assert (f (), 'foo');
162 */ 175 */
163 176
164 octave_value_list 177 octave_value_list
165 tree_anon_fcn_handle::rvalue (int nargout) 178 tree_anon_fcn_handle::rvalue (int nargout)
166 { 179 {