2 ||M|| This file is part of HELM, an Hypertextual, Electronic
3 ||A|| Library of Mathematics, developed at the Computer Science
4 ||T|| Department, University of Bologna, Italy.
6 ||T|| HELM is free software; you can redistribute it and/or
7 ||A|| modify it under the terms of the GNU General Public License
8 \ / version 2 or (at your option) any later version.
9 \ / This software is distributed as is, NO WARRANTY.
10 V_______________________________________________________________ *)
17 let out s = if debug then L.warn s else ()
19 let unquote = ref false
21 (* This turns an Automath identifier into an XML nmtoken *)
23 let l = String.length id in
26 if id.[i] = '\'' || id.[i] = '`' then id.[i] <- '_';
37 let SPC = [' ' '\t' '\n']+
39 let ID = ['0'-'9' 'A'-'Z' 'a'-'z' '_' '\'' '`']+
41 rule line_comment = parse
43 | OC { block_comment lexbuf; line_comment lexbuf }
44 | _ { line_comment lexbuf }
46 and block_comment = parse
48 | OC { block_comment lexbuf; block_comment lexbuf }
49 | LC { line_comment lexbuf; block_comment lexbuf }
50 | _ { block_comment lexbuf }
52 | SPC { token lexbuf }
53 | LC { line_comment lexbuf; token lexbuf }
54 | OC { block_comment lexbuf; token lexbuf }
55 | "_E" { out "E"; P.E }
56 | "'_E'" { out "E"; P.E }
57 | "---" { out "EB"; P.EB }
58 | "'eb'" { out "EB"; P.EB }
59 | "EB" { out "EB"; P.EB }
60 | "--" { out "EXIT"; P.EXIT }
61 | "PN" { out "PN"; P.PN }
62 | "'pn'" { out "PN"; P.PN }
63 | "PRIM" { out "PN"; P.PN }
64 | "'prim'" { out "PN"; P.PN }
65 | "???" { out "PN"; P.PN }
66 | "PROP" { out "PROP"; P.PROP }
67 | "'prop'" { out "PROP"; P.PROP }
68 | "TYPE" { out "TYPE"; P.TYPE }
69 | "'type'" { out "TYPE"; P.TYPE }
71 let s = Lexing.lexeme lexbuf in
72 if !unquote then P.IDENT s else P.IDENT (quote s)
74 | ":=" { out "DEF"; P.DEF }
75 | "(" { out "OP"; P.OP }
76 | ")" { out "CP"; P.CP }
77 | "[" { out "OB"; P.OB }
78 | "]" { out "CB"; P.CB }
79 | "<" { out "OA"; P.OA }
80 | ">" { out "CA"; P.CA }
81 | "@" { out "AT"; P.AT }
82 | "~" { out "TD"; P.TD }
83 | "\"" { out "QT"; P.QT }
84 | ":" { out "CN"; P.CN }
85 | "," { out "CM"; P.CM }
86 | ";" { out "SC"; P.SC }
87 | "." { out "FS"; P.FS }
88 | "+" { out "PLUS"; P.PLUS }
89 | "-" { out "MINUS"; P.MINUS }
90 | "*" { out "TIMES"; P.TIMES }
91 | "=" { out "DEF"; P.DEF }
92 | eof { out "EOF"; P.EOF }