Example #1
0
        public virtual IDerivation Visit(PlaceHolderPhrase aPlaceHolderPhrase, DerivationContext aContext)
        {
            ListDerivation lList = new ListDerivation(true, aContext);
            TextDerivation lText = new TextDerivation(aPlaceHolderPhrase.Name); //Symbol.Create(mGrammar, Name, true);

            lList.Add(lText);
            //add this point to special list for futher replacement
            PlaceHolders.Add(aPlaceHolderPhrase.Name, lText);
            return(lList);
        }
Example #2
0
        public virtual IDerivation Visit(TransCallPhrase aTransCallPhrase, DerivationContext aContext)
        {
            eGenerationMode lOldMode = aContext.Generator.Mode;

            aContext.Generator.Mode = eGenerationMode.RecursiveTopDown;

            //1. Substitute and prepare parameters form context by conf xml
            object[] parametrs = ParamsArray(aTransCallPhrase, aContext);

            if (aTransCallPhrase.TargetAccess != null)
            {
                IDerivation lDeriv = aTransCallPhrase.TargetAccess.Accept(aContext);
                aTransCallPhrase.Grammar.ListTrans.TargetList     = (ListDerivation)lDeriv;
                aTransCallPhrase.Grammar.ListTrans.TargetListName = aTransCallPhrase.TargetAccess.ObjectName;
            }

            aTransCallPhrase.Grammar.SysTrans.Context = aContext;
            //2. do actual call
            object lRetVal = null;

            try
            {
                lRetVal = aTransCallPhrase.BindedMethod.Invoke(aTransCallPhrase.TransductorClass, parametrs);
            }
            catch (Exception ex)
            {
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                lRetVal = ex.Message;
            }
            aContext.Generator.Mode = lOldMode;
            if (lRetVal is int)
            {
                lRetVal = new ExprInt((int)lRetVal);
            }

            IDerivation lDer = lRetVal as IDerivation;

            if (null == lDer)
            {
                lDer = new TextDerivation(lRetVal.ToString());
            }
            XmlNode newNode = aContext.DerivationXml.CreateElement("trans");

            aContext.currentNode.AppendChild(newNode);
            newNode.InnerText = lDer.ToString();

            TLog.Write("T", lDer.ToString());
            return(lDer);
        }