Skip to content

Commit

Permalink
pretty-printing: XBGF fixed; BGF updated
Browse files Browse the repository at this point in the history
git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@474 ab42f6e0-554d-0410-b580-99e487e6eeb2
  • Loading branch information
grammarware committed Feb 17, 2009
1 parent a85bf24 commit 6acca9b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 46 deletions.
45 changes: 35 additions & 10 deletions shared/xsl/bgf2bnf.xslt
Expand Up @@ -59,20 +59,45 @@
</xsl:template>

<xsl:template match="plus">
<xsl:text>( </xsl:text>
<xsl:apply-templates select="./*"/>
<xsl:text>)+ </xsl:text>
<xsl:choose>
<xsl:when test="./bgf:expression/sequence">
<xsl:text>( </xsl:text>
<xsl:apply-templates select="./bgf:expression/sequence/*"/>
<xsl:text>)+ </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="./*"/>
<xsl:text>+ </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="star">
<xsl:text>( </xsl:text>
<xsl:apply-templates select="./*"/>
<xsl:text>)* </xsl:text>
<xsl:choose>
<xsl:when test="./bgf:expression/sequence">
<xsl:text>( </xsl:text>
<xsl:apply-templates select="./bgf:expression/sequence/*"/>
<xsl:text>)* </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="./*"/>
<xsl:text>* </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="optional">
<xsl:apply-templates select="./*"/>
<xsl:text>? </xsl:text>
<xsl:choose>
<xsl:when test="./bgf:expression/sequence">
<xsl:text>( </xsl:text>
<xsl:apply-templates select="./bgf:expression/sequence/*"/>
<xsl:text>)? </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="./*"/>
<xsl:text>? </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="terminal">
Expand Down Expand Up @@ -118,7 +143,7 @@
<xsl:template match="sequence">
<xsl:text>( </xsl:text>
<xsl:apply-templates select="./*"/>
<xsl:text>)</xsl:text>
<xsl:text>) </xsl:text>
</xsl:template>

<!-- top level choices - one per line -->
Expand All @@ -144,7 +169,7 @@
<xsl:text>) </xsl:text>
</xsl:template>


<xsl:template name="car">
<xsl:param name="expr"/>
<xsl:text>
Expand Down
48 changes: 12 additions & 36 deletions shared/xsl/xbgf2xbnf.xslt
Expand Up @@ -37,8 +37,11 @@
<xsl:template match="xbgf:*">
<xsl:value-of select="local-name()" />
<xsl:text>(
</xsl:text>
<xsl:apply-templates select="./bgf:production"/>
</xsl:text>
<xsl:for-each select="./bgf:production">
<xsl:text> </xsl:text>
<xsl:apply-templates select="."/>
</xsl:for-each>
<xsl:call-template name="context">
<xsl:with-param name="in" select="./in"/>
</xsl:call-template>
Expand All @@ -47,47 +50,22 @@
</xsl:template>

<xsl:template match="xbgf:add">
<xsl:value-of select="local-name()" />
<xsl:text>(
</xsl:text>
<xsl:choose>
<xsl:when test="./bgf:production">
<xsl:apply-templates select="./bgf:production"/>
<xsl:call-template name="context">
<xsl:with-param name="in" select="./in"/>
</xsl:call-template>
<xsl:when test="./vertical">
<xsl:text>addV(
</xsl:text>
<xsl:apply-templates select="./vertical/bgf:production"/>
</xsl:when>
<xsl:when test="./bgf:expression">
<xsl:apply-templates select="./bgf:expression[1]"/>
<xsl:text>,
<xsl:when test="./horizontal">
<xsl:text>addH(
</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:apply-templates select="./horizontal/bgf:production"/>
</xsl:when>
</xsl:choose>
<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>
Expand Down Expand Up @@ -133,8 +111,6 @@
<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>
Expand Down

0 comments on commit 6acca9b

Please sign in to comment.