diff --git a/eo-compiler/pom.xml b/eo-compiler/pom.xml index 927b4e5f2b..2be757154e 100644 --- a/eo-compiler/pom.xml +++ b/eo-compiler/pom.xml @@ -73,6 +73,7 @@ SOFTWARE. com.jcabi jcabi-matchers + test com.google.code.findbugs diff --git a/eo-compiler/src/main/antlr4/org/eolang/compiler/Program.g4 b/eo-compiler/src/main/antlr4/org/eolang/compiler/Program.g4 index feb16fc720..56c009ac13 100644 --- a/eo-compiler/src/main/antlr4/org/eolang/compiler/Program.g4 +++ b/eo-compiler/src/main/antlr4/org/eolang/compiler/Program.g4 @@ -210,14 +210,14 @@ EOL } ; -NAME: LO (LETTER | DIGIT)*; - BOOL: 'true' | 'false'; CHAR: '\'' (LETTER | DIGIT) '\''; STRING: '"' ('\\"' | ~'"')* '"'; INTEGER: (PLUS | MINUS)? DIGIT+; FLOAT: (PLUS | MINUS)? DIGIT+ DOT DIGIT+; -HEX: '0x' DIGIT+; +HEX: '0x' (DIGIT | 'a'..'f')+; + +NAME: LO (LETTER | DIGIT)*; LETTER: (HI | LO); HI: [A-Z]; diff --git a/eo-compiler/src/test/resources/org/eolang/compiler/packs/full-syntax.yaml b/eo-compiler/src/test/resources/org/eolang/compiler/packs/full-syntax.yaml index 05844ad6c5..ddee222fcb 100644 --- a/eo-compiler/src/test/resources/org/eolang/compiler/packs/full-syntax.yaml +++ b/eo-compiler/src/test/resources/org/eolang/compiler/packs/full-syntax.yaml @@ -1,6 +1,11 @@ xsls: [] tests: - /program/objects[count(o)=5] + - //o[@base='bool'] + - //o[@base='string'] + - //o[@base='char'] + - //o[@base='float'] + - //o[@base='hex'] eo: | # The purpose of this test case is to make # sure all possible syntax scenarios can @@ -19,7 +24,7 @@ eo: | second > hello third:foo > x f 12 false - (((t 22) r:t 8.54 "yes" 'e').print 88):hey true > !a + (((t 22) r:t 8.54 "yes" 'e').print 88 0x1f):hey true > !a kid f:u z diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/CompileMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/CompileMojo.java index 34dc80d585..30fccf22bc 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/CompileMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/CompileMojo.java @@ -30,6 +30,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.ArrayList; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.LifecyclePhase; @@ -138,12 +139,32 @@ public void execute() throws MojoFailureException { * @param file EO file */ private void compile(final Path file) { + final String name = file.toString().substring( + this.sourcesDirectory.toString().length() + 1 + ); try { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); new Program( - file.toString().substring( - this.sourcesDirectory.toString().length() + 1 - ), + name, + new InputOf(file), + new OutputTo(baos) + ).compile(new ArrayList<>(0)); + final String xml = String.format("%s.xml", name); + new IoChecked<>( + new LengthOf( + new TeeInput( + new InputOf(baos.toString()), + new OutputTo( + this.targetDir.toPath() + .resolve("eo-compiler-raw") + .resolve(xml) + ) + ) + ) + ).value(); + baos.reset(); + new Program( + name, new InputOf(file), new OutputTo(baos) ).compile(); @@ -154,12 +175,7 @@ private void compile(final Path file) { new OutputTo( this.targetDir.toPath() .resolve("eo-compiler") - .resolve( - String.format( - "%s.xml", - file.getFileName().toString() - ) - ) + .resolve(xml) ) ) ) diff --git a/eo-maven-plugin/src/main/resources/org/eolang/maven/to-java.xsl b/eo-maven-plugin/src/main/resources/org/eolang/maven/to-java.xsl index e45aed9c59..9abd2cd77f 100644 --- a/eo-maven-plugin/src/main/resources/org/eolang/maven/to-java.xsl +++ b/eo-maven-plugin/src/main/resources/org/eolang/maven/to-java.xsl @@ -50,6 +50,12 @@ SOFTWARE. * your changes will be discarded on the next build. + * The sources were compiled to XML on + + by the compiler v. + + . + */