A context-free grammar
is given by
As an example we define a grammar for the language
of arithmetical expressions over (using only
and
), i.e.
elements of this language are
or
. However words
like
or
are not in the language.
We define
where
is given by:
![]() |
![]() |
|
![]() |
![]() |
|
![]() |
![]() |
|
![]() |
![]() |
|
![]() |
![]() |
|
![]() |
![]() |
To save space we may combine all the rules with the same left hand side, i.e. we write
![]() |
![]() |
|
![]() |
![]() |
|
![]() |
![]() |