哪种编程语言在其正式规范中具有非常短的无上下文语法?

时间:2021-04-30 22:33:04

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

什么编程语言有短而美的语法(在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.

有些语言更易于解析。前段时间我创建了一个简单的VHDL解析器,但速度非常慢。不是因为它完全用Python实现,而是因为VHDL语法(在EBNF中)很大。 Python的EBNF很漂亮但不是很短。

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.

我建议像LISP这样的许多函数式编程语言都有简短的语法,但我对一种比较流行的简单命令式语言如C或Bash感兴趣。

6 个解决方案

#1


4  

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 .

我没有比较,但Lua是一种以其简单语法而闻名的语言。 BNF位于本参考手册的最后:http://www.lua.org/manual/5.1/manual.html。

#2


3  

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

最简单的命令式语言之一是Oberon-2。 Oberon-2的语法。

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

另请参阅Oberon-07(The Programming Language Oberon-07,PDF)和Component Pascal。

#3


3  

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.

...通常,特别是对于具有简单架构(几个指令,几个寻址模式,几个寄存器)的CPU具有相对较短的语法。

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.

实际上,专用处理器(例如可编程逻辑控制器中的处理器)可以使用语言甚至更简单的语法。但是,最简单的PLC只是布尔方程式计算器。

#4


1  

Pascal has only 2-3 pages of BNF notations

Pascal只有2-3页的BNF符号

#5


0  

What about GL Shading language? Language Specification (PDF)

GL Shading语言怎么样?语言规范(PDF)

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

然而,对于这些爱好,我总是喜欢自己实现一个已知语言的子集,而不选择任何“预制”。

#6


-1  

Lisp is probably pretty small.

Lisp可能很小。

lisp ::= `(´ exp `)´

#1


4  

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 .

我没有比较,但Lua是一种以其简单语法而闻名的语言。 BNF位于本参考手册的最后:http://www.lua.org/manual/5.1/manual.html。

#2


3  

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

最简单的命令式语言之一是Oberon-2。 Oberon-2的语法。

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

另请参阅Oberon-07(The Programming Language Oberon-07,PDF)和Component Pascal。

#3


3  

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.

...通常,特别是对于具有简单架构(几个指令,几个寻址模式,几个寄存器)的CPU具有相对较短的语法。

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.

实际上,专用处理器(例如可编程逻辑控制器中的处理器)可以使用语言甚至更简单的语法。但是,最简单的PLC只是布尔方程式计算器。

#4


1  

Pascal has only 2-3 pages of BNF notations

Pascal只有2-3页的BNF符号

#5


0  

What about GL Shading language? Language Specification (PDF)

GL Shading语言怎么样?语言规范(PDF)

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

然而,对于这些爱好,我总是喜欢自己实现一个已知语言的子集,而不选择任何“预制”。

#6


-1  

Lisp is probably pretty small.

Lisp可能很小。

lisp ::= `(´ exp `)´