BNF & Syntax Diagrams
The layout for BNF works like:
LHS ::= RHS
LHS — (Left Hand Side)
::= — Is Defined by
RHS — (Right Hand Side)
The Right Hand Side defines the Left Hand Side
An Example being:
<DIGIT>::=1|2|3|4|5|6|7|8|9|0
This is also an example of a Terminal type where Digit can only be defined in terms of itself with no further way to break it down.
An Example of a Non-Terminal being:
<DIGIT>::=1|2|3|4|5|6|7|8|9|0 — Terminal
<LETTER>::=A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z — Terminal
<SPACE>::=’ ’ — Terminal
SP10 5NL
<POSTCODE>::=<LETTER><LETTER><DIGIT><SPACE><DIGIT><DIGIT><LETTER>— Non-Terminal
| — Acts as the word ‘OR’
Recursive use:
Making use of <LETTER>::=A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z
<WORD>::=<LETTER>|<LETTER><WORD>
This statement means that for WORD the choices can be either a single <LETTER> ending the recursion being the base state OR ( represented by the ‘|’ ) <LETTER> and then <WORD> again???
This extra call of <WORD> again is what starts the recursion with the process working out like if the OR statement is chosen it will then run like the first argument being simply <LETTER> to which then follows is of course <WORD> restarting the entire thing getting the crossroad of <LETTER>|<LETTER><WORD> these two being the two and only two choices available.
Syntax Diagrams
Simply put are a visual | graphical version of BNF
The layout for BNF works like:
LHS ::= RHS
LHS — (Left Hand Side)
::= — Is Defined by
RHS — (Right Hand Side)
The Right Hand Side defines the Left Hand Side
An Example being:
<DIGIT>::=1|2|3|4|5|6|7|8|9|0
This is also an example of a Terminal type where Digit can only be defined in terms of itself with no further way to break it down.
An Example of a Non-Terminal being:
<DIGIT>::=1|2|3|4|5|6|7|8|9|0 — Terminal
<LETTER>::=A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z — Terminal
<SPACE>::=’ ’ — Terminal
SP10 5NL
<POSTCODE>::=<LETTER><LETTER><DIGIT><SPACE><DIGIT><DIGIT><LETTER>— Non-Terminal
| — Acts as the word ‘OR’
Recursive use:
Making use of <LETTER>::=A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z
<WORD>::=<LETTER>|<LETTER><WORD>
This statement means that for WORD the choices can be either a single <LETTER> ending the recursion being the base state OR ( represented by the ‘|’ ) <LETTER> and then <WORD> again???
This extra call of <WORD> again is what starts the recursion with the process working out like if the OR statement is chosen it will then run like the first argument being simply <LETTER> to which then follows is of course <WORD> restarting the entire thing getting the crossroad of <LETTER>|<LETTER><WORD> these two being the two and only two choices available.
Syntax Diagrams
Simply put are a visual | graphical version of BNF