Esempio n. 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);
        }
Esempio n. 2
0
        public static ClassDefNode Parse(Lexer lex)
        {
            ClassDefNode n = new ClassDefNode();

            Token tkn;

            n.IsAbstract = lex.DequeueIf("abstract", out tkn);
            lex.Dequeue("class");
            n.Identifier = ClassIdentNode.Parse(lex);
            if (ClassInheritNode.IsPresent(lex))
            {
                n.Parents = ClassInheritNode.Parse(lex);
            }

            while (GenericConstraintNode.IsPresent(lex))
            {
                n.Constraints.Add(GenericConstraintNode.Parse(lex));
            }

            lex.Dequeue(TokenType.LBrace);
            //TODO: CLASS_STRUCT_DEFS
            lex.Dequeue(TokenType.RBrace);
            return(n);
        }
Esempio n. 3
0
        public static bool IsPresent(Lexer lex)
        {
            if (AttributeNode.IsPresent(lex))
            {
                return(true);
            }

            var tkn = lex.Peek();

            if (tkn.Type == TokenType.Keyword && tkn.Value == "public")
            {
                return(true);
            }

            if (ClassDefNode.IsPresent(lex))
            {
                return(true);
            }

            if (StructDefNode.IsPresent(lex))
            {
                return(true);
            }

            if (EnumDefNode.IsPresent(lex))
            {
                return(true);
            }

            if (InterfaceDefNode.IsPresent(lex))
            {
                return(true);
            }

            return(false);
        }