[Cuis] Why or why not OMeta? (was Re: Brainstorming question: what non-trivial uses can you think of for an object-based parser? (strings not invited))

Phil (list) pbpublist at gmail.com
Sat May 23 13:34:42 CDT 2015


On Sat, 2015-05-23 at 17:16 +0100, Frank Shearar wrote:
> >
> > I understand that OMeta isn't unique in being an object parser and I
> > started this thread mainly because I'm wondering how much value people
> > can see in parsing things other than text/binary streams.  i.e. is it a
> > genuinely useful feature or a gimmick/freebie that won't see much use?
> 
> I finally found it: I once implemented pattern matching with OMeta:
> http://www.lshift.net/blog/2011/05/15/algebraic-data-types-and-ometa2/
> 
> Given a standard binary tree implementation with Tree whose subclasses
> are Node, Leaf or Empty, I could write:
> 
> depth =
>         {#Empty} -> [0]
>         | {#Leaf anything} -> [1]
>         | {#Node depth:l depth:r} -> [(l max: r) + 1]
> 
>     sum =
>         {#Empty} -> [0]
>         | {#Leaf anything:v} -> [v]
>         | {#Node sum:l sum:r} -> [l + r]
> 
> which, I think, is pretty neat.
> 

That is pretty cool.  I'll add that to the examples.

> frank
> 

Thanks,
Phil






More information about the Cuis mailing list