问题
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
#include
the generated C file,- register the required callbacks and
- 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