No, parsing input using string.split is always incorrect. You really want to write a proper lexer.
Well, this is what libbabelhelper [1] is for. At the moment it is this horrible sscanf-thing because at the time of writing I did not know any better. But since I use it from two daemons already, I think I might just put the new shiny babel lexer into it and see where this will take us.The lexer I posted above is 70 lines of C, including full error checking. In Python, it's probably 15 to 20 lines. Is it really worth switching to a bloated and unreadable format in order to avoid 20 lines of code in each client?Well, it is of course completely up to you where you want to set the barrier to entry for interacting with babeld. And if you want to set that at "being able to write a lexer", well, that is a tradeoff. Just don't be surprised when people try to do sscanf or string.split-style parsing anyway, and subsequently complain about the interface. But then I guess you do like educating people, so maybe that is all well and good... ;)
So if the interface remains as it is, we can still hand users a tool to use to parse it properly.
[1] https://github.com/christf/libbabelhelper Christof -- () ascii ribbon campaign - against html e-mail /\ against proprietary attachments
signature.asc
Description: PGP signature
_______________________________________________ Babel-users mailing list Babel-users@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/babel-users