Beispiel #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);
        }
Beispiel #2
0
        public static StructDefNode Parse(Lexer lex)
        {
            StructDefNode n = new StructDefNode();

            lex.Dequeue("struct");
            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);
        }
Beispiel #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);
        }