Fixed issue 46: Array literals in GEL
git-svn-id: http://google-refine.googlecode.com/svn/trunk@833 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
bf6ba51700
commit
0709ec3f92
@ -12,6 +12,7 @@ Fixes:
|
||||
- Issue 28: "mql-like preview is not properly unquoting numbers"
|
||||
- Issue 45: "Renaming Cells with Ctrl-Enter produced ERROR"
|
||||
Tentative fix for a concurrent bug.
|
||||
- Issue 46: "Array literals in GEL"
|
||||
|
||||
Changes:
|
||||
- Moved unit tests from JUnit to TestNG
|
||||
|
@ -0,0 +1,25 @@
|
||||
package com.metaweb.gridworks.expr.functions.arrays;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONWriter;
|
||||
|
||||
import com.metaweb.gridworks.gel.Function;
|
||||
|
||||
public class ArgsToArray implements Function {
|
||||
|
||||
public Object call(Properties bindings, Object[] args) {
|
||||
return args;
|
||||
}
|
||||
|
||||
public void write(JSONWriter writer, Properties options)
|
||||
throws JSONException {
|
||||
|
||||
writer.object();
|
||||
writer.key("description"); writer.value("Returns all arguments passed to it as an array");
|
||||
writer.key("params"); writer.value("a1, a2, ...");
|
||||
writer.key("returns"); writer.value("array");
|
||||
writer.endObject();
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
import com.metaweb.gridworks.expr.Evaluable;
|
||||
import com.metaweb.gridworks.expr.ParsingException;
|
||||
import com.metaweb.gridworks.expr.functions.arrays.ArgsToArray;
|
||||
import com.metaweb.gridworks.gel.Scanner.NumberToken;
|
||||
import com.metaweb.gridworks.gel.Scanner.RegexToken;
|
||||
import com.metaweb.gridworks.gel.Scanner.Token;
|
||||
@ -197,6 +198,12 @@ public class Parser {
|
||||
} else {
|
||||
throw makeException("Missing )");
|
||||
}
|
||||
} else if (_token.type == TokenType.Delimiter && _token.text.equals("[")) { // [ ... ] array
|
||||
next(true); // swallow [
|
||||
|
||||
List<Evaluable> args = parseExpressionList("]");
|
||||
|
||||
eval = new FunctionCallExpr(makeArray(args), new ArgsToArray());
|
||||
} else {
|
||||
throw makeException("Missing number, string, identifier, regex, or parenthesized expression");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user