tokenizer.java

//---------------------------------------------------------------------------
// White spaces to be skipped
//---------------------------------------------------------------------------

SKIP:
{
    " " | "\t" | "\n" | "\r" | "\f"
}

MORE:
{
    "//" : IN_SINGLE_LINE_COMMENT
    |
    <"/**" ~["/"]>
    : IN_FORMAL_COMMENT
    |
    "/*" : IN_MULTI_LINE_COMMENT
}

<IN_SINGLE_LINE_COMMENT>SPECIAL_TOKEN :
{
    <SINGLE_LINE_COMMENT: "\n" | "\r" | "\r\n" > : DEFAULT
}

<IN_FORMAL_COMMENT>SPECIAL_TOKEN:
{
    <FORMAL_COMMENT: "*/" >
      {
	  // Removes the first 3 characters and the last 2 characters
	  // from the matched string
	  String sstr = image.toString();
	  int slen = sstr.length();
	  matchedToken.image = sstr.substring(3,slen-2);
      }
    : DEFAULT
}

<IN_MULTI_LINE_COMMENT>
SPECIAL_TOKEN :
{
    <MULTI_LINE_COMMENT: "*/"> : DEFAULT
}

<IN_SINGLE_LINE_COMMENT,IN_FORMAL_COMMENT,IN_MULTI_LINE_COMMENT>
MORE :
{
    < ~[] >
}

//---------------------------------------------------------------------------
// Reserved words of the rule language
//---------------------------------------------------------------------------

TOKEN :
{
    <IMPORT: "import">
  | <USING: "using">
  | <NEW: "new">
  | <SETUP: "setup">
  | <RULESET: "ruleset">
  | <RULE: "rule">
  | <PROPERTY: "property">
  | <PRIORITY: "priority">
  | <PACKET: "packet">
  | <WHEN: "when">
  | <THEN: "then">
  | <NOT: "not">
  | <EXISTS: "exists">
  | <COLLECT: "collect">
  | <WHERE: "where">
  | <FROM: "from">
  | <IN: "in">
  | <LOGICAL: "logical">
  | <EVENT: "event">
  | <WAIT: "wait">
  | <UNTIL: "until">
  | <EVALUATE: "evaluate">
  | <REFRESH: "refresh">
  | <ASSERT: "assert">
  | <INSERT: "insert">
  | <RETRACT: "retract">
  | <UPDATE: "update">
  | <APPLY: "apply">
  | <MODIFY: "modify">
  | <BIND: "bind">
  | <VAR: "var">
  | <EXECUTE: "execute">
  | <WHILE: "while">
  | <FOR: "for">
  | <FUNCTION: "function">
  | <RETURN: "return">
  | <BREAK: "break">
  | <CONTINUE: "continue">
  | <IF: "if">
  | <ELSE: "else">
  | <TIMEOUT: "timeout">
  | <INSTANCEOF: "instanceof">
  | <IS: "is">
  | <TIMEOF: "timeof">
  | <OCCURSIN: "occursin">
  | <BEFORE: "before">
  | <AFTER: "after">
  | <DOLLARSIGN: "$">
  | <THROW: "throw">
  | <TRY: "try">
  | <CATCH: "catch">
  | <FINALLY: "finally">
  | <UNKNOWN: "isunknown">
  | <KNOWN: "isknown">
  | <RULETASK: "ruletask">
  | <FUNCTIONTASK: "functiontask">
  | <FLOWTASK: "flowtask">
  | <BODY: "body">
  | <SWITCH: "switch">
  | <CASE: "case">
  | <DEFLT: "default">
  | <FORK: "fork">
  | <GOTO: "goto">
  | <OUT: "out">
  | <INOUT: "inout">
  | <INITIALACTION: "initialaction">
  | <FINALACTION: "finalaction">
  | <FIRING: "firing">
  | <FIRINGLIMIT: "firinglimit">
  | <ORDERING: "ordering">
  | <SELECT: "select">
  | <DYNSELECT: "dynamicselect">
  | <FILTER: "filter">
  | <AGENDAFILTER: "agendafilter">
  | <COMPLETIONFLAG: "completionflag">
  | <INSTANCES: "instances">
  | <HASHER: "hasher">
  | <ITERATOR: "iterator">
  | <MATCHEDCLASSES: "matchedclasses">
  | <ALGORITHM: "algorithm">
}

//---------------------------------------------------------------------------
// Some constants
//---------------------------------------------------------------------------

TOKEN :
{
    <NULL: "null"> | <TRUE: "true"> | <FALSE: "false">
}

//---------------------------------------------------------------------------
// Literals
//   Warning: for Character & String literals, octal escape sequences
//   are not supported!
//---------------------------------------------------------------------------

TOKEN :
{
    <INTEGER_LITERAL:
      <DECIMAL_LITERAL> (["l","L"])?
      | <HEX_LITERAL> (["l","L"])?
      | <OCTAL_LITERAL> (["l","L"])?
    >
    | < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* >
    | < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
    | < #OCTAL_LITERAL: "0" (["0"-"7"])* >
    |
      < FLOATING_POINT_LITERAL:
        (["0"-"9"])+ "." (["0"-"9"])* (<EXPONENT>)? (["f","F","d","D"])?
      | "." (["0"-"9"])+ (<EXPONENT>)? (["f","F","d","D"])?
      | (["0"-"9"])+ <EXPONENT> (["f","F","d","D"])?
      | (["0"-"9"])+ (<EXPONENT>)? ["f","F","d","D"]
      >
    | <#EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
    | <CHARACTER_LITERAL:
      "'"
      (   (~["'","\\","\n","\r"])
        | ("\\" ( ["n","t","b","r","f","\\","'","\""] ))
      )
      "'"
      >
	{
	    String cstr = image.toString();
	    int clen = cstr.length();
	    matchedToken.image = cstr.substring(1,clen-1);
	}
    | <STRING_LITERAL:
      "\""
      (   (~["\"","\\","\n","\r"])
        | ("\\" ( ["n","t","b","r","f","\\","'","\""] ))
      )*
      "\""
      >
	{
	    String sstr = image.toString();
	    int slen = sstr.length();
	    matchedToken.image = sstr.substring(1,slen-1);
	}
}

//---------------------------------------------------------------------------
// Identifiers
//   Very important: see also ilog.rules.tests.IlrUnicharGenerator class
//   which is used to generate the character ranges.
//---------------------------------------------------------------------------

TOKEN :
{
    <IDENTIFIER: <LETTER> (<FOLLOWING>)*>
  |
    <#LETTER:
      [
"\u8000"-"\u9fa5",
"\uac00"-"\ud7a3",
"\uf900"-"\ufa2d",
"\ufb00"-"\ufb06",
"\ufb13"-"\ufb17",
"\ufb1f"-"\ufb28",
"\ufb2a"-"\ufb36",
"\ufb38"-"\ufb3c",
"\ufb3e"-"\ufb3e",
"\ufb40"-"\ufb41",
"\ufb43"-"\ufb44",
"\ufb46"-"\ufbb1",
"\ufbd3"-"\ufd3d",
"\ufd50"-"\ufd8f",
"\ufd92"-"\ufdc7",
"\ufdf0"-"\ufdfb",
"\ufe33"-"\ufe34",
"\ufe4d"-"\ufe4f",
"\ufe69"-"\ufe69",
"\ufe70"-"\ufe72",
"\ufe74"-"\ufe74",
"\ufe76"-"\ufefc",
"\uff04"-"\uff04",
"\uff21"-"\uff3a",
"\uff3f"-"\uff3f",
"\uff41"-"\uff5a",
"\uff66"-"\uffbe",
"\uffc2"-"\uffc7",
"\uffca"-"\uffcf",
"\uffd2"-"\uffd7",
"\uffda"-"\uffdc",
"\uffe0"-"\uffe1",
"\uffe5"-"\uffe6",
"\u0024"-"\u0024",
"\u0041"-"\u005a",
"\u005f"-"\u005f",
"\u0061"-"\u007a",
"\u00a2"-"\u00a5",
"\u00aa"-"\u00aa",
"\u00b5"-"\u00b5",
"\u00ba"-"\u00ba",
"\u00c0"-"\u00d6",
"\u00d8"-"\u00f6",
"\u00f8"-"\u01f5",
"\u01fa"-"\u0217",
"\u0250"-"\u02a8",
"\u02b0"-"\u02b8",
"\u02bb"-"\u02c1",
"\u02d0"-"\u02d1",
"\u02e0"-"\u02e4",
"\u037a"-"\u037a",
"\u0386"-"\u0386",
"\u0388"-"\u038a",
"\u038c"-"\u038c",
"\u038e"-"\u03a1",
"\u03a3"-"\u03ce",
"\u03d0"-"\u03d6",
"\u03da"-"\u03da",
"\u03dc"-"\u03dc",
"\u03de"-"\u03de",
"\u03e0"-"\u03e0",
"\u03e2"-"\u03f3",
"\u0401"-"\u040c",
"\u040e"-"\u044f",
"\u0451"-"\u045c",
"\u045e"-"\u0481",
"\u0490"-"\u04c4",
"\u04c7"-"\u04c8",
"\u04cb"-"\u04cc",
"\u04d0"-"\u04eb",
"\u04ee"-"\u04f5",
"\u04f8"-"\u04f9",
"\u0531"-"\u0556",
"\u0559"-"\u0559",
"\u0561"-"\u0587",
"\u05d0"-"\u05ea",
"\u05f0"-"\u05f2",
"\u0621"-"\u063a",
"\u0640"-"\u064a",
"\u0671"-"\u06b7",
"\u06ba"-"\u06be",
"\u06c0"-"\u06ce",
"\u06d0"-"\u06d3",
"\u06d5"-"\u06d5",
"\u06e5"-"\u06e6",
"\u0905"-"\u0939",
"\u093d"-"\u093d",
"\u0958"-"\u0961",
"\u0985"-"\u098c",
"\u098f"-"\u0990",
"\u0993"-"\u09a8",
"\u09aa"-"\u09b0",
"\u09b2"-"\u09b2",
"\u09b6"-"\u09b9",
"\u09dc"-"\u09dd",
"\u09df"-"\u09e1",
"\u09f0"-"\u09f3",
"\u0a05"-"\u0a0a",
"\u0a0f"-"\u0a10",
"\u0a13"-"\u0a28",
"\u0a2a"-"\u0a30",
"\u0a32"-"\u0a33",
"\u0a35"-"\u0a36",
"\u0a38"-"\u0a39",
"\u0a59"-"\u0a5c",
"\u0a5e"-"\u0a5e",
"\u0a72"-"\u0a74",
"\u0a85"-"\u0a8b",
"\u0a8d"-"\u0a8d",
"\u0a8f"-"\u0a91",
"\u0a93"-"\u0aa8",
"\u0aaa"-"\u0ab0",
"\u0ab2"-"\u0ab3",
"\u0ab5"-"\u0ab9",
"\u0abd"-"\u0abd",
"\u0ae0"-"\u0ae0",
"\u0b05"-"\u0b0c",
"\u0b0f"-"\u0b10",
"\u0b13"-"\u0b28",
"\u0b2a"-"\u0b30",
"\u0b32"-"\u0b33",
"\u0b36"-"\u0b39",
"\u0b3d"-"\u0b3d",
"\u0b5c"-"\u0b5d",
"\u0b5f"-"\u0b61",
"\u0b85"-"\u0b8a",
"\u0b8e"-"\u0b90",
"\u0b92"-"\u0b95",
"\u0b99"-"\u0b9a",
"\u0b9c"-"\u0b9c",
"\u0b9e"-"\u0b9f",
"\u0ba3"-"\u0ba4",
"\u0ba8"-"\u0baa",
"\u0bae"-"\u0bb5",
"\u0bb7"-"\u0bb9",
"\u0c05"-"\u0c0c",
"\u0c0e"-"\u0c10",
"\u0c12"-"\u0c28",
"\u0c2a"-"\u0c33",
"\u0c35"-"\u0c39",
"\u0c60"-"\u0c61",
"\u0c85"-"\u0c8c",
"\u0c8e"-"\u0c90",
"\u0c92"-"\u0ca8",
"\u0caa"-"\u0cb3",
"\u0cb5"-"\u0cb9",
"\u0cde"-"\u0cde",
"\u0ce0"-"\u0ce1",
"\u0d05"-"\u0d0c",
"\u0d0e"-"\u0d10",
"\u0d12"-"\u0d28",
"\u0d2a"-"\u0d39",
"\u0d60"-"\u0d61",
"\u0e01"-"\u0e2e",
"\u0e30"-"\u0e30",
"\u0e32"-"\u0e33",
"\u0e3f"-"\u0e46",
"\u0e81"-"\u0e82",
"\u0e84"-"\u0e84",
"\u0e87"-"\u0e88",
"\u0e8a"-"\u0e8a",
"\u0e8d"-"\u0e8d",
"\u0e94"-"\u0e97",
"\u0e99"-"\u0e9f",
"\u0ea1"-"\u0ea3",
"\u0ea5"-"\u0ea5",
"\u0ea7"-"\u0ea7",
"\u0eaa"-"\u0eab",
"\u0ead"-"\u0eae",
"\u0eb0"-"\u0eb0",
"\u0eb2"-"\u0eb3",
"\u0ebd"-"\u0ebd",
"\u0ec0"-"\u0ec4",
"\u0ec6"-"\u0ec6",
"\u0edc"-"\u0edd",
"\u0f40"-"\u0f47",
"\u0f49"-"\u0f69",
"\u10a0"-"\u10c5",
"\u10d0"-"\u10f6",
"\u1100"-"\u1159",
"\u115f"-"\u11a2",
"\u11a8"-"\u11f9",
"\u1e00"-"\u1e9b",
"\u1ea0"-"\u1ef9",
"\u1f00"-"\u1f15",
"\u1f18"-"\u1f1d",
"\u1f20"-"\u1f45",
"\u1f48"-"\u1f4d",
"\u1f50"-"\u1f57",
"\u1f59"-"\u1f59",
"\u1f5b"-"\u1f5b",
"\u1f5d"-"\u1f5d",
"\u1f5f"-"\u1f7d",
"\u1f80"-"\u1fb4",
"\u1fb6"-"\u1fbc",
"\u1fbe"-"\u1fbe",
"\u1fc2"-"\u1fc4",
"\u1fc6"-"\u1fcc",
"\u1fd0"-"\u1fd3",
"\u1fd6"-"\u1fdb",
"\u1fe0"-"\u1fec",
"\u1ff2"-"\u1ff4",
"\u1ff6"-"\u1ffc",
"\u203f"-"\u2040",
"\u207f"-"\u207f",
"\u20a0"-"\u20ac",
"\u2102"-"\u2102",
"\u2107"-"\u2107",
"\u210a"-"\u2113",
"\u2115"-"\u2115",
"\u2118"-"\u211d",
"\u2124"-"\u2124",
"\u2126"-"\u2126",
"\u2128"-"\u2128",
"\u212a"-"\u2131",
"\u2133"-"\u2138",
"\u2160"-"\u2182",
"\u3005"-"\u3005",
"\u3007"-"\u3007",
"\u3021"-"\u3029",
"\u3031"-"\u3035",
"\u3041"-"\u3094",
"\u309b"-"\u309e",
"\u30a1"-"\u30fa",
"\u30fc"-"\u30fe",
"\u3105"-"\u312c",
"\u3131"-"\u318e",
"\u4e00"-"\u7fff"
      ]>
  |
    <#FOLLOWING:
      [
"\u8000"-"\u9fa5",
"\uac00"-"\ud7a3",
"\uf900"-"\ufa2d",
"\ufb00"-"\ufb06",
"\ufb13"-"\ufb17",
"\ufb1e"-"\ufb28",
"\ufb2a"-"\ufb36",
"\ufb38"-"\ufb3c",
"\ufb3e"-"\ufb3e",
"\ufb40"-"\ufb41",
"\ufb43"-"\ufb44",
"\ufb46"-"\ufbb1",
"\ufbd3"-"\ufd3d",
"\ufd50"-"\ufd8f",
"\ufd92"-"\ufdc7",
"\ufdf0"-"\ufdfb",
"\ufe20"-"\ufe23",
"\ufe33"-"\ufe34",
"\ufe4d"-"\ufe4f",
"\ufe69"-"\ufe69",
"\ufe70"-"\ufe72",
"\ufe74"-"\ufe74",
"\ufe76"-"\ufefc",
"\ufeff"-"\ufeff",
"\uff04"-"\uff04",
"\uff10"-"\uff19",
"\uff21"-"\uff3a",
"\uff3f"-"\uff3f",
"\uff41"-"\uff5a",
"\uff66"-"\uffbe",
"\uffc2"-"\uffc7",
"\uffca"-"\uffcf",
"\uffd2"-"\uffd7",
"\uffda"-"\uffdc",
"\uffe0"-"\uffe1",
"\uffe5"-"\uffe6",
"\u0000"-"\u0008",
"\u000e"-"\u001b",
"\u0024"-"\u0024",
"\u0030"-"\u0039",
"\u0041"-"\u005a",
"\u005f"-"\u005f",
"\u0061"-"\u007a",
"\u007f"-"\u009f",
"\u00a2"-"\u00a5",
"\u00aa"-"\u00aa",
"\u00b5"-"\u00b5",
"\u00ba"-"\u00ba",
"\u00c0"-"\u00d6",
"\u00d8"-"\u00f6",
"\u00f8"-"\u01f5",
"\u01fa"-"\u0217",
"\u0250"-"\u02a8",
"\u02b0"-"\u02b8",
"\u02bb"-"\u02c1",
"\u02d0"-"\u02d1",
"\u02e0"-"\u02e4",
"\u0300"-"\u0345",
"\u0360"-"\u0361",
"\u037a"-"\u037a",
"\u0386"-"\u0386",
"\u0388"-"\u038a",
"\u038c"-"\u038c",
"\u038e"-"\u03a1",
"\u03a3"-"\u03ce",
"\u03d0"-"\u03d6",
"\u03da"-"\u03da",
"\u03dc"-"\u03dc",
"\u03de"-"\u03de",
"\u03e0"-"\u03e0",
"\u03e2"-"\u03f3",
"\u0401"-"\u040c",
"\u040e"-"\u044f",
"\u0451"-"\u045c",
"\u045e"-"\u0481",
"\u0483"-"\u0486",
"\u0490"-"\u04c4",
"\u04c7"-"\u04c8",
"\u04cb"-"\u04cc",
"\u04d0"-"\u04eb",
"\u04ee"-"\u04f5",
"\u04f8"-"\u04f9",
"\u0531"-"\u0556",
"\u0559"-"\u0559",
"\u0561"-"\u0587",
"\u0591"-"\u05a1",
"\u05a3"-"\u05b9",
"\u05bb"-"\u05bd",
"\u05bf"-"\u05bf",
"\u05c1"-"\u05c2",
"\u05c4"-"\u05c4",
"\u05d0"-"\u05ea",
"\u05f0"-"\u05f2",
"\u0621"-"\u063a",
"\u0640"-"\u0652",
"\u0660"-"\u0669",
"\u0670"-"\u06b7",
"\u06ba"-"\u06be",
"\u06c0"-"\u06ce",
"\u06d0"-"\u06d3",
"\u06d5"-"\u06dc",
"\u06df"-"\u06e8",
"\u06ea"-"\u06ed",
"\u06f0"-"\u06f9",
"\u0901"-"\u0903",
"\u0905"-"\u0939",
"\u093c"-"\u094d",
"\u0951"-"\u0954",
"\u0958"-"\u0963",
"\u0966"-"\u096f",
"\u0981"-"\u0983",
"\u0985"-"\u098c",
"\u098f"-"\u0990",
"\u0993"-"\u09a8",
"\u09aa"-"\u09b0",
"\u09b2"-"\u09b2",
"\u09b6"-"\u09b9",
"\u09bc"-"\u09bc",
"\u09be"-"\u09c4",
"\u09c7"-"\u09c8",
"\u09cb"-"\u09cd",
"\u09d7"-"\u09d7",
"\u09dc"-"\u09dd",
"\u09df"-"\u09e3",
"\u09e6"-"\u09f3",
"\u0a02"-"\u0a02",
"\u0a05"-"\u0a0a",
"\u0a0f"-"\u0a10",
"\u0a13"-"\u0a28",
"\u0a2a"-"\u0a30",
"\u0a32"-"\u0a33",
"\u0a35"-"\u0a36",
"\u0a38"-"\u0a39",
"\u0a3c"-"\u0a3c",
"\u0a3e"-"\u0a42",
"\u0a47"-"\u0a48",
"\u0a4b"-"\u0a4d",
"\u0a59"-"\u0a5c",
"\u0a5e"-"\u0a5e",
"\u0a66"-"\u0a74",
"\u0a81"-"\u0a83",
"\u0a85"-"\u0a8b",
"\u0a8d"-"\u0a8d",
"\u0a8f"-"\u0a91",
"\u0a93"-"\u0aa8",
"\u0aaa"-"\u0ab0",
"\u0ab2"-"\u0ab3",
"\u0ab5"-"\u0ab9",
"\u0abc"-"\u0ac5",
"\u0ac7"-"\u0ac9",
"\u0acb"-"\u0acd",
"\u0ae0"-"\u0ae0",
"\u0ae6"-"\u0aef",
"\u0b01"-"\u0b03",
"\u0b05"-"\u0b0c",
"\u0b0f"-"\u0b10",
"\u0b13"-"\u0b28",
"\u0b2a"-"\u0b30",
"\u0b32"-"\u0b33",
"\u0b36"-"\u0b39",
"\u0b3c"-"\u0b43",
"\u0b47"-"\u0b48",
"\u0b4b"-"\u0b4d",
"\u0b56"-"\u0b57",
"\u0b5c"-"\u0b5d",
"\u0b5f"-"\u0b61",
"\u0b66"-"\u0b6f",
"\u0b82"-"\u0b83",
"\u0b85"-"\u0b8a",
"\u0b8e"-"\u0b90",
"\u0b92"-"\u0b95",
"\u0b99"-"\u0b9a",
"\u0b9c"-"\u0b9c",
"\u0b9e"-"\u0b9f",
"\u0ba3"-"\u0ba4",
"\u0ba8"-"\u0baa",
"\u0bae"-"\u0bb5",
"\u0bb7"-"\u0bb9",
"\u0bbe"-"\u0bc2",
"\u0bc6"-"\u0bc8",
"\u0bca"-"\u0bcd",
"\u0bd7"-"\u0bd7",
"\u0be7"-"\u0bef",
"\u0c01"-"\u0c03",
"\u0c05"-"\u0c0c",
"\u0c0e"-"\u0c10",
"\u0c12"-"\u0c28",
"\u0c2a"-"\u0c33",
"\u0c35"-"\u0c39",
"\u0c3e"-"\u0c44",
"\u0c46"-"\u0c48",
"\u0c4a"-"\u0c4d",
"\u0c55"-"\u0c56",
"\u0c60"-"\u0c61",
"\u0c66"-"\u0c6f",
"\u0c82"-"\u0c83",
"\u0c85"-"\u0c8c",
"\u0c8e"-"\u0c90",
"\u0c92"-"\u0ca8",
"\u0caa"-"\u0cb3",
"\u0cb5"-"\u0cb9",
"\u0cbe"-"\u0cc4",
"\u0cc6"-"\u0cc8",
"\u0cca"-"\u0ccd",
"\u0cd5"-"\u0cd6",
"\u0cde"-"\u0cde",
"\u0ce0"-"\u0ce1",
"\u0ce6"-"\u0cef",
"\u0d02"-"\u0d03",
"\u0d05"-"\u0d0c",
"\u0d0e"-"\u0d10",
"\u0d12"-"\u0d28",
"\u0d2a"-"\u0d39",
"\u0d3e"-"\u0d43",
"\u0d46"-"\u0d48",
"\u0d4a"-"\u0d4d",
"\u0d57"-"\u0d57",
"\u0d60"-"\u0d61",
"\u0d66"-"\u0d6f",
"\u0e01"-"\u0e2e",
"\u0e30"-"\u0e3a",
"\u0e3f"-"\u0e4e",
"\u0e50"-"\u0e59",
"\u0e81"-"\u0e82",
"\u0e84"-"\u0e84",
"\u0e87"-"\u0e88",
"\u0e8a"-"\u0e8a",
"\u0e8d"-"\u0e8d",
"\u0e94"-"\u0e97",
"\u0e99"-"\u0e9f",
"\u0ea1"-"\u0ea3",
"\u0ea5"-"\u0ea5",
"\u0ea7"-"\u0ea7",
"\u0eaa"-"\u0eab",
"\u0ead"-"\u0eae",
"\u0eb0"-"\u0eb9",
"\u0ebb"-"\u0ebd",
"\u0ec0"-"\u0ec4",
"\u0ec6"-"\u0ec6",
"\u0ec8"-"\u0ecd",
"\u0ed0"-"\u0ed9",
"\u0edc"-"\u0edd",
"\u0f18"-"\u0f19",
"\u0f20"-"\u0f29",
"\u0f35"-"\u0f35",
"\u0f37"-"\u0f37",
"\u0f39"-"\u0f39",
"\u0f3e"-"\u0f47",
"\u0f49"-"\u0f69",
"\u0f71"-"\u0f84",
"\u0f86"-"\u0f8b",
"\u0f90"-"\u0f95",
"\u0f97"-"\u0f97",
"\u0f99"-"\u0fad",
"\u0fb1"-"\u0fb7",
"\u0fb9"-"\u0fb9",
"\u10a0"-"\u10c5",
"\u10d0"-"\u10f6",
"\u1100"-"\u1159",
"\u115f"-"\u11a2",
"\u11a8"-"\u11f9",
"\u1e00"-"\u1e9b",
"\u1ea0"-"\u1ef9",
"\u1f00"-"\u1f15",
"\u1f18"-"\u1f1d",
"\u1f20"-"\u1f45",
"\u1f48"-"\u1f4d",
"\u1f50"-"\u1f57",
"\u1f59"-"\u1f59",
"\u1f5b"-"\u1f5b",
"\u1f5d"-"\u1f5d",
"\u1f5f"-"\u1f7d",
"\u1f80"-"\u1fb4",
"\u1fb6"-"\u1fbc",
"\u1fbe"-"\u1fbe",
"\u1fc2"-"\u1fc4",
"\u1fc6"-"\u1fcc",
"\u1fd0"-"\u1fd3",
"\u1fd6"-"\u1fdb",
"\u1fe0"-"\u1fec",
"\u1ff2"-"\u1ff4",
"\u1ff6"-"\u1ffc",
"\u200c"-"\u200f",
"\u202a"-"\u202e",
"\u203f"-"\u2040",
"\u206a"-"\u206f",
"\u207f"-"\u207f",
"\u20a0"-"\u20ac",
"\u20d0"-"\u20dc",
"\u20e1"-"\u20e1",
"\u2102"-"\u2102",
"\u2107"-"\u2107",
"\u210a"-"\u2113",
"\u2115"-"\u2115",
"\u2118"-"\u211d",
"\u2124"-"\u2124",
"\u2126"-"\u2126",
"\u2128"-"\u2128",
"\u212a"-"\u2131",
"\u2133"-"\u2138",
"\u2160"-"\u2182",
"\u3005"-"\u3005",
"\u3007"-"\u3007",
"\u3021"-"\u302f",
"\u3031"-"\u3035",
"\u3041"-"\u3094",
"\u3099"-"\u309e",
"\u30a1"-"\u30fa",
"\u30fc"-"\u30fe",
"\u3105"-"\u312c",
"\u3131"-"\u318e",
"\u4e00"-"\u7fff"
      ]>
  | <VARIABLE: "?" <IDENTIFIER>>
    {
	matchedToken.image = image.toString().substring(1);
    }
}

//---------------------------------------------------------------------------
// This token matches ALL UNMATCHED characters.
//   If some lexical error occurs, we should add a token to cover that
//   case instead of catching lexical token errors. In fact, the lexical
//   analysis should always be successful.
//---------------------------------------------------------------------------

TOKEN :
{
  < LPAREN: "(" > | < RPAREN: ")" > | < LBRACE: "{" > | < RBRACE: "}" >
  | < LBRACKET: "[" > | < RBRACKET: "]" >
  | < SEMICOLON: ";" > | < COMMA: "," > | < DOT: "." >
    | <QMARK: "?">
    | <INCR: "++">
    | <DECR: "--">
    | <UNMATCHED: ~["!","&","+","-","*","%","/",":","=","<",">"]>
}

//---------------------------------------------------------------------------
// Identifiers and variables (to support old "?name" syntax)
// This is a list of reserved keywords (can not used as identifiers):
//
//   Java:
//      "return", "break", "continue", "if", "else","new", "instanceof"
//   JRules:
//      "not", "exists", "collect", "logical", "bind", "var", "wait", "until",
//      "timeout", "evaluate", "execute", "refresh", "event", "timeof",
//      "isunknown", "isknown"
//---------------------------------------------------------------------------

Token Identifier() :
{
    Token t;
}
{
    (t=<IDENTIFIER>
     | t="assert"
     | t="insert"
     | t="retract"
     | t="update"
     | t="modify"
     | t="apply"
     | t="execute"
     | t="rule"
     | t="packet"
     | t="priority"
     | t="property"
     | t="ruleset"
     | t="import"
     | t="using"
     | t="setup"
     | t="when"
     | t="then"
     | t="where"
     | t="from"
     | t="in"
     | t="while"
     | t="for"
     | t="function"
     | t="occursin"
     | t="before"
     | t="after"
     | t="$"
     | t="functiontask"
     | t="ruletask"
     | t="flowtask"
     | t="body"
     | t="initialaction"
     | t="finalaction"
     | t="firing"
     | t="firinglimit"
     | t="ordering"
     | t="select"
     | t="dynamicselect"
     | t="filter"
     | t="agendafilter"
     | t="out"
     | t="inout"
     | t="completionflag"
     | t="default"
     | t="iterator"
     | t="algorithm"
     | t="matchedclasses"
     | t="wait"        // BR2003.816
     | t="is"          // BR2002.1147
     )
    { return t; }
}


Token[] ExtendedIdentifier() :
{
    Vector tokens = new Vector();
    Token[] tokenArray;
    Token t1,t2;
}
{
    ( t1=Identifier() { tokens.addElement( t1 ); }
         ( ( t1="." t2=Identifier() )
	   { tokens.addElement( t1 );
	     tokens.addElement( t2 ); } )*
     )
    {
	tokenArray = new Token[ tokens.size() ];
	for ( int i=0; i<tokens.size(); i++) {
	    tokenArray[i] = (Token) tokens.elementAt(i);
	}
	return tokenArray;
    }

}

// User Wish 2000.19: "Use of JRules language keywords in package names"
Token PossiblePackageName() :
{
    Token t;
}
{
    t=PossiblePacketName()
    { return t; }
}
Token PossiblePacketName() :
{
    Token t;
}
{
    (t=Identifier()
     | t="return"
     | t="break"
     | t="continue"
     | t="if"
     | t="else"
     | t="new"
     | t="instanceof"
     | t="timeof"
     | t="not"
     | t="exists"
     | t="collect"
     | t="logical"
     | t="event"
     | t="bind"
     | t="var"
     | t="until"
     | t="timeout"
     | t="evaluate"
     | t="refresh"
     | t="throw"
     | t="try"
     | t="catch"
     | t="finally"
     | t="isunknown"
     | t="isknown"
    )
    { return t; }
}

Token Variable() :
{
    Token t;
}
{
    (t=Identifier() | t=<VARIABLE>) { return t; }
}

//---------------------------------------------------------------------------
// Literals of the language
//---------------------------------------------------------------------------

void LiteralLookahead() :
{
}
{
   <INTEGER_LITERAL>
   | <FLOATING_POINT_LITERAL>
   | <CHARACTER_LITERAL>
   | <STRING_LITERAL>
   | "true"
   | "false"
   | "null"
}

// This rule is bad (missing the sign for the integers and floats)
// and should not be used anymore.

IlrConstantExpression Literal() :
{
    Object object;
    IlrReflect reflect;
    IlrReflectClass type;
    IlrConstantExpression expr;
    IlrConstantValue value;
    Token t;
}
{
   t=<INTEGER_LITERAL>
   {
     reflect = rulesetParser.reflect;
     object = parseIntegerLiteral(t,1);
     if (object instanceof Integer) type = reflect.intType();
     else type = reflect.longType();
     value = new IlrConstantValue(reflect,type,object);
     return new IlrConstantExpression(t,value);
   }
   | t=<FLOATING_POINT_LITERAL>
   {
     reflect = rulesetParser.reflect;
     object = parseFloatLiteral(t,1);
     if (object instanceof Float) type = reflect.floatType();
     else type = reflect.doubleType();
     value = new IlrConstantValue(reflect,type,object);
     return new IlrConstantExpression(t,value);
   }
   | t=<CHARACTER_LITERAL>
   {
     reflect = rulesetParser.reflect;
     object = parseCharacterLiteral(t.image);
     type = reflect.charType();
     value = new IlrConstantValue(reflect,type,object);
     return new IlrConstantExpression(t,value);
   }
   | t=<STRING_LITERAL>
   {
     reflect = rulesetParser.reflect;
     object = parseStringLiteral(t.image);
     type= reflect.stringClass();
     value = new IlrConstantValue(reflect,type,object);
     return new IlrConstantExpression(t,value);
    }
   | t="true"
   {
     reflect = rulesetParser.reflect;
     value = reflect.factory.TRUE;
     return new IlrConstantExpression(t,value);
   }
   | t="false"
   {
     reflect = rulesetParser.reflect;
     value = reflect.factory.FALSE;
     return new IlrConstantExpression(t,value);
   }
   | t="null"
   {
     reflect = rulesetParser.reflect;
     value = reflect.factory.NULL;
     return new IlrConstantExpression(t,value);
   }
}

// This rule should be used instead of previous one.

IlrConstantExpression SignedLiteral() :
{
  Object object;
  IlrReflect reflect;
  IlrReflectClass type;
  IlrConstantExpression expr;
  IlrConstantValue value;
  Token t;
  int sign = 1;
}
{
  ( ( "+" ) { sign = 1; } | ( "-" ) { sign = -1; } ) ?
    ( t=<INTEGER_LITERAL>
      {
	reflect = rulesetParser.reflect;
	object = parseIntegerLiteral(t,sign);
	if (object instanceof Integer) type = reflect.intType();
	else type = reflect.longType();
	value = new IlrConstantValue(reflect,type,object);
	return new IlrConstantExpression(t,value);
      }
    | t=<FLOATING_POINT_LITERAL>
      {
	reflect = rulesetParser.reflect;
	object = parseFloatLiteral(t,sign);
	if (object instanceof Float) type = reflect.floatType();
	else type = reflect.doubleType();
	value = new IlrConstantValue(reflect,type,object);
	return new IlrConstantExpression(t,value);
      }
    )
   | t=<CHARACTER_LITERAL>
   {
     reflect = rulesetParser.reflect;
     object = parseCharacterLiteral(t.image);
     type = reflect.charType();
     value = new IlrConstantValue(reflect,type,object);
     return new IlrConstantExpression(t,value);
   }
   | t=<STRING_LITERAL>
   {
     reflect = rulesetParser.reflect;
     object = parseStringLiteral(t.image);
     type= reflect.stringClass();
     value = new IlrConstantValue(reflect,type,object);
     return new IlrConstantExpression(t,value);
    }
   | t="true"
   {
     reflect = rulesetParser.reflect;
     value = reflect.factory.TRUE;
     return new IlrConstantExpression(t,value);
   }
   | t="false"
   {
     reflect = rulesetParser.reflect;
     value = reflect.factory.FALSE;
     return new IlrConstantExpression(t,value);
   }
   | t="null"
   {
     reflect = rulesetParser.reflect;
     value = reflect.factory.NULL;
     return new IlrConstantExpression(t,value);
   }
}

void SignedNumberLookahead () :
{}
{
    ( "+" | "-" )
    ( <INTEGER_LITERAL> | <FLOATING_POINT_LITERAL> )
}

IlrConstantExpression SignedNumberExpression ():
{
    IlrFactory factory;
    IlrConstantExpression expr;
    IlrConstantValue value;
    Token t;
    Number number;
    int sign = 0;
}
{
    (   ( "+" ) { sign = 1; }
      | ( "-" ) { sign = -1; }
    )
    ( t=<INTEGER_LITERAL>
      {
	factory = rulesetParser.reflect.factory;
	number = parseIntegerLiteral(t,sign);
	if (number instanceof Integer)
	  value = factory.new ConstantValue(number.intValue());
	else
	  value = factory.new ConstantValue(number.longValue());
	return new IlrConstantExpression(t,value);
      }
    | t=<FLOATING_POINT_LITERAL>
      {
	factory = rulesetParser.reflect.factory;
	number = parseFloatLiteral(t,sign);
	if (number instanceof Float)
	  value = factory.new ConstantValue(number.floatValue());
	else
	  value = factory.new ConstantValue(number.doubleValue());
	return new IlrConstantExpression(t,value);
      }
    )
}

//---------------------------------------------------------------------------
// The type names
//   Simple type name is used to specify simple type, eventually using
//   package name. They are used in the import statement. type name is
//   used for a general type, including array type.
//   Example: ilog.rules.IlrRule, java.util.Vector, Form, or int[]
//---------------------------------------------------------------------------

IlrSimpleTypeExpression SimpleTypeName() :
{
    Vector vector = new Vector(5,2);
    Token t;
}
{
    t=Identifier() { vector.addElement(t); }
    (LOOKAHEAD(2) "." t=Identifier() { vector.addElement(t); })*
    {
	int len = vector.size();
	Token[] tokens = new Token[len];
	for (int i = 0; i < len; i++) tokens[i] = (Token)vector.elementAt(i);
	return new IlrSimpleTypeExpression(tokens);
    }
}

// Wish 2002.127
IlrSimpleTypeExpression SimplePackageTypeName() :
{
    Vector vector = new Vector(5,2);
    Token t;
}
{
    t=PossiblePackageName() { vector.addElement(t); }
    (LOOKAHEAD(2) "." t=PossiblePackageName() { vector.addElement(t); })*
    {
	int len = vector.size();
	Token[] tokens = new Token[len];
	for (int i = 0; i < len; i++) tokens[i] = (Token)vector.elementAt(i);
	return new IlrSimpleTypeExpression(tokens);
    }
}

IlrTypeExpression TypeName() :
{
    Token open;
    Token close;
    IlrTypeExpression type;
}
{
    type=SimpleTypeName()
    (
     open="[" close="]" { type = new IlrArrayTypeExpression(open,close,type); }
    )*
    {
	return type;
    }
}



This file was generated on Wed Dec 10 14:33:40 PST 2003 from file tokenizer.java
by the ilog.language.tools.Hilite Java tool written by Hassan Aït-Kaci