objectionary / normalizer

Command Line Normalizer of 𝜑-calculus Expressions
https://www.objectionary.com/normalizer/
MIT License
7 stars 2 forks source link

Compose an EO program that can be normalized via user-defined rules #404

Open deemp opened 3 months ago

deemp commented 3 months ago

We need an example to demonstrate that we reduce metrics due to user-defined rules (link).

We can't normalize inside atoms (https://github.com/objectionary/normalizer/issues/400).

@maxonfjvipon, please provide an example of an EO program where we can reduce metrics via user-defined rules.

yegor256 commented 3 months ago

@deemp how about this one:

[] > input /?

[x] > pass
  x.gt 18 > @

[] > reject
  QQ.io.stdout > @
    "Sorry, no"

[] > accept
  QQ.io.stdout > @
    "You are welcome!"

[p left right] > gate
  p.if > @
    left
    right

[] > app
  gate > @
    pass input
    accept
    reject
deemp commented 3 months ago

@yegor256, I got an error.

Command

npx eoc phi

Error

EO objects registered in .eoc/eo-foreign.json
Assembling into .eoc
[ERROR] Failed to parse '/home/eyjafjallajokull/Desktop/gh/normalizer/try-phi/eo/many-wrappers.eo:4': [4:10] no viable alternative at input '[] > input ': "[] > input /?"
EO program assembled in .eoc
[ERROR] net.sf.saxon.style.XSLMessage@2558eac1: Critical error identified:
  /home/eyjafjallajokull/Desktop/gh/normalizer/try-phi/eo/many-wrappers.eo, 4: [4:10] no viable alternative at input '[] > input ': "[] > input /?";
[ERROR] #fatalError(): Processing terminated by xsl:message at line 31 in fail-on-critical.xsl; SystemID: file:///org/eolang/parser/fail-on-critical.xsl; Line#: 31; Column#: 34
[ERROR] Processing terminated by xsl:message at line 31 in fail-on-critical.xsl
[ERROR] Failed to execute goal org.eolang:eo-maven-plugin:0.38.2:xmir-to-phi (default-cli) on project eoc: 'org.eolang.maven.PhiMojo@2538bc06' execution failed: java.io.UncheckedIOException: java.io.IOException: java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Failed to transform by net.sf.saxon.jaxp.TransformerImpl: Processing terminated by xsl:message at line 31 in fail-on-critical.xsl; SystemID: file:///org/eolang/parser/fail-on-critical.xsl; Line#: 31; Column#: 34 -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
The command "/home/eyjafjallajokull/Desktop/gh/normalizer/node_modules/eolang/mvnw/mvnw eo:xmir-to-phi -Deo.version=0.38.2 -Deo.tag=0.38.2 --quiet -Deo.sourcesDir=/home/eyjafjallajokull/Desktop/gh/normalizer/try-phi/eo -Deo.targetDir=/home/eyjafjallajokull/Desktop/gh/normalizer/try-phi/eo/.eoc -Deo.outputDir=/home/eyjafjallajokull/Desktop/gh/normalizer/try-phi/eo/.eoc/classes -Deo.generatedDir=/home/eyjafjallajokull/Desktop/gh/normalizer/try-phi/eo/.eoc/generated-sources -Deo.placed=/home/eyjafjallajokull/Desktop/gh/normalizer/try-phi/eo/.eoc/eo-placed.csv -Deo.placedFormat=csv -Deo.phiInputDir=/home/eyjafjallajokull/Desktop/gh/normalizer/try-phi/eo/.eoc/2-optimize -Deo.phiOutputDir=/home/eyjafjallajokull/Desktop/gh/normalizer/try-phi/eo/.eoc/phi --batch-mode --color=never --update-snapshots --fail-fast --strict-checksums" exited with #1 code
maxonfjvipon commented 3 months ago

@yegor256 @deemp comments in front of abstract objects are missed

yegor256 commented 3 months ago

@deemp try this:

# Input.
[] > input /?

# Pass.
[x] > pass
  x.gt 18 > @

# Rject.
[] > reject
  QQ.io.stdout > @
    "Sorry, no"

# Accept.
[] > accept
  QQ.io.stdout > @
    "You are welcome!"

# Gate.
[p left right] > gate
  p.if > @
    left
    right

# App.
[] > app
  gate > @
    pass input
    accept
    reject
deemp commented 3 months ago

@yegor256, @maxonfjvipon

eoc phi
EO objects registered in .eoc/eo-foreign.json
Assembling into .eoc
[ERROR] Failed to parse '/home/eyjafjallajokull/Desktop/gh/normalizer/eo-examples-good/pipeline/eo-filtered/example.eo:1': [1:10] no viable alternative at input '[] > input ': "[] > input /?"
EO program assembled in .eoc
[ERROR] net.sf.saxon.style.XSLMessage@9dad9c3: Critical error identified:
  /home/eyjafjallajokull/Desktop/gh/normalizer/eo-examples-good/pipeline/eo-filtered/many-wrappers.eo, 1: [1:10] no viable alternative at input '[] > input ': "[] > input /?";
[ERROR] #fatalError(): Processing terminated by xsl:message at line 31 in fail-on-critical.xsl; SystemID: file:///org/eolang/parser/fail-on-critical.xsl; Line#: 31; Column#: 34
[ERROR] net.sf.saxon.style.XSLMessage@9dad9c3: Critical error identified:
  /home/eyjafjallajokull/Desktop/gh/normalizer/eo-examples-good/pipeline/eo-filtered/example.eo, 1: [1:10] no viable alternative at input '[] > input ': "[] > input /?";
[ERROR] #fatalError(): Processing terminated by xsl:message at line 31 in fail-on-critical.xsl; SystemID: file:///org/eolang/parser/fail-on-critical.xsl; Line#: 31; Column#: 34
[ERROR] net.sf.saxon.style.XSLMessage@9dad9c3: Critical error identified:
  /home/eyjafjallajokull/Desktop/gh/normalizer/eo-examples-good/pipeline/eo-filtered/multiplication-table.eo, 20: [20:0] no viable alternative at input '[] > app\n  INTmalloc.for > @\n    INT2\n    [m]\n      INTwhile > @\n        INTm.as-int.lt 6 > [i] >>\n        [i] >>\n          INTseq > @\n            INT*\n              INTQQ.io.stdout\n                INTQQ.txt.sprintf\n                  INT*\n                    INT"%d x %d = %d\n"\n                    m.as-int > num\n                    num\n                    num.times num\n              EXPONENTEXPONENTEXPONENTm.write\n                INT0\n                num.plus 1\nEXPONENTEXPONENTEXPONENTEXPONENTEXPONENTEXPONENTEXPONENTEXPONENT': "EOF";
[ERROR] #fatalError(): Processing terminated by xsl:message at line 31 in fail-on-critical.xsl; SystemID: file:///org/eolang/parser/fail-on-critical.xsl; Line#: 31; Column#: 34
[ERROR] Processing terminated by xsl:message at line 31 in fail-on-critical.xsl
[ERROR] Failed to execute goal org.eolang:eo-maven-plugin:0.38.2:xmir-to-phi (default-cli) on project eoc: 'org.eolang.maven.PhiMojo@2538bc06' execution failed: java.io.UncheckedIOException: java.io.IOException: java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Failed to transform by net.sf.saxon.jaxp.TransformerImpl: Processing terminated by xsl:message at line 31 in fail-on-critical.xsl; SystemID: file:///org/eolang/parser/fail-on-critical.xsl; Line#: 31; Column#: 34 -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
The command "/home/eyjafjallajokull/Desktop/gh/normalizer/node_modules/eolang/mvnw/mvnw eo:xmir-to-phi -Deo.version=0.38.2 -Deo.tag=0.38.2 --quiet -Deo.sourcesDir=/home/eyjafjallajokull/Desktop/gh/normalizer/eo-examples-good/pipeline/eo-filtered -Deo.targetDir=/home/eyjafjallajokull/Desktop/gh/normalizer/eo-examples-good/pipeline/eo-filtered/.eoc -Deo.outputDir=/home/eyjafjallajokull/Desktop/gh/normalizer/eo-examples-good/pipeline/eo-filtered/.eoc/classes -Deo.generatedDir=/home/eyjafjallajokull/Desktop/gh/normalizer/eo-examples-good/pipeline/eo-filtered/.eoc/generated-sources -Deo.placed=/home/eyjafjallajokull/Desktop/gh/normalizer/eo-examples-good/pipeline/eo-filtered/.eoc/eo-placed.csv -Deo.placedFormat=csv -Deo.phiInputDir=/home/eyjafjallajokull/Desktop/gh/normalizer/eo-examples-good/pipeline/eo-filtered/.eoc/2-optimize -Deo.phiOutputDir=/home/eyjafjallajokull/Desktop/gh/normalizer/eo-examples-good/pipeline/eo-filtered/.eoc/phi --batch-mode --color=never --update-snapshots --fail-fast --strict-checksums" exited with #1 code
maxonfjvipon commented 3 months ago

@deemp which version of eoc do you use?

maxonfjvipon commented 3 months ago

@deemp with eoc 0.21.1 this command works for me: eoc phi --parser=0.38.4 --home-tag=0.38.2. No parsing errors