| java.lang.Object xtc.lang.CParserState
All known Subclasses: xtc.lang.c4.C4ParserState,
CParserState | public class CParserState implements State(Code) | | 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
CParserState.start() and popped again through
CParserState.commit() or
CParserState.abort() .
author: Robert Grimm version: $Revision: 1.15 $ |
Inner Class :protected static class Context | |
Field Summary | |
final protected static boolean | DEBUG The flag for whether to print debug information to the console. | final protected static int | FLAG_MODIFIED The flag for having modified the bindings. | final protected static int | FLAG_PARAMS The flag for having parsed a function parameter list. | final protected static int | FLAG_SCOPE The flag for scopes. | final protected static int | FLAG_STRUCTURE The flag for structure/union declaration lists. | final protected static int | FLAG_TYPEDEF The flag for typedefs. | final protected static int | FLAG_TYPE_SPEC The flag for having parsed a type specifier. | final protected static int | POOL_INCR The increment of the context pool. | final protected static int | POOL_INIT The initial size of the context pool. | protected Annotation | annotation The current annotation, if any. | protected int | nesting The current nesting level. | protected Context | top The top of the context stack. |
Constructor Summary | |
public | CParserState() Create a C parser state object. |
Method Summary | |
public void | abort() | protected void | addToPool(Context c) Return the specified context to the pool, clearing it along the
way. | public Node | annotate(Node node) Annotate the specified node. | public void | bind(String id) Implicitly bind the specified identifier. | public void | bind(String id, boolean isType) Explicitly bind the specified identifier. | public void | commit() | public void | enterStructure() Enter a structure declaration list. | public void | exitStructure() Exit a structure declaration list. | protected void | fillPool(int n) Add the specified number of fresh contexts to the pool. | public void | functionDeclarator() Record a function declarator. | public void | ident(String ident, Location location) Record an ident directive. | public boolean | isType(String id) Determine whether the specified identifier names a type.
Parameters: id - The identifier. | public boolean | isValid(Node idl) Determine whether a declaration actually is a declaration. | public void | lineMarker(String file, int line, String isStartFile, String isReturnToFile, String isSystemHeader, String isExternC, Location location) Record a line marker. | public void | mark() Mark the current annotation. | public void | parameters() Record a function parameter list. | protected Context | pop() Pop a context from the context stack. | public void | popScope() Exit the last scope. | public void | pragma(String directive, Location location) Record a pragma. | protected void | push(Context c) Push the specified context onto the context stack. | public void | pushScope() Enter a new scope. | public void | reset(String file) | public void | start() | protected Context | takeFromPool() Take a context from the pool, refilling the pool if necessary. | public void | typeSpecifier() Record a type specifier. | public void | typedef() Record a typedef storage class specifier. |
DEBUG | final protected static boolean DEBUG(Code) | | The flag for whether to print debug information to the console.
|
FLAG_MODIFIED | final protected static int FLAG_MODIFIED(Code) | | The flag for having modified the bindings.
|
FLAG_PARAMS | final protected static int FLAG_PARAMS(Code) | | The flag for having parsed a function parameter list.
|
FLAG_SCOPE | final protected static int FLAG_SCOPE(Code) | | The flag for scopes.
|
FLAG_STRUCTURE | final protected static int FLAG_STRUCTURE(Code) | | The flag for structure/union declaration lists.
|
FLAG_TYPEDEF | final protected static int FLAG_TYPEDEF(Code) | | The flag for typedefs.
|
FLAG_TYPE_SPEC | final protected static int FLAG_TYPE_SPEC(Code) | | The flag for having parsed a type specifier.
|
POOL_INCR | final protected static int POOL_INCR(Code) | | The increment of the context pool.
|
POOL_INIT | final protected static int POOL_INIT(Code) | | The initial size of the context pool.
|
nesting | protected int nesting(Code) | | The current nesting level.
|
top | protected Context top(Code) | | The top of the context stack. The implementation assumes that
this field always references at least one context, which
corresponds to the global namespace.
|
CParserState | public CParserState()(Code) | | Create a C parser state object.
|
abort | public void abort()(Code) | | |
addToPool | protected void addToPool(Context c)(Code) | | Return the specified context to the pool, clearing it along the
way.
Parameters: c - The context to return. |
annotate | public Node annotate(Node node)(Code) | | Annotate the specified node. If any annotations have been
recorded and
CParserState.mark() marked , the specified node is
wrapped by those annotations and the outer-most annotation is
returned. Otherwise, the specified node is returned.
Parameters: node - The node. The annotated node. |
bind | public void bind(String id)(Code) | | Implicitly bind the specified identifier. Depending on the
current parsing context, the identifier is either bound as a type
or as an object/function/constant.
Parameters: id - The identifier. |
bind | public void bind(String id, boolean isType)(Code) | | Explicitly bind the specified identifier.
Parameters: id - The identifier. Parameters: isType - The flag for whether the identifier represents atype. |
commit | public void commit()(Code) | | |
enterStructure | public void enterStructure()(Code) | | Enter a structure declaration list.
|
exitStructure | public void exitStructure()(Code) | | Exit a structure declaration list.
|
fillPool | protected void fillPool(int n)(Code) | | Add the specified number of fresh contexts to the pool.
Parameters: n - The number to add. |
functionDeclarator | public void functionDeclarator()(Code) | | Record a function declarator.
|
ident | public void ident(String ident, Location location)(Code) | | Record an ident directive.
See Also: SourceIdentity Parameters: ident - The actual identity marker. Parameters: location - The ident directive's source location. |
isType | public boolean isType(String id)(Code) | | Determine whether the specified identifier names a type.
Parameters: id - The identifier. true if the specified identifier names a type. |
isValid | public boolean isValid(Node idl)(Code) | | Determine whether a declaration actually is a declaration. This
method determines whether the sequence
DeclarationSpecifiers l:InitializedDeclaratorList?
can actually represent a declaration. It assumes that any type
specifier encountered while parsing
DeclarationSpecifiers has been marked through
CParserState.typeSpecifier() .
Parameters: idl - The result of parsing the optional initializeddeclarator list. true if the declaration is a declaration. |
lineMarker | public void lineMarker(String file, int line, String isStartFile, String isReturnToFile, String isSystemHeader, String isExternC, Location location)(Code) | | Record a line marker. Note that string values for the four flags
are interpreted as follows: Any non-null string counts for
true , while null counts for false .
See Also: LineMarker Parameters: file - The file name (without quotes). Parameters: line - The line number. Parameters: isStartFile - The start file flag. Parameters: isReturnToFile - The return to file flag. Parameters: isSystemHeader - The system header flag. Parameters: isExternC - The extern C flag. Parameters: location - The line marker's source location. |
mark | public void mark()(Code) | | Mark the current annotation. This method must be called before
recognizing the nonterminals to be annotated. Furthermore, it
must be called within the context of a stateful production.
|
parameters | public void parameters()(Code) | | Record a function parameter list.
|
pop | protected Context pop()(Code) | | Pop a context from the context stack.
The top-most context. |
popScope | public void popScope()(Code) | | Exit the last scope.
|
pragma | public void pragma(String directive, Location location)(Code) | | Record a pragma.
See Also: Pragma Parameters: directive - The actual directive. Parameters: location - The pragma's source location. |
push | protected void push(Context c)(Code) | | Push the specified context onto the context stack.
Parameters: c - The context to push. |
pushScope | public void pushScope()(Code) | | Enter a new scope.
|
start | public void start()(Code) | | |
takeFromPool | protected Context takeFromPool()(Code) | | Take a context from the pool, refilling the pool if necessary.
A fresh context. |
typeSpecifier | public void typeSpecifier()(Code) | | Record a type specifier.
|
typedef | public void typedef()(Code) | | Record a typedef storage class specifier.
|
|
|