Ejemplo n.º 1
0
 private bool buildBody(ClassItemAccessLevel level, bool isStatic, Token token, EnegyData data)
 {
     if (token.getCache().type() == TokenType.Function) //it is a function :)
     {
         token.next();
         return buildMethod(level, isStatic, token, data);
     }else
         return buildVariabel(level, isStatic, token, data);
 }
Ejemplo n.º 2
0
        private bool buildMethod(ClassItemAccessLevel level, bool isStatic, Token token, EnegyData data)
        {
            //control if there are is name after function :)
            if (token.getCache().type() != TokenType.Variabel)
            {
                data.setError(new ScriptError("A method should have a name", token.getCache().posision()), db);
                return false;
            }

            string type = null;

            //okay the name can be a type so wee control it here :)
            if (Types.IsType(token.getCache().ToString(), db))
            {
                type = token.getCache().ToString();

                if(token.next().type() != TokenType.Variabel)
                {
                    data.setError(new ScriptError("A method should have a name", token.getCache().posision()), db);
                    return false;
                }
            }

            Method method = new Method(token.getCache().ToString());

            token.next();

            if (isStatic)
                method.SetStatic();

            method.SetAgumentStack(AgumentParser.parseAguments(token, db, data));
            method.SetBody(new CallScriptMethod(method.GetAgumentStack(), BodyParser.parse(token, data, db)).call);
            method.SetVariabel();//in this way the script can use agument as name :)
            method.setLevel(level);

            builder.SetMethod(method, data, db, token.getCache().posision());
            token.next();
            return true;
        }
Ejemplo n.º 3
0
        private bool buildVariabel(ClassItemAccessLevel level, bool isStatic, Token token, EnegyData data)
        {
            //it is a variabel :)
            //okay it is a variabel ?
            if (token.getCache().type() != TokenType.Variabel) {
                data.setError(new ScriptError("1 Unknown token in class (" + builder.GetContainer().Name + ") body: " + token.getCache().ToString() + " | " + token.getCache().type().ToString(), token.getCache().posision()), db);
                return false;
            }

            Pointer pointer = new Pointer(token.getCache().ToString());

            if(token.next().type() == TokenType.Assigen)
            {
                token.next();
                pointer.SetDefault(new VariabelParser().parse(data, db, token));
            }else if(token.getCache().type() == TokenType.End)
            {
                token.next();
            }
            else
            {
                data.setError(new ScriptError("2 Unknown token in class ("+builder.GetContainer().Name+") body: " + token.getCache().ToString(), token.getCache().posision()), db);
                return false;
            }

            if (isStatic)
                pointer.SetStatic();

            pointer.SetLevel(level);

            builder.SetPointer(pointer, data, db, token.getCache().posision());
            return true;
        }
Ejemplo n.º 4
0
 private bool isStatic(ClassItemAccessLevel level, Token token, EnegyData data)
 {
     if(token.getCache().type() == TokenType.Static)
     {
         token.next();
         return buildBody(level, true, token, data);
     }else
         return buildBody(level, false, token, data);
 }
Ejemplo n.º 5
0
 public void SetLevel(ClassItemAccessLevel level)
 {
     pointer.Level = level;
 }