What makes Ometa special? [closed]
Asked Answered
P

2

21

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?

Parabasis answered 19/9, 2008 at 23:41 Comment(0)
S
12

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.

Silvia answered 10/12, 2008 at 9:27 Comment(4)
Presumably you can't have both left recursion and linear parse times, though?Barreto
Yes you can, because of the memoization. Well, most of the time. Section 5 of the paper explains further.Silvia
+1 for the hight order productions :)Raja
Is there any major tutorials for using it?Itemize
A
7

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

Afoot answered 20/9, 2008 at 5:34 Comment(1)
Subclassing is not the only way in which you can combine grammars, ometa also provides a foreign rule invocation mechanism. This is useful when you want to "derive" from more than one class.Tuberculosis

© 2022 - 2024 — McMap. All rights reserved.