X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;ds=sidebyside;f=helm%2Fsoftware%2Flambda-delta%2Fautomath%2FautLexer.mll;h=b7009f9240011a28392d02c760c7a7b8dade963d;hb=e22808c929a9cebf5e4e2b7428ff0cbf89e1f92a;hp=fa385bca44f595275cbeadf78fd39cb302230a26;hpb=c45c77de154323feaf5bf6aee98c86b95361b9ae;p=helm.git diff --git a/helm/software/lambda-delta/automath/autLexer.mll b/helm/software/lambda-delta/automath/autLexer.mll index fa385bca4..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 = ['#' '%'] @@ -28,13 +42,12 @@ rule line_comment = parse | NL { () } | OC { block_comment lexbuf; line_comment lexbuf } | _ { line_comment lexbuf } - | eof { () } + | eof { () } and block_comment = parse | CC { () } | OC { block_comment lexbuf; block_comment lexbuf } | LC { line_comment lexbuf; block_comment lexbuf } | _ { block_comment lexbuf } - | eof { () } and token = parse | SPC { token lexbuf } | LC { line_comment lexbuf; token lexbuf } @@ -54,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 }