Skip to content

Commit

Permalink
Fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
brodmo committed Aug 25, 2023
1 parent 691b79c commit ef9dce3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.function.Predicate;

import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.tree.ErrorNode;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.ParseTreeListener;
Expand Down Expand Up @@ -60,7 +61,8 @@ public AbstractAntlrListener(TokenCollector collector, File currentFile) {
*/
@SuppressWarnings("unchecked")
public <T extends ParserRuleContext> ContextVisitor<T> visit(Class<T> antlrType, Predicate<T> condition) {
ContextVisitor<T> visitor = new ContextVisitor<>(condition.and(rule -> rule.getClass() == antlrType), collector, variableRegistry);
Predicate<T> typeCheck = rule -> rule.getClass() == antlrType;
ContextVisitor<T> visitor = new ContextVisitor<>(typeCheck.and(condition), collector, variableRegistry);
contextVisitors.add((ContextVisitor<ParserRuleContext>) visitor);
return visitor;
}
Expand All @@ -81,8 +83,9 @@ public <T extends ParserRuleContext> ContextVisitor<T> visit(Class<T> antlrType)
* @param condition An additional condition for the visit.
* @return A visitor for the node.
*/
public TerminalVisitor visit(int terminalType, Predicate<org.antlr.v4.runtime.Token> condition) {
TerminalVisitor visitor = new TerminalVisitor(condition.and(rule -> rule.getType() == terminalType), collector, variableRegistry);
public TerminalVisitor visit(int terminalType, Predicate<Token> condition) {
Predicate<Token> typeCheck = rule -> rule.getType() == terminalType;
TerminalVisitor visitor = new TerminalVisitor(typeCheck.and(condition), collector, variableRegistry);
terminalVisitors.add(visitor);
return visitor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public AbstractAntlrParserAdapter() {
*/
public List<Token> parse(Set<File> files) throws ParsingException {
List<File> filesList = new ArrayList<>(files);
if (files.isEmpty())
return new ArrayList<>();
File firstFile = filesList.remove(0);
TokenCollector collector = new TokenCollector(extractsSemantics, firstFile);
parseFile(firstFile, collector);
Expand Down

0 comments on commit ef9dce3

Please sign in to comment.