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

            lex.Dequeue("where");
            var tkn = lex.Dequeue(TokenType.Identifier);

            n.Parameter = tkn.Value;

            lex.Dequeue(TokenType.Colon);
            do
            {
                if (GenericConstraintTypeSet.Match(lex))
                {
                    lex.Dequeue();
                    n.KeywordConstraints.Add(tkn.Value);
                }
                else
                {
                    n.Constraints.Add(TRefNode.Parse(lex));
                }
            } while(lex.DequeueIf(TokenType.Comma, out tkn));

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