X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Flambda-delta%2Fautomath%2FautLexer.mll;h=b7009f9240011a28392d02c760c7a7b8dade963d;hb=7f89b4dce54266c281479a14c01edc4bd33993d1;hp=006c056b9db0b933f6dbc2e65ace8def82e080d0;hpb=960ed22a5a6c415e2cf0ec9e8f5680d75c3ca0cd;p=helm.git diff --git a/helm/software/lambda-delta/automath/autLexer.mll b/helm/software/lambda-delta/automath/autLexer.mll index 006c056b9..b7009f924 100644 --- a/helm/software/lambda-delta/automath/autLexer.mll +++ b/helm/software/lambda-delta/automath/autLexer.mll @@ -15,6 +15,20 @@ 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 }