use of org.csstudio.autocomplete.parser.engine.expr.ExprMissing in project yamcs-studio by yamcs.
the class ExprParser method parseFunction.
private void parseFunction(ExprToken token, ExprLexer lexer) throws ExprException, IOException {
Expr c = current;
current = null;
ExprToken e = null;
ArrayList<Expr> args = new ArrayList<Expr>();
boolean complete = false;
while ((e = lexer.next()) != null) {
if (e.type.equals(ExprTokenType.Comma)) {
if ((e = lexer.next()) != null) {
current = null;
parseToken(lexer, e);
args.add(current == null ? new ExprMissing() : current);
} else {
args.add(new ExprMissing());
}
} else if (e.type.equals(ExprTokenType.CloseBracket)) {
// end
complete = true;
current = c;
break;
} else {
// first arg
parseToken(lexer, e);
args.add(current == null ? new ExprMissing() : current);
}
}
ExprFunction f = new ExprFunction(token.val, (Expr[]) args.toArray(new Expr[0]));
f.setComplete(complete);
setValue(f);
}
use of org.csstudio.autocomplete.parser.engine.expr.ExprMissing in project yamcs-studio by yamcs.
the class ExprParser method parseConditionalOperator.
private void parseConditionalOperator(ExprToken token, ExprLexer lexer) throws ExprException, IOException {
Expr c = current;
current = null;
ExprToken e = null;
ExprConditionalOperator co = new ExprConditionalOperator(c, null, null);
while ((e = lexer.next()) != null) {
if (e.type.equals(ExprTokenType.Colon)) {
if ((e = lexer.next()) != null) {
current = null;
parseToken(lexer, e);
co.setValueIfFalse(current == null ? new ExprMissing() : current);
} else {
co.setValueIfFalse(new ExprMissing());
}
break;
} else {
parseToken(lexer, e);
co.setValueIfTrue(current == null ? new ExprMissing() : current);
}
}
setValue(co);
}
use of org.csstudio.autocomplete.parser.engine.expr.ExprMissing in project yamcs-studio by yamcs.
the class ExprParser method parseArray.
private void parseArray(ExprLexer lexer) throws ExprException, IOException {
Expr c = current;
current = null;
ExprToken e = null;
int cols = -1;
int count = 0;
ArrayList<Expr> args = new ArrayList<Expr>();
while ((e = lexer.next()) != null) {
if (e.type.equals(ExprTokenType.Comma)) {
// if (current == null)
// throw new ExprException("Arrays cannot contain empty values");
args.add(current == null ? new ExprMissing() : current);
current = null;
count++;
} else if (e.type.equals(ExprTokenType.SemiColon)) {
// if (current == null)
// throw new ExprException("Arrays cannot contain empty values");
args.add(current == null ? new ExprMissing() : current);
current = null;
count++;
// if (count == 0) {
// throw new ExprException("Array rows must contain at least one element");
// }
// if (cols != -1 && count != cols) {
// throw new ExprException("Array rows must be equal sizes");
// }
cols = count;
count = 0;
} else if (e.type.equals(ExprTokenType.CloseBrace)) {
args.add(current == null ? new ExprMissing() : current);
current = c;
int rows = 1;
if (cols == -1)
cols = args.size();
else
rows = args.size() / cols;
ExprArray a = new ExprArray(rows, cols);
for (int i = 0; i < args.size(); i++) {
a.set(0, i, (Expr) args.get(i));
}
setValue(a);
break;
} else {
parseToken(lexer, e);
}
}
}
Aggregations