Example #1
0
        public new static NameSpace Match()
        {
            var space = new NameSpace();

            Parser.Match(Tag.NAMESPACE);
            space.name = Identitifer.Match().ILValue;

            if (Parser.current.tag_value == '=')
            {
                Parser.Match('=');
                Parser.Match('>');
                space.objs.Add(Class.Match(space));
            }
            else
            {
                Parser.Match('{');
                while (current.tag_value == Tag.OBJ)
                {
                    space.objs.Add(Class.Match(space));
                }
                Parser.Match('}');
            }

            return(space);
        }
Example #2
0
        private static Param match_param()
        {
            var param = new Param
            {
                name = Identitifer.Match().ILValue,
            };

            Parser.Match(Tag.AS);
            param.type = Identitifer.Match();
            return(param);
        }
Example #3
0
        public static Identitifer Match()
        {
            var id = new Identitifer("");

            while (true)
            {
                if (Parser.current.tag_value == Tag.ID)
                {
                    id.ILValue += Parser.current.ToString();
                    Parser.Match(Tag.ID);
                    continue;
                }

                if (Parser.current.tag_value == Tag.FLOAT)
                {
                    id.ILValue += Parser.current.ToString();
                    Parser.Match(Tag.FLOAT);
                    continue;
                }

                if (Parser.current.tag_value == Tag.INT)
                {
                    id.ILValue += Parser.current.ToString();
                    Parser.Match(Tag.INT);
                    continue;
                }
                if (Parser.current.tag_value == '.')
                {
                    Parser.Match('.');
                    id.ILValue += ".";
                    continue;
                }

                if (Parser.current.tag_value == ':')
                {
                    Parser.Match(':');
                    Parser.Match(':');
                    id.ILValue += "::";
                    continue;
                }
                break;
            }

            return(id);
        }
Example #4
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);
        }