|
@@ -104,9 +104,15 @@ function forWalker (forLoop) {
|
|
|
const var_attribution = expressionWalker(forLoop.for_id);
|
|
|
const var_initial = expressionWalker(forLoop.for_from);
|
|
|
const condition = expressionWalker(forLoop.for_to);
|
|
|
+ const defaultStep = [{ instance: "operator", type: TYPES.ARITHMETIC, value: '+' }, {
|
|
|
+ instance: "expression",
|
|
|
+ class: "simple",
|
|
|
+ type: TYPES.CONST,
|
|
|
+ value: 1,
|
|
|
+ }]
|
|
|
const step_expression = forLoop.for_pass
|
|
|
? expressionWalker(forLoop.for_pass)
|
|
|
- : [];
|
|
|
+ : defaultStep;
|
|
|
const commands = forLoop.commands.map(commandWalker);
|
|
|
return {
|
|
|
type: "repeatNtimes",
|
|
@@ -231,10 +237,13 @@ function functionCallWalker (functionCall) {
|
|
|
if (name === "$write") {
|
|
|
const lastInput = parameters[parameters.length - 1][0];
|
|
|
// if lastInput is an object with value === '\n', newLine is true
|
|
|
- const newLine = lastInput.value && lastInput.value.match(/^\n$/) !== null;
|
|
|
- const content = newLine
|
|
|
+ const newLine = lastInput.value && lastInput.value.match && lastInput.value.match(/^\n$/) !== null;
|
|
|
+ let content = newLine
|
|
|
? parameters.slice(0, parameters.length - 1)
|
|
|
: parameters;
|
|
|
+ console.log("cont");
|
|
|
+ console.log([].concat(...parameters));
|
|
|
+ content = [].concat(...content);
|
|
|
return {
|
|
|
type: "writer",
|
|
|
newLine,
|
|
@@ -484,6 +493,7 @@ export function parseExpression (text) {
|
|
|
* @param {string} text
|
|
|
* */
|
|
|
export function parseCode (text) {
|
|
|
+ console.log(text);
|
|
|
const parser = IVProgParser.createParser(text, false);
|
|
|
const codeLinesMap = new Map();
|
|
|
const tokens = Array.from(parser.lexer.reset(text));
|