Meta Languages What are they What do you

  • Slides: 8
Download presentation
Meta Languages What are they? What do you use them for? What are the

Meta Languages What are they? What do you use them for? What are the names of the Meta Languages you have used?

Meta Languages – What are they? • Text based methods of describing rules of

Meta Languages – What are they? • Text based methods of describing rules of a language. • Are precise • Always mean the same thing ie, 2+2 = 4

Meta Languages – what are they used for? • To describe more complex programming

Meta Languages – what are they used for? • To describe more complex programming languages • Help programmers with language design & implementation • Represent the SYNTAX of programming languages (the rules of a language)

Meta Languages – you need to know these types: Text-based metalanguages: • BNF –

Meta Languages – you need to know these types: Text-based metalanguages: • BNF – Backus Normal Form • EBNF – Extended Backus-Naur Form Graphically-based metalanguages: • Railroad Diagrams (also known as syntax structure diagrams)

What is the difference between BNF and EBNF? • BNF is very basic –

What is the difference between BNF and EBNF? • BNF is very basic – Shows language elements within brackets <> – Allows use of terminal symbols like * or – – Includes Alternatives | • EBNF was developed to EXTEND BNF in order to include – – Repitition { } Optional elements [ ] Grouped Elements ( ) Simpler symbol for ‘is defined as’ EBNF uses = BNF uses : : =

Examples • BNF Digit : : = 1 | 2 | 3 Number :

Examples • BNF Digit : : = 1 | 2 | 3 Number : : = <digit> * <digit> • EBNF Digit = 1 | 2 | 3 Number = <digit> * <digit> • Railroad Diagram refer to Table 5. 2 in Wilson, p 125

Worked Example • Decide which of the following are legal and which are illegal.

Worked Example • Decide which of the following are legal and which are illegal. Give a reason for your answer Digit : : = 4 | 5 | 6 | 7 | 8 Sum : : = <Digit> * <Digit> a) b) c) d) e) Sum = 4 * 8 Sum = 7 * 5 Sum = 9 * 6 Sum = 5 * 4 Sum = 6 * 1 1. What type of metalanguage was used above?

In Class Questions • Exercise 5. 1 (from Wilson, p 124) Questions 3 &

In Class Questions • Exercise 5. 1 (from Wilson, p 124) Questions 3 & 4 • Exercise 5. 1 (from Fowler, p 164) Questions 3 a) 3 b) 4 and 7