This commit is contained in:
Denis Molony 2017-03-18 15:35:34 +11:00
parent e090ca8525
commit c532516f23
2 changed files with 3 additions and 55 deletions

View File

@ -64,8 +64,7 @@ class Expression extends AbstractValue implements Iterable<Value>
switch (ch)
{
case '@': // function
String functionText = getBalancedText (line.substring (ptr));
// System.out.println ("Func : " + functionText);
String functionText = getFunctionCall (line.substring (ptr));
ptr += functionText.length ();
values.add (Function.getInstance (parent, cell, functionText));
break;
@ -288,7 +287,7 @@ class Expression extends AbstractValue implements Iterable<Value>
}
// called for functions and expressions
static String getBalancedText (String text)
private String getBalancedText (String text)
{
int ptr = text.indexOf ('('); // find first left parenthesis
if (ptr < 0)
@ -333,7 +332,7 @@ class Expression extends AbstractValue implements Iterable<Value>
}
// receives a string starting with the function call
static String getFunctionCall (String text)
private String getFunctionCall (String text)
{
if (text.charAt (0) != '@')
throw new IllegalArgumentException ("Bad function name: " + text);

View File

@ -27,57 +27,6 @@ public class ValueList implements Iterable<Value>
}
}
// public ValueList (Sheet parent, Cell cell, String text)
// {
// this.parent = parent;
//
// int ptr = 0;
// while (ptr < text.length ())
// {
// if (text.charAt (ptr) == '@') // function
// {
// String functionText = Expression.getBalancedText (text.substring (ptr));
// Value v = new Expression (parent, cell, functionText).reduce ();
// values.add (v);
// ptr += functionText.length ();
// }
// else
// {
// String item = getNextItem (text, ptr);
// int pos = item.indexOf ("...");
// if (pos > 0) // range
// {
// Address from = new Address (item.substring (0, pos));
// Address to = new Address (item.substring (pos + 3));
// Range range = new Range (parent, from, to);
//
// for (Address address : range)
// values.add (parent.getCell (address));
// }
// else // cell/number/expression
// {
// Value v = new Expression (parent, cell, item).reduce ();
// values.add (v);
// }
// ptr += item.length ();
// }
//
// if (ptr < text.length () && text.charAt (ptr) == ',')
// ptr++;
// if (ptr < text.length () && text.charAt (ptr) == ')')
// break;
// }
// }
// return substring of text from ptr up to the next comma
// private String getNextItem (String text, int ptr)
// {
// int p = ptr;
// while (++p < text.length () && text.charAt (p) != ',')
// ;
// return text.substring (ptr, p);
// }
public int size ()
{
return values.size ();