Skip to content

Commit

Permalink
xbgf:redefine
Browse files Browse the repository at this point in the history
git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@433 ab42f6e0-554d-0410-b580-99e487e6eeb2
  • Loading branch information
grammarware committed Feb 4, 2009
1 parent a9dca7a commit 526b321
Show file tree
Hide file tree
Showing 15 changed files with 198 additions and 233 deletions.
6 changes: 6 additions & 0 deletions shared/prolog/readXbgf.pro
Expand Up @@ -276,6 +276,12 @@ xml2xbgf(T,undefine(N))
self(name(xbgf:undefine),T),
content(T,N).

xml2xbgf(T,redefine(Ps2))
:-
self(name(xbgf:redefine),T),
children(name(bgf:production),T,Ps1),
maplist(xmlToP,Ps1,Ps2).

xml2xbgf(T,G)
:-
self(name(xbgf:unfold),T),
Expand Down
12 changes: 12 additions & 0 deletions shared/prolog/xbgf1.pro
Expand Up @@ -107,6 +107,18 @@ ps2n(Ps1,N)
[]),
!.

%
% p([l(redefine)], f, +n(p))
%
% Undefine a nonterminal and define a new one with the same name
%

redefine(Ps1,G1,G2)
:-
ps2n(Ps1,N),
undefine(N,G1,G3),
define(Ps1,G3,G2).


%
% p([l(designate)], f, n(p))
Expand Down
18 changes: 18 additions & 0 deletions shared/xsd/xbgf.xsd
Expand Up @@ -33,6 +33,7 @@
<xsd:element ref="xbgf:add"/>
<xsd:element ref="xbgf:chain"/>
<xsd:element ref="xbgf:define"/>
<xsd:element ref="xbgf:redefine"/>
<xsd:element ref="xbgf:designate"/>
<xsd:element ref="xbgf:deyaccify"/>
<xsd:element ref="xbgf:distribute"/>
Expand Down Expand Up @@ -135,6 +136,23 @@
</xsd:complexType>
</xsd:element>

<xsd:element name="redefine">
<xsd:annotation>
<xsd:documentation>
A replace variant that works on production level. When this
transformation is executed, all current productions for the
nonterminal are dropped, and all the given ones are added
to the grammar.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="tag" type="xsd:string"/>
</xsd:complexType>
</xsd:element>

<xsd:element name="designate">
<xsd:annotation>
<xsd:documentation>
Expand Down
30 changes: 13 additions & 17 deletions topics/java/lci/xbgf/edit-doc1.xbgf
Expand Up @@ -7,30 +7,26 @@
<bgf:production>
<nonterminal>PackageOrTypeName</nonterminal>
<bgf:expression>
<choice>
<nonterminal>Identifier</nonterminal>
</bgf:expression>
</bgf:production>
<bgf:production>
<nonterminal>PackageOrTypeName</nonterminal>
<bgf:expression>
<sequence>
<bgf:expression>
<nonterminal>Identifier</nonterminal>
<nonterminal>PackageOrTypeName</nonterminal>
</bgf:expression>
<bgf:expression>
<sequence>
<bgf:expression>
<nonterminal>PackageOrTypeName</nonterminal>
</bgf:expression>
<bgf:expression>
<terminal>.</terminal>
</bgf:expression>
<bgf:expression>
<nonterminal>Identifier</nonterminal>
</bgf:expression>
</sequence>
<terminal>.</terminal>
</bgf:expression>
<bgf:expression>
<nonterminal>Identifier</nonterminal>
</bgf:expression>
</choice>
</sequence>
</bgf:expression>
</bgf:production>
</xbgf:introduce>
<xbgf:vertical>
<nonterminal>PackageOrTypeName</nonterminal>
</xbgf:vertical>

<!--
Local substitution:
Expand Down
7 changes: 3 additions & 4 deletions topics/java/lci/xbgf/editDeclarations.xbgf
Expand Up @@ -1250,10 +1250,9 @@
- [], ;([,([n(VariableDeclaratorRest), *(,([t((,)), n(Identifier), n(VariableDeclaratorRest)])), t((;))]), ,([n(FormalParameters), *(,([t([), t(])])), ?(,([t(throws), n(TypeList)])), t((;))])])
vs.
- [], ;([,([n(ConstantDeclaratorsRest), t((;))]), n(InterfaceMethodDeclaratorRest)])

-->
<xbgf:undefine>InterfaceMethodOrFieldRest</xbgf:undefine>
<!-- BREFACTOR -->
<xbgf:define>
<xbgf:redefine>
<bgf:production>
<nonterminal>InterfaceMethodOrFieldRest</nonterminal>
<bgf:expression>
Expand All @@ -1274,7 +1273,7 @@
</choice>
</bgf:expression>
</bgf:production>
</xbgf:define>
</xbgf:redefine>
<xbgf:vertical>
<nonterminal>InterfaceMethodOrFieldRest</nonterminal>
</xbgf:vertical>
Expand Down
10 changes: 3 additions & 7 deletions topics/java/lci/xbgf/extend-doc1.xbgf
Expand Up @@ -34,8 +34,6 @@
<nonterminal>Identifier</nonterminal>
</bgf:expression>
</bgf:production>
</xbgf:introduce>
<xbgf:add>
<bgf:production>
<nonterminal>ClassName</nonterminal>
<bgf:expression>
Expand All @@ -52,7 +50,7 @@
</sequence>
</bgf:expression>
</bgf:production>
</xbgf:add>
</xbgf:introduce>
<xbgf:add>
<bgf:production>
<nonterminal>FieldAccess</nonterminal>
Expand Down Expand Up @@ -87,9 +85,7 @@
- [], ;([n(Literal), ,([n(Type), t(.), t(class)]), ,([t(void), t(.), t(class)]), t(this), ,([n(ClassName), t(.), t(this)]), ,([t((), n(Expression), t())]), n(ClassInstanceCreationExpression), n(FieldAccess), n(MethodInvocation), n(ArrayAccess)])
-->
<!-- BREFACTOR -->
<xbgf:undefine>PrimaryNoNewArray</xbgf:undefine>
<!-- BREFACTOR -->
<xbgf:define>
<xbgf:redefine>
<bgf:production>
<nonterminal>PrimaryNoNewArray</nonterminal>
<bgf:expression>
Expand Down Expand Up @@ -167,7 +163,7 @@
</choice>
</bgf:expression>
</bgf:production>
</xbgf:define>
</xbgf:redefine>
<xbgf:vertical>
<nonterminal>PrimaryNoNewArray</nonterminal>
</xbgf:vertical>
Expand Down

0 comments on commit 526b321

Please sign in to comment.