Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/migrateGoLanguageModule'…
Browse files Browse the repository at this point in the history
… into feature/migrateGoLanguageModule
  • Loading branch information
TwoOfTwelve committed Apr 23, 2024
2 parents f89a931 + 9c43b92 commit f0d963c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public AbstractVisitor<T> mapRange(TokenType tokenType) {
* @param mapper The mapper function
*/
public TerminalVisitor delegateTerminal(Function<T, TerminalNode> mapper) {
TerminalVisitor delegate = new TerminalVisitor((ignore) -> true);
this.delegate = new DelegateVisitor<>(delegate, parentData -> mapper.apply(parentData).getSymbol());
return delegate;
TerminalVisitor delegateVisitor = new TerminalVisitor(ignore -> true);
this.delegate = new DelegateVisitor<>(delegateVisitor, parentData -> mapper.apply(parentData).getSymbol());
return delegateVisitor;
}

/**
Expand All @@ -95,10 +95,10 @@ public TerminalVisitor delegateTerminal(Function<T, TerminalNode> mapper) {
* @param mapper The mapper function
*/
public TerminalVisitor delegateTerminalExit(Function<T, TerminalNode> mapper) {
TerminalVisitor delegate = new TerminalVisitor((ignore) -> true);
this.delegate = new DelegateVisitor<>(delegate, parentData -> mapper.apply(parentData).getSymbol());
TerminalVisitor delegateVisitor = new TerminalVisitor(ignore -> true);
this.delegate = new DelegateVisitor<>(delegateVisitor, parentData -> mapper.apply(parentData).getSymbol());
this.delegate.mapOnExit();
return delegate;
return delegateVisitor;
}

/**
Expand All @@ -107,7 +107,7 @@ public TerminalVisitor delegateTerminalExit(Function<T, TerminalNode> mapper) {
* @param mapper The mapper function
*/
public <V extends ParserRuleContext> ContextVisitor<V> delegateContext(Function<T, V> mapper) {
ContextVisitor<V> visitor = new ContextVisitor<>((ignore) -> true);
ContextVisitor<V> visitor = new ContextVisitor<>(ignore -> true);
this.delegate = new ContextDelegateVisitor<>(visitor, mapper);
return visitor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,9 @@ private void functionDeclarations() {

private void controlFlowRules() {
visit(IfStmtContext.class).delegateTerminal(IfStmtContext::IF).map(IF_STATEMENT);
visit(BlockContext.class, context -> context.parent instanceof IfStmtContext && context.equals(((IfStmtContext) context.parent).block(0)))
.map(IF_BLOCK_BEGIN, IF_BLOCK_END);
// TODO no else token?
visit(BlockContext.class, context -> context.parent instanceof IfStmtContext && context.equals(((IfStmtContext) context.parent).block(1)))
visit(BlockContext.class, context -> context.parent instanceof IfStmtContext ifStmt && context.equals((ifStmt).block(0))).map(IF_BLOCK_BEGIN,
IF_BLOCK_END);
visit(BlockContext.class, context -> context.parent instanceof IfStmtContext ifStmt && context.equals((ifStmt).block(1)))
.map(ELSE_BLOCK_BEGIN, ELSE_BLOCK_END);

visit(ForStmtContext.class).map(FOR_STATEMENT);
Expand Down

0 comments on commit f0d963c

Please sign in to comment.