Permalink
Browse files

xbgf:equate operator implemented; one test case is still failing

git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@765 ab42f6e0-554d-0410-b580-99e487e6eeb2
  • Loading branch information...
grammarware committed Feb 3, 2010
1 parent d2be3a0 commit 15eab7f71a3a59975cdc46314de58eba426d5045
@@ -373,6 +373,14 @@ xml2xbgf(T,unite(N1,N2))
content(Add,N1),
content(To,N2).
xml2xbgf(T,equate(N1,N2))
:-
self(name(xbgf:equate),T),
child(name(align),T,Align),
child(name(with),T,With),
content(Align,N1),
content(With,N2).
xml2xbgf(T,upgrade(P1,P2))
:-
self(name(xbgf:upgrade),T),
View
@@ -1448,6 +1448,27 @@ unite(N1,N2,G1,G2)
[N1,N2]),
transform(try(xbgf1:renameN_rules(N1,N2)),G1,G2).
%
% p([l(equate)], f, ','([n(n), n(n)]))
%
% Merging two identically defined nonterminals
%
equate(N1,N2,g(Rs1,Ps1),g(Rs2,Ps2))
:-
findN(Ps1,N1,N1Ps1),
findN(Ps1,N2,N2Ps),
xbgf1:renameN(N1,N2,g(Rs1,N1Ps1),g(_,N1Ps2)),
checkforidentity(N1Ps2,N2Ps),
xbgf1:unite(N1,N2,g(Rs1,Ps1),g(Rs2,Ps2)).
checkforidentity([],[]).
checkforidentity([P1|Ps1],Ps2)
:-
removeproduction(P1,Ps2,Ps3),
checkforidentity(Ps1,Ps3).
removeproduction(P1,[P2|Ps2],Ps2) :- eqP(P1,P2).
removeproduction(P1,[P2|Ps2],Ps3) :- [P2|removeproduction(P1,Ps2,Ps3)].
%
% p([l(verticalL)], f, n(l))
View
@@ -133,6 +133,7 @@
<xsd:element ref="xbgf:import"/>
<xsd:element ref="xbgf:vertical"/>
<xsd:element ref="xbgf:horizontal"/>
<xsd:element ref="xbgf:equate"/>
<!-- do we need them? -->
<xsd:element ref="xbgf:rassoc"/>
<xsd:element ref="xbgf:lassoc"/>
@@ -1138,6 +1139,20 @@
</xsd:complexType>
</xsd:element>
<xsd:element name="equate">
<xsd:annotation>
<xsd:documentation>
Two nonterminals, say x and y, are merged, if their definitions are identical.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="align" type="bgf:nonterminal"/>
<xsd:element name="with" type="bgf:nonterminal"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="abstractize">
<xsd:annotation>
<xsd:documentation>
View
@@ -248,4 +248,14 @@
</xsl:text>
</xsl:template>
<xsl:template match="xbgf:equate">
<xsl:value-of select="local-name()" />
<xsl:text>(</xsl:text>
<xsl:apply-templates select="align/text()"/>
<xsl:text>, </xsl:text>
<xsl:apply-templates select="with/text()"/>
<xsl:text>);
</xsl:text>
</xsl:template>
</xsl:stylesheet>
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<bgf:grammar xmlns:bgf="http://planet-sl.org/bgf">
<bgf:production>
<nonterminal>bar</nonterminal>
<bgf:expression>
<nonterminal>wez</nonterminal>
</bgf:expression>
</bgf:production>
</bgf:grammar>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<bgf:grammar xmlns:bgf="http://planet-sl.org/bgf">
<bgf:production>
<nonterminal>foo</nonterminal>
<bgf:expression>
<nonterminal>wez</nonterminal>
</bgf:expression>
</bgf:production>
<bgf:production>
<nonterminal>bar</nonterminal>
<bgf:expression>
<nonterminal>wez</nonterminal>
</bgf:expression>
</bgf:production>
</bgf:grammar>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<xbgf:sequence xmlns:bgf="http://planet-sl.org/bgf" xmlns:xbgf="http://planet-sl.org/xbgf">
<xbgf:equate>
<align>foo</align>
<with>bar</with>
</xbgf:equate>
</xbgf:sequence>
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<bgf:grammar xmlns:bgf="http://planet-sl.org/bgf">
<bgf:production>
<nonterminal>bar</nonterminal>
<bgf:expression>
<choice>
<bgf:expression>
<terminal>x</terminal>
</bgf:expression>
<bgf:expression>
<star>
<bgf:expression>
<nonterminal>wez</nonterminal>
</bgf:expression>
</star>
</bgf:expression>
</choice>
</bgf:expression>
</bgf:production>
</bgf:grammar>
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<bgf:grammar xmlns:bgf="http://planet-sl.org/bgf">
<bgf:production>
<nonterminal>foo</nonterminal>
<bgf:expression>
<choice>
<bgf:expression>
<star>
<bgf:expression>
<nonterminal>wez</nonterminal>
</bgf:expression>
</star>
</bgf:expression>
<bgf:expression>
<terminal>x</terminal>
</bgf:expression>
</choice>
</bgf:expression>
</bgf:production>
<bgf:production>
<nonterminal>bar</nonterminal>
<bgf:expression>
<choice>
<bgf:expression>
<terminal>x</terminal>
</bgf:expression>
<bgf:expression>
<star>
<bgf:expression>
<nonterminal>wez</nonterminal>
</bgf:expression>
</star>
</bgf:expression>
</choice>
</bgf:expression>
</bgf:production>
</bgf:grammar>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<xbgf:sequence xmlns:bgf="http://planet-sl.org/bgf" xmlns:xbgf="http://planet-sl.org/xbgf">
<xbgf:equate>
<align>foo</align>
<with>bar</with>
</xbgf:equate>
</xbgf:sequence>

0 comments on commit 15eab7f

Please sign in to comment.