views:

485

answers:

2

Ometa is "a new object-oriented language for pattern matching." I've encountered pattern matching in languages like Oz tools to parse grammars like Lexx/Yacc or Pyparsing before. Despite looking at example code, reading discussions, and talking to a friend, I still am not able to get a real understanding of what makes Ometa special (or at least, why some people think it is). Any explanation?

+2  A: 

It's a metalanguage, from what I can tell. You can create new language constructs, and create DSLs; but the most compelling thing is that you can subclass from existing parsers to extend a language. That's what I can remember about it, anyway.

I found this to be interesting: http://www.moserware.com/2008/06/ometa-who-what-when-where-why.html

TraumaPony
+2  A: 

Also, most important to me, the Squeak port of Ometa allows for left-recursive rules.

From its PEG heritage it gets backtracking and unlimited lookahead. Memoization of previous parse results allows for linear parse times (nearly all the time (*)).

Higher-order productions allow one to easily refactor a grammar.

This paper - Packrat Parsers Can Support Left Recursion - explains the left recursive properties.

(*) Section 5 of the paper explains that one can suffer superlinear parse times, but this problem doesn't manifest in practical grammars.

Frank Shearar
Presumably you can't have both left recursion and linear parse times, though?
Dominic Cooney
Yes you can, because of the memoization. Well, most of the time. Section 5 of the paper explains further.
Frank Shearar