welcome: please sign in
ARRbot / DSLDSL

Summary

Why shouldn't a DSL also have its own DSL?

The domain of DSL's involves the concepts of "evaluating some DSL", and then "producing some objects and/or code from it".

So, I've created a class that you can subclass called "Evaluator". The "Evaluator" class imbues whatever inherits from it with the power to create DSL evaluators!

The DSL evaluator will have a class method called "eval" which evaluates your DSL, then returns a nested object that has all the accessors that you like.

Example DSL Evaluator

Here's an example DSL DSL for the config file.

Example config file

To evaluate this code in the evaluator, do:

The returned object, 'config', will be an object with accessors for all the "properties" that the DSL was designed to capture. All the methods used to generate those properties in the evaluator get removed, so all you're left with is the produced data.

Questions

1) What would be the best way to define methods that will exist on the "generated" objects?

Other possible names:

2) How would we allow the user to configure "on someting" events? Like, "on connect", or "on ctcp"?

Then, the block assigned to each handler would be evaluated in the scope of the IRC client module, so that it could send messages or whatever.

3) Since this bot will be really fast and efficient, and have really good logging facilities, people will probably want it to join a lot of channels.

If that's the case, then they'll need to restart the bot every time it becomes part of a new channel, since our config file is static. It would be better if the bot master could tell the bot to join a channel, and the config file could be updated automatically.

Could we make the generated object reversible? eg:

Note: It must retain the order of the commands in the original config file. Perhaps it could intelligently group together things like servers and channels?

Resources

ARRbot/DSLDSL (last edited 2010-04-24 15:15:55 by Chris)