Hi Shiva, Yes, of course that's possible. Look at the classes under the “examples" folder to see how you can access the ASTs and start processing them. Cheers, Kris
Hi Kris, I have started with Koopa parser and i was succesfully able to get XML dump and convert it into XSD schema and generate java classes from it. Now am looking for a way where i can directly read AST into Java objects without converting it into XML or XSD. Is there any way to do that. I did a lot of research but couldn't find a appropriate way. Please suggest if there is any way. Shiva
I contacted you via LinkedIn. I hope I picked the right Guy. :-)
Hi Chris No worries on the code to process the XML, I'm gaining confidence in the solution I'm putting together now. As regards LGTM, I took a look and it sufficiently piqued my interest enough to continue the conversation. Probably not here though as leaving my e-mail address could have "unforeseen" consequences and noth ethically correct. Any chance you can contact me on LinkedIn? (my name plus Suncorp should be enough) Cheers Guy
Hi Guy, Sorry, no. I process the data coming from the parser directly, without an intermediate transformation to XML. If you want more insight into the XML, I definitely recommend using the GUI. As the XML is pretty much a dump of the AST, anything you learn in one should be directly applicable in the other. The GUI lets you click on any token in the text and it will show you the path in the tree. There is also an option to visualize the AST in the UI. Even better, when you show the AST, clicking...
Hi Kris We are on IBM Enterprise COBOL for z/OS 4.2.0 (about to upgrade to COBOL 6). Thanks for the detailed response. As I am pre-processing the code anyway, I can easily insert a "nothing" statement into the search as you suggested so no need for you to do anything. I am running this all as a batch process it hadn't occurred to me to run the individual problem cases through the GUI to get more information regarding the error. I'll do that before I apply the fix that gets me around this one and...
So the error says that it could not classify the "END-SEARCH", but everything up to that point seems to have gone allright. In particular it looks like it handled the search statement's condition (note the "condition < searchStatement" in the path). Looking at the grammar it expects to find something after the condition: WHEN condition ( nestedStatements | NEXT SENTENCE ) Your example does not have a nested statement, nor a NEXT SENTENCE, and so the parse fails. Adding a statement after line 044300...
Is there a way to get verbose error messaging out of the parser? So far I have managed to figure out the errors that have been thrown by examining the Cobol code for anomalies, but the latest one has me stumped. Processing D:\work\source-xref\parse\cobol-cpp-batch\EBB520.CBL Writing XML to D:\work\source-xref\cobol-xml-batch\EBB520.xml Error: [EBB520.CBL:2001:12|END-SEARCH|EBB520.CBL:2001:21] @FIXED @WORD @PROGRAM_TEXT_AREA Incomplete parse. Last success ful match: identifier_format6 < identifier...
With the project on github I'm not sure where the best place to communicate is, but we started here. I've create a small example of the problem in a private repo on github where I've added you as a collaborator. (my workplace is still figuring out how they approach open source but I have been given permission to contribute to existing projects). I hope that it is straight forward to use but let me know if anything is confusing. See the readme for more details. I've also made a pull request. You can...
I decided to move the project to GitHub. It is much easier for people to contribute changes there. So if you have something to share, you can now base it off the version found at https://github.com/krisds/koopa/issues . I'm happy to keep the discussion here though.
I decided to move the project to GitHub to make it easier for people to contribute. You can now find it here: https://github.com/krisds/koopa/issues The SourceForge version will remain for historic purposes. I'll keep an eye on the forums here for a while longer.
I decided to move the project to GitHub to make it easier for people to contribute. You can now find it here: https://github.com/krisds/koopa/issues The SourceForge version will remain for historic purposes. I'll keep an eye on the forums here for a while longer.
Hey Adam, Koopa uses SVN right now, so the easiest way to share your changes is to make a diff between your code and the latest commit here, and share that. (I see that SF supports git now, so maybe I'll take some time to migrate the repo over to that. I'm not sure what the best option is.) But before that, do you have an example of dummy operands which Koopa fails to handle ? That way I can inspect what goes wrong, and give you a better answer. I would actually expect Koopa to be able to handle...
I have some changes to handle working with a dummy operand. A dummy operand is explained here: IBM COBOL Language Reference. In short: The COPY statement with REPLACING phrase can be used to replace parts of words. By inserting a dummy operand delimited by colons into the program text, the compiler will replace the dummy operand with the desired text. Example 3 shows how this is used with the dummy operand :TAG:. The colons serve as separators and make TAG a stand-alone operand. I am unsure what...
Simplify grammar for some CICS options
Easy conversion of Start to matching End
TRUE and FALSE in common nodes
Adding a common type for all statement END markers.
Fix double closing of Targets by Flow when there's a WaterTagger.
The XML has the same info as the AST. It's just a way to store it. You can analyze the AST in code, or analyze the XML, in whatever way you want. Calculating a flow graph will mean understanding how a Cobol program flows, and then querying the AST to give you the information you need to calculate it. You'll need to look at sections, paragraphs, specific statements. It's not impossible, or especially hard, but it does take work to do.
The XML has the same info as the AST. It's just a way to store it. You can analyze the AST in code, or analyze the XML, in whatever way you want. Calculating a flow graph will mean understanding how a Cobol program flows, and then querying the AST to give you the information you need to calculate it. You'll need to look at sections, paragraphs, specific statements. It's not impossible, or especially hard, but it does take work to do.
Thanks Kris.. My intend was to create a flowgraph for Cobol program using AST just for my future understanding. Would XML help to builld the flow graph? Pls help me to undestand.
Great! I'll try Kris.. thank you.
I'm not sure what you mean by "variables with hierarchy". Right now only XML export of the full AST is built-in. If you need something custom you will have to code it yourself. The easiest way is to grab the AST and process it how you want. If you look at "JaxenSample" you can see how to do the first part.
Thanks Kris. I found that and it was much helpful. I was wondering If there is anyway I can get the AST in the text format which has only variables with hierachy.. :)
Hi Bharani, Koopa includes a tool which lets you export the AST to XML. You can invoke it with "java -cp koopa.jar koopa.app.cli.ToXml", or use the "Export to XML" action under "Syntax Tree" in the GUI. Hope that helps, Kris
Hi, Please help me on this. I would like to write the AST file into TXT file. Could you please help me on this? It will be helpful If it can be found in the hierarchy model. thanks in advance. Bharani J 11 years with Mainframe new to Java
Start and End are flyweights, so equality can be simplified.
Applying the improved optimizer logic to permutations too.
Performance tweaks
Position-spec test.
Partial expressions in selection objects in EVALUATE statements
Adding position-spec anyway.
Note and test on position-spec in DISPLAY/ACCEPT.
Fix a test file.
FUNCTION name+ INTRINSIC
ACCEPT: WITH is optional
DISPLAY ERASE SCREEN
ENTRY USING BY CONTENT
ACCEPT FROM ENVIRONMENT identifier
COPYs in comments don't count. Obviously.
Guarding against an NPE.
Introducing the CobolProject interface.
Keyword test: refactored from recursion to a loop
Fix grammar for parameters in MF directives.
Cash not find class koopa.core.parsers.combinators.MatchTree
Sorry about that. It's been a while since I used svn and I forgot to add those classes in. Should be fixed now.
Add missing classes.
Cash not find class koopa.core.parsers.combinators.MatchTree
Extended grammar and parser to allow matching against trees (just the root, or in more detail).
Hi Frank / Kris, I would like to generate Tree Listeners for the Koopa AST. Howvere thr utility you have built requires Tokens.list file as input.I could not find the Tokens.list file in the current version of Koopa (or the Build r356 which is the current download file version). Do you have any suggestions on 1. How to generate Tokens.list file for the current Koopa version OR 2. How to genearte Tree Listener without Tokens.list file? Thanks, Mahesh
COPY REPLACING LEADING produces wrong ast
Refactoring Source.
Syntactic sugar for %noskip.
Replaced compiler directives regexes with actua...
Tweaking the loggers.
Rewrite/Refactoring of the sources.
Optimizer
First pass at an omniscient debugger.
Added a GUI option to set some log levels inter...
MF compiler directives
Move support for embedded languages into dedicated grammars
Added syntax in [r384]. E.g. sql::statement
Issue #41: added syntactic sugar for referencin...
It should really just be "Koopa Parser Generator" now, as you can use it for plenty...
Spelling of COBOL compilers
No, there are some hand-written forwarding methods in CobolBaseGrammar to make up...
All missing syntactic sugar was added, wasn't it?
Missing %notempty's. Tweaking CALL statement SI...
Handling optional headers in Micro Focus Cobol.
Compiler directives: refactoring and more tests
Java 5 oops.
Support for tabs.
Support MF VARIABLE format
SQL: ALTER SESSION
XML PARSE WITH ENCODING, and related tweaks
Tweak possible branch orderings
Tweaking OCCURS clause.
Tweaking SIGN clauses
SQL: SELECT COUNT(*)
SELECT INTO host parameters
Separated CICS and SQL from the Cobol source code.
Updated the example project to match the latest...
DELETE statement improvements
Removed support for native code in grammars
Support for some bottom-up parsing. Big update.
LimitedStream.peek was forcing delayed markers,...
Handling comments in COPY REPLACE and pseudo li...
Refactoring BaseStream, reworking its 'seen' li...
Added tests for LimitedStream; some cleanup
Deleted these files as well.
Summer cleaning
Support floating point numbers.
Yes, CONSTANT AS is covered by the constantEntry_level01 rule. RETRY and DYNAMIC...
You've added CONSTANT AS in the meanwhile, did you? Likely something for a new ticket...
"not all input was consumed": parsing of (optional) comma
Bugs in "Export batch results to CSV"
Parsing: Missing data types
Given the nature and goals of Koopa I'm not going to add "not allowed" checks. I...