Class ScopeImpl

  • All Implemented Interfaces:
    Scope

    public class ScopeImpl
    extends java.lang.Object
    implements Scope
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static org.slf4j.Logger LOG  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addChildScope​(Scope scope)
      Adds an enclosed (child) scope
      boolean define​(Symbol symbol)
      Defines a new symbol in this scope
      boolean followUp​(java.lang.String token, boolean isPredict)
      This method is used during context-aware parsing to find multi-token symbols iteratively.
      java.util.Map<java.lang.String,​Scope> getChildScopes()
      Gets a map of all children scopes.
      java.lang.String getName()
      Returns the scope name
      Scope getParentScope()
      Returns the enclosing (parent) scope
      java.util.Map<java.lang.String,​Symbol> getSymbols()  
      Type getType()
      maybe null.
      Symbol resolve​(java.lang.String id)
      Searches and returns a symbol with the given id if it exists.
      Symbol resolve​(java.lang.String[] qualifiedName)
      Searches and returns a symbol with the given qualified name if it exists.
      void setChildScopes​(java.util.Map<java.lang.String,​Scope> childScopes)  
      void setName​(java.lang.String name)  
      void setParentScope​(Scope parentScope)  
      void start​(java.lang.String token)
      This method is used during context-aware parsing to find multi-token symbols iteratively.
      static TokenTree tokenTreeFromSymbols​(java.util.Map<java.lang.String,​Symbol> symbols)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • LOG

        public static final org.slf4j.Logger LOG
    • Constructor Detail

      • ScopeImpl

        public ScopeImpl()
      • ScopeImpl

        public ScopeImpl​(java.lang.String name,
                         Scope parentScope)
      • ScopeImpl

        public ScopeImpl​(java.lang.String name,
                         Scope parentScope,
                         Type type)
    • Method Detail

      • getName

        public java.lang.String getName()
        Description copied from interface: Scope
        Returns the scope name
        Specified by:
        getName in interface Scope
        Returns:
      • getParentScope

        public Scope getParentScope()
        Description copied from interface: Scope
        Returns the enclosing (parent) scope
        Specified by:
        getParentScope in interface Scope
        Returns:
      • define

        public boolean define​(Symbol symbol)
        Description copied from interface: Scope
        Defines a new symbol in this scope
        Specified by:
        define in interface Scope
        Returns:
      • resolve

        public Symbol resolve​(java.lang.String id)
        Description copied from interface: Scope
        Searches and returns a symbol with the given id if it exists. The search is recursive up, so if a symbol is not found in the current scope, the algorithm searches the parent scopes all the way to the root built-in scope.
        Specified by:
        resolve in interface Scope
        Returns:
      • resolve

        public Symbol resolve​(java.lang.String[] qualifiedName)
        Description copied from interface: Scope
        Searches and returns a symbol with the given qualified name if it exists. The search is recursive up, so if a symbol is not found in the current scope, the algorith searches the parend scopes all the way to the root built-in scope.
        Specified by:
        resolve in interface Scope
        Returns:
      • setName

        public void setName​(java.lang.String name)
      • setParentScope

        public void setParentScope​(Scope parentScope)
      • addChildScope

        public void addChildScope​(Scope scope)
        Description copied from interface: Scope
        Adds an enclosed (child) scope
        Specified by:
        addChildScope in interface Scope
      • getChildScopes

        public java.util.Map<java.lang.String,​Scope> getChildScopes()
        Description copied from interface: Scope
        Gets a map of all children scopes. The key of the map is the string name of the children scope and the value is the scope itself.
        Specified by:
        getChildScopes in interface Scope
        Returns:
      • setChildScopes

        public void setChildScopes​(java.util.Map<java.lang.String,​Scope> childScopes)
      • getSymbols

        public java.util.Map<java.lang.String,​Symbol> getSymbols()
        Specified by:
        getSymbols in interface Scope
      • start

        public void start​(java.lang.String token)
        Description copied from interface: Scope
        This method is used during context-aware parsing to find multi-token symbols iteratively. It is used in conjunction with the #followUp method below.
        Specified by:
        start in interface Scope
      • followUp

        public boolean followUp​(java.lang.String token,
                                boolean isPredict)
        Description copied from interface: Scope
        This method is used during context-aware parsing to find multi-token symbols iteratively. It is used in conjunction with the #start method above.
        Specified by:
        followUp in interface Scope
      • tokenTreeFromSymbols

        public static TokenTree tokenTreeFromSymbols​(java.util.Map<java.lang.String,​Symbol> symbols)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getType

        public Type getType()
        Description copied from interface: Scope
        maybe null.
        Specified by:
        getType in interface Scope