От: | remark | http://www.1024cores.net/ | |
Дата: | 09.07.08 16:31 | ||
Оценка: | 7 (2) |
OMeta — a new object-oriented language for pattern matching. OMeta is based on a variant of Parsing Expression Grammars (PEGs) [5]—a recognition-based foundation for describing syntax—which we have extended to handle arbitrary kinds of data. We show that OMeta’s general-purpose pattern matching provides a natural and convenient way for programmers to implement tokenizers, parsers, visitors, and tree transformers, all of which can be extended in interesting ways using familiar object-oriented mechanisms. This makes OMeta particularly well-suited as a medium for experimenting with new designs
for programming languages and extensions to existing languages.
meta E {
dig ::= ’0’ | ... | ’9’;
num ::= <dig>+;
fac ::= <fac> ’*’ <num>
| <fac> ’/’ <num>
| <num>;
exp ::= <exp> ’+’ <fac>
| <exp> ’-’ <fac>
| <fac>;
}