Skip to content

Commit

Permalink
massage can now go from a(ba)* to (ab)*a
Browse files Browse the repository at this point in the history
git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@456 ab42f6e0-554d-0410-b580-99e487e6eeb2
  • Loading branch information
grammarware committed Feb 10, 2009
1 parent 3e022b4 commit 64c6168
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 68 deletions.
2 changes: 2 additions & 0 deletions shared/prolog/xbgf1.pro
Expand Up @@ -744,6 +744,8 @@ massage_rules(+(?(X)),*(X)).
massage_rules(?(X),';'(L)) :- length(L,2),member(X,L),member(true,L).
massage_rules(*(X),';'(L)) :- length(L,2),member(+(X),L),member(true,L).
massage_rules(+(X),','([X,*(X)])).
massage_rules(','([X,*(','([Y,X]))]),','([*(','([X,Y])),X])).
massage_rules(','([X,+(','([Y,X]))]),','([+(','([X,Y])),X])).


%
Expand Down
128 changes: 64 additions & 64 deletions shared/xsd/xbgf.xsd
Expand Up @@ -109,6 +109,19 @@
</xsd:complexType>
</xsd:element>

<xsd:element name="appear">
<xsd:annotation>
<xsd:documentation>
TBD
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

<xsd:element name="chain">
<xsd:annotation>
<xsd:documentation>
Expand All @@ -128,6 +141,19 @@
</xsd:complexType>
</xsd:element>

<xsd:element name="deanonymize">
<xsd:annotation>
<xsd:documentation>
TBD
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

<xsd:element name="define">
<xsd:annotation>
<xsd:documentation>
Expand All @@ -145,20 +171,30 @@
</xsd:complexType>
</xsd:element>

<xsd:element name="redefine">
<xsd:element name="disappear">
<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.
TBD
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production" maxOccurs="unbounded"/>
<xsd:element ref="bgf:production"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

<xsd:element name="downgrade">
<xsd:annotation>
<xsd:documentation>
To be explained later.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production"/>
<xsd:element ref="bgf:production"/>
</xsd:sequence>
<xsd:attribute name="tag" type="xsd:string"/>
</xsd:complexType>
</xsd:element>

Expand All @@ -179,7 +215,7 @@
<xsd:element name="unlabel">
<xsd:annotation>
<xsd:documentation>
TBD
TBD
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
Expand Down Expand Up @@ -492,6 +528,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="remove">
<xsd:annotation>
<xsd:documentation>
Expand Down Expand Up @@ -689,7 +742,7 @@
</xsd:choice>
</xsd:complexType>
</xsd:element>

<xsd:element name="unchain">
<xsd:annotation>
<xsd:documentation>
Expand Down Expand Up @@ -767,7 +820,7 @@
</xsd:sequence>
</xsd:complexType>
</xsd:element>

<xsd:element name="abstractize">
<xsd:annotation>
<xsd:documentation>
Expand All @@ -794,45 +847,6 @@
</xsd:complexType>
</xsd:element>

<xsd:element name="deanonymize">
<xsd:annotation>
<xsd:documentation>
TBD
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

<xsd:element name="appear">
<xsd:annotation>
<xsd:documentation>
TBD
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

<xsd:element name="disappear">
<xsd:annotation>
<xsd:documentation>
TBD
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

<xsd:element name="vertical">
<xsd:annotation>
<xsd:documentation>
Expand Down Expand Up @@ -890,20 +904,6 @@
</xsd:complexType>
</xsd:element>

<xsd:element name="downgrade">
<xsd:annotation>
<xsd:documentation>
To be explained later.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="bgf:production"/>
<xsd:element ref="bgf:production"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

<xsd:element name="upgrade">
<xsd:annotation>
<xsd:documentation>
Expand Down Expand Up @@ -938,4 +938,4 @@
</xsd:choice>
</xsd:group>

</xsd:schema>
</xsd:schema>
14 changes: 10 additions & 4 deletions topics/presentation/metrics/xbgf_overview.py
Expand Up @@ -3,10 +3,16 @@
import sys
import elementtree.ElementTree as ET

safexbgf = ('eliminate','introduce','chain', 'designate', 'deyaccify','distribute',
'extract', 'factor', 'fold', 'horizontal','inline', 'massage',
'rename', 'reroot', 'unfold','vertical', 'yaccify', 'unchain', 'skip')
incdecxbgf = ('add', 'narrow', 'remove','unite', 'widen', 'rassoc', 'lassoc')
safexbgf = ('abridge','detour','anonymize','deanonymize','unlabel','designate',
'deyaccify','yaccify','eliminate','introduce','inline','extract',
'unfold','fold','horizontal','vertical','distribute','factor',
'massage','chain','unchain','skip','reroot','rename')
#safexbgf = ('eliminate','introduce','chain', 'designate', 'deyaccify','distribute',
# 'extract', 'factor', 'fold', 'horizontal','inline', 'massage',
# 'rename', 'reroot', 'unfold','vertical', 'yaccify', 'unchain', 'skip')
incdecxbgf = ('remove','add','disappear','appear','narrow','widen',
'downgrade','upgrade','rassoc','lassoc','unite')
#incdecxbgf = ('add', 'narrow', 'remove','unite', 'widen', 'rassoc', 'lassoc')
messyxbgf = ('permute', 'dump')

rkeys = ('LOC','NOI','NOX','NI~','NI+','NI!','SGO','COR','NI^','SID','SRE')
Expand Down
27 changes: 27 additions & 0 deletions topics/transformation/xbgf/tests/massage7.baseline
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<bgf:grammar xmlns:bgf="http://planet-sl.org/bgf">
<bgf:production>
<nonterminal>N</nonterminal>
<bgf:expression>
<sequence>
<bgf:expression>
<nonterminal>a</nonterminal>
</bgf:expression>
<bgf:expression>
<star>
<bgf:expression>
<sequence>
<bgf:expression>
<nonterminal>b</nonterminal>
</bgf:expression>
<bgf:expression>
<nonterminal>a</nonterminal>
</bgf:expression>
</sequence>
</bgf:expression>
</star>
</bgf:expression>
</sequence>
</bgf:expression>
</bgf:production>
</bgf:grammar>
27 changes: 27 additions & 0 deletions topics/transformation/xbgf/tests/massage7.bgf
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<bgf:grammar xmlns:bgf="http://planet-sl.org/bgf">
<bgf:production>
<nonterminal>N</nonterminal>
<bgf:expression>
<sequence>
<bgf:expression>
<star>
<bgf:expression>
<sequence>
<bgf:expression>
<nonterminal>a</nonterminal>
</bgf:expression>
<bgf:expression>
<nonterminal>b</nonterminal>
</bgf:expression>
</sequence>
</bgf:expression>
</star>
</bgf:expression>
<bgf:expression>
<nonterminal>a</nonterminal>
</bgf:expression>
</sequence>
</bgf:expression>
</bgf:production>
</bgf:grammar>
49 changes: 49 additions & 0 deletions topics/transformation/xbgf/tests/massage7.xbgf
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<xbgf:sequence
xmlns:bgf="http://planet-sl.org/bgf"
xmlns:xbgf="http://planet-sl.org/xbgf">
<xbgf:massage>
<bgf:expression>
<sequence>
<bgf:expression>
<star>
<bgf:expression>
<sequence>
<bgf:expression>
<nonterminal>a</nonterminal>
</bgf:expression>
<bgf:expression>
<nonterminal>b</nonterminal>
</bgf:expression>
</sequence>
</bgf:expression>
</star>
</bgf:expression>
<bgf:expression>
<nonterminal>a</nonterminal>
</bgf:expression>
</sequence>
</bgf:expression>
<bgf:expression>
<sequence>
<bgf:expression>
<nonterminal>a</nonterminal>
</bgf:expression>
<bgf:expression>
<star>
<bgf:expression>
<sequence>
<bgf:expression>
<nonterminal>b</nonterminal>
</bgf:expression>
<bgf:expression>
<nonterminal>a</nonterminal>
</bgf:expression>
</sequence>
</bgf:expression>
</star>
</bgf:expression>
</sequence>
</bgf:expression>
</xbgf:massage>
</xbgf:sequence>

0 comments on commit 64c6168

Please sign in to comment.