Presentation is loading. Please wait.

Presentation is loading. Please wait.

What is this? : : = Definition of a word. A word is comprised of 2 letters.

Similar presentations


Presentation on theme: "What is this? : : = Definition of a word. A word is comprised of 2 letters."— Presentation transcript:

1 What is this? : : = Definition of a word. A word is comprised of 2 letters

2 Programming Techniques

3 Backus-Naur Form or BNF for short & Syntax Diagrams 3.3.7 e Explain the need for, and be able to create and apply, BNF (Backus-Naur form) and syntax diagrams Programming Techniques Module Areas

4 : : = | | What are the minimum and maximum lengths of a word in this language definition? BNF Why is WXYZ not a WORD? Using BNF notation, define a word so that it can have as many letters as you want. Define a sentence using BNF. Incorporate your definition of a word into the structure Create your solutions in a word processed document and email them to jonesm@ntc.kent.sch.uk

5 Alongside defining the syntax of a potential language using the BNF notation there is a formal, symbol based method. SYNTAX DIAGRAMS Using the previous example, the members of letter can be represented as: : : = A | B | C | D Note that the symbols for LETTER (A, B, C, D) are not defined so are placed in circles A D C B LETTER

6 BNF Linking WORD to LETTER symbolically A D C B LETTER WORD Now we are not restricted to specifying how many letters can be included in a WORD. The syntax would allow the program to loop until it had reached the end of a WORD eg by meeting a space or full stop

7 BNF Create a syntax diagram for a sentence A D C B LETTER WORD : : = | ‘,’ { } WORD SENTENCE : : = | ‘,’ { } : : = A | B | C Create syntax diagrams to represent a paragraph, integer and floating point numbers email to jonesm@ntc.kent.sch.uk

8 SYNTAX DIAGRAM Syntax Diagram for a Customer Record (part of) A D C B LETTER FIRST NAME NAMEADDRESSID CUSTOMER RECORD FIRST NAMEMIDDLE NAMELAST NAME CUSTOMER NAME Create a BNF notation to represent this customer record email to jonesm@ntc.kent.sch.uk


Download ppt "What is this? : : = Definition of a word. A word is comprised of 2 letters."

Similar presentations


Ads by Google