Ejemplo n.º 1
0
        public new static Stmt Match()
        {
            Parser.Match('{');
            var stmt = Stmts.Match();

            Parser.Match('}');
            return(stmt);
        }
Ejemplo n.º 2
0
        public static Func Match(Class obj)
        {
            var function = new Func();

            Parser.Match(Tag.FUNC);
            Parser.Match('<');
            if (current.tag_value == Tag.PUBLIC)
            {
                function.isPublic = true;
                Parser.Match(Tag.PUBLIC);
                if (current.tag_value == '|')
                {
                    Parser.Match('|');
                    if (current.tag_value == Tag.STATIC)
                    {
                        function.isStatic = true;
                        Parser.Match(Tag.STATIC);
                    }
                }
            }
            Parser.Match('>');
            function.name = current.ToString();
            Parser.Match(Tag.ID);
            Parser.Match('[');
            if (Parser.current.tag_value == ']')
            {
                function.returnType = new Identitifer("Void");
            }
            else
            {
                if (current.tag_value == Tag.BASIC || current.tag_value == Tag.ID)
                {
                    function.returnType = Identitifer.Match();
                }
                else
                {
                    function.returnType = new Identitifer("void");
                }

                Parser.Match('|');
                if (current.tag_value == Tag.BASIC || current.tag_value == Tag.ID)
                {
                    function._params.Add(match_param());
                    while (current.tag_value == ',')
                    {
                        Parser.Match(',');
                        function._params.Add(match_param());
                    }
                }
            }

            Parser.Match(']');
            if (current.tag_value == '=')
            {
                Parser.Match('=');
                function.block = OneLineFunction.Match();
                Parser.Match(';');
            }
            else
            {
                Parser.Match('{');
                function.block = Stmts.Match();
                Parser.Match('}');
            }

            return(function);
        }