//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// PLEASE DO NOT EDIT WITHOUT THE EXPLICIT CONSENT OF THE AUTHOR! \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
namespace Ilog.Irl
{
/**
* @version Last modified on Tue May 31 19:38:09 2005 by hak
* @author Hassan Aït-Kaci
* @copyright © 2004 ILOG, Inc.
*/
using HashSet = Ilog.Language.Util.HashSet;
internal class Lexicon
{
/**
* Returns true iff the specified string starts with a
* '@', and every other character is alphanumeric or underscore.
*/
internal static bool IsProtectedIdentifier (string s)
{
char c = s[0];
if (c != '@')
return false;
for (int i=1; itrue iff the specified string starts with a
* question mark, and every other character is alphanumeric or
* underscore.
*/
internal static bool IsVariable (string s)
{
char c = s[0];
if (c != '?')
return false;
for (int i=1; itrue iff the specified string is a reserved
* word (i.e., one that may not be used as identifier in
* IRL).
*/
internal static bool IsReservedWord (string word)
{
return reservedWords[word];
}
/**
* Returns true iff the specified string is an IRL
* keyword but not one in Java (i.e., one that may be also
* be used as identifier in IRL).
*/
internal static bool IsIdKeyWord (string word)
{
return idKeyWords[word];
}
/**
* Declares the specified string as a reserved word.
*/
private static void RW (string word)
{
reservedWords[word] = true;
}
/**
* Declares the specified string as a keyword that may be used
* also as an identifier.
*/
private static void ID (string word)
{
idKeyWords[word] = true;
}
/**
* Initializes the tables of reserved word; that is, the table of
* those words that are both Java and IRL keywords, and therefore
* may not be used as identifiers, and the table of IRL keywords
* that may be used also as identifiers.
*/
static Lexicon ()
{
RW("boolean");
RW("break");
RW("byte");
RW("case");
RW("catch");
RW("char");
RW("continue");
RW("double");
RW("else");
RW("false");
RW("finally");
RW("float");
RW("for");
RW("goto");
RW("if");
RW("import");
RW("instanceof");
RW("int");
RW("long");
RW("new");
RW("null");
RW("return");
RW("short");
RW("switch");
RW("throw");
RW("true");
RW("try");
RW("void");
RW("while");
ID("$");
ID("after");
ID("agendafilter");
ID("algorithm");
ID("apply");
ID("as");
ID("assert");
ID("before");
ID("bind");
ID("body");
ID("class"); // odd one (should not logically be here)
ID("collect");
ID("completionflag");
ID("default"); // odd one (should not logically be here)
ID("dynamicselect");
ID("equals");
ID("evaluate");
ID("event");
ID("execute");
ID("exists");
ID("filter");
ID("finalaction");
ID("firing");
ID("firinglimit");
ID("flowtask");
ID("foreach");
ID("fork");
ID("from");
ID("function");
ID("functiontask");
ID("hasher");
ID("in");
ID("initialaction");
ID("inout");
ID("insert");
ID("instances");
ID("is");
ID("isknown");
ID("isunknown");
ID("iterator");
ID("logical");
ID("matchedclasses");
ID("modify");
ID("not");
ID("occursin");
ID("ordering");
ID("out");
ID("packet");
ID("priority");
ID("property");
ID("refresh");
ID("retract");
ID("rule");
ID("ruleset");
ID("ruletask");
ID("select");
ID("setup");
ID("then");
ID("timeout");
ID("until");
ID("update");
ID("var");
ID("wait");
ID("when");
ID("where");
}
}
}