示例#1
0
 public QuantifiedPhrase(Grammar aGrammar, IPhrase aPhr, ExprInt aMin, ExprInt aMax)
     : base(aGrammar)
 {
     Phrase         = aPhr;
     Min            = aMin;
     Max            = aMax;
     IsConfigurable = false;
 }
        public override IDerivation Visit(ExprInt aExpr, DerivationContext aContext)
        {
            CyclesDetectContext context = aContext as CyclesDetectContext;

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

            newContext.Parent = aExpr;
            return(base.Visit(aExpr, 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
 public virtual IDerivation Visit(ExprInt aExpr, DerivationContext aContext)
 {
     return(null);
 }
示例#5
0
 public QuantifiedPhrase(Grammar aGrammar, IPhrase aPhr, ExprInt aMinMax)
     : this(aGrammar, aPhr, aMinMax, aMinMax)
 {
 }