Skip to content

Commit

Permalink
release-related updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mbdevpl committed Jun 1, 2017
1 parent dd18bdc commit 7c0afdc
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/.project
/.settings
/bin
/*.jar
/dist
/lib
2 changes: 2 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
XML output generator for Open Fortran Parser
Copyright 2017 Mateusz Bysiek
64 changes: 53 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,78 @@
# XML output generator for Open Fortran Parser

This is an extension of Open Fortran Parser (OFP), which outputs abstract syntaxt tree (AST)
in XML format - to a file or to 'System.out'.
in XML format of parsed Fortran file - to a file or to `System.out`.


## dependencies

- Open Fortran Parser 0.8.4-1

https://github.com/mbdevpl/open-fortran-parser/releases/tag/v0.8.4-1
https://github.com/mbdevpl/open-fortran-parser/releases/tag/v0.8.4-1

This is a patched version of OFP. Specifically, 'FortranParserActionPrint' class in OFP
could not be properly subclassed due to access levels of members of that class, so for example
writing my own printer would introduce a lot of code duplication. Patch resolves this,
without affecting any functionality of the Parser.
This is a patched version of OFP. Specifically, `FortranParserActionPrint` class in OFP
could not be properly subclassed due to access levels of members of that class, so for example
writing my own printer would introduce a lot of code duplication. Patch resolves this,
without affecting any functionality.

The patch also resolves some issue when compiling with recent GCC versions.
The patch also resolves an issue when compiling with recent GCC versions.

- ANTRL 3.3 (dependency of Open Fortran Parser)

http://www.antlr3.org/download/
http://www.antlr3.org/download/

- Apache Commons CLI
- Apache Commons CLI 1.4 (or later)

https://commons.apache.org/proper/commons-cli/download_cli.cgi
https://commons.apache.org/proper/commons-cli/download_cli.cgi

## how to build

Put dependencies in `lib` directory, and run:

```
ant
```

This will create a `.jar` file in `dist` directory.

## how to run

```bash
java -cp "/path/to/dependencies/*" fortran.ofp.FrontEnd --class fortran.ofp.XMLPrinter \
--output output.xml --verbosity 0~100 input.f
```

where:

- The `--verbosity` flag controls verbosity of the parse tree. Defaluts to `100` when omitted.

* Maximum, `100`, means that all details picked up by Open Fortran Parser will be preserved.

* Minimum, `0`, means that tree will contain only what is needed to reconstruct the program
without changing it's meaning.

- The `--output` flag controls where the XML should be written. Defaults to standard output
when omitted.

... and remaining command-line options are exactly as defined in OFP 0.8.4.

To parse `some_fortran_file.f` and save XML output in `tree.xml` with minimum verbosity:

```bash
java -cp "./lib/*:./dist/*" fortran.ofp.FrontEnd --class fortran.ofp.XMLPrinter \
--output tree.xml --verbosity 0 some_fortran_file.f
```

And to dump XML with maximum verbosity to console:

```bash
java -cp "./lib/*:./dist/*" fortran.ofp.FrontEnd --class fortran.ofp.XMLPrinter \
--verbosity 100 some_fortran_file.f
```


## AST specification

In progress.

Root node is '<ofp>', it has one subnode '<file>'.
Root node is `<ofp>`, it has one subnode `<file>`.
12 changes: 7 additions & 5 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
<property name="src.dir" value="src" />
<property name="bin.dir" value="bin" />
<property name="lib.dir" value="lib" />
<property name="jar.name" value="OpenFortranParserXml-0.1.0.jar" />
<property name="dist.dir" value="dist" />
<property name="jar.name" value="OpenFortranParserXML-0.1.0.jar" />
<property name="mainclass" value="fortran.ofp.Xml" />

<path id="ofp.classpath">
<pathelement location="bin" />
<!-- <pathelement location="resources" /> -->
<fileset dir="${lib.dir}" includes="*.jar" />
</path>

Expand All @@ -28,7 +29,6 @@
<exclude name="**/*.java" />
</fileset>
</copy>
<copy file="LICENSE" todir="${bin.dir}" />
</target>

<target name="build" depends="clean,init">
Expand All @@ -40,10 +40,12 @@
</target>

<target name="jar" depends="build">
<jar jarfile="${jar.name}" basedir="bin" includes="**/*.class">
<jar jarfile="${dist.dir}/${jar.name}" basedir="bin" includes="**/*.class">
<manifest>
<attribute name="Main-Class" value="fortran.ofp.Xml" />
<attribute name="Main-Class" value="${mainclass}" />
</manifest>
<metainf file="LICENSE" />
<metainf file="NOTICE" />
</jar>
</target>

Expand Down

0 comments on commit 7c0afdc

Please sign in to comment.