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

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

Closed
deemp opened this issue Jun 10, 2024 · 8 comments
Closed

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

deemp opened this issue Jun 10, 2024 · 8 comments
Assignees
Labels
(contract) Related to the normalizer contract (eo-phi-normalizer) Related to the eo-phi-normalizer (metrics) Related to normalization metrics priority 2

Comments

@deemp
Copy link
Member

deemp commented Jun 10, 2024

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

We can't normalize inside atoms (#400).

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

@deemp deemp added priority 2 (eo-phi-normalizer) Related to the eo-phi-normalizer (metrics) Related to normalization metrics (contract) Related to the normalizer contract labels Jun 10, 2024
@yegor256
Copy link
Member

yegor256 commented Jun 14, 2024

@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
Copy link
Member Author

deemp commented Jun 14, 2024

@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
Copy link
Member

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

@yegor256
Copy link
Member

@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
Copy link
Member Author

deemp commented Jun 14, 2024

@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
Copy link
Member

@deemp which version of eoc do you use?

@maxonfjvipon
Copy link
Member

@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

@fizruk
Copy link
Collaborator

fizruk commented Oct 18, 2024

Closing in favor of #470.

@fizruk fizruk closed this as completed Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
(contract) Related to the normalizer contract (eo-phi-normalizer) Related to the eo-phi-normalizer (metrics) Related to normalization metrics priority 2
Projects
None yet
Development

No branches or pull requests

4 participants