|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.nyu.cascade.c.CParserState
public class CParserState
The global state for parsing C. This class provides a simplified
symbol table that is organized as a stack of parsing contexts, with
a new context being pushed onto the stack through start()
and popped again through commit()
or abort()
.
Nested Class Summary | |
---|---|
protected static class |
CParserState.Context
A parsing context. |
Field Summary | |
---|---|
protected Annotation |
annotation
The current annotation, if any. |
protected static boolean |
DEBUG
The flag for whether to print debug information to the console. |
protected static int |
FLAG_MODIFIED
The flag for having modified the bindings. |
protected static int |
FLAG_PARAMS
The flag for having parsed a function parameter list. |
protected static int |
FLAG_SCOPE
The flag for scopes. |
protected static int |
FLAG_STRUCTURE
The flag for structure/union declaration lists. |
protected static int |
FLAG_TYPE_SPEC
The flag for having parsed a type specifier. |
protected static int |
FLAG_TYPEDEF
The flag for typedefs. |
protected int |
nesting
The current nesting level. |
protected static int |
POOL_INCR
The increment of the context pool. |
protected static int |
POOL_INIT
The initial size of the context pool. |
protected CParserState.Context |
top
The top of the context stack. |
Constructor Summary | |
---|---|
CParserState()
Create a C parser state object. |
Method Summary | |
---|---|
void |
abort()
|
protected void |
addToPool(CParserState.Context c)
Return the specified context to the pool, clearing it along the way. |
Node |
annotate(Node node)
Annotate the specified node. |
void |
bind(String id)
Implicitly bind the specified identifier. |
void |
bind(String id,
boolean isType)
Explicitly bind the specified identifier. |
void |
commit()
|
void |
enterStructure()
Enter a structure declaration list. |
void |
exitStructure()
Exit a structure declaration list. |
protected void |
fillPool(int n)
Add the specified number of fresh contexts to the pool. |
void |
functionDeclarator()
Record a function declarator. |
void |
ident(String ident,
Location location)
Record an ident directive. |
boolean |
isType(String id)
Determine whether the specified identifier names a type. |
boolean |
isValid(Node idl)
Determine whether a declaration actually is a declaration. |
void |
lineMarker(String file,
int line,
String isStartFile,
String isReturnToFile,
String isSystemHeader,
String isExternC,
Location location)
Record a line marker. |
void |
mark()
Mark the current annotation. |
void |
parameters()
Record a function parameter list. |
protected CParserState.Context |
pop()
Pop a context from the context stack. |
void |
popScope()
Exit the last scope. |
void |
pragma(String directive,
Location location)
Record a pragma. |
protected void |
push(CParserState.Context c)
Push the specified context onto the context stack. |
void |
pushScope()
Enter a new scope. |
void |
reset(String file)
|
void |
start()
|
protected CParserState.Context |
takeFromPool()
Take a context from the pool, refilling the pool if necessary. |
void |
typedef()
Record a typedef storage class specifier. |
void |
typeSpecifier()
Record a type specifier. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final boolean DEBUG
protected static final int POOL_INIT
protected static final int POOL_INCR
protected static final int FLAG_TYPEDEF
protected static final int FLAG_SCOPE
protected static final int FLAG_TYPE_SPEC
protected static final int FLAG_PARAMS
protected static final int FLAG_MODIFIED
protected static final int FLAG_STRUCTURE
protected CParserState.Context top
protected int nesting
protected Annotation annotation
Constructor Detail |
---|
public CParserState()
Method Detail |
---|
protected void fillPool(int n)
n
- The number to add.protected CParserState.Context takeFromPool()
protected void addToPool(CParserState.Context c)
c
- The context to return.protected void push(CParserState.Context c)
c
- The context to push.protected CParserState.Context pop()
public void reset(String file)
reset
in interface State
public void start()
start
in interface State
public void commit()
commit
in interface State
public void abort()
abort
in interface State
public void typedef()
public void parameters()
public void functionDeclarator()
public void typeSpecifier()
public void pushScope()
public void popScope()
public void enterStructure()
public void exitStructure()
public void bind(String id)
id
- The identifier.public void bind(String id, boolean isType)
id
- The identifier.isType
- The flag for whether the identifier represents a
type.public boolean isType(String id)
id
- The identifier.
true
if the specified identifier names a type.public boolean isValid(Node idl)
DeclarationSpecifiers l:InitializedDeclaratorList?can actually represent a declaration. It assumes that any type specifier encountered while parsing
DeclarationSpecifiers
has been marked through typeSpecifier()
.
idl
- The result of parsing the optional initialized
declarator list.
true
if the declaration is a declaration.public void lineMarker(String file, int line, String isStartFile, String isReturnToFile, String isSystemHeader, String isExternC, Location location)
true
, while null counts for false
.
file
- The file name (without quotes).line
- The line number.isStartFile
- The start file flag.isReturnToFile
- The return to file flag.isSystemHeader
- The system header flag.isExternC
- The extern C flag.location
- The line marker's source location.LineMarker
public void pragma(String directive, Location location)
directive
- The actual directive.location
- The pragma's source location.Pragma
public void ident(String ident, Location location)
ident
- The actual identity marker.location
- The ident directive's source location.SourceIdentity
public void mark()
public Node annotate(Node node)
marked
, the specified node is
wrapped by those annotations and the outer-most annotation is
returned. Otherwise, the specified node is returned.
node
- The node.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |