|
@@ -158,9 +158,17 @@ function parseCommands (commands_block, function_obj) {
|
|
case Models.COMMAND_TYPES.iftrue:
|
|
case Models.COMMAND_TYPES.iftrue:
|
|
return parseIfTrue(commands_block, function_obj);
|
|
return parseIfTrue(commands_block, function_obj);
|
|
|
|
|
|
- //case Models.COMMAND_TYPES.repeatNtimes:
|
|
|
|
- default:
|
|
|
|
|
|
+ case Models.COMMAND_TYPES.repeatNtimes:
|
|
return parseRepeatNTimes(commands_block, function_obj);
|
|
return parseRepeatNTimes(commands_block, function_obj);
|
|
|
|
+
|
|
|
|
+ case Models.COMMAND_TYPES.whiletrue:
|
|
|
|
+ return parseWhileTrue(commands_block, function_obj);
|
|
|
|
+
|
|
|
|
+ case Models.COMMAND_TYPES.dowhiletrue:
|
|
|
|
+ return parseDoWhileTrue(commands_block, function_obj);
|
|
|
|
+
|
|
|
|
+ case Models.COMMAND_TYPES.switch:
|
|
|
|
+ return parseSwitch(commands_block, function_obj);
|
|
}
|
|
}
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
@@ -216,7 +224,7 @@ function parseAttribution (command, function_obj) {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
-function parseComment(command, function_obj) {
|
|
|
|
|
|
+function parseComment (command, function_obj) {
|
|
// TODO
|
|
// TODO
|
|
return new Models.Comment(
|
|
return new Models.Comment(
|
|
null
|
|
null
|
|
@@ -267,27 +275,56 @@ function parseRepeatNTimes(command, function_obj) {
|
|
var expression2 = CodeParser.expressionParserCodeVisual(command.condition, function_obj);
|
|
var expression2 = CodeParser.expressionParserCodeVisual(command.condition, function_obj);
|
|
expression2 = expression2[0];
|
|
expression2 = expression2[0];
|
|
|
|
|
|
- var expression3 = CodeParser.expressionParserCodeVisual(command.step_expression, function_obj);
|
|
|
|
-
|
|
|
|
- console.log('expression3', expression3);
|
|
|
|
|
|
+ var var_step = CodeParser.expressionParserCodeVisual(command.step_expression, function_obj);
|
|
|
|
|
|
var commands_block = parseCommands(command.commands, function_obj);
|
|
var commands_block = parseCommands(command.commands, function_obj);
|
|
|
|
|
|
- // var_attribution,
|
|
|
|
- // var_incrementation,
|
|
|
|
- // expression1,
|
|
|
|
- // expression2,
|
|
|
|
- // expression3,
|
|
|
|
- // commands_block
|
|
|
|
|
|
+ var operator = command.step_expression[0].value == '+'
|
|
|
|
+ ? Models.ARITHMETIC_TYPES.plus
|
|
|
|
+ : Models.ARITHMETIC_TYPES.minus;
|
|
|
|
+
|
|
|
|
+ var expression3 = new Models.ExpressionElement(
|
|
|
|
+ Models.EXPRESSION_ELEMENTS.exp_op_exp,
|
|
|
|
+ [
|
|
|
|
+ null,
|
|
|
|
+ operator,
|
|
|
|
+ var_step[1]
|
|
|
|
+ ]);
|
|
|
|
|
|
return new Models.RepeatNTimes(
|
|
return new Models.RepeatNTimes(
|
|
var_attribution,
|
|
var_attribution,
|
|
new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.only_variable, null, null, null, false),
|
|
new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.only_variable, null, null, null, false),
|
|
expression1,
|
|
expression1,
|
|
expression2,
|
|
expression2,
|
|
- null,
|
|
|
|
|
|
+ expression3,
|
|
commands_block);
|
|
commands_block);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+function parseWhileTrue (command, function_obj) {
|
|
|
|
+
|
|
|
|
+ var expression = CodeParser.expressionParserCodeVisual(command.expression, function_obj);
|
|
|
|
+ var commands = parseCommands(command.commands, function_obj);
|
|
|
|
+
|
|
|
|
+ return new Models.WhileTrue(
|
|
|
|
+ expression,
|
|
|
|
+ commands
|
|
|
|
+ );
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function parseDoWhileTrue (command, function_obj) {
|
|
|
|
+
|
|
|
|
+ // TODO
|
|
|
|
+ console.log(command)
|
|
|
|
+
|
|
|
|
+ // return new Models.DoWhileTrue([new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.all, null, null, null, true)], null);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+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))];
|
|
|
|
+
|
|
|
|
+ // return new Models.Switch(new Models.VariableValueMenu(VariableValueMenuManagement.VAR_OR_VALUE_TYPES.variable_and_function, null, null, null, true), sc);
|
|
|
|
+}
|