antlraux package
v0.2.1

antlraux.context
Class Context

java.lang.Object
  |
  +--antlraux.context.Context

public abstract class Context
extends java.lang.Object

The main class for managing contextual information.

This class is implemented around the Scope class. One could say it's just a thin wrapper around it.

Context is thought to be subclassed. In most cases they'll add a bunch of methods adapted to each language's particuarities. This way, they may add:

You may bypass the use of Context and use Scope directly. See its comments for further information.

Author:
Enrique José García Cota
See Also:
Scope

Constructor Summary
Context(int rootScopeTag, java.lang.String rootScopeName)
          It creates a default scope if no other is specified
Context(Scope rootScope)
          Uses a given scope as root scope
 
Method Summary
 Scope closeScope(int tag)
          Closes the current scope
 Scope getCurrentScope()
          Returns the scope
 Scope getRootScope()
          Gets the root scope
 void insert(Declaration d)
          Inserts a declaration in the current scope.
 Scope openScope(int scopeTag, java.lang.String scopeName)
          Opens a new scope
 Scope openScope(Scope newScope)
          Opens a new scope
 void setCurrentScope(Scope s)
          Sets current scope
 Scope toFather()
          Sets the current scope to point to the father
 void toRoot()
          Sets the current scope to the root scope
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Context

public Context(int rootScopeTag,
               java.lang.String rootScopeName)
It creates a default scope if no other is specified


Context

public Context(Scope rootScope)
Uses a given scope as root scope

Method Detail

insert

public void insert(Declaration d)
            throws ContextException
Inserts a declaration in the current scope.

Throws:
ContextException - if a subclass overrides the insertion and throws it

openScope

public Scope openScope(Scope newScope)
                throws ContextException
Opens a new scope

Returns:
the new Scope
Throws:
ContextException - if a subclass throws it

openScope

public Scope openScope(int scopeTag,
                       java.lang.String scopeName)
                throws ContextException
Opens a new scope

Returns:
the new scope
Throws:
ContextException - depending on openScope(Scope)

getCurrentScope

public Scope getCurrentScope()
Returns the scope


setCurrentScope

public void setCurrentScope(Scope s)
Sets current scope


getRootScope

public Scope getRootScope()
Gets the root scope


toRoot

public void toRoot()
Sets the current scope to the root scope


toFather

public Scope toFather()
Sets the current scope to point to the father

Returns:
the previous scope

closeScope

public Scope closeScope(int tag)
                 throws ContextException
Closes the current scope

Returns:
the *recently closed* scope (the OLD one)
Throws:
ContextException - if "name" does not match the current scope's name or if the stack is empty

antlraux package
v0.2.1

Created by Enrique José García Cota