Cobol no longer has to be indented. AFAIK, allmost modern compilers support format free Cobol source.
The original reason was dealing with punch cards. Cobol kept the first 6 positions for a line sequence number. Column 7 was a continuation / comment / debug / form-feed. Area "A", or Columns 8-11, indicated certain special language artifacts like 01 levels, section or paragraph names, et al. Area "B", or Columns 12 - 72, was for open code. Columns 73 - 80 were for OS sequence numbers.
The two languages you mention, Cobol and Fortran, were both written before automatic parser generation existed. And they had no real prior art to draw on for good and bad ideas of how to create parse-able source text. So some of the things -- like Area "A" for special section headers -- made the task of manually writing parsers easier. Modern languages tend to use context free grammars to make parser generation simple. But that postdates Cobol.
发布评论
评论(1)
Cobol 不再需要缩进。 AFAIK,
所有大多数现代编译器都支持格式无关的 Cobol 源代码。最初的原因是处理打孔卡。 Cobol 保留了行序列号的前 6 个位置。第 7 栏是继续/注释/调试/换页。区域“A”,或第 8-11 列,表示某些特殊的语言工件,如 01 级别、部分或段落名称等。区域“B”,或第 12 - 72 列,用于开放代码。第 73 - 80 列是操作系统序列号。
您提到的两种语言 Cobol 和 Fortran 都是在自动解析器生成存在之前编写的。他们没有真正的现有技术可以借鉴如何创建可解析源文本的好的和坏的想法。因此,有些东西(例如用于特殊节标题的区域“A”)使手动编写解析器的任务变得更加容易。现代语言倾向于使用上下文无关语法来简化解析器的生成。但这是在科博尔之后发生的。
Cobol no longer has to be indented. AFAIK,
allmost modern compilers support format free Cobol source.The original reason was dealing with punch cards. Cobol kept the first 6 positions for a line sequence number. Column 7 was a continuation / comment / debug / form-feed. Area "A", or Columns 8-11, indicated certain special language artifacts like 01 levels, section or paragraph names, et al. Area "B", or Columns 12 - 72, was for open code. Columns 73 - 80 were for OS sequence numbers.
The two languages you mention, Cobol and Fortran, were both written before automatic parser generation existed. And they had no real prior art to draw on for good and bad ideas of how to create parse-able source text. So some of the things -- like Area "A" for special section headers -- made the task of manually writing parsers easier. Modern languages tend to use context free grammars to make parser generation simple. But that postdates Cobol.