Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@364 ab42f6e0-554d-0410-b580-99e487e6eeb2
- Loading branch information
1 parent
dc8ae91
commit 99f945d
Showing
6 changed files
with
218 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/sh | ||
|
||
LOCAL=${PWD} | ||
cd `dirname $0` | ||
cd ../.. | ||
SLPS=${PWD} | ||
cd ${LOCAL} | ||
|
||
if [ $# -eq 1 ]; then | ||
OUTPUT=/dev/stdout | ||
elif [ $# -ne 2 ]; then | ||
echo "This tool transforms Transformational BGF documents to EBNF dialect used in JLS." | ||
echo "Usage: xbgf2xbnf <input-xbgf-document> [<output-text>]" | ||
echo "When output file is not specified, stdout is used." | ||
exit 1 | ||
else | ||
OUTPUT=$2 | ||
fi | ||
if [ ! -r $1 ]; then | ||
echo "Oops: $1 not found or not readable." | ||
exit 1 | ||
fi | ||
|
||
xsltproc ${SLPS}/shared/xsl/xbgf2xbnf.xslt $1 > ${OUTPUT} | ||
|
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,166 @@ | ||
<xsl:stylesheet version = '1.0' | ||
xmlns:xsl='http://www.w3.org/1999/XSL/Transform' | ||
xmlns:bgf="http://planet-sl.org/bgf" | ||
xmlns:xbgf="http://planet-sl.org/xbgf" | ||
xmlns:xhtml="http://www.w3.org/1999/xhtml"> | ||
|
||
<xsl:import href="bgf2bnf.xslt" /> | ||
|
||
<xsl:output | ||
method="text" | ||
encoding="UTF-8" | ||
omit-xml-declaration="yes" | ||
/> | ||
|
||
<xsl:template match="/xbgf:sequence"> | ||
<xsl:apply-templates select="./xbgf:*"/> | ||
</xsl:template> | ||
|
||
<!-- optional context --> | ||
<xsl:template name="context"> | ||
<xsl:param name="in"/> | ||
<xsl:choose> | ||
<xsl:when test="$in/nonterminal"> | ||
<xsl:text> in </xsl:text> | ||
<xsl:value-of select="$in/nonterminal" /> | ||
</xsl:when> | ||
<xsl:when test="$in/label"> | ||
<xsl:text> in "</xsl:text> | ||
<xsl:value-of select="$in/label" /> | ||
<xsl:text>"</xsl:text> | ||
</xsl:when> | ||
</xsl:choose> | ||
</xsl:template> | ||
|
||
<!-- add, chain, define, ... --> | ||
|
||
<xsl:template match="xbgf:*"> | ||
<xsl:value-of select="local-name()" /> | ||
<xsl:text>( | ||
</xsl:text> | ||
<xsl:apply-templates select="./bgf:production"/> | ||
<xsl:call-template name="context"> | ||
<xsl:with-param name="in" select="./in"/> | ||
</xsl:call-template> | ||
<xsl:text>); | ||
</xsl:text> | ||
</xsl:template> | ||
|
||
<xsl:template match="xbgf:designate"> | ||
<xsl:value-of select="local-name()" /> | ||
<xsl:text>("</xsl:text> | ||
<xsl:value-of select="./bgf:production/label" /> | ||
<xsl:text>", | ||
</xsl:text> | ||
<xsl:apply-templates select="./bgf:production"/> | ||
<xsl:text>); | ||
</xsl:text> | ||
</xsl:template> | ||
|
||
<xsl:template match="xbgf:deyaccify|xbgf:eliminate|xbgf:horizontal|xbgf:inline|xbgf:undefine"> | ||
<xsl:value-of select="local-name()" /> | ||
<xsl:text>(</xsl:text> | ||
<xsl:value-of select="text()"/> | ||
<xsl:text>); | ||
</xsl:text> | ||
</xsl:template> | ||
|
||
<xsl:template match="xbgf:distribute|xbgf:vertical"> | ||
<xsl:value-of select="local-name()" /> | ||
<xsl:text>(</xsl:text> | ||
<xsl:call-template name="context"> | ||
<xsl:with-param name="in" select="."/> | ||
</xsl:call-template> | ||
<xsl:text> ); | ||
</xsl:text> | ||
</xsl:template> | ||
|
||
<xsl:template match="xbgf:factor|xbgf:massage|xbgf:narrow|xbgf:replace|xbgf:widen"> | ||
<xsl:value-of select="local-name()" /> | ||
<xsl:text>( | ||
</xsl:text> | ||
<xsl:apply-templates select="./bgf:expression[1]"/> | ||
<xsl:text>, | ||
</xsl:text> | ||
<xsl:apply-templates select="./bgf:expression[2]"/> | ||
<xsl:choose> | ||
<xsl:when test="in"> | ||
<xsl:text> | ||
</xsl:text> | ||
<xsl:call-template name="context"> | ||
<xsl:with-param name="in" select="./in"/> | ||
</xsl:call-template> | ||
</xsl:when> | ||
</xsl:choose> | ||
<xsl:text>); | ||
</xsl:text> | ||
</xsl:template> | ||
|
||
<xsl:template match="xbgf:fold|xbgf:unfold"> | ||
<xsl:value-of select="local-name()" /> | ||
<xsl:text>(</xsl:text> | ||
<xsl:value-of select="./nonterminal"/> | ||
<xsl:choose> | ||
<xsl:when test="in"> | ||
<xsl:text> | ||
</xsl:text> | ||
<xsl:call-template name="context"> | ||
<xsl:with-param name="in" select="./in"/> | ||
</xsl:call-template> | ||
</xsl:when> | ||
</xsl:choose> | ||
<xsl:text>); | ||
</xsl:text> | ||
</xsl:template> | ||
|
||
<xsl:template match="xbgf:rename"> | ||
<xsl:value-of select="local-name()" /> | ||
<xsl:text>(</xsl:text> | ||
<xsl:value-of select="local-name(*)" /> | ||
<xsl:text> | ||
</xsl:text> | ||
<xsl:apply-templates select="./*/*[1]"/> | ||
<xsl:text>, | ||
</xsl:text> | ||
<xsl:apply-templates select="./*/*[2]"/> | ||
<xsl:text>); | ||
</xsl:text> | ||
</xsl:template> | ||
|
||
<xsl:template match="xbgf:reroot"> | ||
<xsl:value-of select="local-name()" /> | ||
<xsl:text>(</xsl:text> | ||
<xsl:value-of select="./root"/> | ||
<xsl:text>); | ||
</xsl:text> | ||
</xsl:template> | ||
|
||
<xsl:template match="xbgf:strip"> | ||
<xsl:value-of select="local-name()" /> | ||
<xsl:text>(</xsl:text> | ||
<xsl:choose> | ||
<xsl:when test="label|selector|terminal"> | ||
<xsl:value-of select="local-name(*)" /> | ||
<xsl:text>, "</xsl:text> | ||
<xsl:value-of select="*/text()" /> | ||
<xsl:text>"</xsl:text> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:value-of select="local-name(*)" /> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
<xsl:text>); | ||
</xsl:text> | ||
</xsl:template> | ||
|
||
<xsl:template match="xbgf:unite"> | ||
<xsl:value-of select="local-name()" /> | ||
<xsl:text>(</xsl:text> | ||
<xsl:apply-templates select="add/text()"/> | ||
<xsl:text>, </xsl:text> | ||
<xsl:apply-templates select="to/text()"/> | ||
<xsl:text>); | ||
</xsl:text> | ||
</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