|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.Reader scale.frontend.c.CPreprocessor
public class CPreprocessor
This class reads a file and transforms it using the C preprocessor conventions.
$Id: CPreprocessor.java,v 1.51 2007-06-12 20:21:20 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
This class will send warning messages to System.err
when
any problem in the source file is discovered.
Field Summary | |
---|---|
protected boolean |
allowGNUExtensions
Set true if GNU extensions are allowed. |
static boolean |
classTrace
True if traces are to be performed. |
protected boolean |
strictANSIC
Set true if strict ANSI C required. |
Fields inherited from class java.io.Reader |
---|
lock |
Constructor Summary | |
---|---|
CPreprocessor(java.lang.String filename,
Vector<java.lang.String> userMacros,
Vector<java.lang.String> userDirs,
Vector<java.lang.String> systemDirs,
Vector<java.lang.String> macroText)
Create a reader for C programs that does the C pre-processing. |
Method Summary | |
---|---|
void |
addMacro(java.lang.String name,
java.lang.String text)
Define a simple macro to be used by the pre-processor. |
void |
close()
Close the files associated with this preprocessor. |
CReader |
getCReader()
|
int |
getLineNumber()
|
void |
mark(int readAheadLimit)
Mark the present position in the stream. |
int |
read()
Read a single character. |
int |
read(char[] cbuf,
int off,
int len)
Read characters into a portion of an array. |
java.lang.String |
readLine()
Read a line of text. |
void |
reset()
Reset the stream to the most recent mark. |
void |
setCurrentFtn(java.lang.String currentFtn)
Specify the current function being processed. |
long |
skip(long n)
Skip characters. |
Methods inherited from class java.io.Reader |
---|
markSupported, read, read, ready |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static boolean classTrace
protected boolean allowGNUExtensions
protected boolean strictANSIC
Constructor Detail |
---|
public CPreprocessor(java.lang.String filename, Vector<java.lang.String> userMacros, Vector<java.lang.String> userDirs, Vector<java.lang.String> systemDirs, Vector<java.lang.String> macroText) throws java.io.IOException
A set of user-defined macros can be specified. They must be in one of the forms
NAME NAME=TEXT
Directories to be searched for include files are specified using
two arguments. The userDirs
parameter specifies a
Vector
of String
instances that are
searched when the include file name is specified in the source
file as a string delimited by double quotes. The pre-processor
also includes the directory containing the source file in the list
of directories to be searched.
The systemDirs
parameter specifies an array of
String
instances that are searched when the include
file name is specified as a string delimited by angle-brackets.
filename
- is the source file nameuserMacros
- is a list of user defined macros in the form of
name=text
or null
userDirs
- is a list of directory pathnames to use in
finding user include files or null
systemDirs
- is a list of directory pathnames to use in
finding system include files or null
macroText
- is null
or is used to collect macro
definitions as text strings
java.io.IOException
Method Detail |
---|
public CReader getCReader()
public int getLineNumber()
public void addMacro(java.lang.String name, java.lang.String text)
name
- is the macro nametext
- is the replacement textpublic void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.Reader
java.io.IOException
public int read(char[] cbuf, int off, int len) throws java.io.IOException
read
in class java.io.Reader
cbuf
- - destination bufferoff
- - offset at which to start storing characterslen
- - maximum number of characters to read
java.io.IOException
public java.lang.String readLine() throws java.io.IOException
java.io.IOException
public int read() throws java.io.IOException
read
in class java.io.Reader
java.io.IOException
public void setCurrentFtn(java.lang.String currentFtn)
public long skip(long n) throws java.io.IOException
skip
in class java.io.Reader
n
- - the number of characters to skip
java.io.IOException
public void mark(int readAheadLimit) throws java.io.IOException
mark
in class java.io.Reader
java.io.IOException
public void reset() throws java.io.IOException
reset
in class java.io.Reader
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |