diff tools/make_template.ml @ 41:d45ba7e9b266

Improve template generation; craft template for InductiveTypes
author Adam Chlipala <adamc@hcoop.net>
date Sat, 13 Sep 2008 14:31:51 -0400
parents c8070689f5ca
children 827d7e8a7d9e
line wrap: on
line diff
--- a/tools/make_template.ml	Sat Sep 13 08:58:48 2008 -0400
+++ b/tools/make_template.ml	Sat Sep 13 14:31:51 2008 -0400
@@ -12,15 +12,21 @@
 	print_newline ();
       initial true
   | Some line ->
-      if String.length line >= 2 && line.[0] = '(' && line.[1] = '*' then
-	if line.[String.length line - 2] = '*' && line.[String.length line - 1] = ')' then
-	  initial last_was_empty
-	else
-	  comment last_was_empty
-      else begin
-	print_endline line;
-	initial false
-      end
+      let idx = try Some (String.index line '(') with Not_found -> None in
+      match idx with
+        | Some idx ->
+            if String.length line > idx+1 && line.[idx+1] = '*' then
+              if line.[String.length line - 2] = '*' && line.[String.length line - 1] = ')' then
+	        initial last_was_empty
+	      else
+	        comment last_was_empty
+            else begin
+              print_endline line;
+              initial false
+            end
+        | None ->
+	    print_endline line;
+	    initial false
 
 and comment last_was_empty =
   match read_line () with