Beispiel #1
0
        private void UnsetNext(Token token, EnegyData data, VariabelDatabase db)
        {
            if(token.next().type() != TokenType.Variabel)
            {
                data.setError(new ScriptError("Missing variabel in 'unset' statmenet", token.getCache().posision()), db);
                return;
            }

            //control wee has the variabel in the variabel database.
            if (!db.isExists(token.getCache().ToString()))
            {
                data.setError(new ScriptError("Unknown variabel: " + token.getCache().ToString(), token.getCache().posision()), db);
                return;
            }

            //is this variabel a global.
            if (!db.allowedOveride(token.getCache().ToString()))
            {
                data.setError(new ScriptError("You can not unset the variabel: " + token.getCache().ToString(), token.getCache().posision()), db);
                return;
            }

            //unset the variabel.
            db.removeVariabel(token.getCache().ToString());
        }
Beispiel #2
0
        private CVar p(EnegyData ed, VariabelDatabase db, Token token, bool name)
        {
            this.db = db;

            if (name)
            {
                if (token.next().type() != TokenType.Variabel)
                {
                    ed.setError(new ScriptError("Missing class name after 'class'", token.getCache().posision()), db);
                    return new NullVariabel();
                }

                builder = new Class(token.getCache().ToString());
            }
            else
            {
                builder = new Class();
            }

            if(token.next().type() == TokenType.Extends)
            {
                if(token.next().type() != TokenType.Variabel)
                {
                    ed.setError(new ScriptError("Missing variabel after extends", token.getCache().posision()), db);
                    return new NullVariabel();
                }

                //control if the variabel exteis in the variabel database
                if (!db.isExists(token.getCache().ToString()))
                {
                    ed.setError(new ScriptError("Unknown variabel: " + token.getCache().ToString(), token.getCache().posision()), db);
                    return new NullVariabel();
                }

                CVar buffer = db.get(token.getCache().ToString(), ed);

                if(!(buffer is ClassVariabel))
                {
                    ed.setError(new ScriptError(token.getCache().ToString() + " is not a class", token.getCache().posision()), db);
                    return new NullVariabel();
                }

                builder.Extends((ClassVariabel)buffer);
                token.next();
            }

            if(token.getCache().type() != TokenType.LeftTuborg)
            {
                ed.setError(new ScriptError("Missing { after class name", token.getCache().posision()), db);
                return new NullVariabel();
            }

            token.next();

            while (ed.State == RunningState.Normal && run(token.getCache().type()))
                build(token, ed);

            if(token.getCache().type() != TokenType.RightTuborg)
            {
                ed.setError(new ScriptError("Missing } in end of class building", token.getCache().posision()), db);
                return new NullVariabel();
            }

            token.next();
            if (name)
            {
                db.pushClass(builder, ed);
                if (db is FileVariabelDatabase)
                {
                    builder.SetExtraVariabelDatabase(db);
                    ((FileVariabelDatabase)db).VariabelDatabase.pushClass(builder, ed);
                }
                return null;
            }
            else
            {
                return new ClassVariabel(builder);
            }
        }