Browse Source

Rename command If -> IfThenElse

Lucas Souza 5 years ago
parent
commit
cb1df498ef
3 changed files with 7 additions and 15 deletions
  1. 0 8
      js/ast/commands/if.js
  2. 2 2
      js/ast/commands/index.js
  3. 5 5
      js/ast/ivprogParser.js

+ 0 - 8
js/ast/commands/if.js

@@ -1,8 +0,0 @@
-export class If {
-
-  constructor (condition, ifTrue, ifFalse) {
-    this.condition = condition;
-    this.ifTrue = ifTrue;
-    this.ifFalse = ifFalse;
-  }
-}

+ 2 - 2
js/ast/commands/index.js

@@ -6,8 +6,8 @@ import { ArrayDeclaration } from './arrayDeclaration';
 import { While } from './while';
 import { For } from './for';
 import { Function } from './function';
-import { If } from './if';
+import { IfThenElse } from './ifThenElse';
 
 export {
-  Break, Return, Assign, Declaration, ArrayDeclaration, While, For, Function, If
+  Break, Return, Assign, Declaration, ArrayDeclaration, While, For, Function, IfThenElse
 };

+ 5 - 5
js/ast/ivprogParser.js

@@ -495,7 +495,7 @@ export class IVProgParser {
       } else if (token.type === this.lexerClass.RK_DO) {
         
       } else if (token.type === this.lexerClass.RK_IF) {
-        cmd = this.parseIf();
+        cmd = this.parseIfThenElse();
       }
 
       if (cmd === null)
@@ -510,7 +510,7 @@ export class IVProgParser {
     return {variables: variablesDecl, commands: commands};
   }
 
-  parseIf () {
+  parseIfThenElse () {
     this.pos++;
     this.checkOpenParenthesis();
     this.pos++;
@@ -530,11 +530,11 @@ export class IVProgParser {
       if(this.checkOpenCurly(true)) {
         elseBlock = this.parseCommandBlock(IVProgParser.COMMAND);
       } else {
-        elseBlock = this.parseIf();
+        elseBlock = this.parseIfThenElse();
       }
-      return new Commands.If(logicalExpression, cmdBlocks, elseBlock);
+      return new Commands.IfThenElse(logicalExpression, cmdBlocks, elseBlock);
     }
-    return new Commands.If(logicalExpression, cmdBlocks, null);
+    return new Commands.IfThenElse(logicalExpression, cmdBlocks, null);
   }
 
   parseFor () {