mirror of
https://github.com/JonasunderscoreJones/EPR-Gruppenabgabe-07.git
synced 2025-10-22 19:19:21 +02:00
29 lines
1.2 KiB
Text
29 lines
1.2 KiB
Text
__author__ = "7987847, Werner, 7347119, Fajst, 7735965, Melikidze"
|
|
================================================================================================================
|
|
|
|
a) The context-free grammar generates words that consist of variables (V), which can be any lowercase letter from a to z,
|
|
and operators (O), which can be +, -, *, or /. These variables and operators are combined using parentheses (T).
|
|
Specifically, the grammar generates words by either replacing the start symbol T with a variable (V),
|
|
or by replacing T with an opening parenthesis followed by a combination of a T, an operator (O), and another T, followed by a closing parenthesis.
|
|
|
|
b) The word "(a + ((x - z) / y))" can be generated by the context-free grammar. One possible order of derivation rules to create this word is as follows:
|
|
|
|
T -> (TOT)
|
|
T -> V
|
|
O -> +
|
|
T -> (TOT)
|
|
T -> (TOT)
|
|
T -> V
|
|
O -> -
|
|
T -> V
|
|
O -> /
|
|
T -> V
|
|
|
|
The word "((p) + (o))" can also be generated by the context-free grammar. One possible order of derivation rules to create this word is as follows:
|
|
|
|
T -> (TOT)
|
|
T -> V
|
|
O -> +
|
|
T -> (TOT)
|
|
T -> V
|
|
|