Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Dec 4, 2023
2 parents cde58ba + ccd731d commit 881ed60
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,16 @@ SOFTWARE.
<xsl:text>, </xsl:text>
<xsl:choose>
<xsl:when test="@as">
<xsl:text>"</xsl:text>
<xsl:value-of select="eo:attr-name(@as)"/>
<xsl:text>"</xsl:text>
<xsl:choose>
<xsl:when test="matches(@as,'^[0-9]+$')">
<xsl:value-of select="eo:attr-name(@as)"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>"</xsl:text>
<xsl:value-of select="eo:attr-name(@as)"/>
<xsl:text>"</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="../@base = 'org.eolang.error'">
<xsl:text>"α"</xsl:text>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
xsls:
- /org/eolang/parser/add-default-package.xsl
- /org/eolang/maven/pre/classes.xsl
- /org/eolang/maven/pre/attrs.xsl
- /org/eolang/maven/pre/data.xsl
- /org/eolang/maven/pre/to-java.xsl
tests:
- /program/errors[count(*)=0]
- //java/text()[contains(., 'new PhWith(ret, 0')]
- //java/text()[contains(., 'new PhWith(ret, "ρ"')]
- //java/text()[contains(., 'new PhWith(ret, "text"')]
eo: |
[] > main
stdout x:0 > print1
stdout x:^ > print2
stdout x:text > print3
2 changes: 1 addition & 1 deletion eo-parser/src/main/antlr4/org/eolang/parser/Program.g4
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ version
;

// Binding
as : COLON (NAME | RHO)
as : COLON (NAME | RHO | INT)
;

// Data
Expand Down
3 changes: 3 additions & 0 deletions eo-parser/src/main/java/org/eolang/parser/ParsingTrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
* Train of XSL shifts.
*
* @since 0.1
* @todo #2665:30min Check negative int bindings via xsl. It's possible now to make application
* with integer bindings like {@code x a:0 b:1}. Need to add xsl transformation that would check
* if such binding is negative and would add an error to "errors" section.
*/
public final class ParsingTrain extends TrEnvelope {

Expand Down
5 changes: 4 additions & 1 deletion eo-parser/src/main/java/org/eolang/parser/XeListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -948,11 +948,14 @@ public void exitVersion(final ProgramParser.VersionContext ctx) {
}

@Override
@SuppressWarnings("PMD.ConfusingTernary")
public void enterAs(final ProgramParser.AsContext ctx) {
this.objects.enter();
final String has;
if (ctx.RHO() == null) {
if (ctx.NAME() != null) {
has = ctx.NAME().getText();
} else if (ctx.INT() != null) {
has = ctx.INT().getText();
} else {
has = "^";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ tests:
- //o[@base='string']
- //o[@name='hello' and @const]
- //o[@as='i']
- //o[@as='1']
- //o[@as='0']
- //o[@base='&']
- //o[@base='.<']
- //o[@base='.five']
Expand Down Expand Up @@ -55,8 +57,8 @@ eo: |
"家"
f'
z'
(z 5):hey
z:hoi
(z 5):0
z:1
a.
b.
c.
Expand Down

1 comment on commit 881ed60

@0pdd
Copy link

@0pdd 0pdd commented on 881ed60 Dec 4, 2023

Choose a reason for hiding this comment

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

Puzzle 2665-24cd76fe discovered in eo-parser/src/main/java/org/eolang/parser/ParsingTrain.java) and submitted as #2670. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.