Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does anyone have a working B compiler? [closed]

Tags:

Does anyone know where I could get a good B compiler? I have searched for a B compiler for some time now, but have been having some difficulty finding anything complete for a Windows or Linux system.

Here is an example of B:

main( ) { auto a, b, c, sum; a = 1; b = 2; c = 3; sum = a+b+c; putnumb(sum); } 
like image 385
Anthony Avatar asked Oct 21 '09 14:10

Anthony


People also ask

What is the work of compiler?

A compiler is a special program that translates a programming language's source code into machine code, bytecode or another programming language. The source code is typically written in a high-level, human-readable language such as Java or C++.

What is the example of compiler?

The language processor that reads the complete source program written in high-level language as a whole in one go and translates it into an equivalent program in machine language is called a Compiler. Example: C, C++, C#, Java.

How hard is it to write a compiler?

Writing a compiler requires knowledge of a lot of areas of computer science - regular expressions, context-free grammars, syntax trees, graphs, etc. It can help you see how to apply the theory of computer science to real-world problems.

How does a compiler translate code?

A compiler takes the program code (source code) and converts the source code to a machine language module (called an object file). Another specialized program, called a linker, combines this object file with other previously compiled object files (in particular run-time modules) to create an executable file.


2 Answers

Prompted by this question, there is now a B compiler available from here: https://github.com/Leushenko/ybc

Runs on Windows, Linux, and OSX (binaries provided; in the spirit of the question it is written in an obscure language), where it produces very poor quality x86-32 assembly. Should be GCC-compatible. It is reconstructed out of the available reference material on B, and almost certainly does not reflect the language as it really was in the 1960s. Notably, in the absence of type information (B is untyped), the &a[b] == &*(a + b) rule can not hold on x86, meaning that this task is effectively impossible (without resorting to an interpreter).

Apart from that, Pavel Minaev's comment is right: the language as described is extremely small, far smaller than C, and an experienced/competent compiler programmer could likely write one for you in an afternoon.

Unfortunately this is only a partial answer, as I couldn't tell you where to find a good B compiler.

like image 125
Leushenko Avatar answered Sep 22 '22 08:09

Leushenko


Do you have a Honeywell 6050 running GCOS to run it on? Or maybe an emulator? I know that IBM's 360 and 370 have been emulated but I haven't yet heard of a Honeywell 6000 emulator.

At the University of Waterloo in 1974-76 timeframe I remember writing CS assignments in B rather than Algol-60 which most people in the class were using. I went on to write an emulator for an HP 2100A minicomputer, but that code is long since lost.

As far as I know, B was only implemented on the Honeywell with its 36-bit word length, 9-bit ASCII, etc. And since it's successor C, was hitting the universities at the same time, it didn't last long.

If I remember correctly, Trevor Thompson, one of the founders of MKS, wrote a standard I/O library for B and also wrote a 3D chess game in it. If you can manage to track him down, he is someone who, at one time, had his hands on a B compiler. I just had a look at LinkedIn and I found him. He is one of the owners of Satori Solutions.

If you have a machine running GCOS, or a Honeywell series 60 emulator running GCOS, then you could use the B compiler included in the UW Tools Package from Thinkage. It supports both batch and TSS programs.

like image 34
Michael Dillon Avatar answered Sep 19 '22 08:09

Michael Dillon