DEV Community

Juan Julián Merelo Guervós
Juan Julián Merelo Guervós

Posted on

Which modern languages use grammars as a basic feature?

Perl6 includes grammars as part of the language. Grammars are special classes that can be used to parse text, and so on. I do not know of any other language, modern or otherwise, but I really don't know all of them.
Three of the last Perl 6 Advent Calendar posts are devoted to grammars, so we are really proud of them. But it would be nice to compare with other languages that have them as parts of the batteries included package. Do you know of any?

Top comments (2)

eljayadobe profile image

If you mean strictly part of the language (out of the box, no extra stuff), then I'm not sure.

C++ Boost Spirit has grammars.

Not part of the C++ standard, but Boost is a popular set of libraries for C++. Some of which has become part of C++ standard. It a very large library, but very useful, and well vetted, and written by many of the same people on the C++ standards committee. (I think Boost originated by committee members who were doing neat things they wanted to share, but didn't think those things would be able to become part of the C++ standard. Or they were just trying to relax and take a break from the normal WG21 slog.)

My grammar friends point to Ohm for JavaScript, if you need a grammar parser engine to write your own DSL that will be used in a web app or NodeJS.

Again, not part of the rapidly evolving JavaScript itself (i.e., EMCA-262 ECMAScript), but for JavaScript.

jj profile image
Juan Julián Merelo Guervós

Yep, I meant as part of the language itself. As you say, these features might become part of those languages in the near future.