|
@@ -154,6 +154,13 @@ function parseCommands (commands_block, function_obj) {
|
|
|
|
|
|
case Models.COMMAND_TYPES.functioncall:
|
|
|
return parseFunctionCall(commands_block, function_obj);
|
|
|
+
|
|
|
+ case Models.COMMAND_TYPES.iftrue:
|
|
|
+ return parseIfTrue(commands_block, function_obj);
|
|
|
+
|
|
|
+ //case Models.COMMAND_TYPES.repeatNtimes:
|
|
|
+ default:
|
|
|
+ return parseRepeatNTimes(commands_block, function_obj);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
@@ -218,21 +225,69 @@ function parseComment(command, function_obj) {
|
|
|
|
|
|
function parseFunctionCall (command, function_obj) {
|
|
|
|
|
|
- var parameters = CodeParser.expressionParserCodeVisual(command.parameters_list[0], function_obj);
|
|
|
- var function_called = CodeParser.searchFunction(command.name);
|
|
|
+ var parameters = [];
|
|
|
+ if (command.parameters_list) {
|
|
|
+ command.parameters_list.forEach(function(el) {
|
|
|
+ var temp = CodeParser.expressionParserCodeVisual(el, function_obj);
|
|
|
+ if (temp.content === 0) temp.content = "0";
|
|
|
+ parameters.push(temp[0]);
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- //function_called.parameters_list = parameters;
|
|
|
+ var function_called = CodeParser.searchFunction(command.name);
|
|
|
|
|
|
- console.log('atenção: ', parameters, command.parameters_list);
|
|
|
-
|
|
|
var temp = new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.only_function, null, null, null, false);
|
|
|
temp.function_called = function_called;
|
|
|
temp.parameters_list = parameters;
|
|
|
|
|
|
return new Models.FunctionCall(
|
|
|
temp,
|
|
|
- parameters
|
|
|
+ null
|
|
|
);
|
|
|
+}
|
|
|
+
|
|
|
+function parseIfTrue(command, function_obj) {
|
|
|
+
|
|
|
+ var expression = CodeParser.expressionParserCodeVisual(command.expression, function_obj);
|
|
|
+ var ifTrueBlock = parseCommands(command.ifTrue, function_obj);
|
|
|
+ var ifFalseBlock = parseCommands(command.ifFalse, function_obj);
|
|
|
+
|
|
|
+ return new Models.IfTrue(expression, ifTrueBlock, ifFalseBlock);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+function parseRepeatNTimes(command, function_obj) {
|
|
|
+
|
|
|
+ var var_attribution = CodeParser.expressionParserCodeVisual(command.var_attribution, function_obj);
|
|
|
+ var_attribution = var_attribution[0];
|
|
|
+
|
|
|
+ var expression1 = CodeParser.expressionParserCodeVisual(command.var_initial, function_obj);
|
|
|
+ expression1 = expression1[0];
|
|
|
+
|
|
|
+ var expression2 = CodeParser.expressionParserCodeVisual(command.condition, function_obj);
|
|
|
+ expression2 = expression2[0];
|
|
|
+
|
|
|
+ var expression3 = CodeParser.expressionParserCodeVisual(command.step_expression, function_obj);
|
|
|
+
|
|
|
+ console.log('expression3', expression3);
|
|
|
+
|
|
|
+ var commands_block = parseCommands(command.commands, function_obj);
|
|
|
+
|
|
|
+ // var_attribution,
|
|
|
+ // var_incrementation,
|
|
|
+ // expression1,
|
|
|
+ // expression2,
|
|
|
+ // expression3,
|
|
|
+ // commands_block
|
|
|
+
|
|
|
+ return new Models.RepeatNTimes(
|
|
|
+ var_attribution,
|
|
|
+ new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.only_variable, null, null, null, false),
|
|
|
+ expression1,
|
|
|
+ expression2,
|
|
|
+ null,
|
|
|
+ commands_block);
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
- //new Models.FunctionCall(new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.only_function, null, null, null, false), null
|
|
|
-}
|
|
|
+
|