Advertisement
Guest User

Untitled

a guest
Apr 29th, 2012
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.97 KB | None | 0 0
  1.         int paramIndex = line.indexOf(' '); // The space character after operators
  2.        
  3.         if (paramIndex == -1) { // If no parameters, return
  4.             return -1;
  5.         }
  6.        
  7.         boolean string = false;
  8.  
  9.         for (int count = 0; count < line.length(); count++) { // For each character in line  
  10.             if (line.charAt(count) == ' ' && !string) { // If space and not string
  11.                 line = line.substring(0, count) + line.substring(count + 1, line.length()); // DESTROY
  12.             }
  13.  
  14.             if (line.charAt(count) == '"') { // If quote now
  15.                 string = !string; // Set string toggle
  16.                 line = line.substring(0, count) + line.substring(count + 1, line.length()); // DESTROY
  17.             }
  18.         }
  19.  
  20.         if (line.charAt(line.length() - 1) == ':') { // If label
  21.             for (int count = count2; count < lines.length; count++) { // For each line after label
  22.                 if (lines[count] != null) { // If it isn't null
  23.                     if (lines[count].equals("END")) { // If there's an END, go to that
  24.                         return proc.checkshort(count);
  25.                     } // If not, continue
  26.                 }
  27.             }
  28.             return -1;
  29.         }
  30.  
  31.         if (line.charAt(0) == ';') { // If comment only, return
  32.             return -1;
  33.         }
  34.  
  35.         if (line.equals("END")) { // If comment only, return
  36.             return -1;
  37.         }
  38.  
  39.         for (int count = 0; count < line.length(); count++) { // Remove comment part
  40.             if (line.charAt(count) == ';') {
  41.                 line = line.substring(0, count);
  42.             }
  43.         }
  44.  
  45.         for (int count = 0; count < line.length(); count++) { // Place register values
  46.             if (line.charAt(count) == '$') {
  47.                 line = line.replace("$" + line.charAt(count + 1), "" + proc.getregister(line.charAt(count + 1)));
  48.             }
  49.         }
  50.  
  51.         String operator = line.substring(0, paramIndex); // Comments and labels are removed, find operator
  52.         ArrayList<Integer> commas = new ArrayList<Integer>(); // Commas
  53.         ArrayList<String> params = new ArrayList<String>(); // Parameters
  54.         int paramAmount = 0; // Amount of parameters
  55.  
  56.         commas.add(paramIndex); // Add paramIndex as comma
  57.  
  58.         for (int count = 0; count < line.length(); count++) { // For each character in line
  59.             if (line.charAt(count) == ',') { // If comma
  60.                 commas.add(count); // Add comma index
  61.             }
  62.         }
  63.  
  64.         commas.add(line.length()); // Add line size as commas
  65.  
  66.         // IMPORTANT: Commas must be in order in the ArrayList, that's why the line length is added after finding the parameter commas
  67.  
  68.         for (int count = 0; count < commas.size() - 1; count++) { // For each comma
  69.             params.add(line.substring(commas.get(count), commas.get(count + 1)).replaceAll(",", "")); // Get parameter between commas, remove commas
  70.             paramAmount++;
  71.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement