`Lexicon.java`

    //  FILE. . . . . /home/hak/ilt/src/ilog/rif/Lexicon.java
    //  EDIT BY . . . Hassan Ait-Kaci
    //  ON MACHINE. . Latitude407.Ilog.Biz
    //  STARTED ON. . Wed May  3 14:37:18 2006

    package ilog.rif;

This is a simple lexicon class implementing a very basic token discriminator for the tokenizer in `Tokenizer.java`. It uses explicit declararations for functional and relation symbols since there is no a priori means to distinguish them - at least not from the information in [RIF] Extensible Design.
Author: |  | Hassan Aït-Kaci
Copyright: |  | © 2006 ILOG, Inc.
Version: |  | Last modified on Wed Sep 20 07:54:55 2006 by hak

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

    class Lexicon
    {

Returns `true` iff the specified string starts with a question mark, and every other character is alphanumeric or underscore.

      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 RCL reserved words.

      public static final HashSet reserved = new HashSet();

The following is a store for RCL function identifiers, associated with a corresponding XML tag.

      public static final HashMap functions = new HashMap();

The following is a store for RCL relation identifiers, associated with a corresponding XML tag.

      public static final HashMap relations = new HashMap();

Returns `true` iff the specified string is a function identifier.

      public final static boolean isFunction (String word)
        {
          return functions.containsKey(word);
        }

Returns `true` iff the specified string is a relation identifier.

      public final static boolean isRelation (String word)
        {
          return relations.containsKey(word);
        }

Returns `true` 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 function identifier whose XML tag is itself.

      static final void function (String word)
        {
          functions.put(word,word);
        }

Declares the specified string as a function identifier, with specified XML tag.

      static final void function (String word, String tag)
        {
          functions.put(word,tag);
        }

Declares the specified string as a relation identifier whose XML tag is itself.

      static final void relation (String word)
        {
          relations.put(word,word);
        }

Declares the specified string as a relation identifier, with specified XML tag.

      static final void relation (String word, String tag)
        {
          relations.put(word,tag);
        }

Declares the specified string as a reserved word.

      static final void reserved (String word)
        {
          reserved.add(word);
        }

Initializes the table of function and relation sysmbols.

      static
        {
          reserved("Exists");
          reserved("Forall");
          reserved("Or");
          reserved("And");
          reserved("Neg");
          reserved("Naf");

          relation("reject");
          relation("accept");
          relation("perishable");
          relation("delivered");
          relation("scheduled");
          relation("timediff");
          relation("greaterThan");
          relation("special");
          relation("purchase");
          relation("knows");
          relation("high");

          function("book");

        }

    }

This file was generated on Thu Oct 05 10:28:30 CEST 2006 from file `Lexicon.java`
by the `ilog.language.tools.Hilite` Java tool written by Hassan Aït-Kaci