SCION
SCION copied to clipboard
empty <datamodel> block throws "Unexpected token" SyntaxError
An empty
is a wrapper element which encapsulates any number of elements, each of which defines a single data object.
However, SCION throws the following exception when the datamodel is empty:
$ node test.js
Server running at http://127.0.0.1:3000/
(node:2180) UnhandledPromiseRejectionWarning: simple.scxml:1
var ;
^
SyntaxError: Unexpected token ;
at Object.compileScript (C:\Users\user\node_modules\scxml\lib\runtime\platform-bootstrap\node\platform.js:112:20)
at C:\Users\user\node_modules\scxml\lib\runtime\document-string-to-model.js:117:59
at new Promise (<anonymous>)
at Function.compileModule [as handleRawModule] (C:\Users\user\node_modules\scxml\lib\runtime\document-string-to-model.js:112:21)
at resolved (C:\Users\user\node_modules\scxml\lib\runtime\document-string-to-model.js:256:31)
at <anonymous>
(node:2180) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:2180) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
const http = require('http');
const scxml = require('scxml');
const hostname = '127.0.0.1';
const port = 3000;
var status = "none";
scxml.pathToModel("simple.scxml", function (err, model) {
if (err)
throw err;
model.prepare(function (err, fnModel) {
if (err)
throw err;
var sc = new scxml.scion.Statechart(fnModel);
sc.start();
sc.gen({
name: "next"
});
status = sc.isIn("b");
});
})
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end("status: " + status);
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
<?xml version="1.0" encoding="UTF-8"?>
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" datamodel="ecmascript" name="simple" initial="a">
<datamodel>
</datamodel>
<state id="main_region">
<state id="a">
<transition event="next" target="b">
</transition>
</state>
<state id="b">
</state>
</state>
</scxml>
Thanks for reporting this issue. I will look into it.