public void Visit(PlusRepetition target)
        {
            target.child.Accept(this);
            var f = stack.Pop();

            stack.Push(NFA.OneOrMany(f));
        }
示例#2
0
        private AstNode Element()
        {
            var atomNode = Atom();

            while (More() && PeekIsAny('*', '+', '?'))
            {
                var character = Peek();
                switch (character)
                {
                case '*':
                    atomNode = new KleenStarRepetition(atomNode);
                    Consume('*');
                    break;

                case '+':
                    atomNode = new PlusRepetition(atomNode);
                    Consume('+');
                    break;

                case '?':
                    atomNode = new QuestionRepetition(atomNode);
                    Consume('?');
                    break;

                default:
                    break;
                }
            }
            return(atomNode);
        }