CONTEXT-FREE GRAMMAR

Context-Free grammar is an idea that applies to formal languages such the ones used to program a computer.

ibm-system-370
char* digit = "0123456789";
char* letter = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

Most programming languages are defined by formal descriptions, so it is obvious that the most basic elements of letters and numbers are needed. Early programming languages were not yet case sensitive, this came in the 1970s once interactive programming techniques were possible.

char* lowercase = "abcdefghijklmnopqrstuvwxyz";

Mathematically the idea of a finite field can be considered when deciding the granularity of the grammar considered.

When Backus and Naur designed FORTRAN they developed a formalism to describe the formal language. Their work was influenced by Chomsky in 1956 when he published a paper “Three Models for the Description of Language”. Backus and Naur used a syntax to describe FORTRAN.

<letter> ::= A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z

The | is used to indicate select one of the choices. For example a variable in the original FORTRAN was limited to 2 letters. This was extended with the introduction of the IBM 360. The […] signals that this portion of a rule is not compulsory.

PASCAL

 program = 'PROGRAM', white_space, identifier, white_space,
            'BEGIN', white_space,
            { assignment, ";", white_space },
            'END.' ;
 identifier = alphabetic_character, { alphabetic_character | digit } ;
 number = [ "-" ], digit, { digit } ;
 string = '"' , { all_characters - '"' }, '"' ;
 assignment = identifier , ":=" , ( number | identifier | string ) ;
 alphabetic_character = "A" | "B" | "C" | "D" | "E" | "F" | "G"
                      | "H" | "I" | "J" | "K" | "L" | "M" | "N"
                      | "O" | "P" | "Q" | "R" | "S" | "T" | "U"
                      | "V" | "W" | "X" | "Y" | "Z" ;
 digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
 white_space = ? white_space characters ? ;
 all_characters = ? all visible characters ? ;

With this syntax and a recursive descent design for a compiler is all that is needed to build one.