]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/cic_disambiguation/cicTextualParser2.ml
generate HTML templates using XSLT starting from a bunch of .src files
[helm.git] / helm / ocaml / cic_disambiguation / cicTextualParser2.ml
index d062ed109c704de74c3dd7210af22123ed2b11e4..d5f427c4f92f039367f722eceb4abf3bb0ce6b68 100644 (file)
@@ -23,7 +23,7 @@
  * http://helm.cs.unibo.it/
  *)
 
-let debug = true
+let debug = false
 let debug_print s =
   if debug then begin
     prerr_endline "<NEW_TEXTUAL_PARSER>";
@@ -35,12 +35,17 @@ let debug_print s =
   * thus be interpreted differently than others *)
 let use_fresh_num_instances = false
 
+  (** does the lexer return COMMENT tokens? *)
+let return_comments = false
+
 open Printf
 
 open DisambiguateTypes
 
 exception Parse_error of Token.flocation * string
 
+let cic_lexer = CicTextualLexer2.cic_lexer ~comments:return_comments ()
+
 let fresh_num_instance =
   let n = ref 0 in
   if use_fresh_num_instances then
@@ -52,7 +57,7 @@ let choice_of_uri uri =
   let term = CicUtil.term_of_uri uri in
   (uri, (fun _ _ _ -> term))
 
-let grammar = Grammar.gcreate CicTextualLexer2.cic_lexer
+let grammar = Grammar.gcreate cic_lexer
 
 let term = Grammar.Entry.create grammar "term"
 let term0 = Grammar.Entry.create grammar "term0"
@@ -358,7 +363,7 @@ EXTEND
         let idents = match idents with None -> [] | Some idents -> idents in
         return_tactic loc (TacticAst.Intros (num, idents))
     | [ IDENT "intro" | IDENT "Intro" ] ->
-        return_tactic loc (TacticAst.Intros (Some 1, []))
+        return_tactic loc (TacticAst.Intros (None, []))
     | [ IDENT "left" | IDENT "Left" ] -> return_tactic loc TacticAst.Left
     | [ "let" | "Let" ];
       t = tactic_term; "in"; where = IDENT ->
@@ -400,7 +405,9 @@ EXTEND
       [ cmd = command -> return_tactical loc (TacticAst.Command cmd) ]
     | "sequence" LEFTA
       [ tactics = LIST1 NEXT SEP SYMBOL ";" ->
-          return_tactical loc (TacticAst.Seq tactics)
+          (match tactics with
+          | [tactic] -> tactic
+          | _ -> return_tactical loc (TacticAst.Seq tactics))
       ]
     | "then" NONA
       [ tac = tactical;
@@ -459,6 +466,8 @@ EXTEND
   print_kind: [
     [ [ IDENT "Env" | IDENT "env" | IDENT "Environment" | IDENT "environment" ]
       -> `Env
+    | [ IDENT "Coer" | IDENT "coer" | IDENT "Coercions" | IDENT "coercions" ]
+      -> `Coer
   ] ];
 
   command: [
@@ -523,7 +532,7 @@ EXTEND
   ];
   script_entry: [
     [ cmd = tactical0 -> Command cmd
-    | s = COMMENT -> Comment (loc, s)
+(*     | s = COMMENT -> Comment (loc, s) *)
     ]
   ];
   script: [ [ entries = LIST0 script_entry; EOI -> (loc, entries) ] ];
@@ -557,7 +566,7 @@ module EnvironmentP3 =
 
     let empty = ""
 
-    let aliases_grammar = Grammar.gcreate CicTextualLexer2.cic_lexer
+    let aliases_grammar = Grammar.gcreate cic_lexer
     let aliases = Grammar.Entry.create aliases_grammar "aliases"
 
     let to_string env =