private Type typeDecl(boolean global) throws Exception
    {
        if(scan.sym == Token.var) {
            scan.next();
            return new VarType(global, globals);
        } else if (scan.sym == Token.array) {
            scan.next();
            if(scan.sym == Token.opensquare) {
                ArrayList<Integer> dimension = new ArrayList<Integer>();
                while(scan.sym == Token.opensquare) {
                    scan.next();
                    int i = number().getValue();
                    dimension.add(i);
                    if(scan.sym == Token.closesqare) {
                        scan.next();
                    } else {
                        throw new Exception("Type declaration: no closing ']'");
                    }
                }
                return new ArrayType(dimension, global, globals, currentFunction.locals);
            } else {
                // must be at least one boundary description
                throw new Exception("Type declaration: there must be at least one boundary description for an array");
            }
        } else {
            throw new Exception("Unexpected type declaration");
        }
    }