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

org.eolang.parser.TrParsing is gone in 0.50.1 #3835

Closed
h1alexbel opened this issue Jan 19, 2025 · 10 comments
Closed

org.eolang.parser.TrParsing is gone in 0.50.1 #3835

h1alexbel opened this issue Jan 19, 2025 · 10 comments

Comments

@h1alexbel
Copy link
Contributor

After releasing latest version (0.50.1), the org.eolang.parser.TrParsing is not accessible anymore. We used it in lints repo, in order to transform XMIR that comes from EoSyntax:

import org.eolang.parser.TrParsing;

@Test
@Timeout(60L)
void acceptsCanonicalCode() throws IOException {
    final XML xmir = new Xsline(new TrParsing()).pass(
        new EoSyntax(
            new ResourceOf(
                "org/eolang/lints/canonical.eo"
            )
        ).parsed()
    );
    MatcherAssert.assertThat(
        String.format("no errors in canonical code in %s", xmir),
        new Program(xmir).defects(),
        Matchers.emptyIterable()
    );
}

Now its not accessible, so we cannot use it to get XMIR.

The stylesheets were used by this train:

/org/eolang/parser/cti-adds-errors.xsl
/org/eolang/parser/add-refs.xsl
/org/eolang/parser/expand-qqs.xsl
/org/eolang/parser/add-probes.xsl
/org/eolang/parser/vars-float-up.xsl
/org/eolang/parser/add-refs.xsl
/org/eolang/parser/expand-aliases.xsl
/org/eolang/parser/resolve-aliases.xsl
/org/eolang/parser/add-refs.xsl
/org/eolang/parser/add-default-package.xsl
/org/eolang/parser/explicit-data.xsl
/org/eolang/parser/set-locators.xsl
/org/eolang/parser/clean-up.xsl

Please fix it or provide an alternative train

@h1alexbel
Copy link
Contributor Author

@maxonfjvipon please check

@maxonfjvipon
Copy link
Member

@h1alexbel now we have TrShaking but it's in eo-maven-plugin module and it's package private.

@yegor256 should we move it back to eo-parser? Then we should add documentation to the class that it's used outside of eo-parser. Or we should find other way to get canonical XMIR in lints?

@yegor256
Copy link
Member

yegor256 commented Jan 19, 2025

@maxonfjvipon I believe, EoSyntax should return a canonical XMIR. No shaking should be required in order to use it for linting.

@maxonfjvipon
Copy link
Member

@h1alexbel still an issue?

@h1alexbel
Copy link
Contributor Author

@maxonfjvipon yes, since 0.50.1 is the latest EO release

@h1alexbel
Copy link
Contributor Author

@maxonfjvipon this is still an issue in 0.50.2. We used TrParsing train in canonical EO example, time multiplication table:

+architect yegor256@gmail.com
+home https://www.eolang.org
+package canonical
+unlint empty-object
+unlint object-does-not-match-filename
+version 0.0.0

# Times table, which is a canonical example of EO program.
[args] > canonical
  malloc.for > @
    0
    [x] >>
      seq > @
        *
          x.put 2
          while
            x.as-number.lt 6 > [i]
            [i] >>
              seq > @
                *
                  QQ.io.stdout
                    QQ.txt.sprintf
                      "%d x %d = %d\n"
                      *
                        ^.x
                        ^.x
                        ^.x.as-number.times ^.x
                  ^.x.put
                    ^.x.as-number.plus 1
          true
final XML xmir = new Xsline(new TrParsing()).pass(
  new EoSyntax(
      new ResourceOf(
          "org/eolang/lints/canonical.eo"
      )
  ).parsed()
);

Without that train, EoSyntax#parsed() from EO-parser with version 0.50.2 generates the following XMIR:

<program xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    dob="2025-01-27T11:35:27"
    ms="407"
    name="unknown"
    revision="16e9906"
    time="2025-01-28T07:33:53.688494Z"
    version="0.50.2"
    xsi:noNamespaceSchemaLocation="https://www.eolang.org/xsd/XMIR-0.50.2.xsd">
  <listing>
    +architect yegor256@gmail.com
    +home https://www.eolang.org
    +package canonical
    +unlint empty-object
    +unlint object-does-not-match-filename
    +version 0.0.0

    # Times table, which is a canonical example of EO program.
    [args] &gt; canonical
    malloc.for &gt; @
    0
    [x] &gt;&gt;
    seq &gt; @
    *
    x.put 2
    while
    x.as-number.lt 6 &gt; [i]
    [i] &gt;&gt;
    seq &gt; @
    *
    QQ.io.stdout
    QQ.txt.sprintf
    "%d x %d = %d\n"
    *
    ^.x
    ^.x
    ^.x.as-number.times ^.x
    ^.x.put
    ^.x.as-number.plus 1
    true
  </listing>
  <metas>
    <meta line="23">
      <head>architect</head>
      <tail>yegor256@gmail.com</tail>
      <part>yegor256@gmail.com</part>
    </meta>
    <meta line="24">
      <head>home</head>
      <tail>https://www.eolang.org</tail>
      <part>https://www.eolang.org</part>
    </meta>
    <meta line="25">
      <head>package</head>
      <tail>canonical</tail>
      <part>canonical</part>
    </meta>
    <meta line="26">
      <head>unlint</head>
      <tail>empty-object</tail>
      <part>empty-object</part>
    </meta>
    <meta line="27">
      <head>unlint</head>
      <tail>object-does-not-match-filename</tail>
      <part>object-does-not-match-filename</part>
    </meta>
    <meta line="28">
      <head>version</head>
      <tail>0.0.0</tail>
      <part>0.0.0</part>
    </meta>
  </metas>
  <objects>
    <o line="31" name="canonical" pos="0">
      <o base="" line="31" name="args" pos="1"/>
      <o base=".for" line="32" name="@" pos="8">
        <o base="malloc" line="32" pos="2"/>
        <o base="number" line="33" pos="4">00-00-00-00-00-00-00-00</o>
        <o line="34" name="auto-named-attr-at-34-7" pos="4">
          <o base="" line="34" name="x" pos="5"/>
          <o base="seq" line="35" name="@" pos="6">
            <o base=".with" line="36" pos="8">
              <o base=".with">
                <o base=".with">
                  <o base=".empty">
                    <o base="tuple"/>
                  </o>
                  <o base=".put" line="37" pos="11">
                    <o base="x" line="37" pos="10"/>
                    <o base="number" line="37" pos="16">40-00-00-00-00-00-00-00</o>
                  </o>
                </o>
                <o base="while" line="38" pos="10">
                  <o line="39" pos="12">
                    <o base="" line="39" name="i" pos="32"/>
                    <o base=".lt" line="39" name="@" pos="23">
                      <o base=".as-number" line="39" pos="13">
                        <o base="x" line="39" pos="12"/>
                      </o>
                      <o base="number" line="39" pos="27">40-18-00-00-00-00-00-00</o>
                    </o>
                  </o>
                  <o line="40" name="auto-named-attr-at-40-15" pos="12">
                    <o base="" line="40" name="i" pos="13"/>
                    <o base="seq" line="41" name="@" pos="14">
                      <o base=".with" line="42" pos="16">
                        <o base=".with">
                          <o base=".empty">
                            <o base="tuple"/>
                          </o>
                          <o base=".stdout" line="43" pos="23">
                            <o base=".io" line="43" pos="20">
                              <o base="QQ" line="43" pos="18"/>
                            </o>
                            <o base=".sprintf" line="44" pos="26">
                              <o base=".txt" line="44" pos="22">
                                <o base="QQ" line="44" pos="20"/>
                              </o>
                              <o base="string" line="45" pos="22">25-64-20-78-20-25-64-20-3D-20-25-64-0A</o>
                              <o base=".with" line="46" pos="22">
                                <o base=".with">
                                  <o base=".with">
                                    <o base=".empty">
                                      <o base="tuple"/>
                                    </o>
                                    <o base=".x" line="47" pos="25">
                                      <o base="^" line="47" pos="24"/>
                                    </o>
                                  </o>
                                  <o base=".x" line="48" pos="25">
                                    <o base="^" line="48" pos="24"/>
                                  </o>
                                </o>
                                <o base=".times" line="49" pos="37">
                                  <o base=".as-number" line="49" pos="27">
                                    <o base=".x" line="49" pos="25">
                                      <o base="^" line="49" pos="24"/>
                                    </o>
                                  </o>
                                  <o base=".x" line="49" pos="45">
                                    <o base="^" line="49" pos="44"/>
                                  </o>
                                </o>
                              </o>
                            </o>
                          </o>
                        </o>
                        <o base=".put" line="50" pos="21">
                          <o base=".x" line="50" pos="19">
                            <o base="^" line="50" pos="18"/>
                          </o>
                          <o base=".plus" line="51" pos="33">
                            <o base=".as-number" line="51" pos="23">
                              <o base=".x" line="51" pos="21">
                                <o base="^" line="51" pos="20"/>
                              </o>
                            </o>
                            <o base="number" line="51" pos="39">3F-F0-00-00-00-00-00-00</o>
                          </o>
                        </o>
                      </o>
                    </o>
                  </o>
                </o>
              </o>
              <o base="true" line="52" pos="10"/>
            </o>
          </o>
        </o>
      </o>
    </o>
  </objects>
  <comments>
    <comment line="31">Times table, which is a canonical example of EO program.</comment>
  </comments>
  <sheets>
    <sheet>move-voids-up</sheet>
    <sheet>validate-before-stars</sheet>
    <sheet>resolve-before-star</sheet>
    <sheet>wrap-method-calls</sheet>
    <sheet>const-to-dataized</sheet>
    <sheet>stars-to-tuples</sheet>
  </sheets>
</program>

This XMIR breaks some lints, for instance:

  • unknown name-outside-of-abstract-object
  • object-has-data
  • unknown-name ("The object "QQ" is not defined anywhere", etc.)

To resolve that, I think we can try to get back the train if possible, or to fix EoSyntax#parsed() to return canonical XMIR by default.

We need to fix this, in order to resolve objectionary/lints#241 and upgrade EO dependency from 0.50.0.

@h1alexbel
Copy link
Contributor Author

@maxonfjvipon @yegor256 WDYT?

@maxonfjvipon
Copy link
Member

@h1alexbel working on it

@maxonfjvipon
Copy link
Member

@h1alexbel should be fixed here

@h1alexbel
Copy link
Contributor Author

@maxonfjvipon thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants