Skip to content

Commit

Permalink
perf: Remove experimental parser
Browse files Browse the repository at this point in the history
  • Loading branch information
slavek-kucera authored and ishche committed Oct 29, 2024
1 parent 347969f commit ce3cfe0
Show file tree
Hide file tree
Showing 129 changed files with 2 additions and 12,182 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
/** Enum of supported Cobol language id's */
public enum CobolLanguageId {
COBOL("cobol", new CobolProgramLayout(6, 1, 4, 61, 8)),
EXPERIMENTAL_COBOL("expcobol", new CobolProgramLayout(6, 1, 4, 61, 8)),
HP_COBOL("hpcobol", new CobolProgramLayout(0, 1, 4, 127, 0));

private final CobolProgramLayout layout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.eclipse.lsp.cobol.dialects.hp.HpCleanupStage;
import org.eclipse.lsp.cobol.dialects.hp.HpCopybookProcessingStage;
import org.eclipse.lsp.cobol.dialects.ibm.*;
import org.eclipse.lsp.cobol.dialects.ibm.experimental.ExperimentalParserStage;
import org.eclipse.lsp.cobol.service.settings.CachingConfigurationService;
import org.eclipse.lsp.cobol.service.settings.layout.CodeLayoutStore;

Expand All @@ -63,8 +62,6 @@ public static Pipeline<AnalysisContext> setupPipeline(Injector diCtx, boolean is
switch (dialect) {
case COBOL:
return getPipelineForCobolDialect(diCtx, isAnalysisRequired);
case EXPERIMENTAL_COBOL:
return getPipelineForExpCobol(diCtx, isAnalysisRequired);
case HP_COBOL:
return getPipelineForHpCobol(diCtx, isAnalysisRequired);
default:
Expand Down Expand Up @@ -108,24 +105,6 @@ private static Pipeline<AnalysisContext> getPipelineForHpCobol(Injector diCtx, b
return pipeline;
}

private static Pipeline<AnalysisContext> getPipelineForExpCobol(Injector diCtx, boolean isAnalysisRequired) {
MessageService messageService = diCtx.getInstance(MessageService.class);
CleanerPreprocessor preprocessor = diCtx.getInstance(TrueDialectServiceImpl.class).getPreprocessor(CobolLanguageId.EXPERIMENTAL_COBOL);
DialectService dialectService = diCtx.getInstance(DialectService.class);
Pipeline<AnalysisContext> pipeline = new Pipeline<>();

pipeline.add(new IbmCleanupStage(preprocessor));
pipeline.add(new CompilerDirectivesStage(messageService));
pipeline.add(new DialectProcessingStage(dialectService, preprocessor));
pipeline.add(new PreprocessorStage(diCtx.getInstance(GrammarPreprocessor.class), preprocessor));
if (isAnalysisRequired) {
pipeline.add(new ImplicitDialectProcessingStage(dialectService));
pipeline.add(new ExperimentalParserStage(messageService, diCtx.getInstance(ParseTreeListener.class)));
pipeline.add(new TransformTreeStage(diCtx.getInstance(SymbolsRepository.class), messageService, diCtx.getInstance(SubroutineService.class), diCtx.getInstance(CachingConfigurationService.class), dialectService, diCtx.getInstance(AstProcessor.class), diCtx.getInstance(CodeLayoutStore.class)));
}
return pipeline;
}

private static Pipeline<AnalysisContext> getPipelineForCobolDialect(Injector diCtx, boolean isAnalysisRequired) {
Pipeline<AnalysisContext> pipeline = new Pipeline<>();
DialectService dialectService = diCtx.getInstance(DialectService.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import lombok.NonNull;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.RuleNode;
import org.antlr.v4.runtime.tree.TerminalNode;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.eclipse.lsp.cobol.common.SubroutineService;
Expand All @@ -43,9 +42,6 @@
import org.eclipse.lsp.cobol.common.utils.StringUtils;
import org.eclipse.lsp.cobol.core.*;
import org.eclipse.lsp.cobol.core.semantics.CopybooksRepository;
import org.eclipse.lsp.cobol.dialects.ibm.experimental.visitors.CobolDataDivisionVisitor;
import org.eclipse.lsp.cobol.dialects.ibm.experimental.visitors.CobolIdentificationDivisionVisitor;
import org.eclipse.lsp.cobol.dialects.ibm.experimental.visitors.CobolProcedureDivisionVisitor;
import org.eclipse.lsp.cobol.service.settings.CachingConfigurationService;
import org.eclipse.lsp4j.Location;
import org.eclipse.lsp4j.Position;
Expand All @@ -72,7 +68,7 @@
* elements to add the usages or throw a warning on an invalid definition. If there is a misspelled
* keyword, the visitor finds it and throws a warning.
*/
public class CobolVisitor extends CobolParserBaseVisitor<List<Node>> {
public final class CobolVisitor extends CobolParserBaseVisitor<List<Node>> {
private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(CobolVisitor.class);
protected final List<SyntaxError> errors = new ArrayList<>();
protected final CopybooksRepository copybooks;
Expand Down Expand Up @@ -1284,39 +1280,6 @@ public List<Node> visitConstantName(ConstantNameContext ctx) {
.orElseGet(ImmutableList::of);
}

// NOTE: CobolVisitor is not managed by Guice DI, so can't use annotation here.
@Override
public List<Node> visitChildren(RuleNode node) {
checkInterruption();
if (node.getClass().getEnclosingClass() == CobolIdentificationDivisionParser.class) {
CobolIdentificationDivisionVisitor cobolIdentificationDivisionVisitor = new CobolIdentificationDivisionVisitor(extendedDocument, copybooks);
List<Node> nodes = cobolIdentificationDivisionVisitor.visit(node);
errors.addAll(cobolIdentificationDivisionVisitor.getErrors());
return nodes;
}
if (node.getClass().getEnclosingClass() == CobolDataDivisionParser.class) {
CobolDataDivisionVisitor cobolDataDivisionVisitor = new CobolDataDivisionVisitor(extendedDocument, copybooks, messageService, fileControls);
List<Node> nodes = cobolDataDivisionVisitor.visit(node);
errors.addAll(cobolDataDivisionVisitor.getErrors());
return nodes;
}
if (node.getClass().getEnclosingClass() == CobolProcedureDivisionParser.class) {
CobolProcedureDivisionVisitor cobolProcedureDivisionVisitor = new CobolProcedureDivisionVisitor(
copybooks,
tokenStream,
extendedDocument,
messageService,
subroutineService,
cachingConfigurationService,
programLayout
);
List<Node> nodes = cobolProcedureDivisionVisitor.visit(node);
errors.addAll(cobolProcedureDivisionVisitor.getErrors());
return nodes;
}
return super.visitChildren(node);
}

@Override
protected List<Node> defaultResult() {
return ImmutableList.of();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.eclipse.lsp.cobol.dialects.hp.HpTrueCobolDialect;
import org.eclipse.lsp.cobol.dialects.ibm.*;
import org.eclipse.lsp.cobol.common.dialects.CobolLanguageId;
import org.eclipse.lsp.cobol.dialects.ibm.experimental.EnterpriseCobol64;
import org.eclipse.lsp.cobol.service.settings.CachingConfigurationService;
import org.eclipse.lsp.cobol.service.settings.layout.CodeLayoutStore;

Expand Down Expand Up @@ -64,10 +63,6 @@ public TrueDialectServiceImpl(
messageService, treeListener, subroutineService, cachingConfigurationService, dialectService,
astProcessor, symbolsRepository, codeLayoutStore));

dialects.put(CobolLanguageId.EXPERIMENTAL_COBOL, new EnterpriseCobol64(grammarPreprocessor,
messageService, treeListener, subroutineService, cachingConfigurationService, dialectService,
astProcessor, symbolsRepository, codeLayoutStore));

dialects.put(CobolLanguageId.HP_COBOL, new HpTrueCobolDialect(grammarPreprocessor,
messageService, treeListener, subroutineService, cachingConfigurationService, dialectService,
astProcessor, symbolsRepository, codeLayoutStore, copybookService));
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit ce3cfe0

Please sign in to comment.