Skip to content

Commit

Permalink
#2230: smarter formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jul 11, 2023
1 parent e00f461 commit f665ef1
Showing 1 changed file with 36 additions and 15 deletions.
51 changes: 36 additions & 15 deletions eo-parser/src/test/resources/org/eolang/parser/ebnf/to-ebnf.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,25 @@ SOFTWARE.
<xsl:text> } </xsl:text>
</xsl:template>
<xsl:template match="g:oneOrMore">
<xsl:text> ( </xsl:text>
<xsl:if test="count(g:*) &gt; 1">
<xsl:text> ( </xsl:text>
</xsl:if>
<xsl:apply-templates select="g:*"/>
<xsl:text> ) { </xsl:text>
<xsl:if test="count(g:*) &gt; 1">
<xsl:text> ) </xsl:text>
</xsl:if>
<xsl:text> { </xsl:text>
<xsl:apply-templates select="g:*"/>
<xsl:text> } </xsl:text>
</xsl:template>
<xsl:template match="g:sequence">
<xsl:text> ( </xsl:text>
<xsl:if test="count(g:*) &gt; 1">
<xsl:text> ( </xsl:text>
</xsl:if>
<xsl:apply-templates select="g:*"/>
<xsl:text> ) </xsl:text>
<xsl:if test="count(g:*) &gt; 1">
<xsl:text> ) </xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="g:choice">
<xsl:text> ( </xsl:text>
Expand Down Expand Up @@ -113,20 +122,32 @@ SOFTWARE.
<xsl:value-of select="@maxChar"/>
</xsl:template>
<xsl:template match="g:charCode">
<xsl:text>\textbackslash{}</xsl:text>
<xsl:variable name="txt">
<xsl:text>\textbackslash{}</xsl:text>
<xsl:choose>
<xsl:when test="@value = '9'">
<xsl:text>t</xsl:text>
</xsl:when>
<xsl:when test="upper-case(@value) = 'A'">
<xsl:text>n</xsl:text>
</xsl:when>
<xsl:when test="upper-case(@value) = 'D'">
<xsl:text>r</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>x</xsl:text>
<xsl:value-of select="upper-case(@value)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="@value = '9'">
<xsl:text>t</xsl:text>
</xsl:when>
<xsl:when test="upper-case(@value) = 'A'">
<xsl:text>n</xsl:text>
</xsl:when>
<xsl:when test="upper-case(@value) = 'D'">
<xsl:text>r</xsl:text>
<xsl:when test="ancestor::g:charClass">
<xsl:value-of select="$txt"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>x</xsl:text>
<xsl:value-of select="upper-case(@value)"/>
<xsl:text>"</xsl:text>
<xsl:value-of select="$txt"/>
<xsl:text>"</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Expand Down

0 comments on commit f665ef1

Please sign in to comment.