Skip to content

Which modern languages use grammars as a basic feature?

twitter logo github logo ・1 min read  

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?

twitter logo DISCUSS (2)
markdown guide

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.


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

Classic DEV Post from Jun 15 '19

Micro Frontends: a deep dive into the latest industry trend.

Image from

Juan Julián Merelo Guervós profile image
Coder of code, writer of writings.

Need dark mode?

Create your account (free forever) to customize your experience.

Get Started