|
@@ -322,12 +322,26 @@ export class SemanticAnalyser {
|
|
|
this.checkCommands(type, cmd.commands, optional);
|
|
|
return false;
|
|
|
} else if (cmd instanceof For) {
|
|
|
- this.checkCommand(type, cmd.assignment, optional);
|
|
|
- const resultType = this.evaluateExpressionType(cmd.condition);
|
|
|
- if (!resultType.isCompatible(Types.BOOLEAN)) {
|
|
|
- throw ProcessorErrorFactory.for_condition_type_full(cmd.condition.toString(), cmd.sourceInfo);
|
|
|
+ const var_type = this.evaluateExpressionType(cmd.for_id);
|
|
|
+ if (!var_type.isCompatible(Types.INTEGER)) {
|
|
|
+ // TODO better error message
|
|
|
+ throw new Error("A variavel do comando repita_para deve ser do tipo inteiro");
|
|
|
+ }
|
|
|
+ const from_type = this.evaluateExpressionType(cmd.for_from);
|
|
|
+ if (!from_type.isCompatible(Types.INTEGER)) {
|
|
|
+ // TODO better error message
|
|
|
+ throw new Error("o paramentro 'de' do comando repita_para deve ser do tipo inteiro");
|
|
|
+ }
|
|
|
+ const to_type = this.evaluateExpressionType(cmd.for_to);
|
|
|
+ if (!to_type.isCompatible(Types.INTEGER)) {
|
|
|
+ // TODO better error message
|
|
|
+ throw new Error("o paramentro 'ate' do comando repita_para deve ser do tipo inteiro");
|
|
|
+ }
|
|
|
+ const pass_type = this.evaluateExpressionType(cmd.for_pass);
|
|
|
+ if (!pass_type.isCompatible(Types.INTEGER)) {
|
|
|
+ // TODO better error message
|
|
|
+ throw new Error("o paramentro 'passo' do comando repita_para deve ser do tipo inteiro");
|
|
|
}
|
|
|
- this.checkCommand(type, cmd.increment, optional);
|
|
|
this.checkCommands(type, cmd.commands, optional);
|
|
|
return false;
|
|
|
} else if (cmd instanceof Switch) {
|