Merge branch 'master' into More-Maven-fixes

This commit is contained in:
Jacob Swehla 2017-12-29 11:26:12 -06:00
commit bbcadbf253
3 changed files with 18 additions and 11 deletions

View File

@ -9,6 +9,8 @@ import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
* Top-level class for assembly operations. * Top-level class for assembly operations.
@ -48,11 +50,9 @@ public class Assembler {
* @return The line without its label part * @return The line without its label part
*/ */
private static String removeLabel(String line) { private static String removeLabel(String line) {
if (line.indexOf(':') != -1) {
return line.substring(line.indexOf(':') + 1); return line.replaceAll("\\b\\w*\\b:", "");
} else {
return line;
}
} }
/** /**
@ -94,10 +94,11 @@ public class Assembler {
line = removeComment(line); line = removeComment(line);
//Check for labels //Check for labels
if (line.indexOf(':') != -1) { Pattern pattern = Pattern.compile("\\b\\w*\\b:");
Matcher matcher = pattern.matcher(line);
line = line.substring(0, line.indexOf(':')); if (matcher.find()) {
String label = line.trim(); String label = matcher.group(0).substring(0, matcher.group(0).length() - 1);
LogManager.LOGGER.fine("DEBUG: Label " + label + " @ " + (result.origin + currentOffset)); LogManager.LOGGER.fine("DEBUG: Label " + label + " @ " + (result.origin + currentOffset));
result.labels.put(label, (char) (result.origin + currentOffset)); result.labels.put(label, (char) (result.origin + currentOffset));
@ -134,7 +135,9 @@ public class Assembler {
try { try {
String[] values = line.substring(2, line.length()).split(",");
//Special thanks to https://stackoverflow.com/questions/1757065/
String[] values = line.substring(2, line.length()).split(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)", -1);
for (String value : values) { for (String value : values) {

View File

@ -120,8 +120,8 @@ public abstract class Instruction {
* Whether or not the instruction is valid without any * Whether or not the instruction is valid without any
* operands * operands
*/ */
private static boolean noOperandsValid() { public boolean noOperandsValid() {
return true; return false;
} }
String getMnemonic() { String getMnemonic() {

View File

@ -20,4 +20,8 @@ public class BrkInstruction extends Instruction {
return status; return status;
} }
public boolean noOperandsValid() {
return true;
}
} }