Download GTL, a Grammar Transformation Language for SDF
Transcript
103
5.4. UNLISTED TRANSFORMATIONS ENCOUNTERED
5.3.16
“Removed production ‘[0] D+ IS* -> IntegerConstant’ because
‘D’ includes ‘[0]’ and the production ‘D+ IS* -> IntegerConstant’
exists too”
This transformation is a simple removal of a production.
GTL
1
2
3
4
5
6
functions
Definition &Step16(Definition D) {
begin
<Step16> := remove Production:[0] D+ IS* -> IntegerConstant from <D>;
end;
};
5.4
Unlisted Transformations Encountered
This section provides scripts in GTL for the transformations not listed in the original
adaptation of the C grammar.
5.4.1
Problems encountered during step 2.4.1
The following is a generic script to add sort declarations for all the defined sorts in a
grammar. It assumes that no sort declarations are present.
GTL
1
2
3
4
5
functions
Definition &Unlisted1(Definition D) {
variables
Symbol S;
Grammar SG;
6
7
8
9
10
11
12
13
begin
%% process each defined sort
foreach Production:... -> <S> in <D> do
if not(select <S> from <SG>) then
insert <S> into <SG>;
else
; %% otherwise do nothing since the sort is already declared
14
15
16
17
18
%% now add the sort declarations to the definition
<Unlisted1> := insert <SG> into <D>;
end;
};
5.4.2
Problems encountered during step 2.4.2
The following script deals with each of the listed transformations: