Skip to content
This repository was archived by the owner on Sep 14, 2019. It is now read-only.

Commit 2846211

Browse files
2 parents 9a97982 + 869da04 commit 2846211

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

Robot2018/src/org/usfirst/frc/team199/Robot2018/autonomous/AutoUtils.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ public static Map<String, ArrayList<String[]>> parseScriptFile(String scriptFile
3131
// trim and remove extra whitespace just to make it neater
3232
line = line.trim().replaceAll("\\s+", " ");
3333

34+
// make coordinates with spaces also work
35+
int parenIndex = line.indexOf("(");
36+
while (parenIndex != -1) {
37+
// removes all spaces between the parentheses
38+
int endParenIndex = line.indexOf(")", parenIndex);
39+
String coord = line.substring(parenIndex + 1, endParenIndex);
40+
line = line.substring(0, parenIndex + 1) + coord.replaceAll(" ", "") + line.substring(endParenIndex);
41+
42+
// finds next parentheses
43+
parenIndex = line.indexOf("(", parenIndex + 1);
44+
}
45+
3446
// if there's no instruction on this line, skip
3547
if (line.equals("")) {
3648
continue;
@@ -168,7 +180,7 @@ else if (instruction.equals("jump")) {
168180
* @param message the message to log
169181
*/
170182
private static void logWarning (int lineNumber, String message) {
171-
System.err.println("[WARNING] Line " + lineNumber + ": " + message);
183+
System.err.println("[ERROR] Line " + lineNumber + ": " + message);
172184
}
173185

174186
/**

Robot2018/test/org/usfirst/frc/team199/Robot2018/ParseScriptFileTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void test9() {
134134
@Test
135135
void test10() {
136136
String input = "CLRx:\n"
137-
+ "turn 0x4a"; // unfortunately, the program does not except hexadecimal xD
137+
+ "turn 0x4a"; // unfortunately, the program does not accept hexadecimal xD
138138
Map<String, ArrayList<String[]>> output = AutoUtils.parseScriptFile(input);
139139

140140
assertEquals(1, output.size());
@@ -148,7 +148,8 @@ void test11() {
148148
Map<String, ArrayList<String[]>> output = AutoUtils.parseScriptFile(input);
149149

150150
assertEquals(1, output.size());
151-
assertEquals(true, output.get("CLRx").isEmpty());
151+
assertEquals("moveto", output.get("CLRx").get(0)[0]);
152+
assertEquals("(4,20) (18,47) 39", output.get("CLRx").get(0)[1]);
152153
}
153154

154155
@Test
@@ -168,7 +169,8 @@ void test13() {
168169
Map<String, ArrayList<String[]>> output = AutoUtils.parseScriptFile(input);
169170

170171
assertEquals(1, output.size());
171-
assertEquals(true, output.get("CLRx").isEmpty());
172+
assertEquals("moveto", output.get("CLRx").get(0)[0]);
173+
assertEquals("(4,20) (18,47) 39", output.get("CLRx").get(0)[1]);
172174
}
173175

174176
@Test

0 commit comments

Comments
 (0)