in shell/core/src/main/java/org/apache/felix/gogo/runtime/Parser.java [389:480]
public Array array()
{
Token start = start("[", "array");
Boolean isMap = null;
List<Token> list = new ArrayList<>();
Map<Token, Token> map = new LinkedHashMap<>();
while (true)
{
Token key = next();
if (key == null)
{
throw new EOFError(tz.line, tz.column, "unexpected EOT", getMissing(), "]");
}
if (Token.eq("]", key))
{
push(key);
break;
}
if (Token.eq("\n", key))
{
continue;
}
if (Token.eq("{", key) || Token.eq(";", key) || Token.eq("&", key) || Token.eq("&&", key) || Token.eq("||", key)
|| Token.eq("|", key) || Token.eq("|&", key) || Token.eq(")", key) || Token.eq("}", key) || Token.eq("=", key))
{
throw new SyntaxError(key.line(), key.column(), "unexpected token '" + key + "' while looking for array key");
}
if (Token.eq("(", key))
{
push(key);
key = sequence();
}
if (Token.eq("[", key))
{
push(key);
key = array();
}
if (isMap == null)
{
Token n = next();
if (n == null)
{
throw new EOFError(tz.line, tz.column, "unexpected EOF while looking for array token", getMissing(), "]");
}
isMap = Token.eq("=", n);
push(n);
}
if (isMap)
{
expect("=");
Token val = next();
if (val == null)
{
throw new EOFError(tz.line, tz.column, "unexpected EOF while looking for array value", getMissing(), "0");
}
else if (Token.eq(";", val) || Token.eq("&", val) || Token.eq("&&", val) || Token.eq("||", val) || Token.eq("|", val) || Token.eq("|&", val)
|| Token.eq(")", key) || Token.eq("}", key) || Token.eq("=", key))
{
throw new SyntaxError(key.line(), key.column(), "unexpected token '" + key + "' while looking for array value");
}
else if (Token.eq("[", val))
{
push(val);
val = array();
}
else if (Token.eq("(", val))
{
push(val);
val = sequence();
}
else if (Token.eq("{", val))
{
push(val);
val = closure();
}
map.put(key, val);
}
else
{
list.add(key);
}
}
Token end = end("]");
if (isMap == null || !isMap)
{
return new Array(whole(start, end), list, null);
}
else
{
return new Array(whole(start, end), null, map);
}
}