Permalink
Browse files

normalization activities go to transformation, not to presentation;

internal tools are introduced;
BGF-TXL-BGF progress


git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@837 ab42f6e0-554d-0410-b580-99e487e6eeb2
  • Loading branch information...
grammarware committed Sep 30, 2010
1 parent d6c6929 commit 5061ece1f56ded9bc6b0babd69f84e264d33f6a0
@@ -0,0 +1,30 @@
#!/bin/sh
# Takes in:
# ...<postfix-optional>
# Returns:
# <optional>...</optional>
# And takes in:
# ...<postfix-star>
# Returns:
# <star>...</star>
# And takes in:
# ...<postfix-plus>
# Returns:
# <plus>...</plus>
LOCAL=${PWD}
cd `dirname $0`
cd ../..
SLPS=${PWD}
cd ${LOCAL}
if [ ! -r $1 ]; then
echo "Oops: $1 not found or not readable."
exit 255
elif [ $# -eq 2 ]; then
/usr/local/bin/xsltproc ${SLPS}/topics/transformation/normalization/postfix2confix.xslt $1 > $2
else
echo "Internal tool: use at your own risk! Turns postfix iteration constructs to confix ones."
echo "Usage: confixiterations <input> <output>"
exit 1
fi
View
@@ -0,0 +1,32 @@
#!/bin/sh
# Takes in:
# repeat ...
# Returns:
# repeat_...
# And takes in:
# opt ...
# Returns:
# opt_...
LOCAL=${PWD}
cd `dirname $0`
cd ../..
SLPS=${PWD}
cd ${LOCAL}
if [ ! -r $1 ]; then
echo "Oops: $1 not found or not readable."
exit 255
elif [ $# -eq 2 ]; then
cp $1 $2
perl -pi -w -e 's/repeat statement/repeat_statement/g;' $2
perl -pi -w -e 's/repeat compound/repeat_compound/g;' $2
perl -pi -w -e 's/repeat literalOrType/repeat_literalOrType/g;' $2
perl -pi -w -e 's/repeat literalOrVariable/repeat_literalOrVariable/g;' $2
perl -pi -w -e 's/repeat barLiteralsAndTypes/repeat_barLiteralsAndTypes/g;' $2
perl -pi -w -e 's/opt typeRepeater/opt_typeRepeater/g;' $2
else
echo "Internal tool: use at your own risk! Fixes spaces in XML tag names produced by TXL."
echo "Usage: fixtxlxml <input> <output>"
exit 1
fi
@@ -0,0 +1,28 @@
#!/bin/sh
# Takes in:
# <unknown>(</unknown>
# Returns:
# <sequence><bgf:expression>
# And takes in:
# <unknown>)</unknown>
# Returns:
# </bgf:expression></sequence>
LOCAL=${PWD}
cd `dirname $0`
cd ../..
SLPS=${PWD}
cd ${LOCAL}
if [ ! -r $1 ]; then
echo "Oops: $1 not found or not readable."
exit 255
elif [ $# -eq 2 ]; then
cp $1 $2
perl -pi -w -e 's/<unknown>\(<\/unknown>/<sequence><bgf:expression>/g;' $2
perl -pi -w -e 's/<unknown>\)<\/unknown>/<\/bgf:expression><\/sequence>/g;' $2
else
echo "Internal tool: use at your own risk! Turns parentheses to BGF sequences."
echo "Usage: markgroups <input> <output>"
exit 1
fi
View
@@ -16,11 +16,10 @@ elif [ $# -eq 2 ]; then
perl -pi -w -e 's/<unknown>\)\?<\/unknown>/<unknown>\)<\/unknown><postfix-optional\/>/g;' $1.tmp
perl -pi -w -e 's/<unknown>\?\)\?<\/unknown>/<postfix-optional\/><unknown>\)<\/unknown><postfix-optional\/>/g;' $1.tmp
perl -pi -w -e "s/<unknown>\(\'.\'<\/unknown>/<unknown>\(<\/unknown><terminal>.<\/terminal>/g;" $1.tmp
perl -pi -w -e 's/<unknown>\(<\/unknown>/<sequence><bgf:expression>/g;' $1.tmp
perl -pi -w -e 's/<unknown>\)<\/unknown>/<\/bgf:expression><\/sequence>/g;' $1.tmp
/usr/local/bin/xsltproc ${SLPS}/topics/extraction/w3c/postfix2confix.xslt $1.tmp > $2.tmp
`dirname $0`/../internals/markgroups $1.tmp $1.tmp.2
`dirname $0`/../internals/confixiterations $1.tmp.2 $2.tmp
/usr/local/bin/xsltproc ${SLPS}/topics/extraction/w3c/cleanup.xslt $2.tmp > $2
rm -f $1.tmp $2.tmp
rm -f $1.tmp $1.tmp.2 $2.tmp
else
echo "This tool transforms an XML document used by World Wide Web Consortium and produces a BGF grammar"
echo "Usage: spec2bgf <input-xml-document> <output-grammar>"
View
@@ -12,24 +12,14 @@ if [ ! -r $1 ]; then
elif [ $# -eq 2 ]; then
rm -f $2
txl $1 ${SLPS}/topics/extraction/txl/TXLGrammar/Txl/txl.txl -xml > grammar.xml
perl -pi -w -e 's/repeat statement/repeat_statement/g;' grammar.xml
perl -pi -w -e 's/repeat compound/repeat_compound/g;' grammar.xml
perl -pi -w -e 's/repeat literalOrType/repeat_literalOrType/g;' grammar.xml
perl -pi -w -e 's/repeat literalOrVariable/repeat_literalOrVariable/g;' grammar.xml
perl -pi -w -e 's/repeat barLiteralsAndTypes/repeat_barLiteralsAndTypes/g;' grammar.xml
perl -pi -w -e 's/opt typeRepeater/opt_typeRepeater/g;' grammar.xml
xsltproc ${SLPS}/topics/extraction/txl/txl2bgf.xslt grammar.xml > $2
rm -f grammar.xml
`dirname $0`/../internals/fixtxlxml grammar.xml grammar2.xml
xsltproc ${SLPS}/topics/extraction/txl/txl2bgf.xslt grammar2.xml > $2
echo 'rm -f grammar.xml grammar2.xml'
elif [ $# -eq 1 ]; then
txl $1 ${SLPS}/topics/extraction/txl/TXLGrammar/Txl/txl.txl -xml > grammar.xml
perl -pi -w -e 's/repeat statement/repeat_statement/g;' grammar.xml
perl -pi -w -e 's/repeat compound/repeat_compound/g;' grammar.xml
perl -pi -w -e 's/repeat literalOrType/repeat_literalOrType/g;' grammar.xml
perl -pi -w -e 's/repeat literalOrVariable/repeat_literalOrVariable/g;' grammar.xml
perl -pi -w -e 's/repeat barLiteralsAndTypes/repeat_barLiteralsAndTypes/g;' grammar.xml
perl -pi -w -e 's/opt typeRepeater/opt_typeRepeater/g;' grammar.xml
xsltproc ${SLPS}/topics/extraction/txl/txl2bgf.xslt grammar.xml > ${LOCAL}/`basename $1 .txl`.bgf
rm -f grammar.xml
`dirname $0`/../internals/fixtxlxml grammar.xml grammar2.xml
xsltproc ${SLPS}/topics/extraction/txl/txl2bgf.xslt grammar2.xml > ${LOCAL}/`basename $1 .txl`.bgf
rm -f grammar.xml grammar2.xml
else
echo "This tool extracts a BGF grammar from a TXL grammar"
echo "Usage: txl2bgf <txl-grammar> [<output-grammar>]"
@@ -1,4 +1,4 @@
bgfdir = ../../storage/bgf/tests
bgfdir = ../../storage/bgf/tests.small
tooldir = ../../../shared/tools
test:
@@ -99,7 +99,7 @@ function main match [</xsl:text>
</xsl:choose>
</xsl:template>
<xsl:template match="epsilon">
<xsl:text>EPSILON</xsl:text>
<xsl:text>[empty]</xsl:text>
</xsl:template>
<xsl:template match="empty">
<xsl:text>EMPTY</xsl:text>
@@ -141,13 +141,13 @@ function main match [</xsl:text>
</xsl:template>
<!-- inner choices - BNF bar -->
<xsl:template match="choice">
<xsl:text>(</xsl:text>
<!--<xsl:text>(</xsl:text> -->
<xsl:apply-templates select="./bgf:expression[1]/*"/>
<xsl:for-each select="./bgf:expression[position()&gt;1]">
<xsl:text> | </xsl:text>
<xsl:apply-templates select="./*"/>
</xsl:for-each>
<xsl:text>)</xsl:text>
<!--<xsl:text>)</xsl:text>-->
</xsl:template>
<xsl:template name="no-parenthesis">
<xsl:param name="expr"/>
@@ -103,6 +103,11 @@
</terminal>
</bgf:expression>
</xsl:when>
<xsl:when test="type/typeSpec/typeid/id = 'empty'">
<bgf:expression>
<epsilon/>
</bgf:expression>
</xsl:when>
<!-- fallback -->
<xsl:otherwise>
<bgf:expression>

0 comments on commit 5061ece

Please sign in to comment.