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 !G.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"; AP.E }
54 | "'_E'" { out "E"; AP.E }
55 | "---" { out "EB"; AP.EB }
56 | "'eb'" { out "EB"; AP.EB }
57 | "EB" { out "EB"; AP.EB }
58 | "--" { out "EXIT"; AP.EXIT }
59 | "PN" { out "PN"; AP.PN }
60 | "'pn'" { out "PN"; AP.PN }
61 | "PRIM" { out "PN"; AP.PN }
62 | "'prim'" { out "PN"; AP.PN }
63 | "???" { out "PN"; AP.PN }
64 | "PROP" { out "PROP"; AP.PROP }
65 | "'prop'" { out "PROP"; AP.PROP }
66 | "TYPE" { out "TYPE"; AP.TYPE }
67 | "'type'" { out "TYPE"; AP.TYPE }
69 let s = Lexing.lexeme lexbuf in
70 if !G.unquote then AP.IDENT s else AP.IDENT (quote s)
72 | ":=" { out "DEF"; AP.DEF }
73 | "(" { out "OP"; AP.OP }
74 | ")" { out "CP"; AP.CP }
75 | "[" { out "OB"; AP.OB }
76 | "]" { out "CB"; AP.CB }
77 | "<" { out "OA"; AP.OA }
78 | ">" { out "CA"; AP.CA }
79 | "@" { out "AT"; AP.AT }
80 | "~" { out "TD"; AP.TD }
81 | "\"" { out "QT"; AP.QT }
82 | ":" { out "CN"; AP.CN }
83 | "," { out "CM"; AP.CM }
84 | ";" { out "SC"; AP.SC }
85 | "." { out "FS"; AP.FS }
86 | "+" { out "PLUS"; AP.PLUS }
87 | "-" { out "MINUS"; AP.MINUS }
88 | "*" { out "TIMES"; AP.TIMES }
89 | "=" { out "DEF"; AP.DEF }
90 | eof { out "EOF"; AP.EOF }