Skip to content

Commit

Permalink
#159: syntax fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Nov 15, 2020
1 parent 59102f8 commit e718091
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 13 deletions.
1 change: 1 addition & 0 deletions eo-compiler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ SOFTWARE.
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-matchers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
Expand Down
6 changes: 3 additions & 3 deletions eo-compiler/src/main/antlr4/org/eolang/compiler/Program.g4
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
34 changes: 25 additions & 9 deletions eo-maven-plugin/src/main/java/org/eolang/maven/CompileMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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)
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ SOFTWARE.
<xsl:value-of select="$EOL"/>
<xsl:text> * your changes will be discarded on the next build.</xsl:text>
<xsl:value-of select="$EOL"/>
<xsl:text> * The sources were compiled to XML on </xsl:text>
<xsl:value-of select="/program/@time"/>
<xsl:text> by the compiler v.</xsl:text>
<xsl:value-of select="/program/@version"/>
<xsl:text>.</xsl:text>
<xsl:value-of select="$EOL"/>
<xsl:text> */</xsl:text>
<xsl:value-of select="$EOL"/>
<xsl:value-of select="$EOL"/>
Expand Down

0 comments on commit e718091

Please sign in to comment.