Sdd Syntax Descriptions

1,291 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,291
On SlideShare
0
From Embeds
0
Number of Embeds
18
Actions
Shares
0
Downloads
52
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Sdd Syntax Descriptions

  1. 1. Implementing Software Solutions Language Syntax Required for Software Solutions
  2. 2. What is a Metalanguage? <ul><li>Metalanguages provide an understanding of rules implemented into programming languages. </li></ul><ul><li>They represent a languages syntax which is used like a checklist when compiling a program to remove errors before execution takes place. </li></ul>
  3. 3. Why Do We Need Them? <ul><li>Computers operate in an environmnet full of rules. The use of syntax descriptions enables the computer and programmer to understand the boundaries of its environment. </li></ul><ul><li>All data types, data structures and control structures used must have their own set of syntax developed to adhere to. </li></ul>
  4. 4. Types of Metalanguages? <ul><li>BNF or EBNF – Which is a text based description of syntax. </li></ul><ul><li>Railroad Diagram – Is the graphical based description which is easier to understand. </li></ul>
  5. 5. BNF Symbols Is defined as :: = Indicates choice between elements | Non terminal symbol < > Meaning Symbol
  6. 6. EBNF Symbols Encloses optional elements [ ] Encloses elements to be repeated { } Is defined as = Indicates choice between elements | Non terminal symbol < > Meaning Symbol
  7. 7. Railroad Symbols Predefined element Fixed element Path lines Meaning Symbol
  8. 8. Activity 1 <ul><li>Consider the following EBNF diagram. </li></ul><ul><li><Digit> = 1 | 2| 3 </li></ul><ul><li><Number> = <Digit> * <Digit> </li></ul><ul><li><Sum> = {<Number>} – {<Number>} </li></ul><ul><li>Identify which of the following statements are legal and illegal. </li></ul><ul><ul><ul><li>Sum = (1 * 2) – (2 * 3) </li></ul></ul></ul><ul><ul><ul><li>Sum = (1 * 4) – (2 * 3) </li></ul></ul></ul><ul><ul><ul><li>Sum = (1 * 2) – (2 + 3) </li></ul></ul></ul>
  9. 9. Activity 1 <ul><li>Consider the following Railroad diagram. </li></ul><ul><li>Identify which of the following statements are legal and illegal. </li></ul><ul><ul><ul><li>String = 5a$ </li></ul></ul></ul><ul><ul><ul><li>String = a$ </li></ul></ul></ul><ul><ul><ul><li>String = aa43 </li></ul></ul></ul><ul><ul><ul><li>String = $b56 </li></ul></ul></ul><ul><ul><ul><li>String = aaac11bc$ </li></ul></ul></ul>String Letter Number Letter $
  10. 10. Data Structure Syntax <ul><li>Arrays </li></ul><ul><li>The declaration of an array is: </li></ul><ul><li>Arrayname(5) </li></ul><ul><li>Therefore, the syntax description would be: </li></ul><ul><li><Digit> = 0 | 1 | 2 …| 9 </li></ul><ul><li><Letter> = a | b | c … |z </li></ul><ul><li><Index> = {<Digit>} </li></ul><ul><li><Arrayname> = {<Letter>} </li></ul><ul><li><Array> = <Arrayname> (<Index>) </li></ul>
  11. 11. Data Structure Syntax <ul><li>Arrays </li></ul><ul><li>So therefore if we typed in our code the following processes would be incorrect: </li></ul><ul><ul><li>Dogs (10) </li></ul></ul><ul><ul><li>cat [1] </li></ul></ul><ul><ul><li>trees (index) </li></ul></ul>
  12. 12. Data Structure Syntax <ul><li>Multidimensional Arrays </li></ul><ul><li>The declaration of a multidimensional array is: Arrayname(Digit, Digit) </li></ul>Using this knowledge create a set syntax descriptions in railroad format for the above multidimensional array.
  13. 13. Data Structure Syntax <ul><li>Array of Records </li></ul><ul><li>Below is an example of a Array of Records </li></ul>Create a set of syntax descriptions for an Array of records using EBNF 12 Ben 11 John Age Name
  14. 14. Activity 2 <ul><li>The following EBNF describes the rules for an array of records. </li></ul><ul><li><Digit> = 1 | 2| 3…| 9 </li></ul><ul><li><Ucharacter> = A | B | C …..| Z </li></ul><ul><li><LCharacter> = a | b | c ……| z </li></ul><ul><li><Character> = <UCharacter> | <LCharacter> </li></ul><ul><li><Boolean> = [Y|N] | [T|F] </li></ul><ul><li><Fieldname> = {<Character>} </li></ul><ul><li><Fieldentry> = {<Character> | <Digit> | <Boolean>} </li></ul><ul><li><Record> = <Fieldname> {<Fieldentry>} </li></ul><ul><li><Arrayofrecords> = <Record> {<Record>} </li></ul>
  15. 15. Activity 2 <ul><li>Identify whether the following are valid or invalid. </li></ul>a) b) c) 17 Dina Andys Age First Name Surname 78 Case 25 17 Ball 12 Cost Item ID1 F 23/4/02 John T 25/4/99 Jenny Medication Visit Patient
  16. 16. Activity 2 <ul><li>Below is a VB statement for opening a file via random access. </li></ul><ul><li>Open “MYFIL.FIL” For Random AS FileNum Len = Max </li></ul>Using either EBNF or Railroad create a set of syntax diagrams for this procedure.
  17. 17. Answer <ul><li><Digit> = 1 | 2| 3…| 9 </li></ul><ul><li><Ucharacter> = A | B | C …..| Z </li></ul><ul><li><LCharacter> = a | b | c ……| z </li></ul><ul><li><Character> = <UCharacter> | <LCharacter> </li></ul><ul><li><Variable> = {<Character>} </li></ul><ul><li><Filenumber> = {<Digit>} </li></ul><ul><li><Accesstype> = Random | Sequential </li></ul><ul><li><Pathname> = “ {<Character>} . {<Character} “ </li></ul><ul><li><Fileaccess> = Open <Pathname> For <Accesstype> As <Filenumber> </li></ul><ul><li>Len = <Variable> </li></ul>

×