|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmapss.dif.language.Reader
public class Reader
DIF Reader class. Top level class for reading DIF files and converting them to graphs. Input of this structure is a DIF (Dataflow Interchange Format) text. Output is a list of hierarchies or DIF graphs.
To read a DIF file, first a Reader object should be initialized for that file.
Then compile()
function should be called. The compiler will compare
the types of graphs read with the ones defined in file "analysers.txt" which is
in the same package as this class. If it finds a type match it will construct
the appropriate graph whose runtime type is as defined in the DIF file
otherwise it will skip the graph.
Although Reader class can find default analysis classes from
"analysers.txt", it is not necessary to use the default analysers.
compile(mapss.dif.language.LanguageAnalysis[])
method can be used to pass custom LanguageAnalysis classes to the Reader. This
overrides the analysis classes defined in "analysis.txt".
Information about the DIF file is not cached therefore compile method can be called after modifying the original file to apply the changes.
GNU C preprocessor commands are available for this reader. In order to use
multiple files for related graphs #include
command can be used.
CPP documentation is available
at http://gcc.gnu.org/onlinedocs/cpp/
.
GNU CPP version 2.95.3-5 (cygwin special) was used during the development of
this class. cpp(java.lang.String)
method requires the format generated by this version.
For using a different preprocessor version check its documentation.
Hierarchical relationships between different kinds of graphs are regulated
according to the rules in LanguageAnalysis._acceptableSubHierarchy(mapss.dif.DIFHierarchy)
.
For more information on this package see the package
documentation and LanguageAnalysis
.
The following codes illustrate the usage of Reader:
Reader reader = new Reader(fileName); reader.compile(); DIFHierarchy topHierarchy = reader.getTopHierarchy();
LanguageAnalysis
,
Writer
,
DIFHierarchy
,
DIFGraph
Field Summary | |
---|---|
protected LanguageAnalysis[] |
_analysers
Set to an array of default analysers defined in "analysers.txt" if compile() is used. |
protected java.lang.String |
_fileName
|
Constructor Summary | |
---|---|
Reader(java.lang.String fileName)
Constructs a Reader for this file. |
Method Summary | |
---|---|
void |
addAnalyser(LanguageAnalysis analyser)
Add new LanguageAnalysis subclass object to the analysers. |
void |
addOptions(java.lang.String[] options)
Adds options to the preprocessor. |
void |
compile()
Default compiler using default keywords defined in "analysers.txt" under mapss.dif.language . |
void |
compile(LanguageAnalysis[] analysers)
Compiler with custom analysers. |
java.util.LinkedHashMap |
cpp(java.lang.String fileName)
Seperates all files that the given file depends on by processing the output from "cpp fileName |
java.util.Collection |
getGraphs()
Returns the graphs read during compilation as a collection of DIFGraph objects. |
java.util.Collection |
getHierarchies()
Returns the graphs read during compilation as a collection of DIFHierarchy objects. |
DIFHierarchy |
getTopHierarchy()
Returns the top level hierarchy of a dif specification. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.String _fileName
protected LanguageAnalysis[] _analysers
compile()
is used. Not set if custom LanguageAnalysis objects
are used.
Constructor Detail |
---|
public Reader(java.lang.String fileName) throws java.io.IOException
java.io.IOException
- If "analysers.txt" could not be read.Method Detail |
---|
public void addAnalyser(LanguageAnalysis analyser)
analyser
- The LanguageAnalysis subclass object.public void addOptions(java.lang.String[] options)
options
- Options to add to the preprocessor. Each word should be
provided as an element in the array. Words are seperated by
whitespaces.public void compile() throws java.io.IOException, DIFLanguageException
mapss.dif.language
.
This function first pre-processes file by first running cpp(java.lang.String)
.
java.io.IOException
- If there is a problem reading the input file.
DIFLanguageException
- If there is a parse problem in the dif
file.public void compile(LanguageAnalysis[] analysers) throws java.io.IOException, DIFLanguageException
This function first pre-processes file by first running cpp(java.lang.String)
.
analysers
- An array of different analysers to use with the
compiler. Behaviour is not defined if same type of analysis is defined
more than once in this array.
java.io.IOException
- If there is a problem reading the input files.
DIFLanguageException
- If there is a parse problem.public java.util.LinkedHashMap cpp(java.lang.String fileName) throws java.io.IOException, DIFLanguageException
This method assumes that cpp uses the
For details and compliance of the cpp version in your system see gnu
cpp web site.
# lineNumber fileName flag
format for the output
(with whitespace between # and lineNumber).
Also it uses "cpp -M fileName
fileName
- File to compile
java.io.IOException
- If any of the files cannot be read.
DIFLanguageException
public java.util.Collection getGraphs()
Note that this form doesn't contain any information about hierarchical relations between the graphs read.
DIFGraph
public java.util.Collection getHierarchies()
DIFHierarchy
public DIFHierarchy getTopHierarchy()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |