Commits

Stephen McKamey committed d9717ef

- minor cleanup

  • Participants
  • Parent commits e851fa1

Comments (0)

Files changed (4)

File src/org/duelengine/duel/ast/BlockNode.java

 			hash = hash * HASH_PRIME + this.value.hashCode();
 		}
 		return hash;
-	}}
+	}
+}

File src/org/duelengine/duel/parsing/DuelLexer.java

 			return false;
 		}
 
-		if (this.ch == DuelGrammar.OP_ELEM_END) {
-			this.nextChar();
-		}
-
 		if (this.suspendMode && !asAttr && (begin.equals(DuelGrammar.OP_COMMENT))) {
 
 			// always unwrap commented content of suspend-mode elements
 			this.nextChar();
 		}
 
-		// reset the buffer, mark start
+		// reset the buffer
 		this.buffer.setLength(0);
 
 		for (int i=0, length=end.length(); this.ch != EOF; ) {
 				if (i >= length) {
 					length--;
 
+					// consume final char
+					this.nextChar();
+
 					// trim ending delim from buffer
 					this.buffer.setLength(this.buffer.length() - length);
 					return this.buffer.toString();
 			this.nextChar();
 		}
 
-		// TODO: determine better exception type
-		throw new IOException("Unterminated block");
+		throw new SyntaxException("Unterminated block", this.token_index, this.token_line, this.token_column);
 	}
 
 	/**

File src/org/duelengine/duel/parsing/DuelToken.java

 	public String toString() {
 		StringBuilder buffer = new StringBuilder(this.type.toString());
 		if (this.value != null) {
-			buffer.append(": "+this.value);
+			buffer.append(": ").append(this.value);
 		}
 		else if (this.block != null) {
-			buffer.append(": "+this.block);
+			buffer.append(": ").append(this.block);
 		}
 		return buffer.toString();
 	}

File test/org/duelengine/duel/parsing/DuelLexerTests.java

 package org.duelengine.duel.parsing;
 
+import java.io.IOException;
 import java.util.Arrays;
 
 import org.junit.Test;
 		assertArrayEquals(expected, actual);
 	}
 
-	private void dumpList(String label, Object[] tokens) {
-		System.out.println();
-		System.out.print(label+":");
-		for (Object token : tokens) {
-			System.out.print("\n\t"+token);
+	private void dumpLists(Object[] expected, Object[] actual) {
+
+		for (Object token : expected) {
+			System.out.println(token.toString());
 		}
-		System.out.println();
+
+		for (Object token : actual) {
+			System.err.println(token.toString());
+		}
 	}
 }