|
@@ -339,10 +339,22 @@ export class IVProgParser {
|
|
let n_lines = dim1;
|
|
let n_lines = dim1;
|
|
let n_columns = dim2;
|
|
let n_columns = dim2;
|
|
let initial = null;
|
|
let initial = null;
|
|
|
|
+ let dim_is_id = false;
|
|
|
|
+ if(dim1 instanceof Expressions.VariableLiteral || dim2 instanceof Expressions.VariableLiteral) {
|
|
|
|
+ dim_is_id = true;
|
|
|
|
+ if(dimensions > 1 && (dim1 == null || dim2 == null)) {
|
|
|
|
+ // TODO better error message
|
|
|
|
+ throw new Error("array with id dimension must have all dims");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
if(isConst && equalsToken.type !== this.lexerClass.EQUAL ) {
|
|
if(isConst && equalsToken.type !== this.lexerClass.EQUAL ) {
|
|
throw SyntaxErrorFactory.const_not_init(sourceInfo);
|
|
throw SyntaxErrorFactory.const_not_init(sourceInfo);
|
|
}
|
|
}
|
|
if(equalsToken.type === this.lexerClass.EQUAL) {
|
|
if(equalsToken.type === this.lexerClass.EQUAL) {
|
|
|
|
+ if(dim_is_id) {
|
|
|
|
+ // TODO better error message
|
|
|
|
+ throw new Error("Cannot init array with a variable as dimesion");
|
|
|
|
+ }
|
|
this.pos += 1
|
|
this.pos += 1
|
|
initial = this.parseArrayLiteral(typeString);
|
|
initial = this.parseArrayLiteral(typeString);
|
|
}
|
|
}
|