-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from yegor256/164
164: new EO-to-Java compiler
- Loading branch information
Showing
119 changed files
with
3,280 additions
and
2,201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
eo-compiler/src/main/java/org/eolang/compiler/Pack.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2016-2020 Yegor Bugayenko | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included | ||
* in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package org.eolang.compiler; | ||
|
||
import com.jcabi.xml.ClasspathSources; | ||
import com.jcabi.xml.XSL; | ||
import com.jcabi.xml.XSLDocument; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.Iterator; | ||
import java.util.LinkedList; | ||
import org.cactoos.list.ListOf; | ||
import org.cactoos.list.Mapped; | ||
|
||
/** | ||
* Pack of all XSL sheets. | ||
* | ||
* @since 0.1 | ||
*/ | ||
public final class Pack implements Iterable<XSL> { | ||
|
||
/** | ||
* All of them. | ||
*/ | ||
private final Collection<String> sheets; | ||
|
||
/** | ||
* Ctor, with the default sequence of sheets. | ||
*/ | ||
@SuppressWarnings("PMD.AvoidDuplicateLiterals") | ||
public Pack() { | ||
this( | ||
new ListOf<>( | ||
"errors/not-empty-atoms.xsl", | ||
"errors/middle-varargs.xsl", | ||
"errors/duplicate-names.xsl", | ||
"errors/broken-aliases.xsl", | ||
"errors/duplicate-aliases.xsl", | ||
"errors/global-nonames.xsl", | ||
"errors/same-line-names.xsl", | ||
"errors/self-naming.xsl", | ||
"add-refs.xsl", | ||
"wrap-method-calls.xsl", | ||
"vars-float-up.xsl", | ||
"add-refs.xsl", | ||
"resolve-aliases.xsl", | ||
"add-default-package.xsl", | ||
"errors/broken-refs.xsl", | ||
"errors/unknown-names.xsl", | ||
"errors/noname-attributes.xsl" | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* Ctor. | ||
* | ||
* @param names Names of them in classpath | ||
*/ | ||
public Pack(final Collection<String> names) { | ||
this.sheets = Collections.unmodifiableCollection(names); | ||
} | ||
|
||
@Override | ||
public Iterator<XSL> iterator() { | ||
return new Mapped<>( | ||
doc -> new XSLDocument( | ||
Program.class.getResourceAsStream(doc) | ||
).with(new ClasspathSources()), | ||
this.sheets | ||
).iterator(); | ||
} | ||
|
||
/** | ||
* Make a copy, with an additional XSL. | ||
* @param xsl Name in classpath | ||
* @return New pack | ||
*/ | ||
public Pack with(final String xsl) { | ||
final Collection<String> after = new LinkedList<>(this.sheets); | ||
after.add(xsl); | ||
return new Pack(after); | ||
} | ||
} |
Oops, something went wrong.
eba8b28
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
104-4512cd36
disappeared fromeo-compiler/src/test/java/org/eolang/compiler/syntax/ArgumentTest.java
, that's why I closed #129. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.eba8b28
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
105-90b91742
disappeared fromeo-compiler/src/main/java/org/eolang/compiler/syntax/MethodImpl.java
, that's why I closed #131. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.eba8b28
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
95-fabf1b89
disappeared fromeo-compiler/src/main/java/org/eolang/compiler/syntax/Object.java
, that's why I closed #106. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.