开发者

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

开发者 https://www.devze.com 2022-12-11 22:48 出处:网络
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

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 i开发者_如何学JAVAs 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.


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 .


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 `)´
0

精彩评论

暂无评论...
验证码 换一张
取 消