Skip to content

Commit

Permalink
wip: basic support preprocessors in hw parser
Browse files Browse the repository at this point in the history
  • Loading branch information
ishche committed Apr 18, 2024
1 parent ec77c48 commit 974adb2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 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().replace('\u200B', ' ')),
? new SplitParser(CharStreams.fromString(context.getExtendedDocument().toString()),
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 @@ -303,7 +303,7 @@ private void paragraph() {
private void statement() {
ctx.push(new Statement());
try {
while (!match(".") && ctx.getLexer().hasMore()) {
while (!match(".") && !isNextDivisionEofOrEop() && !isParagraph() && !isSection() && !isEndOfProgram()) {
consume();
}
optional(".");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private ProcedureDivisionBodyContext createProcedureDivisionBodyContext(Procedur

if (node instanceof Statement) {
assureParagraphsCtx(genStack, pdbCtx, node);
ParserRuleContext s = parseStatement((Statement) node);
ParserRuleContext s = parseSentence((Statement) node);
lastToken = (CommonToken) s.stop;
s.setParent(genStack.peek());
genStack.peek().addChild(s);
Expand Down Expand Up @@ -199,7 +199,7 @@ private void handleSectionNode(LinkedList<ParserRuleContext> genStack, CstNode n
genStack.push(paragraphsContext);
}

private ParserRuleContext parseStatement(Statement node) {
private ParserRuleContext parseSentence(Statement node) {
Token startToken = findStartToken(node).get();
String input = generatePrefix(charStream, startToken) + node.toText();
CobolProcedureDivisionLexer antlrLexer =
Expand Down

0 comments on commit 974adb2

Please sign in to comment.