(eg see, hit, I, the, a, ball, jackpot)
(eg <sentence>, <verb>, <subject>, <object> )
(eg <sentence>)
<sentence> --> <subject><verb><object> <subject> --> I <verb> --> see | hit <object> --> <article> <noun> <article> --> the | a <noun> --> ball | jackpot
The symbol -> means "is defined as"
The symbol | means "OR"
In BNF, each rule has a single nonterminal on its left hand side.
<sentence> ==> <subject><verb><object>
==> I <verb><object>
==> I hit <article> <noun>
==> I hit the <noun>
==> I hit the jackpot
Does it make a difference which is replaced? (Try it).
<sentence> ==> <subject><verb><object>
==> <subject> <verb> <article> <noun>
==> <subject> <verb> <article> jackpot
==> <subject> <verb> the jackpot
==> <subject> hit the jackpot
==> I hit the jackpot
<ones> --> 1
| 1<ones>
<ablist> --> ab
| a<ablist>b
<ablist> ==> ab
<ablist> ==> a<ablist>b
==> aabb
<ablist> ==> a<ablist>b
==> aa<ablist>bb
==> aaabbb
<L> --> ab
| ab<L>
<L> --> a<L>b<L>c
| ab
| bc
<exp> --> <id>
| <exp> + <exp>
| <exp> - <exp>
| <exp> * <exp>
| <exp> / <exp>
| (<exp>)
<id> --> A
| B
| C
<exp> ==> <exp> + <exp>
==> <exp> * <exp> + <exp>
==> <id> * <exp> + <exp>
==> A * <exp> + <exp>
==> A * <id> + <exp>
==> A * B + <exp>
==> A * B + <id>
==> A * B + C
<program> --> program <ident> is <stmts> end;
<stmts> --> <stmt> ; | <stmt> ; <stmts>
<stmt> --> <ident> := <expr>
| if <boolExp> then <stmts> end if
<ident> --> <letter> | <letter> <characters>
<characters> --> <character> | <character> <characters>
<character> --> <letter> | <digit> | _
<letter> --> a | b ... | z | A ... | Z
<digit> --> 0 | 1 | 2 | ... | 9
<expr> --> <expr> + <expr>
| ...
| <ident>
| <number>
| ( <expr> )
<number> --> <digit>
| <digit> <number>
<boolExp> --> ...