Re: libseed-list AlgoScript and custom module importer



On Thu, Jun 10, 2010 at 11:35 AM, Jonatan Liljedahl <lijon kymatica com> wrote:
> I'm working on a parser for "AlgoScript", which compiles to javascript and
> has some nice syntactic sugar and hides some of javascripts uglyness.
> Example:
>
>    [0..10].do {x -> print x}
>
> =>
>
>    (Array.range(0,10)).forEach(function(x){return(print(x));})
>
> I have an algoscript.parse() function that parses algoscript and returns a
> string of javascript.

This sounds cool! I sort of wanted to do this with coffeescript and Seed once.
>
> One thing I'm thinking about is how I should solve module imports.. Surely I
> could have an import(name) function, but it would be a bit ugly to have this
> AND imports.gi.name for the gobject stuff.
>
> The best thing would be if imports.name could check the file extension and
> run it through my parser if it ends with '.as' or something like that. Any
> ideas how this could be achieved? Maybe the seed importer could have hooks
> that is called for files not ending with '.js'?
>
> algoscript_importer = function(filename,str) {
>  return eval(algoscript.parse(str));
> }
>
> imports.unknownFileCallback = algoscript_importer;
>
> Or it could just pass the filename and not the contents, or it could have a
> table of callbacks for each suffix:
>
> imports.customImporterCallback['as'] = algoscript_importer;
>
> What do you think? I imagine that this could be very useful for other stuff
> as well..
>
> I would be happy to try and add support for this if you want.
>
> /Jonatan

I'm a little hesitant with the file extension, but maybe some sort of
line to parse in the shebang? I can actually probably give a pass at
this in a few days, I'm getting ready to do a biggggg rework of Seed.

> _______________________________________________
> libseed-list mailing list
> libseed-list gnome org
> http://mail.gnome.org/mailman/listinfo/libseed-list
>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]