Skip to content

Commit

Permalink
feat(#3742): rename classes back
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Dec 24, 2024
1 parent 86a2091 commit dc92fa4
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
package org.eolang.parser;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import org.antlr.v4.runtime.BaseErrorListener;
Expand All @@ -41,7 +40,7 @@
* Accumulates all parsing errors related to EO parser.
* @since 0.50
*/
final class DrEoParserErrors extends BaseErrorListener implements Iterable<Directive> {
final class EoParserErrors extends BaseErrorListener {

/**
* Errors accumulated.
Expand All @@ -57,7 +56,7 @@ final class DrEoParserErrors extends BaseErrorListener implements Iterable<Direc
* Ctor.
* @param src The source in lines
*/
DrEoParserErrors(final List<Text> src) {
EoParserErrors(final List<Text> src) {
this(new ArrayList<>(0), new Lines(src));
}

Expand All @@ -66,7 +65,7 @@ final class DrEoParserErrors extends BaseErrorListener implements Iterable<Direc
* @param errors Errors accumulated
* @param lines The source in lines
*/
private DrEoParserErrors(final List<ParsingException> errors, final Lines lines) {
private EoParserErrors(final List<ParsingException> errors, final Lines lines) {
this.errors = errors;
this.lines = lines;
}
Expand All @@ -79,9 +78,12 @@ public int size() {
return this.errors.size();
}

@Override
public Iterator<Directive> iterator() {
return new DrErrors(this.errors).iterator();
/**
* All errors accumulated as directives.
* @return The errors.
*/
public Iterable<Directive> directives() {
return new DrErrors(this.errors);
}

// @checkstyle ParameterNumberCheck (10 lines)
Expand Down
6 changes: 3 additions & 3 deletions eo-parser/src/main/java/org/eolang/parser/EoSyntax.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,22 @@ public EoSyntax(final String nme, final Input ipt) {
*/
public XML parsed() throws IOException {
final List<Text> lines = this.lines();
final DrParsingErrors spy = new DrParsingErrors(lines);
final GeneralErrors spy = new GeneralErrors(lines);
final EoLexer lexer = new EoIndentLexer(this.normalize());
lexer.removeErrorListeners();
lexer.addErrorListener(spy);
final EoParser parser = new EoParser(
new CommonTokenStream(lexer)
);
parser.removeErrorListeners();
final DrEoParserErrors eospy = new DrEoParserErrors(lines);
final EoParserErrors eospy = new EoParserErrors(lines);
parser.addErrorListener(eospy);
final XeEoListener xel = new XeEoListener(this.name);
new ParseTreeWalker().walk(xel, parser.program());
final XML dom = Syntax.CANONICAL.pass(
new XMLDocument(
new Xembler(
new Directives(xel).append(spy).append(eospy)
new Directives(xel).append(spy.directives()).append(eospy.directives())
).domQuietly()
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
package org.eolang.parser;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.antlr.v4.runtime.BaseErrorListener;
import org.antlr.v4.runtime.RecognitionException;
Expand All @@ -38,7 +37,7 @@
*
* @since 0.30.0
*/
final class DrParsingErrors extends BaseErrorListener implements Iterable<Directive> {
final class GeneralErrors extends BaseErrorListener {

/**
* Errors accumulated.
Expand All @@ -54,15 +53,15 @@ final class DrParsingErrors extends BaseErrorListener implements Iterable<Direct
* Ctor.
* @param lines The source in lines
*/
DrParsingErrors(final Text... lines) {
GeneralErrors(final Text... lines) {
this(new ListOf<>(lines));
}

/**
* Ctor.
* @param src The source in lines
*/
DrParsingErrors(final List<Text> src) {
GeneralErrors(final List<Text> src) {
this(new ArrayList<>(0), new Lines(src));
}

Expand All @@ -71,7 +70,7 @@ final class DrParsingErrors extends BaseErrorListener implements Iterable<Direct
* @param errors Errors accumulated
* @param lines The source in lines
*/
private DrParsingErrors(final List<ParsingException> errors, final Lines lines) {
private GeneralErrors(final List<ParsingException> errors, final Lines lines) {
this.errors = errors;
this.lines = lines;
}
Expand All @@ -98,16 +97,19 @@ public void syntaxError(
);
}

@Override
public Iterator<Directive> iterator() {
return new DrErrors(this.errors).iterator();
}

/**
* How many errors?
* @return Count of errors accumulated
*/
public int size() {
return this.errors.size();
}

/**
* All errors accumulated as directives.
* @return The errors
*/
public Iterable<Directive> directives() {
return new DrErrors(this.errors);
}
}
2 changes: 1 addition & 1 deletion eo-parser/src/main/java/org/eolang/parser/PhiSyntax.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public PhiSyntax(
@Override
public XML parsed() throws IOException {
final XePhiListener xel = new XePhiListener(this.name);
final DrParsingErrors spy = new DrParsingErrors(this.input);
final GeneralErrors spy = new GeneralErrors(this.input);
final PhiLexer lexer = new PhiLexer(
CharStreams.fromStream(
new InputStreamOf(this.input)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* </p>
* @since 0.50
* @todo #3332:30min Add more decorators for the error message.
* For example, {@link DrParsingErrors} currently contains logic related to the message formatting.
* For example, {@link GeneralErrors} currently contains logic related to the message formatting.
* It's better to create a separate class for this purpose.
*/
final class UnderlinedMessage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
package org.eolang.parser;

import java.util.stream.Stream;
import org.eolang.parser.errors.UnderlinedMessage;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down

0 comments on commit dc92fa4

Please sign in to comment.