Exemplo n.º 1
0
Arquivo: Dc.cs Projeto: alain1337/Dc
        void Preprocess(List <RuleMatch> rules)
        {
            RuleMatch prevRule = null;

            for (var i = 0; i < rules.Count; i++)
            {
                if (rules[i].Rule.Type == GrammarTokenType.Operator && (prevRule == null ||
                                                                        (prevRule.Rule.Type == GrammarTokenType.Operator && prevRule.Rule.Operands == 2) ||
                                                                        (prevRule.Rule.Type == GrammarTokenType.Operator && prevRule.Rule.Operands == 1 && prevRule.Rule.Associativity == GrammarTokenAssociativity.Right) ||
                                                                        (prevRule.Rule.Type == GrammarTokenType.LeftParenthesis)))
                {
                    if (rules[i].Lexem.Text == "-")
                    {
                        rules[i] = _sy.Match(new Lexem("u-", typeof(string), Kinds.Operator));
                    }
                    else if (rules[i].Lexem.Text == "+")
                    {
                        rules[i] = _sy.Match(new Lexem("u+", typeof(string), Kinds.Operator));
                    }
                }

                prevRule = rules[i];
            }
        }