Exemple #1
0
        /// <summary>
        /// Parses Acc to array or seq ([], .)
        /// and ListTrans call e.g. Param.Count()
        /// </summary>
        /// <param Name="lBaseAcc"></param>
        /// <returns>true - access found, continue chain of accs, false - stop parsing</returns>
        private bool Acc(ref IExpr lBaseAcc)
        {
            //arr
            if (null != lex)
            {
                if (lex.Text == "[")
                {
                    lex = lex.Next();
                    IExpr lIndExpr = Expr();
                    ExpectSign("]");
                    lBaseAcc = new AccessArray(mGrammar, (Access)lBaseAcc, lIndExpr);
                    return(true);
                }

                //struct
                if (lex.Text == ".")
                {
                    lex = lex.Next();
                    string lFieldName = lex.Text;
                    lex = lex.Next();
                    if (lex != null && lex.Type == LexemType.LeftBr)
                    {
// call of ListTrans
                        lex      = lex.Next();
                        lBaseAcc = (IExpr)TransCall1((Access)lBaseAcc, lFieldName);
                    }
                    else
                    {
                        lBaseAcc = new AccessSeq(mGrammar, lBaseAcc, lFieldName);
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemple #2
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);
        }
        public override IDerivation Visit(AccessSeq aAccessSeq, DerivationContext aContext)
        {
            CyclesDetectContext context = aContext as CyclesDetectContext;

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

            newContext.Parent = aAccessSeq;
            return(base.Visit(aAccessSeq, newContext));
        }
Exemple #4
0
        public virtual IDerivation Visit(AccessSeq aAccessSeq, DerivationContext aContext)
        {
            IDerivation lD = aAccessSeq.mParentAccess.Accept(aContext);

            /*if (lD is ListDerivation)
             * {
             * lD = ((ListDerivation) lD)[0];
             * }*/
            DictionaryDerivation lDic = lD as DictionaryDerivation;

            if (lDic != null)
            {
                return(lDic[aAccessSeq.mFieldName]);
            }
            else
            {
                throw new GrammarDeductException("Incorrect . access! There is no DictionaryDerivation!");
            }
        }
 public virtual IDerivation Visit(AccessSeq aAccessSeq, DerivationContext aContext)
 {
     return(null);
 }