001/* An interface used by the expression parser for identifier lookup.
002
003 Copyright (c) 2001-2007 The Regents of the University of California.
004 All rights reserved.
005 Permission is hereby granted, without written agreement and without
006 license or royalty fees, to use, copy, modify, and distribute this
007 software and its documentation for any purpose, provided that the above
008 copyright notice and the following two paragraphs appear in all copies
009 of this software.
010
011 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
014 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
015 SUCH DAMAGE.
016
017 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
021 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
022 ENHANCEMENTS, OR MODIFICATIONS.
023
024 PT_COPYRIGHT_VERSION_2
025 COPYRIGHTENDKEY
026
027 @ProposedRating Red (liuxj)
028 @AcceptedRating Red (liuxj)
029
030 */
031package ptolemy.data.expr;
032
033import java.util.Set;
034
035import ptolemy.kernel.util.IllegalActionException;
036
037//////////////////////////////////////////////////////////////////////////
038//// ParserScope
039
040/**
041 An interface used by the expression parser for identifier lookup.
042 <p>
043 An object implementing this interface represents the set of identifiers that
044 can be used in an expression being evaluated.
045
046 @author Xiaojun Liu, Steve Neuendorffer
047 @version $Id$
048 @see ptolemy.data.expr.PtParser
049 */
050public interface ParserScope {
051    /** Look up and return the value with the specified name in the
052     *  scope. Return null if the name is not defined in this scope.
053     *  @param name The name of the variable to be looked up.
054     *  @return The token associated with the given name in the scope.
055     *  @exception IllegalActionException If a value in the scope
056     *  exists with the given name, but cannot be evaluated.
057     */
058    public ptolemy.data.Token get(String name) throws IllegalActionException;
059
060    /** Look up and return the type of the value with the specified
061     *  name in the scope. Return null if the name is not defined in
062     *  this scope.
063     *  @param name The name of the variable to be looked up.
064     *  @return The token associated with the given name in the scope.
065     *  @exception IllegalActionException If a value in the scope
066     *  exists with the given name, but cannot be evaluated.
067     */
068    public ptolemy.data.type.Type getType(String name)
069            throws IllegalActionException;
070
071    /** Look up and return the type term for the specified name
072     *  in the scope. Return null if the name is not defined in this
073     *  scope, or is a constant type.
074     *  @param name The name of the variable to be looked up.
075     *  @return The InequalityTerm associated with the given name in
076     *  the scope.
077     *  @exception IllegalActionException If a value in the scope
078     *  exists with the given name, but cannot be evaluated.
079     */
080    public ptolemy.graph.InequalityTerm getTypeTerm(String name)
081            throws IllegalActionException;
082
083    /** Return a list of names corresponding to the identifiers
084     *  defined by this scope.  If an identifier is returned in this
085     *  list, then get() and getType() will return a value for the
086     *  identifier.  Note that generally speaking, this list is
087     *  extremely expensive to compute, and users should avoid calling
088     *  it.  It is primarily used for debugging purposes.
089     *  @return A list of names corresponding to the identifiers
090     *  defined by this scope.
091     *  @exception IllegalActionException If constructing the list causes
092     *  it.
093     */
094    public Set identifierSet() throws IllegalActionException;
095}