diff --git a/prism/src/parser/ast/ConstantList.java b/prism/src/parser/ast/ConstantList.java index 4f892269..05ff0012 100644 --- a/prism/src/parser/ast/ConstantList.java +++ b/prism/src/parser/ast/ConstantList.java @@ -49,12 +49,28 @@ public class ConstantList extends ASTElement // This is to just to provide positional info. private Vector nameIdents = new Vector(); - // Constructor - + /** Constructor */ public ConstantList() { } + /** Constructor from a Values object, i.e., a list of name=value tuples */ + public ConstantList(Values constValues) throws PrismLangException + { + for (int i = 0; i < constValues.getNumValues(); i++) { + Type type = constValues.getType(i); + if (type.equals(TypeBool.getInstance()) || + type.equals(TypeInt.getInstance()) || + type.equals(TypeDouble.getInstance())) { + addConstant(new ExpressionIdent(constValues.getName(i)), + new ExpressionLiteral(type, constValues.getValue(i)), + type); + } else { + throw new PrismLangException("Unsupported type for constant " + constValues.getName(i)); + } + } + } + // Set methods public void addConstant(ExpressionIdent n, Expression c, Type t)