Which programming language has very short context-free Grammar in its formal specification?

StackOverflow https://stackoverflow.com/questions/1777011

  •  21-09-2019
  •  | 
  •  

Question

What programming language has short and beautiful grammars (in EBNF)?

Some languages are easer to be parsed. Some time ago I have created a simple VHDL parser, but it was very slow. Not because it is implemented completely in Python, but because VHDL grammar (in EBNF) is huge. The EBNF of Python is beautiful but it is not very short.

I suggest that many functional programming languages like LISP have short simple grammars, but I am interested in a more popular simple imperative language like C or Bash.

Was it helpful?

Solution

I haven't compared, but Lua is a language renowned for its simple syntax. The BNF is at the very end of this reference manual: http://www.lua.org/manual/5.1/manual.html .

OTHER TIPS

Assembly languages!

...in general, and particularly for CPUs which have a simple architecture (few instructions, few addressing modes, few registers) have a relatively short grammar.

In fact, specialized processors, such as these found in programmable logic controllers can have a language with even simpler grammars. But then again the most simple of the PLCs are little more than Boolean equation calculators.

One of the simplest imperative languages is Oberon-2. Syntax of Oberon-2.

Also take a look at Oberon-07 (The Programming Language Oberon-07, PDF) and Component Pascal.

Pascal has only 2-3 pages of BNF notations

What about GL Shading language? Language Specification (PDF)

However for these kind of hobbies I always preferred to implement a subset of a known language by myself without choosing anything "premade"..

Lisp is probably pretty small.

lisp ::= `(´ exp `)´
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top