// FILE. . . . . /home/hak/ilt/src/ilog/rif/Lexicon.java
// EDIT BY . . . Hassan Ait-Kaci
// ON MACHINE. . 4j4zn71
// STARTED ON. . Thu Apr 03 13:44:34 2008

package ilog.rif.bld;

/**
 * This is a simple lexicon class implementing a very basic token
 * discriminator for the tokenizer in <a
 * href="Tokenizer.html"><tt>Tokenizer.java</tt></a>.
 *
 * @version     Last modified on Mon Apr 07 14:14:41 2008 by hak
 * @author      <a href="mailto:hak@ilog.com">Hassan A&iuml;t-Kaci</a>
 * @copyright   &copy; 2006 <a href="http://www.ilog.com/">ILOG, Inc.</a>
 */

import java.util.HashMap;
import java.util.HashSet;

class Lexicon
{
  /**
   * Returns <tt>true</tt> iff the specified string starts with a
   * question mark, and every other character is a word character.
   */
  public final static boolean isVariable (String s)
    {
      char c = s.charAt(0);

      if (c != '?')
        return false;

      for (int i=1; i<s.length(); i++)
          {
            c = s.charAt(i);
            if (!Character.isLetterOrDigit(c) && c != '_')
              return false;
          }

      return true;
    }       

  /**
   * The following is a store for BLD reserved words.
   */
  public static final HashSet reserved = new HashSet();

  /**
   * Returns <tt>true</tt> iff the specified string is a reserved
   * RCL word.
   */
  public final static boolean isReserved (String word)
    {
      return reserved.contains(word);
    }

  /**
   * Declares the specified string as a reserved word.
   */
  static final void reserved (String word)
    {
      reserved.add(word);
    }

}
