[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #41032] Command function parsing: does handle
From: |
Michael C. Grant |
Subject: |
[Octave-bug-tracker] [bug #41032] Command function parsing: does handle certain patterns involving commas as parentheses |
Date: |
Mon, 30 Dec 2013 08:33:22 +0000 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.73.11 (KHTML, like Gecko) Version/7.0.1 Safari/537.73.11 |
Follow-up Comment #5, bug #41032 (project octave):
OK, this is a crazy freaking rabbit hole. Here are some observations. When I
say "bracket" below, I mean a parenthesis, curly brace, OR square bracket.
Furthermore, in the examples, I'm using the following modified version of the
command_test1 function:
function command_test1(varargin)
disp(sprintf('|%s|',varargin{:}));
* MATLAB sometimes allows the first token to be an operator, sometimes not. I
believe you are aware of those rules because I saw a reference to them in
another bug report/patch. This is irrelevant to me personally.
* The first token of a command cannot begin with a parenthesis (open or
closed). However, the first argument *can* begin with any other bracket, and
subsequent tokens can indeed begin with a parenthesis.
>> command_test1 (text]
command_test1 (text]
|
Error: Unbalanced or unexpected parenthesis or bracket.
>> command_test1 [text]
|[text]|
>> command_test1 {text}
|{text}|
>> command_test1 {text1} (text2)
|{text1}||(text2)|
* Except for the above distinction brackets are treated identically and
interchangeably. In other words, an open bracket is matched by *any* close
bracket. (It gets weirder; stay tuned.)
>> command_test1 {text]
|{text]|
* Whenever the total number of open brackets *equals* the number of close
brackets, we have what might be considered reasonable behavior: 1) single
quotes are treated as string delimiters, and must be matched; and 2)
whitespace separates tokens. Note that the quotes surrounding a
quote-delimited string are removed, even if the string forms just a part of a
command token.
>> command_test1 {'('[')')')'test'n'{}
command_test1 {'('[')')')'test'n'{}
|
Error: A MATLAB string constant is not terminated properly.
>> command_test1 {([)))'test''n'{}
|{([)))test'n{}|
* Whenever the total number of open brackets *is less OR greater* (yes, either
way) than the number of close brackets, the text is passed unprocessed,
including single quotes and whitespace.
>> command_test1 {'('[')')')'test''n'{'}
|{'('[')')')test'n{'}|
* Commands can be split across lines with '...'. No matter the state of the
brackets, the token ends. The ellipsis may be followed with arbitrary text,
which is dropped.
>> command_test1 {test1}...test2
{test3}
|{test1}||{test3}|
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?41032>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #41032] Command function parsing: does handle certain patterns involving commas as parentheses, anonymous, 2013/12/30
- Message not available
- [Octave-bug-tracker] [bug #41032] Command function parsing: does handle certain patterns involving commas as parentheses, Michael C. Grant, 2013/12/30
- [Octave-bug-tracker] [bug #41032] Command function parsing: does handle certain patterns involving commas as parentheses, John W. Eaton, 2013/12/30
- [Octave-bug-tracker] [bug #41032] Command function parsing: does handle certain patterns involving commas as parentheses, Michael C. Grant, 2013/12/30
- [Octave-bug-tracker] [bug #41032] Command function parsing: does handle certain patterns involving commas as parentheses,
Michael C. Grant <=
- [Octave-bug-tracker] [bug #41032] Command function parsing: does handle certain patterns involving commas as parentheses, John W. Eaton, 2013/12/30
- [Octave-bug-tracker] [bug #41032] Command function parsing: does handle certain patterns involving commas as parentheses, Michael C. Grant, 2013/12/30
- [Octave-bug-tracker] [bug #41032] Command function parsing: does handle certain patterns involving commas as parentheses, Michael C. Grant, 2013/12/30
- [Octave-bug-tracker] [bug #41032] Command function parsing: does handle certain patterns involving commas as parentheses, Michael C. Grant, 2013/12/30