diff --git a/lib/compiler/scjson-to-module.js b/lib/compiler/scjson-to-module.js index 1f75c242..56d27424 100644 --- a/lib/compiler/scjson-to-module.js +++ b/lib/compiler/scjson-to-module.js @@ -473,12 +473,7 @@ var actionTags = { foreachFnNames.map(function(fnName){return ' ' + generateFnCall(fnName) + ';';}).join('\n') + '\n' + ' }\n' + '} else{\n' + - ' for(' + index + ' in ' + shallowArrayName + '){\n' + - ' if(' + shallowArrayName + '.hasOwnProperty(' + index + ')){\n' + - ' ' + item + ' = ' + shallowArrayName + '[' + index + '];\n' + - foreachFnNames.map(function(fnName){return ' ' + generateFnCall(fnName) + ';';}).join('\n') + '\n' + - ' }\n' + - ' }\n' + + ' this.raise({ name:"error.execution", data : {}});\n' + '}'; return forEachContents; diff --git a/lib/compiler/static-analysis/scxml-analyzer.js b/lib/compiler/static-analysis/scxml-analyzer.js index 690121cd..27b7e213 100644 --- a/lib/compiler/static-analysis/scxml-analyzer.js +++ b/lib/compiler/static-analysis/scxml-analyzer.js @@ -80,7 +80,13 @@ var openNodeTypes = { validateJavascriptExpression(node.attributes.cond.value, parser.startTagPosition - 1, parser.position); } - } + }, + "foreach": function (node) { + if(node.attributes.item) { + var constructedExpression = node.attributes.item.value + '=testvalue;'; + validateJavascriptExpression(constructedExpression, parser.startTagPosition - 1, getTagIndexFromCurrentPosition('foreach', true)); + } + } }; var closedNodeTypes = { @@ -173,6 +179,20 @@ function goThroughSyntaxTree (tree) { }; } +//('foreach') looks for next +function getTagIndexFromCurrentPosition (tagName, isEnd) { + + if (isEnd) { + var tagString = ""; + + return parser.position + currentScxml.substring(parser.position).indexOf(tagString) + tagString.length; + } else { + var tagString = "<" + tagName + ">"; + + return currentScxml.substring(0, parser.startTagPosition).lastIndexOf(tagString); + } +} + var treeTypes = { "BlockStatement": function (tree) { tree = tree.body; diff --git a/test/run-tests-node.sh b/test/run-tests-node.sh index 9f594d65..096e8812 100755 --- a/test/run-tests-node.sh +++ b/test/run-tests-node.sh @@ -36,6 +36,7 @@ node scxml-test-framework/lib/test-client.js -v -r console \ scxml-test-framework/test/targetless-transition/*.scxml \ scxml-test-framework/test/w3c-ecma/test150.txml.scxml \ scxml-test-framework/test/w3c-ecma/test151.txml.scxml \ + scxml-test-framework/test/w3c-ecma/test152.txml.scxml \ scxml-test-framework/test/w3c-ecma/test309.txml.scxml \ scxml-test-framework/test/w3c-ecma/test312.txml.scxml \ scxml-test-framework/test/w3c-ecma/test313.txml.scxml \ diff --git a/test/scxml-test-framework b/test/scxml-test-framework index bbf10166..4d579394 160000 --- a/test/scxml-test-framework +++ b/test/scxml-test-framework @@ -1 +1 @@ -Subproject commit bbf101665412b0f80c340df9f109f9c2af4120eb +Subproject commit 4d5793943d45731ae06c0fe8c246c65531bf6828