Bakus naur form

569 views

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
569
On SlideShare
0
From Embeds
0
Number of Embeds
30
Actions
Shares
0
Downloads
11
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Bakus naur form

  1. 1. Bakus-Naur Form
  2. 2. What is it?• A formal, mathematical way to describe a language• It describes the grammar of a language, so that there is no disagreement or ambiguity as to what is allowed• How ….?
  3. 3. Production Rules• Symbol := alternative1 | alternative 2 …• alternative1 := subsymbol1 | terminal• Terminals are the end of the line, they terminate the production process.• The language described is the set of all the strings you can produce by following the production rules
  4. 4. Example BNF Grammar<S> := ‘-’ <FN> | <FN><FN> := <DL> | <DL> ‘.’ <DL><DL> := <D> | <D> <DL><D> := ‘0’|’1’|’2’|’3’|’4’|’5’ |’6’|’7’|’8’|’9’S=Start Symbol, FN = Fractional Number, DL = Digit list, D=digit
  5. 5. Question 1
  6. 6. Question 2
  7. 7. American example
  8. 8. Challenge• Create BNF for a UK postcode<postcode> := <onetwolets><onetwodig><optionlet>sp<onetwodig><twolets><onetwolets> := <twolets> | <letter><twolets> := <letter><letter><onetwodig> := <digit> | <digit><digit><optionlet> : | <letter><letter> := a|b|c|d|e|f …….<number> := 0|1|2 ……
  9. 9. Syntax Diagrams
  10. 10. Syntax diagram elements Create a Syntax diagram for a Windows filename

×