Code is on GitHub
See example.php and the README for more infos.
Contributions welcome! Just fork it and make a pull request. If you find bugs, please report them there.
Edit:
It is inspired by dlhs armascript python parser but since I don't speak python very well, I thought I do my own in PHP.
Armagetron-PHP-Parser
Re: Armagetron-PHP-Parser
It's nice to see some parsers that abstract away some of the pains of dealing with ladderlog data (parsing, player/team tracking).
Some small critiques:
• I'm not a fan of needing to declare the parameters for a ladderlog event. For example: “protected static function player_renamed($old, $new, $ip, $screenName)”. You end up with duplicated code when you want to implement some functionality that will work on 0.2.8, 0.4 and sty+ct(+ap).
That's why in armascript event handler methods only take one parameter, an event object, which holds all the data for the event. It also makes it simpler to adapt if the event changes—you only need to update the event registration instead of every call-site where the event is used.
• Any reason for the parsing functions needing to be static? If I want to track some data it now needs to be global.
• Looks like command text escaping isn't implemented: Commands::say("line 1\nline 2")
Some small critiques:
• I'm not a fan of needing to declare the parameters for a ladderlog event. For example: “protected static function player_renamed($old, $new, $ip, $screenName)”. You end up with duplicated code when you want to implement some functionality that will work on 0.2.8, 0.4 and sty+ct(+ap).
That's why in armascript event handler methods only take one parameter, an event object, which holds all the data for the event. It also makes it simpler to adapt if the event changes—you only need to update the event registration instead of every call-site where the event is used.
• Any reason for the parsing functions needing to be static? If I want to track some data it now needs to be global.
• Looks like command text escaping isn't implemented: Commands::say("line 1\nline 2")
Re: Armagetron-PHP-Parser
Thanks for your feedback!
A better design is already in my mind and I started to rewrite the event handeling and the parser to be more intuitv usuable/extendable. I will publish it when I come back from holidays.
Oops... Guess I can't fix that before I leave.
A better design is already in my mind and I started to rewrite the event handeling and the parser to be more intuitv usuable/extendable. I will publish it when I come back from holidays.
[/quote]dlh wrote: • Looks like command text escaping isn't implemented: Commands::say("line 1\nline 2")
Oops... Guess I can't fix that before I leave.
Re: Armagetron-PHP-Parser
I rewrote the parser logic. Parser functions are not static anymore and an event object is passed as the only argument now.
Documentation is also updated.
Documentation is also updated.