// @"\A\s*call\s+(?<name>.+)" unsafe public override bool IsSyntaxMatchFast(char *ptr, int length, ref List <string> args) { string callStr = "call"; // should be interned fixed(char *ptrB = callStr) { // skip whitespaces DHJassSyntax.skipWhiteSpacesFast(ref ptr); // "call" keyword should be here if (!DHJassSyntax.checkStringsEqual(ptr, ptrB, callStr.Length)) { return(false); } // skip the "call`" bytes ptr += callStr.Length; // make sure the "call" is followed by whitespace if (*ptr != ' ') { return(false); } // skip whitespaces DHJassSyntax.skipWhiteSpacesFast(ref ptr); // add argument args.Add(new string(ptr)); return(true); } }
// @"\A\s*exitwhen\s*(?<condition>.*)" unsafe public override bool IsSyntaxMatchFast(char *ptr, int length, ref List <string> args) { string exitwhenStr = "exitwhen"; // should be interned fixed(char *ptrB = exitwhenStr) { // skip whitespaces DHJassSyntax.skipWhiteSpacesFast(ref ptr); // "exitwhen" keyword should be here if (!DHJassSyntax.checkStringsEqual(ptr, ptrB, exitwhenStr.Length)) { return(false); } // skip the "exitwhen`" bytes ptr += exitwhenStr.Length; // skip whitespaces DHJassSyntax.skipWhiteSpacesFast(ref ptr); // add argument args.Add(new string(ptr)); return(true); } }
// @"\A\s*(if|elseif)\s*(?<condition>.*[^\s]{1})\s*then" unsafe public override bool IsSyntaxMatchFast(char *code, int length, ref List <string> args) { string ifStr = "if"; // should be interned string elseifStr = "elseif"; string thenStr = "then"; char *ptr = code; fixed(char *ptrIF = ifStr, ptrELSEIF = elseifStr, ptrTHEN = thenStr) { // skip whitespaces DHJassSyntax.skipWhiteSpacesFast(ref ptr); // "if" or "elseif" keyword should be here if (DHJassSyntax.checkStringsEqual(ptr, ptrIF, ifStr.Length)) { ptr += ifStr.Length; // skip the "if" bytes } else if (DHJassSyntax.checkStringsEqual(ptr, ptrELSEIF, elseifStr.Length)) { ptr += elseifStr.Length; // skip the "elseif" bytes } else { return(false); } // skip whitespaces DHJassSyntax.skipWhiteSpacesFast(ref ptr); // go to the end of this string where "then" string should be char *pEnd = (code + length) - thenStr.Length; // check for "then" string if (!DHJassSyntax.checkStringsEqual(pEnd, ptrTHEN, thenStr.Length)) { return(false); } // skip whitespaces from the end --pEnd; DHJassSyntax.skipWhiteSpacesReverseFast(ref pEnd); // make sure the condition is not empty if (ptr > pEnd) { return(false); } // add argument args.Add(new string(ptr, 0, (int)(pEnd - ptr) + 1)); return(true); } }
// @"\A\s*set\s+(?<name>[^=]+[^\s]|[^=]+)\s*=\s*(?<value>.+)" unsafe public override bool IsSyntaxMatchFast(char *ptr, int length, ref List <string> args) { string setStr = "set"; // should be interned fixed(char *ptrB = setStr) { // skip whitespaces DHJassSyntax.skipWhiteSpacesFast(ref ptr); // "set" keyword should be here if (!DHJassSyntax.checkStringsEqual(ptr, ptrB, setStr.Length)) { return(false); } // skip the "set`" bytes ptr += setStr.Length; // there should be white space after "set" if (*ptr != ' ') { return(false); } // skip whitespaces DHJassSyntax.skipWhiteSpacesFast(ref ptr); // move to the end of variable name char *pVariableEnd = DHJassSyntax.reachEndOfVarArrNameSyntaxFast(ptr); if (pVariableEnd == null) { return(false); } // memorize starting position of variable's name char *pVariableStart = ptr; ptr = pVariableEnd; // skip whitespaces DHJassSyntax.skipWhiteSpacesFast(ref ptr); // make sure the '=' is present if (*ptr != '=') { return(false); } ++ptr; // move beyond '=' // skip whitespaces DHJassSyntax.skipWhiteSpacesFast(ref ptr); // add variable name argument args.Add(new string(pVariableStart, 0, (int)(pVariableEnd - pVariableStart))); // add variable value argument args.Add(new string(ptr)); return(true); } }