Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Apr 11, 2024
2 parents 27ac1df + ad4f94d commit 1394961
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 464 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,6 @@ SOFTWARE.
</xsl:with-param>
<xsl:with-param name="rho" select="'this'"/>
</xsl:apply-templates>
<xsl:if test="o[@const]">
<xsl:value-of select="eo:tabs(3)"/>
<xsl:text>ret = new PhConst(ret);</xsl:text>
<xsl:value-of select="eo:eol(0)"/>
</xsl:if>
<xsl:value-of select="eo:tabs(3)"/>
<xsl:text>return ret;</xsl:text>
<xsl:value-of select="eo:eol(2)"/>
Expand All @@ -268,11 +263,6 @@ SOFTWARE.
</xsl:with-param>
<xsl:with-param name="rho" select="'rho'"/>
</xsl:apply-templates>
<xsl:if test="o[@const]">
<xsl:value-of select="eo:tabs(3)"/>
<xsl:text>ret = new PhConst(ret);</xsl:text>
<xsl:value-of select="eo:eol(0)"/>
</xsl:if>
<xsl:value-of select="eo:tabs(3)"/>
<xsl:text>return ret;</xsl:text>
<xsl:value-of select="eo:eol(2)"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
666
two.f1.f2 x
stdout > z
sprintf > f!
sprintf > f
"Hello, ".trim
x 0x1fff n

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public final class ParsingTrain extends TrEnvelope {
"/org/eolang/parser/errors/unused-aliases.xsl",
"/org/eolang/parser/warnings/unit-test-without-phi.xsl",
"/org/eolang/parser/explicit-data.xsl",
"/org/eolang/parser/const-to-dataized.xsl",
"/org/eolang/parser/set-locators.xsl",
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License (MIT)
Copyright (c) 2016-2024 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="const-to-dataized" version="2.0">
<!--
Replace @const with dataized.as-bytes
1. a > b! => (dataized a).as-bytes > b
2. x.y z > m! => (dataized (x.y z)).as-bytes > m
-->
<xsl:output encoding="UTF-8" method="xml"/>
<!-- Generate unique name for an abstract object -->
<xsl:function name="eo:unique-name">
<xsl:param name="name"/>
<xsl:param name="scope"/>
<xsl:param name="counter"/>
<xsl:variable name="unique" select="concat($name, '-', $counter)"/>
<xsl:choose>
<xsl:when test="$scope[o[@name=$unique]]">
<xsl:value-of select="eo:unique-name($name, $scope, $counter + 1)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$unique"/>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<!-- Template -->
<xsl:template match="o[@const]">
<xsl:element name="o">
<xsl:attribute name="base" select="'.as-bytes'"/>
<xsl:attribute name="name" select="@name"/>
<xsl:attribute name="line" select="@line"/>
<xsl:attribute name="pos" select="@pos + 8"/>
<xsl:element name="o">
<xsl:attribute name="base" select="'org.eolang.dataized'"/>
<xsl:element name="o">
<xsl:for-each select="@*[name()!='const' and name()!='name']">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:if test="@abstract">
<xsl:attribute name="name">
<xsl:value-of select="eo:unique-name(@name, ./parent::o, 1)"/>
</xsl:attribute>
</xsl:if>
<xsl:for-each select="o">
<xsl:apply-templates select="."/>
</xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
tests:
- //o[@base='.as-bytes' and @line and @pos and @name='x' and o[@base='org.eolang.dataized' and o[@base='org.eolang.int' and not(@name)]]]
- //o[@base='.as-bytes' and @line and @pos and @name='m' and o[@base='org.eolang.dataized' and o[@abstract and @name='m-3' and count(o)=2]]]
- //o[@base='.as-bytes' and @line and @pos and @name='z' and o[@base='org.eolang.dataized' and o[@base='.o' and not(@name) and count(o)=1]]]
- //o[@base='.as-bytes' and @line and @pos and @name='y' and o[@base='org.eolang.dataized' and o[@base='org.eolang.c' and not(@name)]]]
- //objects[count(//o[@const])=0]
eo: |
# This is the default 64+ symbols comment in front of abstract object.
[] > foo
int > x!
# This is the default 64+ symbols comment in front of named abstract object.
[] > m!
a
b
c 1 2 > y!
.o > z!
# This is the default 64+ symbols comment in front of named abstract object.
[] > m-1
# This is the default 64+ symbols comment in front of named abstract object.
[] > m-2
145 changes: 0 additions & 145 deletions eo-runtime/src/main/java/org/eolang/PhConst.java

This file was deleted.

Loading

0 comments on commit 1394961

Please sign in to comment.