Presentation is loading. Please wait.

Presentation is loading. Please wait.

Backus Naur form.

Similar presentations


Presentation on theme: "Backus Naur form."— Presentation transcript:

1 Backus Naur form

2 Different Programming Languages
Different programming languages take different forms For i = 1 to 10 (is VB6) For(i=1, i<=10, 1++) (is C++) A Visual Basic compiler would not understand the C++ syntax.

3 BNF We need a set of rules that specifies every part of the language to overcome this problem We use Backus Naur Form or Syntax Diagrams

4 BNF Example All languages use integers
The integer can be a single digit <integer>::= <digit> This is read as an integer is defined (::=) to be a digit Now we define the digit <digit>::=1|2|3|4|5|6|7|8|9 Anything that needs defining is put in <>

5 BNF Example Our full definition is <integer>::= <digit>
We need to consider the length of the integer All integers more than one digit begin with digit <integer>::= <digit> <integer> This definition is recursive (calls itself)

6 BNF Example

7 BNF Example <unsigned integer>::=<digit>|<digit><integer> This can be expressed through a syntax diagram All definitions should be created by paths through the diagram from left to right

8 BNF Example

9 A Signed Integer - BNF Example

10 BNF Example


Download ppt "Backus Naur form."

Similar presentations


Ads by Google