Home > Software engineering >  What is the metasyntax used in the Scala spec?
What is the metasyntax used in the Scala spec?

Time:09-08

I'm reading the Scala spec, link to 2.13. What is the exact metasyntax (I think that's the term) that's used to express the Spec? I believe it's an extension of the Backus-Naur Form but I can't quite figure out every component.

Note: I'm not an expert on programming theory, so I hope you apologize if I use some terms incorrectly, my goal is simply to understand how the spec is defined.

CodePudding user response:

I believe it's an extension of the Backus-Naur Form

I believe that "an extension of the Backus-Naur Form" is the closest you can get.

Various extensions, augmentations, variations, and modifications of BNF are in so widespread use in Programming Language Specifications that most authors do not bother specifying them, since everybody is just so used to reading them all the time that they understand them intuitively.

Chapter 13 – Syntax Summary, section 13.1 – Lexical Syntax says the following [bold emphasis mine]:

The lexical syntax of Scala is given by the following grammar in EBNF form

But that is still ambiguous. Originally, EBNF was designed by Niklaus Wirth, and it would make sense that Martin Odersky uses it, since he studied under Wirth.

However, there are many slight variations of Wirth's EBNF in widespread use, plus, other "extended versions" of BNF are also referred to as "EBNF", so that does not really tell you anything either.

  • Related