mirror of
https://github.com/JonasunderscoreJones/EPR-Gruppenabgabe-07.git
synced 2025-10-23 08:39:19 +02:00
ex 2
This commit is contained in:
parent
4c6caa686a
commit
381e7dced0
1 changed files with 29 additions and 0 deletions
29
task2_epi.txt
Normal file
29
task2_epi.txt
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
__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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue