diff --git a/src/main/java/org/sablecc/sablecc/GenParser.java b/src/main/java/org/sablecc/sablecc/GenParser.java
index 5a108046e7367b8a1e050b501e64c59636b53c7b..bcb654d553f23cfdc869ca050020225a20c058e5 100644
--- a/src/main/java/org/sablecc/sablecc/GenParser.java
+++ b/src/main/java/org/sablecc/sablecc/GenParser.java
@@ -289,10 +289,9 @@ public class GenParser extends DepthFirstAdapter
                    ids.names.put(node, name);
 
                    //list of inAAlt code.
-                   Object []list_alt = (Object [])node.getAlts().toArray();
-                   for(int i = 0; i< list_alt.length; i++)
+                   for(PAlt alt : node.getAlts())
                    {
-                     ((PAlt)list_alt[i]).apply(this);
+                     alt.apply(this);
                    }
                  }
 
@@ -329,10 +328,9 @@ public class GenParser extends DepthFirstAdapter
                      ids.names.put(alt, currentAlt);
                    }
 
-                   AElem list_elem[] = (AElem[]) alt.getElems().toArray(new AElem[0]);
-                   for(int i=0; i<list_elem.length;i++)
+                   for(PElem elem : alt.getElems())
                    {
-                     list_elem[i].apply(this);
+                     elem.apply(this);
                    }
                  }
 
@@ -428,7 +426,7 @@ public class GenParser extends DepthFirstAdapter
         final Node node = alts.get(productions[i].name);
 
         final BufferedWriter finalFile = file;
-        final LinkedList stack = new LinkedList();
+        final Deque<Element> stack = new LinkedList<>();
 
         node.apply(new DepthFirstAdapter()
                    {
@@ -447,9 +445,8 @@ public class GenParser extends DepthFirstAdapter
 
         try
         {
-          for(Iterator it = stack.iterator(); it.hasNext();)
+          for(Element e : stack)
           {
-            Element e = (Element) it.next();
             macros.apply(file, e.macro, e.arguments);
           }
         }
@@ -479,11 +476,11 @@ public class GenParser extends DepthFirstAdapter
                                  new FileOutputStream(
                                    new File(pkgDir, "parser.dat"))));
 
-      Vector outerArray = new Vector();
+      Vector<Vector<int[]>> outerArray = new Vector<>();
       //Generating of paring tables
       for(int i = 0; i < Grammar.action_.length; i++)
       {
-        Vector innerArray = new Vector();
+        Vector<int[]> innerArray = new Vector<>();
 
         String mostFrequentAction = "ERROR";
         int mostFrequentDestination = i;
@@ -551,14 +548,11 @@ public class GenParser extends DepthFirstAdapter
       file.write("" + table);
 
       out.writeInt(outerArray.size());
-      for(Enumeration e = outerArray.elements(); e.hasMoreElements();)
+      for(Vector<int[]> innerArray : outerArray)
       {
-        Vector innerArray = (Vector) e.nextElement();
         out.writeInt(innerArray.size());
-        for(Enumeration n = innerArray.elements(); n.hasMoreElements();)
+        for(int[] array : innerArray)
         {
-          int[] array = (int[]) n.nextElement();
-
           for(int i = 0; i < 3; i++)
           {
             out.writeInt(array[i]);
@@ -571,11 +565,11 @@ public class GenParser extends DepthFirstAdapter
       macros.apply(file, "ParserGotoHeader");
 
       table = new StringBuffer();
-      outerArray = new Vector();
+      outerArray = new Vector<>();
 
       for(int j = 0; j < nonterminals.length - 1; j++)
       {
-        Vector innerArray = new Vector();
+        Vector<int[]> innerArray = new Vector<>();
 
         int mostFrequent = -1;
         int frequence = 0;
@@ -620,14 +614,11 @@ public class GenParser extends DepthFirstAdapter
       file.write("" + table);
 
       out.writeInt(outerArray.size());
-      for(Enumeration e = outerArray.elements(); e.hasMoreElements();)
+      for(Vector<int[]> innerArray : outerArray)
       {
-        Vector innerArray = (Vector) e.nextElement();
         out.writeInt(innerArray.size());
-        for(Enumeration n = innerArray.elements(); n.hasMoreElements();)
+        for(int[] array : innerArray)
         {
-          int[] array = (int[]) n.nextElement();
-
           for(int i = 0; i < 2; i++)
           {
             out.writeInt(array[i]);
@@ -645,8 +636,8 @@ public class GenParser extends DepthFirstAdapter
 
       Map<String, Integer> errorIndex = new TreeMap<>();
 
-      outerArray = new Vector();
-      Vector indexArray = new Vector();
+      Vector<String> outerArray2 = new Vector<>();
+      Vector<Integer> indexArray = new Vector<>();
 
       index.append("            ");
       for(int i = 0; i < Grammar.action_.length; i++)
@@ -680,7 +671,7 @@ public class GenParser extends DepthFirstAdapter
         else
         {
           table.append("            \"" + s + "\"," + System.getProperty("line.separator"));
-          outerArray.addElement(s.toString());
+          outerArray2.addElement(s.toString());
           errorIndex.put(s.toString(), nextIndex);
           indexArray.addElement(nextIndex);
           index.append(nextIndex++ + ", ");
@@ -689,10 +680,9 @@ public class GenParser extends DepthFirstAdapter
 
       file.write("" + table);
 
-      out.writeInt(outerArray.size());
-      for(Enumeration e = outerArray.elements(); e.hasMoreElements();)
+      out.writeInt(outerArray2.size());
+      for(String s : outerArray2)
       {
-        String s = (String) e.nextElement();
         out.writeInt(s.length());
         int length = s.length();
         for(int i = 0; i < length; i++)
@@ -702,10 +692,9 @@ public class GenParser extends DepthFirstAdapter
       }
 
       out.writeInt(indexArray.size());
-      for(Enumeration e = indexArray.elements(); e.hasMoreElements();)
+      for(int n : indexArray)
       {
-        Integer n = (Integer) e.nextElement();
-        out.writeInt(n.intValue());
+        out.writeInt(n);
       }
 
       out.close();