Пример #1
0
        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);
        }
Пример #2
0
        public static GenericParamNode Parse(Lexer lex)
        {
            GenericParamNode n = new GenericParamNode();

            lex.Dequeue(TokenType.Less);
            Token tkn;

            do
            {
                n.Parameters.Add(ClassIdentNode.Parse(lex));
            } while(lex.DequeueIf(TokenType.Comma, out tkn));
            lex.Dequeue(TokenType.Greater);

            return(n);
        }
Пример #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);
        }
Пример #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);
        }