简体   繁体   English

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

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

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. 前段时间我创建了一个简单的VHDL解析器,但速度非常慢。 Not because it is implemented completely in Python, but because VHDL grammar (in EBNF) is huge. 不是因为它完全用Python实现,而是因为VHDL语法(在EBNF中)很大。 The EBNF of Python is beautiful but it is not very short. 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感兴趣。

I haven't compared, but Lua is a language renowned for its simple syntax. 我没有比较,但Lua是一种以其简单语法而闻名的语言。 The BNF is at the very end of this reference manual: http://www.lua.org/manual/5.1/manual.html . BNF位于本参考手册的最后: 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. ...通常,特别是对于具有简单架构(几个指令,几个寻址模式,几个寄存器)的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只是布尔方程式计算器。

One of the simplest imperative languages is Oberon-2. 最简单的命令式语言之一是Oberon-2。 Syntax of 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

Pascal只有2-3页的BNF表示法

What about GL Shading language? GL Shading语言怎么样? Language Specification (PDF) 语言规范 (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可能很小。

lisp ::= `(´ exp `)´

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM