Reading in From Curly Bracket to Curly Bracket Java Lexer
Popular quiz! What exercise C, Python, Ruby, Become, Java, PHP, Oz, D++, Rust, and Perl have in common?
The answer? They all employ curly braces to group statements, merely { } weren't always the symbol of choice. When I learned to plan, there was no symbol at all.
FORTRAN GOTO
My first programming linguistic communication was FORTRAN, and it didn't have braces—it didn't know how to group statements at all. Each line stood alone.
If a line said "A = A + ane" the FORTRAN compiler generated lawmaking to do just that.
If a statement said "DIMENSION A(12)," the compiler would make a note and, later all the executable code was laid down, emit infinite for the assortment.
The statement "SUBROUTINE FOO(I1, I2, I3)" would produce the entry prolog for passing variables.
Instead of groupings, FORTRAN used the infamous GOTO argument to leap around lawmaking. (Really, FORTRAN deleted spaces within a line, then Get TO or even One thousand O T O would have done the flim-flam.)
The bit of FORTRAN on the left is in C to the right:
Here's the classic if-then-else sequence:
GOTO just seemed natural to the states associates linguistic communication programmers.
COBOL.
The gimmicky language COBOL is unlike because it was originally intended to exist a programming language for not-programmers, a failed goal that many technologies have aspired to over the years, such as 4GL languages, database direction systems in full general, and SQL in item.
COBOL, interestingly, tin be compiled with simple pattern matching because its syntax contains no recursive definition. Information technology was designed to be English-like (for some definitions of English language anyway).
And so, COBOL had statement grouping. Well, sort of. COBOL had one-half a grouping.
For instance, the syntax for an if argument was
IF I IS EQUAL TO iv THEN
Movement 1 TO B
MOVE 2 TO C
ELSE
Movement 2 TO B
Movement 3 TO C.
The final menstruum airtight the IF-And then-ELSE sequence. (Later, COBOL added a END-IF.)
Begin ALGOL END
ALGOL start had the idea of using keywords to group statement, which gave birth to the chemical compound argument.
The IF argument had the syntax of
IF relational And then statement
In place of the "statement" you could insert multiple statements enclosed in the two keywords Brainstorm and Stop. In fact, the body of functions themselves were mandatorily sandwiched between those two keywords.
Practice PL/I END
The IBM language PL/I was a melting pot of ideas from COBOL, FORTRAN, and ALGOL. It used the keyword DO instead of Brainstorm but picked up all the interesting ideas from ALGOL.
(I'm typing BEGIN, DO, and Stop in capital for a reason. These languages were designed for punch cards, which, for the near part, were express to upper case, as were all the early on timeshare systems. The CDC machines, for case, used brandish code to stand for a character. This crammed everything—messages, digits, punctuation, all of information technology— into a six-chip character. With only 64 combinations, there was no room for lowercase.)
$( BCPL $)
A consequential change happened in Cambridge, UK. For his doctorate thesis, Martin Richards designed a very low level programming language, intending for it to be used to compile a larger, higher level language: the Combined Programming Linguistic communication (CPL).
Cambridge University was going to implement CPL, an ALGOL like linguistic communication, in cooperation with London Academy, hence the name "combined." Others have wondered if the C stands for Cambridge.
Whatever the example, Richards designed a simplified basic linguistic communication: Basic Combined Programing Language (BCPL). For this, he specified special symbols to create chemical compound statements instead of using the larger BEGIN and Cease. The specification used a unusual "section" symbol, the closing instance being underlined. In his volume, and I think on the early on MIT CTSS systems, the BCPL compilers used the note "$ (" and "$ )" as the section brackets.
BCPL had a huge impact on many researchers. Microsoft's Hungarian naming convention is a outcome of early MS developers leaping from XEROX PARC to the Redmond software mill, carrying their BCPL derived coding conventions with them.
BCPL also had an impact on Ken Thompson.
{ B }
Effectually 1969, Thompson designed a new programming language he called B, the precursor to C. It was very much influenced past Richard's BCPL, and the section brackets to ascertain a compound argument was accept from it. Merely when Ken looked at the then new Teletype model 37 keyboard and notice the new curly subclass symbols, minted in 1967, did he choose them as the section brackets for his new programming language.
This meant that Dennis Ritchie used curly brackets for his C programming language, an extension of Ken's B language, and the residue is history.
The influence of C is far reaching, as shown by the fact that almost every programming language devised since C has used curly brackets to create compound statements.
Oberon to Go
It's interesting that Go, the relatively new Google programming linguistic communication, is very much a modern version of Niklaus Wirth'south excellent Oberon.
Oberon, true to its ALGOL roots, adopted more explicit statement bracketing, dropping the extra BEGIN when executing more than ane argument.
For example, Pascal, Wirth's before language, used the following
IF i = 3 And then Begin
a := i;
b := 2
Cease
Oberon said the same thing every bit
IF i = 3 Then
a := ane;
b := ii
END
Go streamlined this into
if i == 3 {
a = 1
b = 2
}
There'south more to Go than recycled Oberon ideas, just by replacing the longer keywords with curly brackets, Go is the terminal affiliate in a long history of bracketing compound statements with keywords.
But none of this would take been possible, of course, had it not been for the Teletype Model 37 and Ken Thompson'southward independent spirit. Without them, we might all be nonetheless typing DO and Terminate.
shewmakerdecterral.blogspot.com
Source: https://www.linkedin.com/pulse/history-curly-braces-brantley-coile
0 Response to "Reading in From Curly Bracket to Curly Bracket Java Lexer"
Post a Comment