]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/lambda-delta/automath/autLexer.mll
- we now add the kernel options in the preamble of the URI hierarchy
[helm.git] / helm / software / lambda-delta / automath / autLexer.mll
index 006c056b9db0b933f6dbc2e65ace8def82e080d0..b7009f9240011a28392d02c760c7a7b8dade963d 100644 (file)
    
    let debug = false
    let out s = if debug then L.warn s else ()
+
+   let unquote = ref false
+
+(* This turns an Automath identifier into an XML nmtoken *)
+   let quote id =
+      let l = String.length id in
+      let rec aux i =
+         if i < l then begin
+            if id.[i] = '\'' || id.[i] = '`' then id.[i] <- '_';
+           aux (succ i)
+         end else
+           id
+      in
+      aux 0
 }
 
 let LC  = ['#' '%']
@@ -53,7 +67,10 @@ and token = parse
    | "'prop'" { out "PROP"; P.PROP   }
    | "TYPE"   { out "TYPE"; P.TYPE   }
    | "'type'" { out "TYPE"; P.TYPE   }
-   | ID       { out "ID"; P.IDENT (Lexing.lexeme lexbuf) }   
+   | ID       { out "ID"; 
+                   let s = Lexing.lexeme lexbuf in
+                   if !unquote then P.IDENT s else P.IDENT (quote s)
+              }
    | ":="     { out "DEF"; P.DEF     }
    | "("      { out "OP"; P.OP       }
    | ")"      { out "CP"; P.CP       }