public static InterfaceDefNode Parse(Lexer lex)
        {
            InterfaceDefNode n = new InterfaceDefNode();

            lex.Dequeue("interface");
            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);
            while (InterfaceEntryNode.IsPresent(lex))
            {
                n.Entries.Add(InterfaceEntryNode.Parse(lex));
            }
            lex.Dequeue(TokenType.RBrace);

            return(n);
        }
Beispiel #2
0
        public static ClassInheritNode Parse(Lexer lex)
        {
            ClassInheritNode n = new ClassInheritNode();

            lex.Dequeue(TokenType.Colon);

            Token tkn;

            do
            {
                n.Bases.Add(TRefNode.Parse(lex));
            } while(lex.DequeueIf(TokenType.Comma, out tkn));

            return(n);
        }
Beispiel #3
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 #4
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);
        }