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 !O.debug_lexer then L.warn s else ()
19 (* This turns an Automath identifier into an XML nmtoken *)
21 let l = String.length id in
24 if id.[i] = '\'' || id.[i] = '`' then id.[i] <- '_';
35 let SPC = [' ' '\t' '\n']+
37 let ID = ['0'-'9' 'A'-'Z' 'a'-'z' '_' '\'' '`']+
39 rule line_comment = parse
41 | OC { block_comment lexbuf; line_comment lexbuf }
42 | _ { line_comment lexbuf }
44 and block_comment = parse
46 | OC { block_comment lexbuf; block_comment lexbuf }
47 | LC { line_comment lexbuf; block_comment lexbuf }
48 | _ { block_comment lexbuf }
50 | SPC { token lexbuf }
51 | LC { line_comment lexbuf; token lexbuf }
52 | OC { block_comment lexbuf; token lexbuf }
53 | "_E" { out "E"; P.E }
54 | "'_E'" { out "E"; P.E }
55 | "---" { out "EB"; P.EB }
56 | "'eb'" { out "EB"; P.EB }
57 | "EB" { out "EB"; P.EB }
58 | "--" { out "EXIT"; P.EXIT }
59 | "PN" { out "PN"; P.PN }
60 | "'pn'" { out "PN"; P.PN }
61 | "PRIM" { out "PN"; P.PN }
62 | "'prim'" { out "PN"; P.PN }
63 | "???" { out "PN"; P.PN }
64 | "PROP" { out "PROP"; P.PROP }
65 | "'prop'" { out "PROP"; P.PROP }
66 | "TYPE" { out "TYPE"; P.TYPE }
67 | "'type'" { out "TYPE"; P.TYPE }
69 let s = Lexing.lexeme lexbuf in
70 if !O.unquote then P.IDENT s else P.IDENT (quote s)
72 | ":=" { out "DEF"; P.DEF }
73 | "(" { out "OP"; P.OP }
74 | ")" { out "CP"; P.CP }
75 | "[" { out "OB"; P.OB }
76 | "]" { out "CB"; P.CB }
77 | "<" { out "OA"; P.OA }
78 | ">" { out "CA"; P.CA }
79 | "@" { out "AT"; P.AT }
80 | "~" { out "TD"; P.TD }
81 | "\"" { out "QT"; P.QT }
82 | ":" { out "CN"; P.CN }
83 | "," { out "CM"; P.CM }
84 | ";" { out "SC"; P.SC }
85 | "." { out "FS"; P.FS }
86 | "+" { out "PLUS"; P.PLUS }
87 | "-" { out "MINUS"; P.MINUS }
88 | "*" { out "TIMES"; P.TIMES }
89 | "=" { out "DEF"; P.DEF }
90 | eof { out "EOF"; P.EOF }