Browse Source

textual to visual: finished

Igor 2 years ago
parent
commit
31aef4f032
3 changed files with 23 additions and 14 deletions
  1. 23 7
      js/util/codeParser.js
  2. 0 2
      js/util/iassignHelpers.js
  3. 0 5
      js/visualUI/commands/generic_expression.js

+ 23 - 7
js/util/codeParser.js

@@ -314,17 +314,33 @@ function parseWhileTrue (command, function_obj) {
 
 function parseDoWhileTrue (command, function_obj) {
   
-  // TODO
-  console.log(command)
+  var expression = CodeParser.expressionParserCodeVisual(command.expression, function_obj);
+  var commands = parseCommands(command.commands, function_obj);
 
-			// return new Models.DoWhileTrue([new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null);
+  return new Models.DoWhileTrue(
+    expression, 
+    commands
+  );
 }
 
 function parseSwitch (command, function_obj) {
 
-  console.log(command)
-  
-			// var sc = [new Models.SwitchCase(new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true))];
+  var expression = CodeParser.expressionParserCodeVisual(command.expression, function_obj);
+
+  var sc = [];
+  if (command.cases) {
+    command.cases.forEach(function(case_el) {
 
-			// return new Models.Switch(new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.variable_and_function, null, null, null, true), sc);
+      var temp_exp = CodeParser.expressionParserCodeVisual(case_el.expression, function_obj);
+      var temp_commands = parseCommands(case_el.commands, function_obj);
+      var temp_case = new Models.SwitchCase(temp_exp[0], temp_commands);
+
+      sc.push(temp_case);
+    })
+  }
+
+	return new Models.Switch(
+    expression[0], 
+    sc
+  );
 }

+ 0 - 2
js/util/iassignHelpers.js

@@ -49,8 +49,6 @@ function setActivityConfig (config_json) {
 }
 
 function setPreviousAlgorithm (code) {
-  console.log('conteúdo: ')
-  console.log(code)
   
   var code_obj = null;
   try {

+ 0 - 5
js/visualUI/commands/generic_expression.js

@@ -1654,11 +1654,6 @@ export function searchFunction (function_name) {
 
 export function expressionParserCodeVisual (parsed, function_obj) {
 
-  console.log('\nparsed')
-  console.log(parsed)
-  console.log('\n\n')
-  
-
   if (!parsed) return null;
 
   var var_not_found = [];