SCXML parsing IOS

久未见 提交于 2019-12-11 04:00:23

问题


Do anyone have any idea about writing SCXML parsers in IOS ?

I went through this http://www.w3.org/TR/scxml/ and have idea about SCXML.

I need to create parsing architecture now.

Kindly let me know if anyone has idea.

Thanks in advance.


回答1:


SCXML is just XML, so if you simply want to parse the document, you only need an XML parser. This article has a good overview of various XML parsers available for iOS: http://www.raywenderlich.com/553/how-to-chose-the-best-xml-parser-for-your-iphone-project

On the other hand, if you need to execute the SCXML document as a state machine, then you need an SCXML engine. If you create an iOS app using UIWebView/PhoneGap, then you could potentially use SCION as your SCXML engine, as it is implemented JavaScript. Disclaimer: I am the author fo this library.




回答2:


Not sure about SCXML interpreters that can run on iOS, but uSCXML can generate ANSI-C for the control flow implied in a given SCXML file and you'd only have to provide callbacks for datamodel specific expressions.

$ uscxml-transform -tc -i your.machine.scxml -o your.machine.c

A scaffolding for the generated machines that passes all IRP tests is given here. In essence, you merely

  1. #include the generated C file,
  2. register the required callbacks and
  3. run the whole machine until there is nothing left to do.

The example scaffolding is somewhat more elaborate as it will work with all of uSCXML's data-models and supports multiple invoked SCXML interpreters. If you only need one state-chart, the three steps above are sufficient. The generated source code is commented and a stripped down example (from our legacy branch) is available here (inline SCXML is not yet supported in new master branch).

We did evaluate the performance of microstep(T) with our approach and it is ridiculously fast, primarily because we precalculate conflicts(T_1, T_2). With the algorithm from Appendix D in the recommendation as a baseline, we achieved a speed-up of 10-20x in the IRP tests (to be published any day now).

If this approach seems suitable but gives you troubles, feel free to post an issue on github and I will be happy to add more information.

Disclaimer: I am the uSCXML maintainer.



来源:https://stackoverflow.com/questions/12489893/scxml-parsing-ios

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!