Armagetron-PHP-Parser

Something else for Armagetron? Goody!
Post Reply
User avatar
Jip
Round Winner
Posts: 397
Joined: Sat Sep 26, 2009 5:32 pm

Armagetron-PHP-Parser

Post by Jip »

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.

User avatar
dlh
Formerly That OS X Guy
Posts: 2035
Joined: Fri Jan 02, 2004 12:05 am
Contact:

Re: Armagetron-PHP-Parser

Post by dlh »

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")

User avatar
Jip
Round Winner
Posts: 397
Joined: Sat Sep 26, 2009 5:32 pm

Re: Armagetron-PHP-Parser

Post by Jip »

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.
dlh wrote: • Looks like command text escaping isn't implemented: Commands::say("line 1\nline 2")
[/quote]
Oops... Guess I can't fix that before I leave.

User avatar
Jip
Round Winner
Posts: 397
Joined: Sat Sep 26, 2009 5:32 pm

Re: Armagetron-PHP-Parser

Post by Jip »

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.

Post Reply