public bool TryParseCode(string name_usage, string valueToSet, out DHJassCommand command) { string name; string param; if (DHJassSyntax.checkTypeVariableUsageSyntaxFast(name_usage, out name)) { command = new DHJassPassVariableCommand(name); value = new DHJassGetValueOnDemandCommand(valueToSet); return(true); } else if (DHJassSyntax.checkArrayVariableUsageSyntaxFast(name_usage, out name, out param)) { command = new DHJassPassVariableCommand(name); index = new DHJassGetValueOnDemandCommand(param); value = new DHJassGetValueOnDemandCommand(valueToSet); return(true); } command = null; return(false); }
public bool TryParseCode(string code, out DHJassCommand command) { if (String.IsNullOrEmpty(code)) { command = null; return(false); } string name; string param; List <string> operands; List <string> operators; bool isDirectValue; object parsedValue; unsafe { fixed(char *pStr = code) { char *ptr = DHJassSyntax.removeWsRbRecursive(pStr, pStr + code.Length); code = new string(ptr); if (isDirectValue = DHJassSyntax.checkDirectValueSyntaxFast(*ptr)) { foreach (DHJassValue parser in DbJassTypeValueKnowledge.TypeValuePairs.Values) { if (parser.TryParseDirect(code, out parsedValue)) { DHJassValue value = parser.GetNew(); value.Value = parsedValue; command = new DHJassPassValueCommand(value); return(true); } } } else { switch (code) { case "null": command = new DHJassPassValueCommand(new DHJassUnusedType()); return(true); case "true": command = new DHJassPassValueCommand(new DHJassBoolean(null, true)); return(true); case "false": command = new DHJassPassValueCommand(new DHJassBoolean(null, false)); return(true); } } if (DHJassSyntax.checkLogicalExpressionsSyntaxFast(ptr, out operands, out operators))//code, out match)) { return(TryGetLogicalExpressionCommandFast(operands, operators, out command)); } else if (DHJassSyntax.checkRelationalExpressionsSyntaxFast(ptr, out operands, out operators)) // out match)) { return(TryGetRelationalExpressionCommandFast(operands, operators, out command)); //match, out command); } else if (DHJassSyntax.checkArithmeticExpressionsSyntaxFast(ptr, out operands, out operators)) // out match)) { return(TryGetArithmeticExpressionCommandFast(operands, operators, out command)); //match, out command); } else if (!isDirectValue) { if (DHJassSyntax.checkNegativeOperatorUsageSyntaxFast(ptr, out name)) { return(TryGetNegativeOperatorCommand(name, out command)); } else if (DHJassSyntax.checkTypeVariableUsageSyntaxFast(ptr, out name)) { return(TryGetVariableCommand(name, out command)); } else if (DHJassSyntax.checkArrayVariableUsageSyntaxFast(ptr, out name, out param)) { return(TryGetArrayElementCommand(name, param, out command)); } else if (DHJassSyntax.checkFunctionUsageSyntaxFast(ptr, out name, out operands)) // out match)) { return(TryGetCallFunctionCommandFast(name, operands, out command)); } else if (DHJassSyntax.checkFunctionPointerUsageSyntaxFast(ptr, out name)) { return(TryGetFunctionPointerCommand(name, out command)); } } } } command = null; return(false); }