Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Feb 20, 2023
2 parents 40a1115 + 751a248 commit 6d88feb
Show file tree
Hide file tree
Showing 15 changed files with 181 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ void assemblesNotFailWithFailOnErrorFlag(@TempDir final Path temp) throws Except
"+alias stdout org.eolang.io.stdout",
"+home https://github.com/objectionary/eo",
"+package test",
"+version 0.0.0",
"",
"[x] < wrong>\n (stdout \"Hello!\" x).print\n"
),
Expand All @@ -109,6 +110,7 @@ void assemblesNotFailWithFailOnErrorFlag(@TempDir final Path temp) throws Except
"+alias stdout org.eolang.io.stdout",
"+home https://github.com/objectionary/eo",
"+package test",
"+version 0.0.0",
"",
"[x] > main\n (stdout \"Hello!\" x).print\n"
),
Expand Down
7 changes: 2 additions & 5 deletions eo-parser/src/main/java/org/eolang/parser/ParsingTrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ public final class ParsingTrain extends TrEnvelope {

/**
* Sheets in the right order.
*
* @todo #1542:90m Add xsl transformation
* that checks the presence of +version meta.
* The version meta have to be correct.
* It can be divided by 2 xsl checks.
*/
private static final String[] SHEETS = {
"/org/eolang/parser/errors/not-empty-atoms.xsl",
Expand All @@ -78,6 +73,7 @@ public final class ParsingTrain extends TrEnvelope {
"/org/eolang/parser/warnings/unsorted-metas.xsl",
"/org/eolang/parser/warnings/incorrect-architect.xsl",
"/org/eolang/parser/warnings/incorrect-home.xsl",
"/org/eolang/parser/warnings/incorrect-version.xsl",
"/org/eolang/parser/expand-aliases.xsl",
"/org/eolang/parser/resolve-aliases.xsl",
"/org/eolang/parser/synthetic-references.xsl",
Expand All @@ -89,6 +85,7 @@ public final class ParsingTrain extends TrEnvelope {
"/org/eolang/parser/warnings/duplicate-metas.xsl",
"/org/eolang/parser/warnings/mandatory-package-meta.xsl",
"/org/eolang/parser/warnings/mandatory-home-meta.xsl",
"/org/eolang/parser/warnings/mandatory-version-meta.xsl",
"/org/eolang/parser/warnings/correct-package-meta.xsl",
"/org/eolang/parser/errors/unused-aliases.xsl",
"/org/eolang/parser/errors/data-objects.xsl",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License (MIT)
Copyright (c) 2016-2023 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" id="incorrect-version" version="2.0">
<xsl:output encoding="UTF-8" method="xml"/>
<xsl:template match="/program/errors">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
<xsl:for-each select="/program/metas/meta">
<xsl:variable name="meta-head" select="head"/>
<xsl:variable name="meta-tail" select="tail"/>
<xsl:if test="$meta-head='version' and not(matches($meta-tail, '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$'))">
<xsl:element name="error">
<xsl:attribute name="check">
<xsl:text>incorrect-version</xsl:text>
</xsl:attribute>
<xsl:attribute name="line">
<xsl:value-of select="@line"/>
</xsl:attribute>
<xsl:attribute name="severity">
<xsl:text>warning</xsl:text>
</xsl:attribute>
<xsl:text>Wrong format of semver"</xsl:text>
<xsl:value-of select="$meta-tail"/>
<xsl:text>"</xsl:text>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:copy>
</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,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License (MIT)
Copyright (c) 2016-2023 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" id="mandatory-version-meta" version="2.0">
<xsl:output encoding="UTF-8"/>
<xsl:template match="/program/errors">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
<xsl:if test="count(/program/metas/meta[head ='version'])=0">
<xsl:element name="error">
<xsl:attribute name="check">
<xsl:text>missing-version-meta</xsl:text>
</xsl:attribute>
<xsl:attribute name="line">
<xsl:value-of select="@line"/>
</xsl:attribute>
<xsl:attribute name="severity">
<xsl:text>warning</xsl:text>
</xsl:attribute>
<xsl:text>Missing version meta</xsl:text>
</xsl:element>
</xsl:if>
<xsl:if test="count(/program/metas/meta[head ='version'])&gt;1">
<xsl:element name="error">
<xsl:attribute name="check">
<xsl:text>more-one-version-meta</xsl:text>
</xsl:attribute>
<xsl:attribute name="line">
<xsl:value-of select="@line"/>
</xsl:attribute>
<xsl:attribute name="severity">
<xsl:text>warning</xsl:text>
</xsl:attribute>
<xsl:text>More than one version specified</xsl:text>
</xsl:element>
</xsl:if>
</xsl:copy>
</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
Expand Up @@ -22,6 +22,7 @@ eo: |
+alias x
+package org.abc
+home www.abc.com
+version 0.0.0
[] > a
b > @
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ tests:
eo: |
+home https://github.com/objectionary/eo
+package org.eolang.custom
+version 0.0.0
[] > app
QQ.txt.sprintf > @
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
xsls:
- /org/eolang/parser/warnings/incorrect-version.xsl
tests:
- /program/errors[count(error[@severity='warning'])=2]
- /program/errors/error[@line='3']
- /program/errors/error[@line='5']

eo: |
+version 0.0.0
+version 0.2.1
+version alpha
+alias org.eolang.io.stdout
+version 1.0.0-alpha.beta
[x] > foo
x.div in.nextInt > @
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
xsls:
- /org/eolang/parser/warnings/mandatory-version-meta.xsl
tests:
- /program/errors[count(error[@severity='warning'])=1]
- /program/errors[count(error[@severity='error'])=0]
eo: |
+home https://github.com/objectionary/eo
+package test
+alias stding org.eolang.io.stdin
[] > main
(stdout "Hello, world!").print > @
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
xsls:
- /org/eolang/parser/warnings/mandatory-version-meta.xsl
tests:
- /program/errors[count(error[@severity='warning'])=1]
- /program/errors[count(error[@severity='error'])=0]
eo: |
+alias stding org.eolang.io.stdin
+alias stdout org.eolang.io.stdout
+home https://github.com/objectionary/eo
+package sandbox
+version 0.0.0
+version 0.0.0
[] > main
(stdout "Hello, world!").print
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ tests:
eo: |
+home https://github.com/objectionary/eo
+package test
+version 0.0.0
[x] > foo
[] > y
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ eo: |
+alias org.eolang.txt.scanner
+home https://github.com/objectionary/eo
+package test
+version 0.0.0
[args] > main
[y] > leap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ tests:
eo: |
+home https://github.com/objectionary/eo
+package org.eolang.priority
+version 0.0.0
[] > x
1.times 2 (1.plus other.value)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ tests:
eo: |
+home https://github.com/objectionary/eo
+package org.eolang.priority
+version 0.0.0
[] > sum
^.a.plus ^.b > @
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
tests:
- /program/errors[count(*)=0]
- //o[@name='f' and @line='4']
- //o[@base='f' and @ref='4']
- //o[@name='f' and @line='5']
- //o[@base='f' and @ref='5']
eo: |
+home https://github.com/objectionary/eo
+package test
+version 0.0.0
[args...] > main
[n] > f
f 5 > @
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
tests:
- /program/errors[count(error)=1]
- //error[@severity='warning' and @line=5 and text()="'(1.plus 2)' contains redundant parentheses"]
- //error[@severity='warning' and @line=6 and text()="'(1.plus 2)' contains redundant parentheses"]
eo: |
+home https://github.com/objectionary/eo
+package a.b.c
+version 0.0.0
[] > x
(1.plus 2) > y

1 comment on commit 6d88feb

@0pdd
Copy link

@0pdd 0pdd commented on 6d88feb Feb 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1542-94d035b1 disappeared from eo-parser/src/main/java/org/eolang/parser/ParsingTrain.java), that's why I closed #1809. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

Please sign in to comment.