Browse Source

[FIX] Boolean literal checking wrong values.

[FIX] IfThenElse not properly checking for IF token after ELSE
Lucas de Souza 6 years ago
parent
commit
32a1d79893
1 changed files with 5 additions and 2 deletions
  1. 5 2
      js/ast/ivprogParser.js

+ 5 - 2
js/ast/ivprogParser.js

@@ -346,7 +346,7 @@ export class IVProgParser {
   }
 
   getBoolLiteral (token) {
-    const val = token.type === this.lexerClass.RK_True ? true : false;
+    const val = token.type === this.lexerClass.RK_TRUE ? true : false;
     return new Expressions.BoolLiteral(val);
   }
 
@@ -634,11 +634,14 @@ export class IVProgParser {
     if(maybeElse.type === this.lexerClass.RK_ELSE) {
       this.pos++;
       this.consumeNewLines();
+      const maybeIf = this.getToken();
       let elseBlock = null;
       if(this.checkOpenCurly(true)) {
         elseBlock = this.parseCommandBlock();
-      } else {
+      } else if(maybeIf.type === this.lexerClass.RK_IF) {
         elseBlock = this.parseIfThenElse();
+      } else {
+        throw SyntaxError.createError('if or {', maybeIf);
       }
       return new Commands.IfThenElse(logicalExpression, cmdBlocks, elseBlock);
     }