package org.spoofax.jsglr2.parser.result;

import org.spoofax.jsglr2.messages.Category;
import org.spoofax.jsglr2.messages.Message;
import org.spoofax.jsglr2.parser.Position;

public class ParseFailureCause {

	public enum Type {

		UnexpectedEOF("Unexpected end of input", Category.PARSING),
		UnexpectedInput("Unexpected input", Category.PARSING),
		InvalidStartSymbol("Invalid start symbol", Category.PARSING), Cycle("Cycle in parse forest", Category.CYCLE),
		NonAssoc("Operator is non-associative", Category.NONASSOC),
		NonNested("Operator is non-nested", Category.NONASSOC);

		public final String message;
		public final Category category;

		Type(String message, Category category) {
			this.message = message;
			this.category = category;
		}

	}

	public final Type type;
	public final Position position;

	public ParseFailureCause(Type type, Position position) {
		this.type = type;
		this.position = position;
	}

	public ParseFailureCause(Type type) {
		this(type, null);
	}

	public Message toMessage() {
		return Message.error(type.message, type.category, position);
	}

}

@@ -203,17 +203,20 @@
 ause %7B%0A%0A
-%09
+    
 public e
@@ -227,18 +227,24 @@
 Type %7B%0A%0A
-%09%09
+        
 Unexpect
@@ -295,18 +295,24 @@
 RSING),%0A
-%09%09
+        
 Unexpect
@@ -358,18 +358,24 @@
 RSING),%0A
-%09%09
+        
 InvalidS
@@ -476,18 +476,24 @@
 CYCLE),%0A
-%09%09
+        
 NonAssoc
@@ -544,18 +544,24 @@
 ASSOC),%0A
-%09%09
+        
 NonNeste
@@ -609,18 +609,24 @@
 SSOC);%0A%0A
-%09%09
+        
 public f
@@ -646,18 +646,24 @@
 essage;%0A
-%09%09
+        
 public f
@@ -687,18 +687,24 @@
 egory;%0A%0A
-%09%09
+        
 Type(Str
@@ -737,19 +737,28 @@
 gory) %7B%0A
-%09%09%09
+            
 this.mes
@@ -777,11 +777,20 @@
 ge;%0A
-%09%09%09
+            
 this
@@ -815,18 +815,30 @@
 ry;%0A
-%09%09%7D%0A%0A%09%7D%0A%0A%09
+        %7D%0A%0A    %7D%0A%0A    
 publ
@@ -857,17 +857,20 @@
 e type;%0A
-%09
+    
 public f
@@ -894,17 +894,20 @@
 ition;%0A%0A
-%09
+    
 public P
@@ -951,26 +951,32 @@
 position) %7B%0A
-%09%09
+        
 this.type = 
@@ -981,18 +981,24 @@
 = type;%0A
-%09%09
+        
 this.pos
@@ -1015,21 +1015,27 @@
 sition;%0A
-%09%7D%0A%0A%09
+    %7D%0A%0A    
 public P
@@ -1064,18 +1064,24 @@
 type) %7B%0A
-%09%09
+        
 this(typ
@@ -1094,13 +1094,19 @@
 l);%0A
-%09%7D%0A%0A%09
+    %7D%0A%0A    
 publ
@@ -1134,10 +1134,16 @@
 ) %7B%0A
-%09%09
+        
 retu
@@ -1203,9 +1203,12 @@
 n);%0A
-%09
+    
 %7D%0A%0A%7D

Replace tabs with spaces in ParseFailureCause