Пример #1
0
        public static SubdefNode Parse(Lexer lex)
        {
            SubdefNode n = new SubdefNode();

            while (AttributeNode.IsPresent(lex))
            {
                n.Attributes.Add(AttributeNode.Parse(lex));
            }

            Token pubTkn;

            n.IsPublic = lex.DequeueIf("public", out pubTkn);

            if (ClassDefNode.IsPresent(lex))
            {
                n.Definition = ClassDefNode.Parse(lex);
            }
            else if (StructDefNode.IsPresent(lex))
            {
                n.Definition = StructDefNode.Parse(lex);
            }
            else if (EnumDefNode.IsPresent(lex))
            {
                n.Definition = EnumDefNode.Parse(lex);
            }
            else if (InterfaceDefNode.IsPresent(lex))
            {
                n.Definition = InterfaceDefNode.Parse(lex);
            }

            return(n);
        }
Пример #2
0
        public static NamespaceNode Parse(Lexer lex)
        {
            var n = new NamespaceNode();

            lex.Dequeue("namespace");
            n.Identifier = TRefNode.Parse(lex);
            lex.Dequeue(TokenType.LBrace);

            while (SubdefNode.IsPresent(lex))
            {
                n.Subdefinitions.Add(SubdefNode.Parse(lex));
            }

            lex.Dequeue(TokenType.RBrace);

            return(n);
        }