Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved ANTLR specific classes to axiom.lang.antlr
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
- Loading branch information
1 parent
4459d85
commit ac85a7e
Showing
12 changed files
with
106 additions
and
85 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
infra/axiom/src/main/java/com/evolveum/axiom/lang/antlr/AxiomAntlrStatementSource.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,71 @@ | ||
/* | ||
* Copyright (c) 2020 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.axiom.lang.antlr; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
import org.antlr.v4.runtime.CharStream; | ||
import org.antlr.v4.runtime.CharStreams; | ||
import org.antlr.v4.runtime.CommonTokenStream; | ||
|
||
import com.evolveum.axiom.api.AxiomIdentifier; | ||
import com.evolveum.axiom.lang.antlr.AxiomLexer; | ||
import com.evolveum.axiom.lang.antlr.AxiomParser; | ||
import com.evolveum.axiom.lang.antlr.AxiomParser.StatementContext; | ||
import com.evolveum.axiom.lang.spi.AxiomIdentifierResolver; | ||
import com.evolveum.axiom.lang.spi.AxiomStatementStreamListener; | ||
import com.evolveum.axiom.lang.spi.AxiomSyntaxException; | ||
|
||
public class AxiomAntlrStatementSource { | ||
|
||
private final StatementContext root; | ||
private final String sourceName; | ||
|
||
public static AxiomAntlrStatementSource from(String sourceName, InputStream stream) throws IOException, AxiomSyntaxException { | ||
return from(sourceName, CharStreams.fromStream(stream)); | ||
} | ||
|
||
public static StatementContext contextFrom(String sourceName, CharStream stream) { | ||
AxiomLexer lexer = new AxiomLexer(stream); | ||
AxiomParser parser = new AxiomParser(new CommonTokenStream(lexer)); | ||
lexer.removeErrorListeners(); | ||
parser.removeErrorListeners(); | ||
AxiomErrorListener errorListener = new AxiomErrorListener(sourceName); | ||
parser.addErrorListener(errorListener); | ||
StatementContext statement = parser.statement(); | ||
errorListener.validate(); | ||
return statement; | ||
} | ||
|
||
public static AxiomAntlrStatementSource from(String sourceName, CharStream stream) throws AxiomSyntaxException { | ||
StatementContext statement = contextFrom(sourceName, stream); | ||
return new AxiomAntlrStatementSource(sourceName, statement); | ||
} | ||
|
||
protected AxiomAntlrStatementSource(String sourceName, StatementContext statement) { | ||
this.sourceName = sourceName; | ||
this.root = statement; | ||
} | ||
|
||
public String sourceName() { | ||
return sourceName; | ||
} | ||
|
||
protected final StatementContext root() { | ||
return root; | ||
} | ||
|
||
public final void stream(AxiomIdentifierResolver statements, AxiomIdentifierResolver arguments, AxiomStatementStreamListener listener, | ||
Optional<Set<AxiomIdentifier>> emitOnly) { | ||
AxiomAntlrVisitor<?> visitor = new AxiomAntlrVisitor<>(sourceName, statements, arguments, listener, emitOnly.orElse(null)); | ||
visitor.visit(root); | ||
} | ||
|
||
} |
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
14 changes: 0 additions & 14 deletions
14
infra/axiom/src/main/java/com/evolveum/axiom/lang/impl/AxiomModelInfo.java
This file was deleted.
Oops, something went wrong.
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
7 changes: 0 additions & 7 deletions
7
infra/axiom/src/main/java/com/evolveum/axiom/lang/impl/DelegatedRequirement.java
This file was deleted.
Oops, something went wrong.
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
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