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