Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Jacob Swehla 2017-12-29 11:25:55 -06:00
commit 3d60f9a67c
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.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Top-level class for assembly operations.
@ -48,11 +50,9 @@ public class Assembler {
* @return The line without its label part
*/
private static String removeLabel(String line) {
if (line.indexOf(':') != -1) {
return line.substring(line.indexOf(':') + 1);
} else {
return line;
}
return line.replaceAll("\\b\\w*\\b:", "");
}
/**
@ -94,10 +94,11 @@ public class Assembler {
line = removeComment(line);
//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(':'));
String label = line.trim();
if (matcher.find()) {
String label = matcher.group(0).substring(0, matcher.group(0).length() - 1);
LogManager.LOGGER.fine("DEBUG: Label " + label + " @ " + (result.origin + currentOffset));
result.labels.put(label, (char) (result.origin + currentOffset));
@ -134,7 +135,9 @@ public class Assembler {
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) {

View File

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

View File

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