Esempio n. 1
0
        internal TextObject CallFunction(
            string functionName,
            List <TextExpression> functionParams,
            TextObject parent)
        {
            TextObject[] textObjectArray1 = new TextObject[functionParams.Count];
            TextObject[] textObjectArray2 = new TextObject[functionParams.Count];
            for (int index = 0; index < functionParams.Count; ++index)
            {
                textObjectArray1[index] = new TextObject(functionParams[index].EvaluateString(this, parent));
                textObjectArray2[index] = new TextObject(functionParams[index].RawValue);
            }
            this._curParams.Push(textObjectArray1);
            this._curParamsWithoutEvaluate.Push(textObjectArray2);
            MBStringBuilder mbStringBuilder = new MBStringBuilder();
            MBTextModel     functionBody    = this.GetFunctionBody(functionName);

            mbStringBuilder.Initialize(callerMemberName: nameof(CallFunction));
            foreach (TextExpression rootExpression in (IEnumerable <TextExpression>)functionBody.RootExpressions)
            {
                mbStringBuilder.Append <string>(rootExpression.EvaluateString(this, parent));
            }
            string stringAndRelease = mbStringBuilder.ToStringAndRelease();

            this._curParams.Pop();
            return(new TextObject(stringAndRelease));
        }
Esempio n. 2
0
 private MBTextModel ParseInternal(List <MBTextToken> tokens)
 {
     this.LoadSequenceStack(tokens);
     this.UpdateLookAheads();
     this._queryModel = new MBTextModel();
     this.Statements();
     this.DiscardToken(TokenType.SequenceTerminator);
     return(this._queryModel);
 }
        public static string Process(
            MBTextModel dataRepresentation,
            TextProcessingContext textContext,
            TextObject parent = null)
        {
            MBStringBuilder mbStringBuilder = new MBStringBuilder();

            mbStringBuilder.Initialize(callerMemberName: nameof(Process));
            foreach (TextExpression rootExpression in (IEnumerable <TextExpression>)dataRepresentation.RootExpressions)
            {
                if (rootExpression != null)
                {
                    string str = rootExpression.EvaluateString(textContext, parent).ToString();
                    mbStringBuilder.Append <string>(str);
                }
            }
            return(mbStringBuilder.ToStringAndRelease());
        }
Esempio n. 4
0
        internal MultiStatement GetVariableValue(string variableName, TextObject parent)
        {
            TextObject  variable    = (TextObject)null;
            MBTextModel mbTextModel = (MBTextModel)null;

            if (parent == null || !parent.GetVariableValue(variableName, out variable))
            {
                this._variables.TryGetValue(variableName, out variable);
            }
            if (variable != null)
            {
                mbTextModel = MBTextParser.Parse(MBTextManager.Tokenizer.Tokenize(variable.ToString()));
            }
            if (mbTextModel == null)
            {
                return((MultiStatement)null);
            }
            return(mbTextModel.RootExpressions.Count == 1 && mbTextModel.RootExpressions[0] is MultiStatement ? new MultiStatement((IEnumerable <TextExpression>)(mbTextModel.RootExpressions[0] as MultiStatement).SubStatements) : new MultiStatement((IEnumerable <TextExpression>)mbTextModel.RootExpressions));
        }
Esempio n. 5
0
 public void SetFunction(string functionName, MBTextModel functionBody) => this._functions[functionName] = functionBody;