objectionary / eo

EOLANG, an Experimental Pure Object-Oriented Programming Language Based on 𝜑-calculus
https://www.eolang.org
MIT License
1.01k stars 126 forks source link

Does `UnphiMojo` (or `PhiMojo`) remove `metas`? #3354

Open volodya-lombrozo opened 2 weeks ago

volodya-lombrozo commented 2 weeks ago

This problem comes from this discussion: https://github.com/objectionary/jeo-maven-plugin/issues/684#issuecomment-2322808373

It seems that UnphiMojo (or PhiMojo) doesn't preserve the metas element in xmir.

<?xml version="1.0" encoding="UTF-8"?>
<program dob="2024-07-29T12:22:21"
         ms="106"
         name="Hello"
         revision="2fa8c4c"
         time="2024-08-30T12:48:09.663685429Z"
         version="0.39.0"><!--This is XMIR - a dialect of XML, which is used to present a parsed EO program. For more information please visit https://news.eolang.org/2022-11-25-xmir-guide.html-->
   <listing>{⟦
  j$Hello ↦ ⟦
    version ↦ Φ.org.eolang.int (α0 ↦ Φ.org.eolang.bytes (Δ ⤍ 00-00-00-00-00-00-00-37)),
...
  ⟧
⟧}</listing>
   <errors/>
   <sheets/>
   <license/>
   <metas/>
   <objects>
      <o abstract="" name="j$Hello">
         <o base=".int" name="version">
            <o base=".eolang">
               <o base=".org">
                  <o base="Q"/>
               </o>
            </o>
...
   </objects>
</program>

This causes problems in other related plugins.

yegor256 commented 2 weeks ago

@volodya-lombrozo what do you mean "doesn't preserve"? How to reproduce this problem?

volodya-lombrozo commented 2 weeks ago

@yegor256 I checked that 'disambling' and 'assembling' by 'jeo-maven-plugin' doesn't remove metas elements from the xmir. 'opeo-maven-plugin' doesn't remove them either. So, I guess it is 'phi/unphi' removes metas from the xmir

To reproduce the problem you can try to run this integration test.

maxonfjvipon commented 1 week ago

@volodya-lombrozo PhiMojo accepts .xmir files and produced .phi files. The .phi file does not contain any meta information since phi calculus format does not assume that. UnphiMojo tries to guess some metas, like +package, but since .phi file does not contain it - there's no place to take them out.

volodya-lombrozo commented 1 week ago

@maxonfjvipon Since we are going to optimize the production code using phi expressions, we need to preserve all the information. Otherwise we won't be able to return back to the initial platform.

maxonfjvipon commented 1 week ago

@volodya-lombrozo what exactly metas are you interested in?

volodya-lombrozo commented 1 week ago

@maxonfjvipon All of them. Btw, we already have some problems related to absence of metas https://github.com/objectionary/jeo-maven-plugin/issues/684

maxonfjvipon commented 1 week ago

@volodya-lombrozo PhiMojo prints +package meta to .phi file if it's present. Also our phi parser can add +package meta from .phi file to xmir meta. Can you please provide an example where you're trying to phi/unphi XMIR with present package meta and it does not appear after transformations?

volodya-lombrozo commented 1 week ago

Have you seen this https://github.com/objectionary/jeo-maven-plugin/issues/684#issuecomment-2321383387 ? Here is the logs where you can find detailed information.

Also I've checked several xmir files and most of them contain the following metas:

  <metas>
    <meta>
      <head>package</head>
      <tail>org/eolang/benchmark</tail>
      <part>org/eolang/benchmark</part>
    </meta>
    <meta>
      <head>alias</head>
      <tail>org.eolang.jeo.opcode</tail>
      <part>org.eolang.jeo.opcode</part>
    </meta>
    <meta>
      <head>alias</head>
      <tail>org.eolang.jeo.label</tail>
      <part>org.eolang.jeo.label</part>
    </meta>
  </metas>

But, please, don't add "ad-hoc" solution. This metas might change in the future.

maxonfjvipon commented 5 days ago

@volodya-lombrozo please give me an example of XMIR or at least EO that is broken after phi and unphi

volodya-lombrozo commented 5 days ago

@maxonfjvipon

<?xml version="1.0" encoding="UTF-8"?>
<program dob="2024-07-29T12:22:21"
         ms="106"
         name="Hello"
         revision="2fa8c4c"
         time="2024-08-30T12:48:09.663685429Z"
         version="0.39.0"><!--This is XMIR - a dialect of XML, which is used to present a parsed EO program. For more information please visit https://news.eolang.org/2022-11-25-xmir-guide.html-->
   <listing>{⟦
  j$Hello ↦ ⟦
    version ↦ Φ.org.eolang.int (α0 ↦ Φ.org.eolang.bytes (Δ ⤍ 00-00-00-00-00-00-00-37)),
...
  ⟧
⟧}</listing>
   <errors/>
   <sheets/>
   <license/>
     <metas>
    <meta>
      <head>package</head>
      <tail>org/eolang/benchmark</tail>
      <part>org/eolang/benchmark</part>
    </meta>
    <meta>
      <head>alias</head>
      <tail>org.eolang.jeo.opcode</tail>
      <part>org.eolang.jeo.opcode</part>
    </meta>
    <meta>
      <head>alias</head>
      <tail>org.eolang.jeo.label</tail>
      <part>org.eolang.jeo.label</part>
    </meta>
  </metas>
   <objects>
      <o abstract="" name="j$Hello"></o>
   </objects>
</program>
maxonfjvipon commented 4 days ago

@volodya-lombrozo I did eoc phi and eoc unphi on your example and what I got: PHI after eoc phi:

{
  ⟦
    org/eolang/benchmark ↦ ⟦
      j$Hello ↦ ⟦⟧,
      λ ⤍ Package
    ⟧
  ⟧
}

XMIR after eoc unphi:

<?xml version="1.0" encoding="UTF-8"?>
<program dob="2024-05-22T13:54:22"
         ms="92"
         name="Hello"
         revision="48e8be4"
         time="2024-09-10T14:20:05.074899Z"
         version="0.38.2"><!--This is XMIR - a dialect of XML, which is used to present a parsed EO program. For more information please visit https://news.eolang.org/2022-11-25-xmir-guide.html-->
   <listing>{
  ⟦
    org/eolang/benchmark ↦ ⟦
      j$Hello ↦ ⟦⟧,
      λ ⤍ Package
    ⟧
  ⟧
}</listing>
   <errors/>
   <sheets/>
   <license/>
   <metas>
      <meta>
         <head>package</head>
         <tail>org/eolang/benchmark</tail>
         <part>org/eolang/benchmark</part>
      </meta>
   </metas>
   <objects>
      <o abstract="" name="j$Hello"/>
   </objects>
</program>

Package is not missed

yegor256 commented 4 days ago

@volodya-lombrozo again, I suggest giving two code snippets in each bug report: 1) XMIR before phi-unphi and 2) XMIR after phi-unphi. They should be equal. If they are not, it's a bug either in phi-unphi or in the first XMIR.