[Ometa] Decompiling doesn't always work

Alessandro Warth alexwarth at gmail.com
Tue May 10 15:05:31 PDT 2011


Hi Frank,

It looks like the debugger is trying to decompile #depth and/or pretty-print
the code, and it's treating it like Smalltalk code, not OMeta, so things are
going wrong.

I'll try to fix this in the next couple of days, but in the meantime, I
think I know what's wrong with your rule.

depth =3D
>        {#empty} -> [0]
>        | {#leaf anything:a} -> [1]
>        | {#node anything:l anything:r} -> [l depth max: r depth]
>

There are two problems:

(1) the recursive sends of #depth are not quite right -- depth is a method
of your grammar, not of the "listy" objects themselves. So instead of saying

... -> [l depth max: r depth]

you should be saying

...
| {#node depth:l depth:r} -> [l max: r]

In other words, match each subtree with your grammar's #depth rule, and bind
the results to local variables that you can use in the semantic action.

(2) This one is not an OMeta-related bug, but I think you forgot to add 1 to
the result of #max:.

Cheers,
Alex


> but there's a problem: trying to decompile this results in a walkback
> "Error: subscript is out of bounds: 1".
>
> TreeWalker subclasses OMeta2, so "TreeWalker compilerClass" evaluates to
> OMeta2Compiler as expected. "TreeWalker decompilerClass" is of course
> Decompiler.
>
> What's going wrong? Might this be caused by a syntax error in depth (a
> distinct possibility)?
>
> frank
>
> _______________________________________________
> OMeta mailing list
> OMeta at vpri.org
> http://vpri.org/mailman/listinfo/ometa
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://vpri.org/pipermail/ometa/attachments/20110510/eabbfbc2/attachme=
nt.htm


More information about the OMeta mailing list