Пример #1
0
        public static UIElement CreateControl(IPhrase element, List <string> aOuterSymbols)
        {
            if (element is Seqence)
            {
                MainWindow.AllSequenses++;
                return(new SeqenceControl(element as Seqence, aOuterSymbols));
            }
            else if (element is AlternativeSet)
            {
                MainWindow.AllAlternativeSets++;
                return(new AlternativeControl(element as AlternativeSet, aOuterSymbols));
            }
            else if (element is QuantifiedPhrase)
            {
                return(new QuantifierControl(element as QuantifiedPhrase, aOuterSymbols));
            }
            else if (element is NonTerminal)
            {
                NonTerminal s = element as NonTerminal;

                MainWindow.AllNonTerminals++;
                return(new NonTerminalControl(s, aOuterSymbols));
            }
            else if (element is Terminal)
            {
                Terminal s = element as Terminal;

                Label l = new Label();
                l.Content = s.Text;
                //Run r = new Run(s.Text);
                l.Foreground = Brushes.Red;
                return(l);
            }


            Label unk = new Label();

            if (element is AccessSeq)
            {
                AccessSeq acc = element as AccessSeq;
                unk.Content = "#" + acc.ObjectName + "." + acc.mFieldName;
            }
            else if (element is TransCallPhrase)
            {
                TransCallPhrase trans = element as TransCallPhrase;
                unk.Content = "call " + trans.BindedMethod.Name;
            }
            else if (element is AccessArray)
            {
                AccessArray ar = element as AccessArray;
                unk.Content = ar.ObjectName + "[" + ar.IndexExpr.ToString() + "]";
            }
            else
            {
                unk.Content = "unknown:" + element.ToString();
            }
            return(unk);
        }
Пример #2
0
        public override IDerivation Visit(TransCallPhrase aTransCallPhrase, DerivationContext aContext)
        {
            CyclesDetectContext context = aContext as CyclesDetectContext;

            aTransCallPhrase.Parent = context.Parent;
            CyclesDetectContext newContext = new CyclesDetectContext(aContext as CyclesDetectContext);

            newContext.Parent = aTransCallPhrase;
            return(base.Visit(aTransCallPhrase, newContext));
        }
Пример #3
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);
        }
Пример #4
0
        private object[] ParamsArray(TransCallPhrase aTransCallPhrase, DerivationContext aContext)
        {
            int lParamsCount = aTransCallPhrase.Params.Count;

            object[] parametrs = new object[lParamsCount];
            int      i         = 0;

            foreach (IExpr lParam in aTransCallPhrase.Params)
            {
                parametrs[i] = lParam.GetValue(aContext);
                i++;
            }
            return(parametrs);
        }
Пример #5
0
        //

        public virtual IDerivation Visit(TransCallPhrase aTransCallPhrase, DerivationContext aContext)
        {
            return(null);
        }