Add koral:rewrite to query and corpus transformations

Change-Id: I97e3050d39b936256616bdf46203a784de6a3414
diff --git a/parser/parser.go b/parser/parser.go
index a6f29f9..d19b19f 100644
--- a/parser/parser.go
+++ b/parser/parser.go
@@ -277,12 +277,14 @@
 	case *ast.Token:
 		if n.Wrap == nil {
 			return rawNode{
-				Type: "koral:token",
+				Type:     "koral:token",
+				Rewrites: n.Rewrites,
 			}
 		}
 		return rawNode{
-			Type: "koral:token",
-			Wrap: json.RawMessage(nodeToRaw(n.Wrap).toJSON()),
+			Type:     "koral:token",
+			Wrap:     json.RawMessage(nodeToRaw(n.Wrap).toJSON()),
+			Rewrites: n.Rewrites,
 		}
 
 	case *ast.TermGroup:
@@ -294,13 +296,15 @@
 			Type:     "koral:termGroup",
 			Operands: operands,
 			Relation: "relation:" + string(n.Relation),
+			Rewrites: n.Rewrites,
 		}
 
 	case *ast.Term:
 		raw := rawNode{
-			Type:  "koral:term",
-			Key:   n.Key,
-			Match: "match:" + string(n.Match),
+			Type:     "koral:term",
+			Key:      n.Key,
+			Match:    "match:" + string(n.Match),
+			Rewrites: n.Rewrites,
 		}
 		if n.Foundry != "" {
 			raw.Foundry = n.Foundry