// $ANTLR end heirarchy


        // $ANTLR start endsite
        // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:103:1: endsite returns [EndSite end = new EndSite()] : END_SITE LCURLY v= offsets RCURLY ;
        public EndSite endsite() // throws RecognitionException [1]
        {
            EndSite end = new EndSite();

            Vector3?v = null;


            try
            {
                // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:104:2: ( END_SITE LCURLY v= offsets RCURLY )
                // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:104:4: END_SITE LCURLY v= offsets RCURLY
                {
                    Match(input, END_SITE, FOLLOW_END_SITE_in_endsite700);
                    Match(input, LCURLY, FOLLOW_LCURLY_in_endsite707);
                    PushFollow(FOLLOW_offsets_in_endsite714);
                    v = offsets();
                    followingStackPointer_--;

                    end.Offset = (Vector3)v;
                    Match(input, RCURLY, FOLLOW_RCURLY_in_endsite720);
                }
            }
            catch (RecognitionException re)
            {
                ReportError(re);
                Recover(input, re);
            }
            finally
            {
            }
            return(end);
        }
        // $ANTLR end values


        // $ANTLR start heirarchy
        // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:89:1: heirarchy[BvhDocument d] returns [BvhNode node = new BvhNode()] : ( ROOT | JOINT ) ID LCURLY v= offsets ch= channels ( (child= heirarchy[d] )+ | end= endsite ) RCURLY ;
        public BvhNode heirarchy(BvhDocument d) // throws RecognitionException [1]
        {
            BvhNode node = new BvhNode();

            IToken  ID1 = null;
            Vector3?v   = null;

            List <FODChannel> ch = null;

            BvhNode child = null;

            EndSite end = null;



            d.Nodes.Add(node);

            try
            {
                // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:94:2: ( ( ROOT | JOINT ) ID LCURLY v= offsets ch= channels ( (child= heirarchy[d] )+ | end= endsite ) RCURLY )
                // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:94:4: ( ROOT | JOINT ) ID LCURLY v= offsets ch= channels ( (child= heirarchy[d] )+ | end= endsite ) RCURLY
                {
                    // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:94:4: ( ROOT | JOINT )
                    int alt2  = 2;
                    int LA2_0 = input.LA(1);

                    if ((LA2_0 == ROOT))
                    {
                        alt2 = 1;
                    }
                    else if ((LA2_0 == JOINT))
                    {
                        alt2 = 2;
                    }
                    else
                    {
                        NoViableAltException nvae_d2s0 =
                            new NoViableAltException("94:4: ( ROOT | JOINT )", 2, 0, input);

                        throw nvae_d2s0;
                    }
                    switch (alt2)
                    {
                    case 1:
                        // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:94:5: ROOT
                    {
                        Match(input, ROOT, FOLLOW_ROOT_in_heirarchy611);
                        node.IsRoot = true;
                    }
                    break;

                    case 2:
                        // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:94:33: JOINT
                    {
                        Match(input, JOINT, FOLLOW_JOINT_in_heirarchy616);
                    }
                    break;
                    }

                    ID1 = (IToken)input.LT(1);
                    Match(input, ID, FOLLOW_ID_in_heirarchy619);
                    node.Name = ID1.Text;
                    Match(input, LCURLY, FOLLOW_LCURLY_in_heirarchy627);
                    PushFollow(FOLLOW_offsets_in_heirarchy635);
                    v = offsets();
                    followingStackPointer_--;

                    node.Offset = (Vector3)v;
                    PushFollow(FOLLOW_channels_in_heirarchy646);
                    ch = channels();
                    followingStackPointer_--;

                    node.Channels = ch.ToArray();
                    // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:98:6: ( (child= heirarchy[d] )+ | end= endsite )
                    int alt4  = 2;
                    int LA4_0 = input.LA(1);

                    if (((LA4_0 >= ROOT && LA4_0 <= JOINT)))
                    {
                        alt4 = 1;
                    }
                    else if ((LA4_0 == END_SITE))
                    {
                        alt4 = 2;
                    }
                    else
                    {
                        NoViableAltException nvae_d4s0 =
                            new NoViableAltException("98:6: ( (child= heirarchy[d] )+ | end= endsite )", 4, 0, input);

                        throw nvae_d4s0;
                    }
                    switch (alt4)
                    {
                    case 1:
                        // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:98:8: (child= heirarchy[d] )+
                    {
                        // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:98:8: (child= heirarchy[d] )+
                        int cnt3 = 0;
                        do
                        {
                            int alt3  = 2;
                            int LA3_0 = input.LA(1);

                            if (((LA3_0 >= ROOT && LA3_0 <= JOINT)))
                            {
                                alt3 = 1;
                            }


                            switch (alt3)
                            {
                            case 1:
                                // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:98:9: child= heirarchy[d]
                            {
                                PushFollow(FOLLOW_heirarchy_in_heirarchy660);
                                child = heirarchy(d);
                                followingStackPointer_--;

                                node.Nodes.Add(child);
                            }
                            break;

                            default:
                                if (cnt3 >= 1)
                                {
                                    goto loop3;
                                }
                                EarlyExitException eee =
                                    new EarlyExitException(3, input);
                                throw eee;
                            }
                            cnt3++;
                        } while (true);

loop3:
                        ;                       // Stops C# compiler whinging that label 'loop3' has no statements
                    }
                    break;

                    case 2:
                        // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:99:8: end= endsite
                    {
                        PushFollow(FOLLOW_endsite_in_heirarchy677);
                        end = endsite();
                        followingStackPointer_--;

                        node.End = end;
                    }
                    break;
                    }

                    Match(input, RCURLY, FOLLOW_RCURLY_in_heirarchy685);
                }
            }
            catch (RecognitionException re)
            {
                ReportError(re);
                Recover(input, re);
            }
            finally
            {
            }
            return(node);
        }