|
1 | 1 | # XML output generator for Open Fortran Parser |
2 | 2 |
|
3 | 3 | This is an extension of Open Fortran Parser (OFP), which outputs abstract syntaxt tree (AST) |
4 | | -in XML format - to a file or to 'System.out'. |
| 4 | +in XML format of parsed Fortran file - to a file or to `System.out`. |
5 | 5 |
|
6 | 6 |
|
7 | 7 | ## dependencies |
8 | 8 |
|
9 | 9 | - Open Fortran Parser 0.8.4-1 |
10 | 10 |
|
11 | | - https://github.com/mbdevpl/open-fortran-parser/releases/tag/v0.8.4-1 |
| 11 | + https://github.com/mbdevpl/open-fortran-parser/releases/tag/v0.8.4-1 |
12 | 12 |
|
13 | | - This is a patched version of OFP. Specifically, 'FortranParserActionPrint' class in OFP |
14 | | - could not be properly subclassed due to access levels of members of that class, so for example |
15 | | - writing my own printer would introduce a lot of code duplication. Patch resolves this, |
16 | | - without affecting any functionality of the Parser. |
| 13 | + This is a patched version of OFP. Specifically, `FortranParserActionPrint` class in OFP |
| 14 | + could not be properly subclassed due to access levels of members of that class, so for example |
| 15 | + writing my own printer would introduce a lot of code duplication. Patch resolves this, |
| 16 | + without affecting any functionality. |
17 | 17 |
|
18 | | - The patch also resolves some issue when compiling with recent GCC versions. |
| 18 | + The patch also resolves an issue when compiling with recent GCC versions. |
19 | 19 |
|
20 | 20 | - ANTRL 3.3 (dependency of Open Fortran Parser) |
21 | 21 |
|
22 | | - http://www.antlr3.org/download/ |
| 22 | + http://www.antlr3.org/download/ |
23 | 23 |
|
24 | | - - Apache Commons CLI |
| 24 | + - Apache Commons CLI 1.4 (or later) |
25 | 25 |
|
26 | | - https://commons.apache.org/proper/commons-cli/download_cli.cgi |
| 26 | + https://commons.apache.org/proper/commons-cli/download_cli.cgi |
27 | 27 |
|
| 28 | +## how to build |
| 29 | + |
| 30 | +Put dependencies in `lib` directory, and run: |
| 31 | + |
| 32 | +``` |
| 33 | +ant |
| 34 | +``` |
| 35 | + |
| 36 | +This will create a `.jar` file in `dist` directory. |
28 | 37 |
|
29 | 38 | ## how to run |
30 | 39 |
|
| 40 | +```bash |
| 41 | +java -cp "/path/to/dependencies/*" fortran.ofp.FrontEnd --class fortran.ofp.XMLPrinter \ |
| 42 | + --output output.xml --verbosity 0~100 input.f |
| 43 | +``` |
| 44 | + |
| 45 | +where: |
| 46 | + |
| 47 | + - The `--verbosity` flag controls verbosity of the parse tree. Defaluts to `100` when omitted. |
| 48 | + |
| 49 | + * Maximum, `100`, means that all details picked up by Open Fortran Parser will be preserved. |
| 50 | + |
| 51 | + * Minimum, `0`, means that tree will contain only what is needed to reconstruct the program |
| 52 | + without changing it's meaning. |
| 53 | + |
| 54 | + - The `--output` flag controls where the XML should be written. Defaults to standard output |
| 55 | + when omitted. |
| 56 | + |
| 57 | +... and remaining command-line options are exactly as defined in OFP 0.8.4. |
| 58 | + |
| 59 | +To parse `some_fortran_file.f` and save XML output in `tree.xml` with minimum verbosity: |
| 60 | + |
| 61 | +```bash |
| 62 | +java -cp "./lib/*:./dist/*" fortran.ofp.FrontEnd --class fortran.ofp.XMLPrinter \ |
| 63 | + --output tree.xml --verbosity 0 some_fortran_file.f |
| 64 | +``` |
| 65 | + |
| 66 | +And to dump XML with maximum verbosity to console: |
| 67 | + |
| 68 | +```bash |
| 69 | +java -cp "./lib/*:./dist/*" fortran.ofp.FrontEnd --class fortran.ofp.XMLPrinter \ |
| 70 | + --verbosity 100 some_fortran_file.f |
| 71 | +``` |
| 72 | + |
31 | 73 |
|
32 | 74 | ## AST specification |
33 | 75 |
|
34 | 76 | In progress. |
35 | 77 |
|
36 | | -Root node is '<ofp>', it has one subnode '<file>'. |
| 78 | +Root node is `<ofp>`, it has one subnode `<file>`. |
0 commit comments