Skip to content

Commit

Permalink
bug(objectionary#3674): alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
maxonfjvipon committed Feb 19, 2025
1 parent f121fe7 commit edfa9d3
Show file tree
Hide file tree
Showing 13 changed files with 176 additions and 223 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ SOFTWARE.
of the object.
-->
<xsl:output encoding="UTF-8" method="xml"/>
<xsl:import href="/org/eolang/parser/_specials.xsl"/>
<xsl:function name="eo:locator" as="xs:string">
<xsl:param name="program" as="node()"/>
<xsl:param name="o" as="node()"/>
Expand All @@ -43,7 +44,7 @@ SOFTWARE.
<xsl:value-of select="eo:locator($program, $o/parent::o)"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>Φ</xsl:text>
<xsl:value-of select="$eo:program"/>
<xsl:if test="$program/metas/meta[head='package']">
<xsl:text>.</xsl:text>
<xsl:value-of select="$program/metas/meta[head='package']/tail"/>
Expand All @@ -55,7 +56,7 @@ SOFTWARE.
<xsl:when test="$o/@name">
<xsl:choose>
<xsl:when test="$o/@name = '@'">
<xsl:text>φ</xsl:text>
<xsl:value-of select="$eo:phi"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$o/@name"/>
Expand All @@ -65,10 +66,10 @@ SOFTWARE.
<xsl:otherwise>
<xsl:choose>
<xsl:when test="starts-with($o/parent::o/@base, '.') and not($o/preceding-sibling::o)">
<xsl:text>ρ</xsl:text>
<xsl:value-of select="$eo:rho"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>α</xsl:text>
<xsl:value-of select="$eo:alpha"/>
<xsl:value-of select="count($o/preceding-sibling::o) - count($o/parent::o[starts-with(@base, '.')])"/>
</xsl:otherwise>
</xsl:choose>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ SOFTWARE.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" id="attrs" version="2.0">
<xsl:output encoding="UTF-8" method="xml"/>
<xsl:import href="/org/eolang/parser/_specials.xsl"/>
<xsl:template match="class[not(@base)]/o[@name]">
<xsl:apply-templates select="." mode="with-attributes"/>
</xsl:template>
Expand All @@ -38,10 +39,10 @@ SOFTWARE.
<xsl:apply-templates select="@name"/>
<xsl:variable name="type">
<xsl:choose>
<xsl:when test="@base and @base!='∅'">
<xsl:when test="@base and @base!=$eo:empty">
<xsl:text>bound</xsl:text>
</xsl:when>
<xsl:when test="@base and @base='∅'">
<xsl:when test="@base and @base=$eo:empty">
<xsl:text>void</xsl:text>
</xsl:when>
<xsl:when test="@atom">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,32 @@ SOFTWARE.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:eo="https://www.eolang.org" xmlns:xs="http://www.w3.org/2001/XMLSchema" id="to-java" version="2.0">
<xsl:import href="/org/eolang/parser/_datas.xsl"/>
<xsl:import href="/org/eolang/parser/_specials.xsl"/>
<xsl:param name="disclaimer" select="'This file was auto-generated by eo-maven-plugin, your changes will be discarded on the next build'"/>
<xsl:output encoding="UTF-8" method="xml"/>
<!-- VARIABLES -->
<xsl:variable name="TAB">
<xsl:text> </xsl:text>
</xsl:variable>
<xsl:variable name="RHO">
<xsl:text>ρ</xsl:text>
</xsl:variable>
<xsl:variable name="PHI">
<xsl:text>φ</xsl:text>
</xsl:variable>
<xsl:variable name="ALPHA">
<xsl:text>α</xsl:text>
<xsl:value-of select="$eo:space"/>
<xsl:value-of select="$eo:space"/>
</xsl:variable>
<!-- FUNCTIONS -->
<!-- EOL -->
<xsl:function name="eo:eol">
<xsl:param name="tabs"/>
<xsl:value-of select="'&#10;'"/>
<xsl:value-of select="$eo:new-line"/>
<xsl:value-of select="eo:tabs($tabs)"/>
</xsl:function>
<!-- TABS -->
<xsl:function name="eo:tabs">
<xsl:param name="n"/>
<xsl:for-each select="1 to $n">
<xsl:text> </xsl:text>
<xsl:value-of select="$TAB"/>
</xsl:for-each>
</xsl:function>
<!-- Get clean escaped object name -->
<xsl:function name="eo:clean" as="xs:string">
<xsl:param name="n" as="xs:string"/>
<xsl:value-of select="concat('EO', replace(replace(replace(replace(replace($n, '_', '__'), '-', '_'), '@', $PHI), 'α', '_'), '\$', '\$EO'))"/>
<xsl:value-of select="concat('EO', replace(replace(replace(replace(replace($n, '_', '__'), '-', '_'), '@', $eo:phi), $eo:alpha, '_'), '\$', '\$EO'))"/>
</xsl:function>
<!-- Get object name with suffix -->
<xsl:function name="eo:suffix" as="xs:string">
Expand Down Expand Up @@ -102,7 +95,7 @@ SOFTWARE.
<xsl:param name="n" as="xs:string"/>
<xsl:choose>
<xsl:when test="$n='@'">
<xsl:value-of select="$PHI"/>
<xsl:value-of select="$eo:phi"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$n"/>
Expand Down Expand Up @@ -158,7 +151,7 @@ SOFTWARE.
<xsl:when test="$mtd='^'">
<xsl:value-of select="$base"/>
<xsl:text>.take("</xsl:text>
<xsl:value-of select="$RHO"/>
<xsl:value-of select="$eo:rho"/>
<xsl:text>");</xsl:text>
</xsl:when>
<xsl:otherwise>
Expand Down Expand Up @@ -501,7 +494,7 @@ SOFTWARE.
<xsl:text>();</xsl:text>
</xsl:template>
<!-- Attribute body: regular object, not method -->
<xsl:template match="o[@base and @base!='' and not(starts-with(@base, '.'))]">
<xsl:template match="o[@base and @base!='' and not(starts-with(@base, '.'))]">
<xsl:param name="indent"/>
<xsl:param name="name"/>
<xsl:param name="rho"/>
Expand Down Expand Up @@ -558,7 +551,7 @@ SOFTWARE.
<xsl:param name="name"/>
<xsl:param name="rho"/>
<xsl:variable name="method" select="substring-after(@base, '.')"/>
<xsl:if test="starts-with(@base, concat('.', $ALPHA))">
<xsl:if test="starts-with(@base, concat('.', $eo:alpha))">
<xsl:message terminate="yes">
<xsl:text>Dispatching alpha attributes is not supported in EO yet, found: </xsl:text>
<xsl:value-of select="@base"/>
Expand Down Expand Up @@ -647,8 +640,8 @@ SOFTWARE.
<xsl:choose>
<xsl:when test="@as">
<xsl:choose>
<xsl:when test="starts-with(@as, $ALPHA)">
<xsl:value-of select="eo:attr-name(substring-after(@as, $ALPHA))"/>
<xsl:when test="starts-with(@as, $eo:alpha)">
<xsl:value-of select="eo:attr-name(substring-after(@as, $eo:alpha))"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>"</xsl:text>
Expand Down
4 changes: 2 additions & 2 deletions eo-parser/src/main/java/org/eolang/parser/DrProgram.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*
* @since 0.44.0
*/
public final class DrProgram implements Iterable<Directive> {
final class DrProgram implements Iterable<Directive> {

/**
* Name of the program.
Expand All @@ -49,7 +49,7 @@ public final class DrProgram implements Iterable<Directive> {
* Ctor.
* @param nme Name of the program
*/
public DrProgram(final String nme) {
DrProgram(final String nme) {
this.name = nme;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ public void enterAname(final EoParser.AnameContext ctx) {
.prop(
"name",
String.format(
"auto-named-attr-at-%d-%d",
"α%d%d",
ctx.getStart().getLine(),
ctx.getStart().getCharPositionInLine()
)
Expand Down
3 changes: 2 additions & 1 deletion eo-parser/src/main/resources/org/eolang/parser/_funcs.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:math="http://www.w3.org/2005/xpath-functions/math" xmlns:eo="https://www.eolang.org" xmlns:xs="http://www.w3.org/2001/XMLSchema" id="_funcs" version="2.0">
<xsl:import href="/org/eolang/parser/_specials.xsl"/>
<xsl:function name="eo:has-data" as="xs:boolean">
<xsl:param name="o" as="element()"/>
<xsl:sequence select="normalize-space(string-join($o/text(), '')) != ''"/>
Expand All @@ -33,7 +34,7 @@ SOFTWARE.
</xsl:function>
<xsl:function name="eo:void" as="xs:boolean">
<xsl:param name="o" as="element()"/>
<xsl:sequence select="$o/@base='∅'"/>
<xsl:sequence select="$o/@base=$eo:empty"/>
</xsl:function>
<!-- BYTES TO STRING -->
<xsl:function name="eo:bytes-to-string" as="xs:string">
Expand Down
51 changes: 51 additions & 0 deletions eo-parser/src/main/resources/org/eolang/parser/_specials.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License (MIT)
Copyright (c) 2016-2025 Objectionary.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:eo="https://www.eolang.org" id="_specials" version="2.0">
<xsl:variable name="eo:alpha" select="'α'"/>
<xsl:variable name="eo:xi" select="'ξ'"/>
<xsl:variable name="eo:delta" select="'Δ'"/>
<xsl:variable name="eo:phi" select="'φ'"/>
<xsl:variable name="eo:rho" select="'ρ'"/>
<xsl:variable name="eo:program" select="'Φ'"/>
<xsl:variable name="eo:def-package" select="'Φ̇'"/>
<xsl:variable name="eo:lambda" select="'λ'"/>
<xsl:variable name="eo:arrow">
<xsl:value-of select="$eo:space"/>
<xsl:text>↦</xsl:text>
<xsl:value-of select="$eo:space"/>
</xsl:variable>
<xsl:variable name="eo:dashed-arrow">
<xsl:value-of select="$eo:space"/>
<xsl:text>⤍</xsl:text>
<xsl:value-of select="$eo:space"/>
</xsl:variable>
<xsl:variable name="eo:lb" select="'⟦'"/>
<xsl:variable name="eo:rb" select="'⟧'"/>
<xsl:variable name="eo:clb" select="'('"/>
<xsl:variable name="eo:crb" select="')'"/>
<xsl:variable name="eo:empty" select="'∅'"/>
<xsl:variable name="eo:space" select="' '"/>
<xsl:variable name="eo:new-line" select="'&#10;'"/>
</xsl:stylesheet>
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ SOFTWARE.
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template match="o[@base!='$' and @base!='^' and @base!='∅']" mode="no-dots">
<xsl:template match="o[@base!='$' and @base!='^' and @base!=$eo:empty]" mode="no-dots">
<xsl:variable name="base" select="./@base"/>
<xsl:choose>
<!-- Closes object in the same scope -->
Expand Down
Loading

0 comments on commit edfa9d3

Please sign in to comment.