-
Notifications
You must be signed in to change notification settings - Fork 15
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@1152 ab42f6e0-554d-0410-b580-99e487e6eeb2
- Loading branch information
1 parent
46c3008
commit b948135
Showing
3 changed files
with
127 additions
and
1 deletion.
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
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 "Pretty-prints ΞBGF." | ||
echo "Usage: cbgf2cbnf <input-cbgf-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/cbgf2cbnf.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?xml version="1.0"?> | ||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:bgf="http://planet-sl.org/bgf" xmlns:cbgf="http://planet-sl.org/cbgf" xmlns:xhtml="http://www.w3.org/1999/xhtml" version="1.0"> | ||
<xsl:import href="bgf2bnf.xslt"/> | ||
<xsl:output method="text" encoding="UTF-8" omit-xml-declaration="yes"/> | ||
<xsl:template match="/cbgf:relationship"> | ||
<xsl:apply-templates select="./cbgf:*"/> | ||
</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> | ||
<!-- chain, define, ... --> | ||
<xsl:template match="cbgf:*"> | ||
<xsl:value-of select="local-name()"/> | ||
<xsl:text>( | ||
</xsl:text> | ||
<xsl:call-template name="cse"> | ||
<xsl:with-param name="lst" select="*"/> | ||
</xsl:call-template> | ||
<xsl:text>); | ||
</xsl:text> | ||
</xsl:template> | ||
<xsl:template match="cbgf:rename-rename"> | ||
<xsl:choose> | ||
<xsl:when test="local-name(*[1]) = 'nonterminal'"> | ||
<xsl:text>rename-renameN</xsl:text> | ||
</xsl:when> | ||
<xsl:when test="local-name(*[1]) = 'label'"> | ||
<xsl:text>rename-renameL</xsl:text> | ||
</xsl:when> | ||
<xsl:when test="local-name(*[1]) = 'selector'"> | ||
<xsl:text>rename-renameS</xsl:text> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:value-of select="local-name()"/> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
<xsl:text>(</xsl:text> | ||
<xsl:value-of select="*/from"/> | ||
<xsl:text>, </xsl:text> | ||
<xsl:value-of select="*/to"/> | ||
<xsl:text>); | ||
</xsl:text> | ||
</xsl:template> | ||
<xsl:template match="cbgf:vertical-horizontal|cbgf:horizontal-vertical"> | ||
<xsl:value-of select="local-name()"/> | ||
<xsl:text>(</xsl:text> | ||
<xsl:value-of select="nonterminal"/> | ||
<xsl:text>); | ||
</xsl:text> | ||
</xsl:template> | ||
<xsl:template match="cbgf:reroot-reroot"> | ||
<xsl:value-of select="local-name()"/> | ||
<xsl:text>( | ||
[</xsl:text> | ||
<xsl:call-template name="csv"> | ||
<xsl:with-param name="lst" select="from/root"/> | ||
<xsl:with-param name="sep" select="', '"/> | ||
</xsl:call-template> | ||
<xsl:text>], | ||
[</xsl:text> | ||
<xsl:call-template name="csv"> | ||
<xsl:with-param name="lst" select="to/root"/> | ||
<xsl:with-param name="sep" select="', '"/> | ||
</xsl:call-template> | ||
<xsl:text>] | ||
); | ||
</xsl:text> | ||
</xsl:template> | ||
<!-- secondary functions --> | ||
<xsl:template name="csv"> | ||
<xsl:param name="lst"/> | ||
<xsl:param name="sep"/> | ||
<xsl:value-of select="$lst[1]"/> | ||
<xsl:for-each select="$lst[position() > 1]"> | ||
<xsl:value-of select="$sep"/> | ||
<xsl:value-of select="."/> | ||
</xsl:for-each> | ||
</xsl:template> | ||
<xsl:template name="cse"> | ||
<xsl:param name="lst"/> | ||
<xsl:text> </xsl:text> | ||
<xsl:apply-templates select="$lst[1]"/> | ||
<xsl:for-each select="$lst[position() > 1]"> | ||
<xsl:text>, | ||
</xsl:text> | ||
<xsl:apply-templates select="."/> | ||
</xsl:for-each> | ||
</xsl:template> | ||
</xsl:stylesheet> |