Exemple #1
0
        internal void Add(Rule rule)
        {
            foreach (SyntaxKind typeLeft in rule.RuleDescriptor.TokenRangeLeft)
            {
                foreach (SyntaxKind typeRight in rule.RuleDescriptor.TokenRangeRight)
                {
                    RuleBucket bucket;
                    Dictionary<SyntaxKind, RuleBucket> leftTokenMap;

                    if (!this.Map.TryGetValue(typeLeft, out leftTokenMap))
                    {
                        this.Map[typeLeft] = new Dictionary<SyntaxKind, RuleBucket>();
                        this.Map[typeLeft][typeRight] = bucket = new RuleBucket();
                    }
                    else
                    {
                        // if this is true, a bucket has been found, and can leave the else safely
                        if (!leftTokenMap.TryGetValue(typeRight, out bucket))
                        {
                            this.Map[typeLeft][typeRight] = bucket = new RuleBucket();
                        }
                    }

                    bucket.Add(rule);
                }
            }
        }
Exemple #2
0
        // This methods is here for when I need to add precedence to the rules
        internal void Add(Rule rule)
        {
            if (this.rules == null)
            {
                this.rules = new List<Rule>();
            }

            this.rules.Add(rule);
        }