Exemple #1
0
        public DHJassCallFunctionCommand(string code)
        {
            //Match match;
            string        name;
            List <string> args;

            if (DHJassSyntax.checkFunctionUsageSyntaxFast(code, out name, out args)) //out match))
            {
                parse(name, args);                                                   //match);
            }
            else
            {
                function = null;
            }
        }
Exemple #2
0
        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);
        }