Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(#3481): remove add-refs.xsl #3827

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ SOFTWARE.
<xsl:value-of select="eo:base-to-loc($o/o[1])"/>
<xsl:value-of select="$o/@base"/>
</xsl:when>
<xsl:when test="$o/@ref">
<xsl:value-of select="$o//ancestor::objects//o[@name=$o/@base and @line=$o/@ref]/@loc"/>
</xsl:when>
<xsl:when test="$o/@base = 'Q'">
<xsl:text>Φ</xsl:text>
</xsl:when>
Expand Down
2 changes: 0 additions & 2 deletions eo-parser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ Considering the following `yaml` file:

```yaml
sheets:
- /org/eolang/parser/add-refs.xsl
- /org/eolang/parser/expand-aliases.xsl
- /org/eolang/parser/resolve-aliases.xsl
- /org/eolang/parser/add-default-package.xsl
Expand Down Expand Up @@ -88,7 +87,6 @@ and the `eo` section is used for defining aliases and the main function.
This section is used to define the XSLT stylesheets that will be used for transforming the input
program. The following stylesheets are defined in this section:

- `/org/eolang/parser/add-refs.xsl`: This stylesheet is used to add references to the program.
- `/org/eolang/parser/expand-aliases.xsl`: This stylesheet is used to expand aliases in the program.
- `/org/eolang/parser/resolve-aliases.xsl`: This stylesheet is used to resolve aliases in the
program.
Expand Down
4 changes: 2 additions & 2 deletions eo-parser/src/main/java/org/eolang/parser/Xmir.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ public final class Xmir implements XML {
*/
private static final Train<Shift> FOR_PHI = new TrFull(
new TrClasspath<>(
"/org/eolang/parser/shake/add-refs.xsl",
"/org/eolang/parser/shake/expand-qqs.xsl",
"/org/eolang/parser/shake/vars-float-up.xsl",
"/org/eolang/parser/shake/build-fqns.xsl",
"/org/eolang/parser/shake/expand-qqs.xsl",
"/org/eolang/parser/shake/expand-aliases.xsl",
"/org/eolang/parser/shake/resolve-aliases.xsl",
"/org/eolang/parser/shake/add-default-package.xsl",
Expand Down
7 changes: 0 additions & 7 deletions eo-parser/src/main/resources/org/eolang/parser/phi/to-phi.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,6 @@ SOFTWARE.
<xsl:when test="not(starts-with(@base, '.'))">
<xsl:variable name="start">
<xsl:choose>
<xsl:when test="@ref and not(eo:has-data(.))">
<xsl:value-of select="eo:add-xi(true())"/>
<xsl:apply-templates select="." mode="path">
<xsl:with-param name="find" select="@base"/>
</xsl:apply-templates>
<xsl:value-of select="eo:specials(@base, true())"/>
</xsl:when>
<xsl:when test="eo:has-data(.) and (@base='org.eolang.number' or @base='org.eolang.string')">
<xsl:value-of select="text()"/>
</xsl:when>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,6 @@ SOFTWARE.
<!-- Not method -->
<xsl:when test="not(starts-with(@base, '.'))">
<xsl:choose>
<xsl:when test="@ref and not(eo:has-data(.))">
<xsl:value-of select="eo:add-xi(true())"/>
<xsl:apply-templates select="." mode="path">
<xsl:with-param name="find" select="@base"/>
</xsl:apply-templates>
<xsl:value-of select="eo:specials(@base, true())"/>
</xsl:when>
<xsl:when test="eo:has-data(.) and (@base='org.eolang.number' or @base='org.eolang.string')">
<xsl:value-of select="text()"/>
</xsl:when>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ SOFTWARE.
<xsl:choose>
<xsl:when test="exists($argument) and not(exists($argument/@name))">
<xsl:element name="o">
<xsl:for-each select="$argument/@*">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates select="$argument/@*"/>
<xsl:attribute name="name" select="@name"/>
<xsl:attribute name="const"/>
<xsl:for-each select="$argument/o">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,28 @@ SOFTWARE.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" id="add-default-package" version="2.0">
<!--
Here we go through all objects that DON'T have @ref attributes
Here we go through all objects that are not:
1. methods (starts with .)
2. @, Q, ^ or $
3. mentioned in aliases

and add default package to them.

We ignore objects that are present in aliases with their exact
names. For example, this object 'hello' won't be touched, we
won't think that it belongs to org.eolang package:

+alias hello

# No comment.
[] > app
hello > @
-->
<xsl:output encoding="UTF-8" method="xml"/>
<xsl:template match="o[@base]">
<xsl:apply-templates select="." mode="with-base"/>
</xsl:template>
<xsl:template match="o[not(@ref)]" mode="with-base">
<xsl:apply-templates select="." mode="no-refs"/>
</xsl:template>
<xsl:template match="o[not(contains(@base, '.'))]" mode="no-refs">
<xsl:template match="o[not(contains(@base, '.'))]" mode="with-base">
<xsl:apply-templates select="." mode="no-dots"/>
</xsl:template>
<xsl:template match="o[@base!='@' and @base!='Q' and @base!='^' and @base!='∅' and @base!='$']" mode="no-dots">
Expand Down
120 changes: 0 additions & 120 deletions eo-parser/src/main/resources/org/eolang/parser/shake/add-refs.xsl

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ SOFTWARE.
<xsl:with-param name="of" select="$current"/>
</xsl:apply-templates>
</xsl:when>
<!-- Next iteration -->
<xsl:otherwise>
<xsl:apply-templates mode="with-rho" select=".">
<xsl:with-param name="rhos" select="$rhos - 1"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ SOFTWARE.
</xsl:choose>
</xsl:template>
<xsl:template match="o[@base='bytes']" mode="with-data">
<xsl:apply-templates select="." mode="base-bytes"/>
</xsl:template>
<xsl:template match="o[@ref]" mode="base-bytes">
<o base="org.eolang.bytes">
<xsl:for-each select="@*[name()!='base']">
<xsl:attribute name="{name()}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,17 @@ SOFTWARE.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" id="resolve-aliases" version="2.0">
<!--
Here we go through all objects that DON'T have @ref attributes
and try to find their references in aliases. If we find them,
we change their @base attributes. If not, we decide that they
are in org.eolang package and also change the @base attribute.
Here we go through all objects that are not methods or have
composite FQN and try to find their references in aliases.
If we find them, we change their @base attributes. If not,
we decide that they are in org.eolang package and also change
the @base attribute.
-->
<xsl:output encoding="UTF-8" method="xml"/>
<xsl:template match="o[@base]">
<xsl:apply-templates select="." mode="with-base"/>
</xsl:template>
<xsl:template match="o[not(@ref)]" mode="with-base">
<xsl:apply-templates select="." mode="with-ref"/>
</xsl:template>
<xsl:template match="o[not(contains(@base, '.'))]" mode="with-ref">
<xsl:template match="o[not(contains(@base, '.'))]" mode="with-base">
<xsl:variable name="o" select="."/>
<xsl:copy>
<xsl:attribute name="base">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ SOFTWARE.
<xsl:attribute name="base">
<xsl:value-of select="@name"/>
</xsl:attribute>
<xsl:attribute name="ref">
<xsl:value-of select="@line"/>
</xsl:attribute>
<xsl:attribute name="cut">
<xsl:value-of select="count(descendant::o)"/>
</xsl:attribute>
<xsl:apply-templates select="@line"/>
<xsl:apply-templates select="@method"/>
</xsl:element>
Expand Down
6 changes: 3 additions & 3 deletions eo-parser/src/test/java/org/eolang/parser/XslBenchmarkIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public class XslBenchmarkIT {
* Pairs of XSL and worst XMIR for the XSL.
*/
@Param({
"/org/eolang/parser/add-default-package.xsl|org/eolang/parser/benchmark/native.xmir",
"/org/eolang/parser/add-refs.xsl|org/eolang/parser/benchmark/native.xmir",
"/org/eolang/parser/explicit-data.xsl|org/eolang/parser/benchmark/native.xmir"
"/org/eolang/parser/shake/add-default-package.xsl|org/eolang/parser/benchmark/native.xmir",
"/org/eolang/parser/shake/build-fqns.xsl|org/eolang/parser/benchmark/native.xmir",
"/org/eolang/parser/shake/explicit-data.xsl|org/eolang/parser/benchmark/native.xmir"
})
private String pairs;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
# SOFTWARE.
---
sheets:
- /org/eolang/parser/shake/expand-qqs.xsl
- /org/eolang/parser/shake/add-refs.xsl
- /org/eolang/parser/shake/vars-float-up.xsl
- /org/eolang/parser/shake/build-fqns.xsl
- /org/eolang/parser/shake/expand-qqs.xsl
- /org/eolang/parser/shake/add-default-package.xsl
- /org/eolang/parser/shake/explicit-data.xsl
- /org/eolang/parser/print/dataized-to-const.xsl
Expand All @@ -32,7 +32,7 @@ asserts:
- //o[@base='.as-bytes' and @name='second']/o[@base='org.eolang.dataized']
- //o[@base='org.eolang.a' and @const and @name='third']/o[@base='org.eolang.b']
- //o[@name='fourth-1' and not(@base)]
- //o[@base='fourth-1' and @name='fourth' and @const]
- //o[@base='.fourth-1' and @name='fourth' and @const]
- //o[@base='org.eolang.number' and @name='fifths' and @const]/o[@base='org.eolang.bytes' and text()!='']
- //o[@base='org.eolang.bytes' and @name='sixth' and @const and text()='2A-']
input: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# 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
# 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
Expand All @@ -22,16 +22,16 @@
---
sheets:
- /org/eolang/parser/shake/cti-adds-errors.xsl
- /org/eolang/parser/shake/add-refs.xsl
- /org/eolang/parser/shake/vars-float-up.xsl
- /org/eolang/parser/shake/build-fqns.xsl
- /org/eolang/parser/shake/expand-qqs.xsl
- /org/eolang/parser/shake/add-probes.xsl
- /org/eolang/parser/shake/vars-float-up.xsl
- /org/eolang/parser/shake/expand-aliases.xsl
- /org/eolang/parser/shake/resolve-aliases.xsl
- /org/eolang/parser/shake/add-default-package.xsl
- /org/eolang/parser/shake/explicit-data.xsl
- /org/eolang/parser/shake/set-locators.xsl
- /org/eolang/parser/shake/clean-up.xsl
- /org/eolang/parser/shake/blank-xsd-schema.xsl
asserts:
- /program[not(errors)]
- //o[@name='a' and @loc='Φ.org.abc.a']
Expand All @@ -44,7 +44,7 @@ asserts:
- //o[not(@base) and @loc='Φ.org.abc.tt.α2']
- //o[@base='∅' and @name='e' and @loc='Φ.org.abc.tt.α2.e']
- //o[@base='.hello' and @loc='Φ.org.abc.tt.α2.φ']
- //o[@base='e' and @loc='Φ.org.abc.tt.α2.φ.ρ']
- //o[@base='.e' and @loc='Φ.org.abc.tt.α2.φ.ρ']
- //o[@name='q' and @base='.p' and @loc='Φ.org.abc.q']
- //o[@base='.^' and not(@name) and @loc='Φ.org.abc.q.ρ']
- //o[@base='.^' and not(@name) and @loc='Φ.org.abc.q.ρ.ρ']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
---
sheets:
- /org/eolang/parser/shake/cti-adds-errors.xsl
- /org/eolang/parser/shake/add-refs.xsl
- /org/eolang/parser/shake/vars-float-up.xsl
- /org/eolang/parser/shake/build-fqns.xsl
- /org/eolang/parser/shake/expand-qqs.xsl
- /org/eolang/parser/shake/add-probes.xsl
- /org/eolang/parser/shake/vars-float-up.xsl
- /org/eolang/parser/shake/expand-aliases.xsl
- /org/eolang/parser/shake/resolve-aliases.xsl
- /org/eolang/parser/shake/add-default-package.xsl
- /org/eolang/parser/shake/explicit-data.xsl
- /org/eolang/parser/shake/set-locators.xsl
- /org/eolang/parser/shake/clean-up.xsl
- /org/eolang/parser/shake/blank-xsd-schema.xsl
asserts:
- /program[not(errors)]
- //metas[count(.//meta[head/text()='probe'])=1]
Expand Down
Loading
Loading