示例#1
0
        private void FillFollowPosClosure(int posOffset, AstNode inner)
        {
            var firstPosVisitor = new FirstPosGetter();

            foreach (int pos in inner.Accept(lastPosGetter, posOffset))
            {
                positions[pos].FollowPos.AddAll(inner.Accept(firstPosVisitor, posOffset));
            }
        }
示例#2
0
        public RegularTree(AstNode root)
        {
            this.EoiCharSetNode = CharSetNode.Create(EoiChar);
            this.AugmentedRoot  = new CatNode(new List <AstNode> {
                root, EoiCharSetNode
            });

            var positionBuilder = new PositionBuilder();

            AugmentedRoot.Accept(positionBuilder, null);
            Positions = positionBuilder.Positions;

            EoiPosition = Positions.FindIndex(pos => pos.Characters.Contains(EoiChar));
            Debug.Assert(EoiPosition >= 0);

            var firstPosVisitor = new FirstPosGetter();

            this.FirstPos = AugmentedRoot.Accept(firstPosVisitor, 0);

            var followPosBuilder = new FollowPosBuilder(Positions);

            AugmentedRoot.Accept(followPosBuilder, 0);
        }