Added SemanticAnalyzer ElseIfStatement
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
This commit is contained in:
parent
6fa57cf319
commit
195440e9d9
@ -309,9 +309,18 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
|||||||
@Override
|
@Override
|
||||||
public TypeCheckResult analyze(IfElseNode toCheck) {
|
public TypeCheckResult analyze(IfElseNode toCheck) {
|
||||||
var resultIf = toCheck.ifStatement.accept(this);
|
var resultIf = toCheck.ifStatement.accept(this);
|
||||||
|
var validElseIf = true;
|
||||||
|
|
||||||
|
if(toCheck.elseIfStatements.size() != 0) {
|
||||||
|
for(IfNode ifNode : toCheck.elseIfStatements) {
|
||||||
|
var resultIfFor = ifNode.accept(this);
|
||||||
|
validElseIf = validElseIf && resultIfFor.isValid();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(toCheck.elseStatement != null){
|
if(toCheck.elseStatement != null){
|
||||||
var resultElse = toCheck.elseStatement.accept(this);
|
var resultElse = toCheck.elseStatement.accept(this);
|
||||||
return new TypeCheckResult(resultIf.isValid() && resultElse.isValid(), new BaseType(TypeEnum.VOID));
|
return new TypeCheckResult(resultIf.isValid() && resultElse.isValid() && validElseIf, new BaseType(TypeEnum.VOID));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user