Esempio n. 1
0
        private bool ParseTokensTerminate(out STTokensTerminate argTokens, out string[] argLinesNoParse)
        {
            var pLinea0 = mLine;
            var pPos0   = mPosition;

            argTokens = ParseTokens <STTokensTerminate>();
            argTokens.TerminateChar = (mSymbol?.FirstOrDefault()).GetValueOrDefault('\x0');

            if (mSymbol == null)
            {
                var pLines = new List <string>();

                argTokens.Terminate = ESTTokenizerTerminate.No;
                if (pLinea0 < mLines.Length && pPos0 < mLines[pLinea0].Length)
                {
                    pLines.Add(mLines[pLinea0].Substring(pPos0));
                }
                pLines.AddRange(mLines.Skip(pLinea0 + 1));

                argLinesNoParse = pLines.ToArray();

                return(false);
            }

            argLinesNoParse = null;
            if (mSymbol != null)
            {
                switch (mSymbol)
                {
                case syTerminate:
                    argTokens.Terminate = ESTTokenizerTerminate.ShowResult;

                    return(true);

                case syTerminateHide:
                    argTokens.Terminate = ESTTokenizerTerminate.HideResult;

                    return(true);

                default:
                    throw new STException(string.Format(Properties.Resources.NoExpectTokenException, mSymbol), mLine, mPosition);
                }
            }

            return(false);
        }
Esempio n. 2
0
        public EvalExprInResult EvalPrompt(ST.STTokensTerminate argTokens, CancellationToken argCancelToken)
        {
            var pReader  = new ST.STTokensReader(argTokens, argCancelToken);
            var pIn      = STToExprIn(pReader);
            var pContext = new EvalContext {
                CancelToken = argCancelToken
            };
            var pOut = EvalIn(pContext, pIn);
            var pIOE = mVars.AddInOut(pIn, pOut, out string pNameVarIn, out string pNameVarOut);

            if (argTokens.Terminate == ST.ESTTokenizerTerminate.ShowResult)
            {
                mPost.PrintExprOutPost(GetPromptVar(pNameVarOut), pOut);
            }

            return(new EvalExprInResult {
                Terminate = argTokens.Terminate, InExpr = pIn, OutExpr = pOut, NameVarIn = pNameVarIn, NameVarOut = pNameVarOut
            });
        }