Skip to content

Commit

Permalink
wip: split parser on statement level
Browse files Browse the repository at this point in the history
  • Loading branch information
ishche committed Apr 17, 2024
1 parent 9322e2c commit b2ed28f
Show file tree
Hide file tree
Showing 31 changed files with 2,398 additions and 194 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public StageResult<ParserStageResult> run(AnalysisContext context, StageResult<D
ParserListener listener = new ParserListener(context.getExtendedDocument(), context.getCopybooksRepository());
CobolErrorStrategy errorStrategy = new CobolErrorStrategy(messageService);
AstBuilder parser = ParserUtils.isHwParserEnabled()
? new SplitParser(CharStreams.fromString(context.getExtendedDocument().toString()),
? new SplitParser(CharStreams.fromString(context.getExtendedDocument().toString().replace('\u200B', ' ')),
listener, errorStrategy, treeListener)
: new AntlrCobolParser(CharStreams.fromString(context.getExtendedDocument().toString()),
listener, errorStrategy, treeListener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,6 @@ private List<Node> transformAST(AnalysisContext ctx,
return syntaxTree;
}

private void addEmbeddedNodes(Node rootNode, List<Node> embeddedNodes) {
for (Node dialectNode : embeddedNodes) {
Optional<Node> nodeByPosition =
RangeUtils.findNodeByPosition(
rootNode,
dialectNode.getLocality().getUri(),
dialectNode.getLocality().getRange().getStart());

nodeByPosition.orElse(rootNode).addChild(dialectNode);
}
}

private Node processSyntaxTree(AnalysisConfig analysisConfig, SymbolAccumulatorService symbolAccumulatorService, AnalysisContext ctx, List<Node> syntaxTree) {
Node rootNode = syntaxTree.get(0);
addCopyNodes(ctx, rootNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.eclipse.lsp.cobol.common.message.MessageServiceProvider;
import org.eclipse.lsp.cobol.core.CobolLexer;
import org.eclipse.lsp.cobol.core.CobolParser;
import org.eclipse.lsp.cobol.core.MessageServiceParser;

/**
* This implementation of the error strategy customizes error messages that are extracted from the
Expand Down Expand Up @@ -284,7 +285,7 @@ protected void consumeUntilNext(Parser recognizer, List<Integer> skipToTokenList
ttype = recognizer.getInputStream().LA(1);
}
if (skipTokenCount > 0) {
CobolParser cobolParser = (CobolParser) recognizer;
MessageServiceParser cobolParser = (MessageServiceParser) recognizer;
ANTLRErrorListener errorListenerDispatch = cobolParser.getErrorListenerDispatch();
CommonToken offendingToken = new CommonToken(sToken);
Token lastToken = recognizer.getInputStream().LT(-1);
Expand Down
Loading

0 comments on commit b2ed28f

Please sign in to comment.