Exemple #1
0
        // *****************************************************************************
        // IMatchable implementation
        // *****************************************************************************
        public override IMatchable FindObject(MatchNode matchNode, int index)
        {
            if (matchNode.GetType() != MatchNode.Matchnode_Exprent)
            {
                return(null);
            }
            List <Exprent> lstAllExprents = GetAllExprents();

            if (lstAllExprents == null || (lstAllExprents.Count == 0))
            {
                return(null);
            }
            string position = (string)matchNode.GetRuleValue(IMatchable.MatchProperties.Exprent_Position
                                                             );

            if (position != null)
            {
                if (position.Matches("-?\\d+"))
                {
                    return(lstAllExprents[(lstAllExprents.Count + System.Convert.ToInt32(position)) %
                                          lstAllExprents.Count]);
                }
            }
            else if (index < lstAllExprents.Count)
            {
                // care for negative positions
                // use 'index' parameter
                return(lstAllExprents[index]);
            }
            return(null);
        }
Exemple #2
0
        // *****************************************************************************
        // IMatchable implementation
        // *****************************************************************************
        public override IMatchable FindObject(MatchNode matchNode, int index)
        {
            int node_type = matchNode.GetType();

            if (node_type == MatchNode.Matchnode_Statement && !(this.stats.Count == 0))
            {
                string position = (string)matchNode.GetRuleValue(IMatchable.MatchProperties.Statement_Position
                                                                 );
                if (position != null)
                {
                    if (position.Matches("-?\\d+"))
                    {
                        return(this.stats[(this.stats.Count + System.Convert.ToInt32(position)) % this.stats
                                          .Count]);
                    }
                }
                else if (index < this.stats.Count)
                {
                    // care for negative positions
                    // use 'index' parameter
                    return(this.stats[index]);
                }
            }
            else if (node_type == MatchNode.Matchnode_Exprent && this.exprents != null && !(this
                                                                                            .exprents.Count == 0))
            {
                string position = (string)matchNode.GetRuleValue(IMatchable.MatchProperties.Exprent_Position
                                                                 );
                if (position != null)
                {
                    if (position.Matches("-?\\d+"))
                    {
                        return(this.exprents[(this.exprents.Count + System.Convert.ToInt32(position)) % this
                                             .exprents.Count]);
                    }
                }
                else if (index < this.exprents.Count)
                {
                    // care for negative positions
                    // use 'index' parameter
                    return(this.exprents[index]);
                }
            }
            return(null);
        }
        // *****************************************************************************
        // IMatchable implementation
        // *****************************************************************************
        public override bool Match(MatchNode matchNode, MatchEngine engine)
        {
            if (!base.Match(matchNode, engine))
            {
                return(false);
            }
            int type = (int)matchNode.GetRuleValue(IMatchable.MatchProperties.Exprent_Functype
                                                   );

            return(type == null || this.funcType == type);
        }
Exemple #4
0
        // *****************************************************************************
        // IMatchable implementation
        // *****************************************************************************
        public override IMatchable FindObject(MatchNode matchNode, int index)
        {
            IMatchable @object = base.FindObject(matchNode, index);

            if (@object != null)
            {
                return(@object);
            }
            if (matchNode.GetType() == MatchNode.Matchnode_Exprent)
            {
                string position = (string)matchNode.GetRuleValue(IMatchable.MatchProperties.Exprent_Position
                                                                 );
                if ("head".Equals(position))
                {
                    return(GetHeadexprent());
                }
            }
            return(null);
        }