### Build ProLeap COBOL Parser with Maven Source: https://github.com/uwol/proleap-cobol-parser/blob/main/README.md This command-line snippet shows how to build the ProLeap COBOL parser project using Maven. It includes commands for cleaning, packaging, and installing the project, as well as running tests. ```bash $ mvn clean package $ mvn clean install $ mvn clean test ``` -------------------------------- ### Generate ASG from COBOL Code (Java) Source: https://github.com/uwol/proleap-cobol-parser/blob/main/README.md Example Java code demonstrating how to use the ProLeap COBOL parser to generate an Abstract Semantic Graph (ASG) from a COBOL source file. It shows file input, format specification, parsing, and basic ASG navigation. ```java // generate ASG from plain COBOL code java.io.File inputFile = new java.io.File("src/test/resources/io/proleap/cobol/asg/HelloWorld.cbl"); io.proleap.cobol.preprocessor.CobolPreprocessor.CobolSourceFormatEnum format = io.proleap.cobol.preprocessor.CobolPreprocessor.CobolSourceFormatEnum.TANDEM; io.proleap.cobol.asg.metamodel.Program program = new io.proleap.cobol.asg.runner.impl.CobolParserRunnerImpl().analyzeFile(inputFile, format); // navigate on ASG io.proleap.cobol.asg.metamodel.CompilationUnit compilationUnit = program.getCompilationUnit("HelloWorld"); io.proleap.cobol.asg.metamodel.ProgramUnit programUnit = compilationUnit.getProgramUnit(); io.proleap.cobol.asg.metamodel.data.DataDivision dataDivision = programUnit.getDataDivision(); io.proleap.cobol.asg.metamodel.data.datadescription.DataDescriptionEntry dataDescriptionEntry = dataDivision.getWorkingStorageSection().getDataDescriptionEntry("ITEMS"); Integer levelNumber = dataDescriptionEntry.getLevelNumber(); ``` -------------------------------- ### COBOL Code and AST Representation Source: https://github.com/uwol/proleap-cobol-parser/blob/main/README.md Demonstrates a sample COBOL program and its corresponding Abstract Syntax Tree (AST) generated by the parser. The AST represents the syntactic structure of the COBOL code. ```cobol Identification Division. Program-ID. HELLOWORLD. Procedure Division. Display "Hello world". STOP RUN. ``` ```text (startRule (compilationUnit (programUnit (identificationDivision Identification Division . (programIdParagraph Program-ID . (programName (cobolWord HELLOWORLD)) .)) (procedureDivision Procedure Division . (procedureDivisionBody (paragraphs (sentence (statement (displayStatement Display (displayOperand (literal "Hello world")))) .) (sentence (statement (stopStatement STOP RUN))) .)))))) ) ``` -------------------------------- ### Maven Dependency for ProLeap COBOL Parser Source: https://github.com/uwol/proleap-cobol-parser/blob/main/README.md Instructions on how to include the ProLeap COBOL parser library in a Maven project by adding the dependency to the pom.xml file. ```xml io.github.uwol proleap-cobol-parser 4.0.0 ``` -------------------------------- ### Java: Generate ASG and Traverse AST from COBOL Source: https://github.com/uwol/proleap-cobol-parser/blob/main/README.md This Java code demonstrates how to use the ProLeap COBOL parser to generate an Abstract Semantic Graph (ASG) from COBOL source code and then traverse the Abstract Syntax Tree (AST) using a custom visitor. It requires the COBOL parser library and specifies the source format. ```java java.io.File inputFile = new java.io.File("src/test/resources/io/proleap/cobol/asg/HelloWorld.cbl"); io.proleap.cobol.preprocessor.CobolPreprocessor.CobolSourceFormatEnum format = io.proleap.cobol.preprocessor.CobolPreprocessor.CobolSourceFormatEnum.TANDEM; io.proleap.cobol.asg.metamodel.Program program = new io.proleap.cobol.asg.runner.impl.CobolParserRunnerImpl().analyzeFile(inputFile, format); // traverse the AST io.proleap.cobol.CobolBaseVisitor visitor = new io.proleap.cobol.CobolBaseVisitor() { @Override public Boolean visitDataDescriptionEntryFormat1(final io.proleap.cobol.CobolParser.DataDescriptionEntryFormat1Context ctx) { io.proleap.cobol.asg.metamodel.data.datadescription.DataDescriptionEntry entry = (io.proleap.cobol.asg.metamodel.data.datadescription.DataDescriptionEntry) program.getASGElementRegistry().getASGElement(ctx); String name = entry.getName(); return visitChildren(ctx); } }; for (final io.proleap.cobol.asg.metamodel.CompilationUnit compilationUnit : program.getCompilationUnits()) { visitor.visit(compilationUnit.getCtx()); } ``` -------------------------------- ### COBOL Display Statement Source: https://github.com/uwol/proleap-cobol-parser/blob/main/src/test/resources/io/proleap/cobol/preprocessor/copy/extension/txt/variable/copybooks/SomeCopyBook.txt This snippet demonstrates the basic COBOL DISPLAY statement, used to output data to the console or a specified output device. It's a fundamental command for displaying messages or variable contents. ```COBOL 001000 Display "Hi" ``` -------------------------------- ### Display Text in COBOL Source: https://github.com/uwol/proleap-cobol-parser/blob/main/src/test/resources/io/proleap/cobol/preprocessor/copy/extension/precedence/variable/copybooks/SomeCopyBook.txt This snippet demonstrates the basic `DISPLAY` statement in COBOL, used to output a string literal to the standard output. It requires a COBOL compiler and runtime environment. The code displays the literal string "txt extension". ```COBOL 001000 DISPLAY "txt extension" ``` -------------------------------- ### Citation for ProLeap COBOL Parser Source: https://github.com/uwol/proleap-cobol-parser/blob/main/README.md This is a BibTeX entry for citing the ProLeap COBOL parser in research publications. It includes title, author, year, and publication URL. ```bibtex @misc{wolffgang2018cobol, title={ProLeap COBOL parser}, author={Wolffgang, Ulrich and others}, year={2018}, howpublished={\url{https://github.com/uwol/proleap-cobol-parser}}, } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.