Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inlining and extracting groups (inner choices, possibly sequences) fo…
…r enhancing the TXL extractor and exporter git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@838 ab42f6e0-554d-0410-b580-99e487e6eeb2
- Loading branch information
1 parent
5061ece
commit 0060ce5
Showing
8 changed files
with
105 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
bgfdir = ../../../storage/bgf/tests.small | ||
tooldir = ../../../../shared/tools | ||
|
||
test: | ||
ls -1 ${bgfdir} | xargs -n1 ./runtestcase ${tooldir} ${bgfdir} | ||
|
||
clean: | ||
rm -f *~ tmp.*.bgf tmp.xbgf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0"?> | ||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:bgf="http://planet-sl.org/bgf" xmlns:xbgf="http://planet-sl.org/xbgf" version="1.0"> | ||
<xsl:output method="xml" encoding="UTF-8"/> | ||
<xsl:template match="/bgf:grammar"> | ||
<xbgf:sequence xmlns:bgf="http://planet-sl.org/bgf" xmlns:xbgf="http://planet-sl.org/xbgf"> | ||
<xsl:for-each select="bgf:production"> | ||
<xsl:if test="bgf:expression/sequence//choice"> | ||
<xsl:call-template name="extract"> | ||
<xsl:with-param name="name" select="nonterminal"/> | ||
<xsl:with-param name="choices" select="bgf:expression/sequence//choice"/> | ||
</xsl:call-template> | ||
</xsl:if> | ||
</xsl:for-each> | ||
</xbgf:sequence> | ||
</xsl:template> | ||
<xsl:template name="extract"> | ||
<xsl:param name="name"/> | ||
<xsl:param name="choices"/> | ||
<xsl:for-each select="$choices"> | ||
<xbgf:extract xmlns:bgf="http://planet-sl.org/bgf" xmlns:xbgf="http://planet-sl.org/xbgf"> | ||
<bgf:production> | ||
<nonterminal> | ||
<xsl:value-of select="$name"/> | ||
<xsl:text>-grp-</xsl:text> | ||
<xsl:value-of select="position()"/> | ||
</nonterminal> | ||
<bgf:expression> | ||
<xsl:copy-of select="."/> | ||
</bgf:expression> | ||
</bgf:production> | ||
<in> | ||
<nonterminal><xsl:value-of select="$name"/></nonterminal> | ||
</in> | ||
</xbgf:extract> | ||
</xsl:for-each> | ||
</xsl:template> | ||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0"?> | ||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:bgf="http://planet-sl.org/bgf" xmlns:xbgf="http://planet-sl.org/xbgf" version="1.0"> | ||
<xsl:output method="xml" encoding="UTF-8"/> | ||
<xsl:template match="/bgf:grammar"> | ||
<xbgf:sequence xmlns:bgf="http://planet-sl.org/bgf" xmlns:xbgf="http://planet-sl.org/xbgf"> | ||
<xsl:for-each select="bgf:production"> | ||
<xsl:if test="contains(nonterminal,'-grp-')"> | ||
<xbgf:inline> | ||
<xsl:value-of select="nonterminal"/> | ||
</xbgf:inline> | ||
</xsl:if> | ||
</xsl:for-each> | ||
</xbgf:sequence> | ||
</xsl:template> | ||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/sh | ||
|
||
xsltproc extract.xslt $2/$3 > tmp.xbgf | ||
if [ $? -ne 0 ] | ||
then | ||
exit 255 | ||
fi | ||
$1/xbgf tmp.xbgf $2/$3 tmp.1.bgf | ||
if [ $? -ne 0 ] | ||
then | ||
exit 255 | ||
fi | ||
xsltproc inline.xslt tmp.1.bgf > tmp.xbgf | ||
if [ $? -ne 0 ] | ||
then | ||
exit 255 | ||
fi | ||
$1/xbgf tmp.xbgf tmp.1.bgf tmp.2.bgf | ||
if [ $? -ne 0 ] | ||
then | ||
exit 255 | ||
fi | ||
$1/gdt tmp.2.bgf $2/$3 | ||
if [ $? -ne 0 ] | ||
then | ||
exit 255 | ||
fi |