Am 01.04.2011 20:56, schrieb Karim:
On 04/01/2011 08:29 PM, Knacktus wrote:
Am 01.04.2011 19:09, schrieb Karim:

Hello All,

I would to ask you if somebody has experience or can give direction in a
new project I have.
I have a meta language description (in xml) from which I should generate
code on different
languages. In my case, lisp and tcl.

You need to provide more information of your description to get some
specific hints. The other day a had a xml file containing a business
object model with hierarchy and relations. Then I wrote a code
generator to build a module with Python classes for each business
item. The code generator created properties for lazily resolving
relations modelled via ids in the database and stuff like that. This
was very straightforeward using a simple print statements like the
following:

print "class %s(object):\n" % class_name
print " def __init__(self, %s)" % constr_arg
...

Cheers,

Jan


In fact in xml I have something like that:

A metafunction in fact kind of

<metfunc name=call_back_do_stuff_function>
<parameter>x</parameter>
<parameter>y</parameter>
</metafunc>


I have to generate the call_back_do_stuff_function(x,y) in lisp and tcl
according to a catalog of specs
of what this function must do generically.

I can do prints for each metafunctio I read but my concern is is there
std libs to help to have good design
and methodology. Is it interesting to use command module of something
like that, is interesting to use
a parser like pylex or pyparsing? I have 50 metafunctions in catalog for
now.

In fact, my point is to have a great extensive design methodology.
Strategy pattern would suit?
Other patterns? std modules?


No ideas about patterns or standarad lib modules from my side, but a short description of how I would do it:

Create an abstraction for the catalogue. That's as far as I can see the hardest part. Here you have to decide if and how to split the things your functions have to do into reusable chunks. Then create code generators for these chunks (using print statements). You can name these functions and store the references in dicts like catalog_comp_name_to_tcl_gen. If you get new functions that need new building blocks you can write new generator functions and extend your dictionaries.

The generation of your tcl and lisp "functions-frames" should be straigt forward. You need to link the parameters to the building block generator functions you've created before.

When you're done with that, you can improve the design step by step. Too me, this approach works better than thinking to much about design in advance, as often you don't see what you really need unless you've started to code.

HTH,

Jan




Lots of question here!

Regards
Karim




Any idea in term of design, examples, links will be appreciated!

Kind Regards
Karim
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to