What is this? : : = Definition of a word. A word is comprised of 2 letters
Programming Techniques
Backus-Naur Form or BNF for short & Syntax Diagrams e Explain the need for, and be able to create and apply, BNF (Backus-Naur form) and syntax diagrams Programming Techniques Module Areas
: : = | | 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 them to
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
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
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 to
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 to