Question: Question 1 : - Given the following grammar: S - > cSAS S - > B a a S - > epsilon A - >

Question 1:-
Given the following grammar:
S -> cSAS
S -> B a a
S -> epsilon
A -> A a
A -> epsilon
B -> b B
B -> b
In both sections you are asked to write a translation scheme (scheme translation)(to differentiate).
Definition Directed Syntax
Let's recall that semantic actions can be integrated into a translation scheme: code sections surrounded by brackets
curled (on the right side of the derivation rules. The position of the action determines when it will be performed
The passage on the cutting tree.
If it is necessary, it is allowed to add to the grammar the derivation rule S'-> S when S' is
The new initial variable.
A-
Add semantic operations to this grammar so that during the reading of the input, each sign a will be printed
twice Example: for the input cbaaabbaa the output will be aaaaaaaaaa( ten a's)
Use (a(print) to write a to the output.
B-
Add semantic operations to the given grammar so that only a signs that meet the following conditions are printed
to output
The a sign will appear in the output provided that the number of a signs we have seen in the meantime (including the current a sign) is large
Just from the number of b signs we've seen so far. (The recording as usual is read from left to right).
Another thing: when two or more c signs appear in the input in a row then counting signs
The a resets (as if we haven't seen any sign a yet).
For example for the input cbaaaccbbaaa the output will be aa.
The first a (on the left) will not be printed because at this stage the number of a signs we have seen is not greater than a number
The b signs (we saw one sign of each type). The next two a signs (the second and third from the left)
will be printed -- the second will be printed because we saw two a signs and only one b. The third a will be printed because we saw 3 signs
a and only one b. Later, two c's appear in a row and this resets the count of the a's. after you see
the two b signs immediately after cc (the number of b signs we saw is 3 and the number of a signs is 0
Therefore the last three a's will not be printed.
At least one legacy feature must be used in the solution (built-in features are also allowed). Do not use
in global variables (to practice using features).
Write down specifically the meaning of each feature you define and whether it is built or inherited.
(or neither this nor that).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!