Package com.sun.tools.corba.ee.idl
Class Preprocessor
- java.lang.Object
-
- com.sun.tools.corba.ee.idl.Preprocessor
-
public class Preprocessor extends java.lang.ObjectThis class should be extended if new pragmas are desired. If the preprocessor encounters a pragma name which it doesn't recognize (anything other than ID, prefix, or version), it calls the method otherPragmas. This is the only method which need be overridden. The Preprocessor base class has a number of utility-like methods which can be used by the overridden otherPragmas method.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Stack<java.lang.Boolean>alreadyProcessedABranchprivate static java.lang.Stringindentprivate booleanlastWasMacroIDprivate java.util.Vector<java.lang.String>macrosprivate Parserparserprivate java.util.Vector<PragmaHandler>pragmaHandlersprivate java.util.Vector<SymtabEntry>PragmaIDsprivate Scannerscannerprivate java.util.Hashtable<java.lang.String,java.lang.String>symbols(package private) Tokentoken
-
Constructor Summary
Constructors Constructor Description Preprocessor()Public zero-argument constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private ExpressionandExpr(Expression e, SymtabEntry entry)(package private) ExpressionbooleanConstExpr(SymtabEntry entry)protected java.lang.Objectclone()(package private) voidcloseScope(SymtabEntry entry)This method is called when the parser encounters a right curly brace.private voidconstExpr()(package private) java.lang.StringcurrentToken()Get the current token.private voiddefine()private ExpressiondefinedExpr(SymtabEntry entry)private voidelif()private booleanembedded(java.lang.String string, int index, int endIndex)private ExpressionequalityExpr(Expression e, SymtabEntry entry)(package private) java.lang.StringexpandMacro(java.lang.String macroDef, Token t)(package private) SymtabEntrygetEntryForName(java.lang.String string)This method, given an entry name, returns the entry with that name.private java.lang.StringgetFilename(java.lang.String name)private java.util.Vector<java.lang.String>getParmValues()(package private) java.lang.StringgetStringToEOL()This method returns a string of all of the characters from the input file from the current position up to, but not including, the end-of-line character(s).(package private) java.lang.StringgetUntil(char c)This method returns a string of all of the characters from the input file from the current position up to, but not including, the given character.private voididPragma()private voidifClause()private voidifdef(boolean not)private voidifDefine(boolean inParens, boolean not)private voidinclude()private voidinclude2(IncludeEntry include)private voidinclude3(IncludeEntry include)private voidinclude4(IncludeEntry include, java.lang.String filename)(package private) voidinit(Parser p)private booleaninQuotes(java.lang.String string, int index)private voidlocalPragma()private voidlocalServantPragma()private voidmacro(java.util.Vector<java.lang.String> parmNames)private voidmacroParms(java.util.Vector<java.lang.String> parmNames)private voidmacroParms2(java.util.Vector<java.lang.String> parmNames)private voidmacroParmValues(java.util.Vector<java.lang.String> values)private voidmatch(int type)private voidminiMatch(int type)(package private) java.lang.StringnextToken()This method returns the next token String from the input file.private ExpressionnotExpr(SymtabEntry entry)(package private) voidopenScope(SymtabEntry entry)This method is called when the parser encounters a left curly brace.private ExpressionorExpr(Expression e, SymtabEntry entry)private voidotherPragmas(java.lang.String pragmaType, java.lang.String currentToken)(package private) voidparseException(java.lang.String message)This method displays a Parser Exception complete with line number and position information with the given message string.private voidpragma()private voidprefixPragma()(package private) ExpressionprimaryExpr(SymtabEntry entry)(package private) Tokenprocess(Token t)(package private) voidregisterPragma(PragmaHandler handler)private java.lang.StringremoveDoublePound(java.lang.String string)Remove any occurrences of ##.private java.lang.StringreplaceAll(java.lang.String string, java.lang.String from, java.lang.String to)(package private) SymtabEntryscopedName()This method assumes that the current token marks the beginning of a scoped name.private voidskipToEndif()private voidskipToEndiforElse()(package private) voidskipToEOL()Skip to the end of the line.(package private) java.lang.StringskipUntil(char c)This method skips the data in the input file until the specified character is encountered, then it returns the next token.private java.lang.StringtokenToString()private voidundefine()private voidversionPragma()
-
-
-
Field Detail
-
PragmaIDs
private final java.util.Vector<SymtabEntry> PragmaIDs
-
pragmaHandlers
private final java.util.Vector<PragmaHandler> pragmaHandlers
-
lastWasMacroID
private boolean lastWasMacroID
-
parser
private Parser parser
-
scanner
private Scanner scanner
-
symbols
private java.util.Hashtable<java.lang.String,java.lang.String> symbols
-
macros
private java.util.Vector<java.lang.String> macros
-
alreadyProcessedABranch
private final java.util.Stack<java.lang.Boolean> alreadyProcessedABranch
-
token
Token token
-
indent
private static java.lang.String indent
-
-
Method Detail
-
init
void init(Parser p)
-
clone
protected java.lang.Object clone()
- Overrides:
clonein classjava.lang.Object
-
process
Token process(Token t) throws java.io.IOException, ParseException
- Throws:
java.io.IOExceptionParseException
-
include
private void include() throws java.io.IOException, ParseException- Throws:
java.io.IOExceptionParseException
-
include2
private void include2(IncludeEntry include) throws java.io.IOException, ParseException
- Throws:
java.io.IOExceptionParseException
-
include3
private void include3(IncludeEntry include) throws java.io.IOException, ParseException
- Throws:
java.io.IOExceptionParseException
-
include4
private void include4(IncludeEntry include, java.lang.String filename) throws java.io.IOException, ParseException
- Throws:
java.io.IOExceptionParseException
-
define
private void define() throws java.io.IOException, ParseException- Throws:
java.io.IOExceptionParseException
-
undefine
private void undefine() throws java.io.IOException, ParseException- Throws:
java.io.IOExceptionParseException
-
ifClause
private void ifClause() throws java.io.IOException, ParseException- Throws:
java.io.IOExceptionParseException
-
constExpr
private void constExpr() throws java.io.IOException, ParseException- Throws:
java.io.IOExceptionParseException
-
booleanConstExpr
Expression booleanConstExpr(SymtabEntry entry) throws java.io.IOException, ParseException
- Throws:
java.io.IOExceptionParseException
-
orExpr
private Expression orExpr(Expression e, SymtabEntry entry) throws java.io.IOException, ParseException
- Throws:
java.io.IOExceptionParseException
-
andExpr
private Expression andExpr(Expression e, SymtabEntry entry) throws java.io.IOException, ParseException
- Throws:
java.io.IOExceptionParseException
-
notExpr
private Expression notExpr(SymtabEntry entry) throws java.io.IOException, ParseException
- Throws:
java.io.IOExceptionParseException
-
definedExpr
private Expression definedExpr(SymtabEntry entry) throws java.io.IOException, ParseException
- Throws:
java.io.IOExceptionParseException
-
equalityExpr
private Expression equalityExpr(Expression e, SymtabEntry entry) throws java.io.IOException, ParseException
- Throws:
java.io.IOExceptionParseException
-
primaryExpr
Expression primaryExpr(SymtabEntry entry) throws java.io.IOException, ParseException
- Throws:
java.io.IOExceptionParseException
-
ifDefine
private void ifDefine(boolean inParens, boolean not) throws java.io.IOException, ParseException- Throws:
java.io.IOExceptionParseException
-
ifdef
private void ifdef(boolean not) throws java.io.IOException, ParseException- Throws:
java.io.IOExceptionParseException
-
elif
private void elif() throws java.io.IOException, ParseException- Throws:
java.io.IOExceptionParseException
-
skipToEndiforElse
private void skipToEndiforElse() throws java.io.IOException, ParseException- Throws:
java.io.IOExceptionParseException
-
skipToEndif
private void skipToEndif() throws java.io.IOException, ParseException- Throws:
java.io.IOExceptionParseException
-
pragma
private void pragma() throws java.io.IOException, ParseException- Throws:
java.io.IOExceptionParseException
-
localPragma
private void localPragma() throws java.io.IOException, ParseException- Throws:
java.io.IOExceptionParseException
-
localServantPragma
private void localServantPragma() throws java.io.IOException, ParseException- Throws:
java.io.IOExceptionParseException
-
idPragma
private void idPragma() throws java.io.IOException, ParseException- Throws:
java.io.IOExceptionParseException
-
prefixPragma
private void prefixPragma() throws java.io.IOException, ParseException- Throws:
java.io.IOExceptionParseException
-
versionPragma
private void versionPragma() throws java.io.IOException, ParseException- Throws:
java.io.IOExceptionParseException
-
registerPragma
void registerPragma(PragmaHandler handler)
-
otherPragmas
private void otherPragmas(java.lang.String pragmaType, java.lang.String currentToken) throws java.io.IOException- Throws:
java.io.IOException
-
currentToken
java.lang.String currentToken()
Get the current token.- Returns:
- the current token
-
getEntryForName
SymtabEntry getEntryForName(java.lang.String string)
This method, given an entry name, returns the entry with that name. It can take fully or partially qualified names and returns the appropriate entry defined within the current scope. If no entry exists, null is returned.- Parameters:
string- entry name to look for- Returns:
- entry with that name or
nullif no entry
-
getStringToEOL
java.lang.String getStringToEOL() throws java.io.IOExceptionThis method returns a string of all of the characters from the input file from the current position up to, but not including, the end-of-line character(s).- Returns:
- String from current position
- Throws:
java.io.IOException
-
getUntil
java.lang.String getUntil(char c) throws java.io.IOExceptionThis method returns a string of all of the characters from the input file from the current position up to, but not including, the given character. It encapsulates parenthesis and quoted strings, meaning it does not stop if the given character is found within parentheses or quotes. For instance, given the input of `start(inside)end', getUntil ('n') will return "start(inside)e"- Parameters:
c- token to read up to. The token itself will not be read.- Throws:
java.io.IOException
-
tokenToString
private java.lang.String tokenToString()
-
nextToken
java.lang.String nextToken() throws java.io.IOExceptionThis method returns the next token String from the input file.- Returns:
- the next token String
- Throws:
java.io.IOException
-
scopedName
SymtabEntry scopedName() throws java.io.IOException
This method assumes that the current token marks the beginning of a scoped name. It then parses the subsequent identifier and double colon tokens, builds the scoped name, and finds the symbol table entry with that name.- Returns:
- a SymtabEntry of the name
- Throws:
java.io.IOException
-
skipToEOL
void skipToEOL() throws java.io.IOExceptionSkip to the end of the line.- Throws:
java.io.IOException
-
skipUntil
java.lang.String skipUntil(char c) throws java.io.IOExceptionThis method skips the data in the input file until the specified character is encountered, then it returns the next token.- Parameters:
c- token to indicate end of skipping- Throws:
java.io.IOException
-
parseException
void parseException(java.lang.String message)
This method displays a Parser Exception complete with line number and position information with the given message string.- Parameters:
message- message to display as part of the Exception- See Also:
Throwable.getMessage()
-
expandMacro
java.lang.String expandMacro(java.lang.String macroDef, Token t) throws java.io.IOException, ParseException- Throws:
java.io.IOExceptionParseException
-
miniMatch
private void miniMatch(int type) throws ParseException- Throws:
ParseException
-
getParmValues
private java.util.Vector<java.lang.String> getParmValues() throws java.io.IOException, ParseException- Throws:
java.io.IOExceptionParseException
-
macroParmValues
private void macroParmValues(java.util.Vector<java.lang.String> values) throws java.io.IOException, ParseException- Throws:
java.io.IOExceptionParseException
-
macro
private void macro(java.util.Vector<java.lang.String> parmNames) throws java.io.IOException, ParseException- Throws:
java.io.IOExceptionParseException
-
macroParms
private void macroParms(java.util.Vector<java.lang.String> parmNames) throws java.io.IOException, ParseException- Throws:
java.io.IOExceptionParseException
-
macroParms2
private void macroParms2(java.util.Vector<java.lang.String> parmNames) throws java.io.IOException, ParseException- Throws:
java.io.IOExceptionParseException
-
replaceAll
private java.lang.String replaceAll(java.lang.String string, java.lang.String from, java.lang.String to)
-
embedded
private boolean embedded(java.lang.String string, int index, int endIndex)
-
inQuotes
private boolean inQuotes(java.lang.String string, int index)
-
removeDoublePound
private java.lang.String removeDoublePound(java.lang.String string)
Remove any occurrences of ##.
-
getFilename
private java.lang.String getFilename(java.lang.String name) throws java.io.FileNotFoundException- Throws:
java.io.FileNotFoundException
-
match
private void match(int type) throws java.io.IOException, ParseException- Throws:
java.io.IOExceptionParseException
-
openScope
void openScope(SymtabEntry entry)
This method is called when the parser encounters a left curly brace. An extender of PragmaHandler may find scope information useful. For example, the prefix pragma takes effect as soon as it is encountered and stays in effect until the current scope is closed. If a similar pragma extension is desired, then the openScope and closeScope methods are available for overriding.- Parameters:
entry- the symbol table entry whose scope has just been opened. Be aware that, since the scope has just been entered, this entry is incomplete at this point.
-
closeScope
void closeScope(SymtabEntry entry)
This method is called when the parser encounters a right curly brace. An extender of PragmaHandler may find scope information useful. For example, the prefix pragma takes effect as soon as it is encountered and stays in effect until the current scope is closed. If a similar pragma extension is desired, then the openScope and closeScope methods are available for overriding.- Parameters:
entry- the symbol table entry whose scope has just been closed.
-
-