diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
index <HASH>..<HASH> 100644
--- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
@@ -361,14 +361,12 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov
         this.sourceUnit = sourceUnit;
         this.moduleNode = new ModuleNode(sourceUnit);
 
-        CharStream charStream = createCharStream(sourceUnit);
-
-        this.lexer = new GroovyLangLexer(charStream);
+        this.lexer = new GroovyLangLexer(createCharStream(sourceUnit));
         this.parser =
                 new GroovyLangParser(
                     new CommonTokenStream(this.lexer));
 
-        this.parser.setErrorHandler(new DescriptiveErrorStrategy(charStream));
+        this.parser.setErrorHandler(new DescriptiveErrorStrategy(this.lexer.getInputStream()));
 
         this.tryWithResourcesASTTransformation = new TryWithResourcesASTTransformation(this);
         this.groovydocManager = GroovydocManager.getInstance();
Trivial refactoring: use the char stream of lexer instead