Skip to content

Commit

Permalink
new deyaccification rules
Browse files Browse the repository at this point in the history
git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@436 ab42f6e0-554d-0410-b580-99e487e6eeb2
  • Loading branch information
grammarware committed Feb 4, 2009
1 parent f456199 commit e26925c
Show file tree
Hide file tree
Showing 25 changed files with 115 additions and 68 deletions.
84 changes: 83 additions & 1 deletion shared/prolog/xbgf1.pro
Expand Up @@ -147,7 +147,89 @@ designate(P1,g(Rs,Ps1),g(Rs,Ps2))
% Use EBNF-based regular expression operator instead of BNF encoding
%

deyaccify(N,g(Rs,Ps1),g(Rs,Ps2))
deyaccify(N,g(Rs,Ps1),g(Rs,Ps3))
:-
splitN(Ps1,N,Ps2,Ps2a,Ps2b),
require(
( length(Ps2, Len), Len > 1 ),
'Nonterminal ~q must be defined vertically for deyaccification to work.',
[N]),
Ps2 = [P1,P2],
require(
once(xbgf1:newdeyaccify_rules(N,P1,P2,P3)),
'Nonterminal ~q is not deyaccifiable: ~q and ~q',
[N,P1,P2]),
append(Ps2a,[P3|Ps2b],Ps3).

% N: Nab|x -> N: x(ab)*
newdeyaccify_rules(N,P1,P2,P3)
:-
P1 = p(As,N,','([n(N)|Xs1])),
P2 = p(As,N,Xs2),
normalizeG(','(Xs1),Xs3),
normalizeG(','([Xs2]),Xs4),
(
eqX(Xs3,Xs4),!,
P3 = p(As,N,+(','(Xs1)))
;
P3 = p(As,N,','([Xs2,*(','(Xs1))]))
).
% N: abN|x -> N: (ab)*x
newdeyaccify_rules(N,P1,P2,P3)
:-
P1 = p(As,N,','(Xs1)),
tailless(Xs1,[],Xs2),
tailof(Xs1,n(N)),
P2 = p(As,N,Xs3),
normalizeG(','(Xs2),Xs4),
normalizeG(','([Xs3]),Xs5),
(
eqX(Xs4,Xs5),!,
P3 = p(As,N,+(','(Xs2)))
;
P3 = p(As,N,','([*(','(Xs2)),Xs3]))
).
%%%%%%
% N: Nab|x -> N: x(ab)*
newdeyaccify_rules(N,P1,P2,P3)
:-
P2 = p(As,N,','([n(N)|Xs1])),
P1 = p(As,N,Xs2),
normalizeG(','(Xs1),Xs3),
normalizeG(','([Xs2]),Xs4),
(
eqX(Xs3,Xs4),!,
P3 = p(As,N,+(','(Xs1)))
;
P3 = p(As,N,','([Xs2,*(','(Xs1))]))
).
% N: abN|x -> N: (ab)*x
newdeyaccify_rules(N,P1,P2,P3)
:-
P2 = p(As,N,','(Xs1)),
tailless(Xs1,[],Xs2),
tailof(Xs1,n(N)),
P1 = p(As,N,Xs3),
normalizeG(','(Xs2),Xs4),
normalizeG(','([Xs3]),Xs5),
(
eqX(Xs4,Xs5),!,
P3 = p(As,N,+(','(Xs2)))
;
P3 = p(As,N,','([*(','(Xs2)),Xs3]))
).

% Needed -> prelude.pro
% Not needed -> throw away
tailof([X],X).
tailof([_|T],X) :- tailof(T,X).
tailless([_],L1,L1).
tailless([H|T],L1,L3)
:-
concat([L1,[H]],L2),
tailless(T,L2,L3).

olddeyaccify(N,g(Rs,Ps1),g(Rs,Ps2))
:-
splitN1(Ps1,N,P1,Ps2a,Ps2b),
P1 = p(As,N,X1),
Expand Down
3 changes: 0 additions & 3 deletions topics/java/lci/xbgf/deyaccify-doc2.xbgf
Expand Up @@ -8,7 +8,6 @@
vs.
- [], ;([n(SwitchBlockStatementGroup), ,([n(SwitchBlockStatementGroups), n(SwitchBlockStatementGroup)])])
-->
<xbgf:horizontal>SwitchBlockStatementGroups</xbgf:horizontal>
<xbgf:deyaccify>SwitchBlockStatementGroups</xbgf:deyaccify>
<xbgf:extract>
<bgf:production>
Expand Down Expand Up @@ -56,7 +55,6 @@
vs.
- [], ;([n(CatchClause), ,([n(Catches), n(CatchClause)])])
-->
<xbgf:horizontal>Catches</xbgf:horizontal>
<xbgf:deyaccify>Catches</xbgf:deyaccify>

<!--
Expand All @@ -65,7 +63,6 @@
vs.
- [], ;([n(BlockStatement), ,([n(BlockStatements), n(BlockStatement)])])
-->
<xbgf:horizontal>BlockStatements</xbgf:horizontal>
<xbgf:deyaccify>BlockStatements</xbgf:deyaccify>

</xbgf:sequence>
10 changes: 0 additions & 10 deletions topics/java/lci/xbgf/editDeclarations.xbgf
Expand Up @@ -65,7 +65,6 @@
with
p([], 'ExtendsInterfaces', ;([','([t(extends), n('InterfaceType')]), ','([n('ExtendsInterfaces'), t((',')), n('InterfaceType')])]))
-->
<xbgf:horizontal>ExtendsInterfaces</xbgf:horizontal>
<xbgf:deyaccify>ExtendsInterfaces</xbgf:deyaccify>
<xbgf:fold>
<nonterminal>TypeList</nonterminal>
Expand Down Expand Up @@ -234,7 +233,6 @@
with
p([], 'SwitchLabels', ;([n('SwitchLabel'), ','([n('SwitchLabels'), n('SwitchLabel')])])),
-->
<xbgf:horizontal>SwitchLabels</xbgf:horizontal>
<xbgf:deyaccify>SwitchLabels</xbgf:deyaccify>

<!--
Expand Down Expand Up @@ -358,7 +356,6 @@
vs.
- [], ,([t({), ?(,([n(VariableInitializer), *(,([t((,)), n(VariableInitializer)])), ?(t((,)))])), t(})])
-->
<xbgf:horizontal>VariableInitializers</xbgf:horizontal>
<xbgf:deyaccify>VariableInitializers</xbgf:deyaccify>
<xbgf:inline>VariableInitializers</xbgf:inline>

Expand All @@ -368,7 +365,6 @@
vs.
- [], ,([t({), *(n(ClassBodyDeclaration)), t(})])
-->
<xbgf:horizontal>ClassBodyDeclarations</xbgf:horizontal>
<xbgf:deyaccify>ClassBodyDeclarations</xbgf:deyaccify>
<xbgf:inline>ClassBodyDeclarations</xbgf:inline>
<xbgf:massage>
Expand Down Expand Up @@ -398,7 +394,6 @@
vs.
- [], ,([t({), *(n(InterfaceBodyDeclaration)), t(})])
-->
<xbgf:horizontal>InterfaceMemberDeclarations</xbgf:horizontal>
<xbgf:deyaccify>InterfaceMemberDeclarations</xbgf:deyaccify>
<xbgf:inline>InterfaceMemberDeclarations</xbgf:inline>
<xbgf:massage>
Expand Down Expand Up @@ -434,9 +429,7 @@
vs.
- [], ,([?(,([t(package), n(QualifiedIdentifier), t((;))])), *(n(ImportDeclaration)), *(n(TypeDeclaration))])
-->
<xbgf:horizontal>ImportDeclarations</xbgf:horizontal>
<xbgf:deyaccify>ImportDeclarations</xbgf:deyaccify>
<xbgf:horizontal>TypeDeclarations</xbgf:horizontal>
<xbgf:deyaccify>TypeDeclarations</xbgf:deyaccify>
<xbgf:inline>ImportDeclarations</xbgf:inline>
<xbgf:inline>TypeDeclarations</xbgf:inline>
Expand Down Expand Up @@ -512,7 +505,6 @@
</bgf:expression>
</bgf:production>
</xbgf:extract>
<xbgf:horizontal>Modifiers</xbgf:horizontal>
<xbgf:deyaccify>Modifiers</xbgf:deyaccify>
<xbgf:inline>Modifiers</xbgf:inline>
<xbgf:massage>
Expand Down Expand Up @@ -768,7 +760,6 @@
<nonterminal>InterfaceMemberDecl</nonterminal>
</in>
</xbgf:unfold>
<xbgf:horizontal>MethodDeclarator</xbgf:horizontal>
<xbgf:deyaccify>MethodDeclarator</xbgf:deyaccify>
<xbgf:inline>MethodDeclarator</xbgf:inline>

Expand Down Expand Up @@ -1127,7 +1118,6 @@
vs.
- [], ,([n(FormalParameters), n(BracketsOpt), ?(,([t(throws), n(QualifiedIdentifierList)])), t((;))])
-->
<xbgf:horizontal>FormalParameterList</xbgf:horizontal>
<xbgf:deyaccify>FormalParameterList</xbgf:deyaccify>
<xbgf:extract>
<bgf:production>
Expand Down
3 changes: 0 additions & 3 deletions topics/java/lci/xbgf/editExpressions-jls1.xbgf
Expand Up @@ -14,10 +14,8 @@
<xbgf:horizontal>PrimaryNoNewArray</xbgf:horizontal>
<xbgf:inline>PrimaryNoNewArray</xbgf:inline>

<xbgf:horizontal>Dims</xbgf:horizontal>
<xbgf:deyaccify>Dims</xbgf:deyaccify>
<xbgf:inline>Dims</xbgf:inline>
<xbgf:horizontal>DimExprs</xbgf:horizontal>
<xbgf:deyaccify>DimExprs</xbgf:deyaccify>
<xbgf:inline>DimExprs</xbgf:inline>
<xbgf:inline>DimExpr</xbgf:inline>
Expand Down Expand Up @@ -86,7 +84,6 @@
vs.
- [], ,([t(new), n(QualifiedIdentifier), n(Arguments)])
-->
<xbgf:horizontal>ArgumentList</xbgf:horizontal>
<xbgf:deyaccify>ArgumentList</xbgf:deyaccify>
<xbgf:inline>ArgumentList</xbgf:inline>
<xbgf:fold>
Expand Down
2 changes: 0 additions & 2 deletions topics/java/lci/xbgf/editExpressions.xbgf
Expand Up @@ -261,7 +261,6 @@
vs.
- [], ;([n(StatementExpressionList), ,([?(t(final)), n(Type), n(VariableDeclarators)])])
-->
<xbgf:horizontal>StatementExpressionList</xbgf:horizontal>
<xbgf:deyaccify>StatementExpressionList</xbgf:deyaccify>
<xbgf:extract>
<bgf:production>
Expand Down Expand Up @@ -292,7 +291,6 @@
vs.
- [], ,([t({), ?(n(VariableInitializers)), ?(t((,))), t(})])
-->
<xbgf:horizontal>VariableInitializers</xbgf:horizontal>
<xbgf:deyaccify>VariableInitializers</xbgf:deyaccify>
<xbgf:inline>VariableInitializers</xbgf:inline>

Expand Down
1 change: 0 additions & 1 deletion topics/java/lci/xbgf/extendModifiers.xbgf
Expand Up @@ -215,7 +215,6 @@
vs.
- [], ;([n(ConstantModifier), ,([n(ConstantModifier), n(ConstantModifers)])])
-->
<xbgf:horizontal>ConstantModifiers</xbgf:horizontal>
<xbgf:deyaccify>ConstantModifiers</xbgf:deyaccify>
<xbgf:yaccify>
<bgf:production>
Expand Down
7 changes: 0 additions & 7 deletions topics/java/lci/xbgf/generalizeModifiers.xbgf
Expand Up @@ -55,19 +55,12 @@
-->

<!-- First the deyaccification -->
<xbgf:horizontal>AbstractMethodModifiers</xbgf:horizontal>
<xbgf:deyaccify>AbstractMethodModifiers</xbgf:deyaccify>
<xbgf:horizontal>InterfaceModifiers</xbgf:horizontal>
<xbgf:deyaccify>InterfaceModifiers</xbgf:deyaccify>
<xbgf:horizontal>MethodModifiers</xbgf:horizontal>
<xbgf:deyaccify>MethodModifiers</xbgf:deyaccify>
<xbgf:horizontal>FieldModifiers</xbgf:horizontal>
<xbgf:deyaccify>FieldModifiers</xbgf:deyaccify>
<xbgf:horizontal>ConstructorModifiers</xbgf:horizontal>
<xbgf:deyaccify>ConstructorModifiers</xbgf:deyaccify>
<xbgf:horizontal>ClassModifiers</xbgf:horizontal>
<xbgf:deyaccify>ClassModifiers</xbgf:deyaccify>
<xbgf:horizontal>ConstantModifiers</xbgf:horizontal>
<xbgf:deyaccify>ConstantModifiers</xbgf:deyaccify>

<!-- ISSUE PERMISSIVENESS
Expand Down
1 change: 0 additions & 1 deletion topics/java/lci/xbgf/generalizeNames-doc1.xbgf
Expand Up @@ -52,7 +52,6 @@ vs
<add>ExpressionName</add>
<to>QualifiedIdentifier</to>
</xbgf:unite>
<xbgf:horizontal>QualifiedIdentifier</xbgf:horizontal>
<xbgf:deyaccify>QualifiedIdentifier</xbgf:deyaccify>

<!-- use another name -->
Expand Down
1 change: 0 additions & 1 deletion topics/java/lci/xbgf/generalizeNames.xbgf
Expand Up @@ -61,7 +61,6 @@ vs
<to>QualifiedIdentifier</to>
</xbgf:unite>

<xbgf:horizontal>QualifiedIdentifier</xbgf:horizontal>
<xbgf:deyaccify>QualifiedIdentifier</xbgf:deyaccify>

</xbgf:sequence>
1 change: 0 additions & 1 deletion topics/java/lci/xbgf/inlineStatements.xbgf
Expand Up @@ -170,7 +170,6 @@
</bgf:expression>
</bgf:production>
</xbgf:project>
<xbgf:horizontal>SwitchLabels</xbgf:horizontal>
<xbgf:deyaccify>SwitchLabels</xbgf:deyaccify>
<xbgf:inline>SwitchStatement</xbgf:inline>

Expand Down
1 change: 0 additions & 1 deletion topics/java/lci/xbgf/refactor-app1.xbgf
Expand Up @@ -10,7 +10,6 @@
-->
<xbgf:inline>SimpleName</xbgf:inline>
<xbgf:inline>QualifiedName</xbgf:inline>
<xbgf:horizontal>Name</xbgf:horizontal>
<xbgf:deyaccify>Name</xbgf:deyaccify>

</xbgf:sequence>
30 changes: 28 additions & 2 deletions topics/java/lci/xbgf/refactor-app3.xbgf
Expand Up @@ -7,9 +7,35 @@
- [], ,([n(Annotation), ?(n(Annotations))])
vs.
- [], ;([n(Annotation), ,([n(Annotations), n(Annotation)])])

Later this should become just deyaccify
-->
<xbgf:massage>
<bgf:expression>
<optional>
<bgf:expression>
<nonterminal>Annotations</nonterminal>
</bgf:expression>
</optional>
</bgf:expression>
<bgf:expression>
<choice>
<bgf:expression>
<nonterminal>Annotations</nonterminal>
</bgf:expression>
<bgf:expression>
<epsilon/>
</bgf:expression>
</choice>
</bgf:expression>
<in>
<nonterminal>Annotations</nonterminal>
</in>
</xbgf:massage>
<xbgf:distribute>
<nonterminal>Annotations</nonterminal>
</xbgf:distribute>
<xbgf:vertical>
<nonterminal>Annotations</nonterminal>
</xbgf:vertical>
<xbgf:deyaccify>Annotations</xbgf:deyaccify>

<!--
Expand Down
3 changes: 0 additions & 3 deletions topics/java/lci/xbgf/refactorClasses-doc2.xbgf
Expand Up @@ -134,7 +134,6 @@
vs.
- [], ,([t({), ?(n(ClassBodyDeclarations)), t(})])
-->
<xbgf:horizontal>ClassBodyDeclarations</xbgf:horizontal>
<xbgf:deyaccify>ClassBodyDeclarations</xbgf:deyaccify>
<xbgf:inline>ClassBodyDeclarations</xbgf:inline>
<xbgf:massage>
Expand Down Expand Up @@ -296,7 +295,6 @@
</bgf:expression>
</bgf:production>
</xbgf:extract>
<xbgf:horizontal>FormalParameterList</xbgf:horizontal>
<xbgf:deyaccify>FormalParameterList</xbgf:deyaccify>
<xbgf:inline>FormalParameterList</xbgf:inline>
<xbgf:extract>
Expand Down Expand Up @@ -330,7 +328,6 @@
','([n('ModifiersOpt'), t(void), n('Identifier'), n('FormalParameters'), ?(','([t(throws), n('TypeList')])), n('MethodBody')])),

-->
<xbgf:horizontal>MethodDeclarator</xbgf:horizontal>
<xbgf:deyaccify>MethodDeclarator</xbgf:deyaccify>
<xbgf:fold>
<nonterminal>BracketsOpt</nonterminal>
Expand Down
5 changes: 0 additions & 5 deletions topics/java/lci/xbgf/refactorClasses-doc3.xbgf
Expand Up @@ -103,7 +103,6 @@
vs.
- [], ,([t({), ?(n(ClassBodyDeclarations)), t(})])
-->
<xbgf:horizontal>ClassBodyDeclarations</xbgf:horizontal>
<xbgf:deyaccify>ClassBodyDeclarations</xbgf:deyaccify>
<xbgf:inline>ClassBodyDeclarations</xbgf:inline>
<xbgf:massage>
Expand Down Expand Up @@ -427,7 +426,6 @@
Identifier "(" [ FormalParameterList ] ")"
MethodDeclarator "[" "]"
-->
<xbgf:horizontal>MethodDeclarator</xbgf:horizontal>
<xbgf:deyaccify>MethodDeclarator</xbgf:deyaccify>
<xbgf:inline>MethodDeclarator</xbgf:inline>

Expand Down Expand Up @@ -692,7 +690,6 @@
vs.
- [], ;([n(Identifier), ,([n(VariableDeclaratorId), t([), t(])])])
-->
<xbgf:horizontal>VariableDeclaratorId</xbgf:horizontal>
<xbgf:deyaccify>VariableDeclaratorId</xbgf:deyaccify>

<!--
Expand Down Expand Up @@ -1088,7 +1085,6 @@
vs.
- [], ,([t(<), n(TypeParameterList), t(>)])
-->
<xbgf:horizontal>TypeParameterList</xbgf:horizontal>
<xbgf:deyaccify>TypeParameterList</xbgf:deyaccify>
<xbgf:inline>TypeParameterList</xbgf:inline>

Expand All @@ -1109,7 +1105,6 @@
AdditionalBound is defined as:
"&amp;" InterfaceType
-->
<xbgf:horizontal>AdditionalBoundList</xbgf:horizontal>
<xbgf:deyaccify>AdditionalBoundList</xbgf:deyaccify>
<xbgf:inline>AdditionalBoundList</xbgf:inline>
<xbgf:massage>
Expand Down

0 comments on commit e26925c

Please sign in to comment.