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 ()
21 let SPC = [' ' '\t' '\n']+
25 let ALPHA = ['A'-'Z' 'a'-'z' '_']
27 let ID = ALPHA+ (ALPHA | FIG)*
30 rule block_comment = parse
32 | OC { block_comment lexbuf; block_comment lexbuf }
33 | _ { block_comment lexbuf }
36 | SPC { " " ^ qstring lexbuf }
37 | BS BS { "\\" ^ qstring lexbuf }
38 | BS QT { "\"" ^ qstring lexbuf }
39 | _ as c { String.make 1 c ^ qstring lexbuf }
41 | SPC { token lexbuf }
42 | OC { block_comment lexbuf; token lexbuf }
43 | ID as id { out ("ID " ^ id); TP.ID id }
44 | IX as ix { out ("IX " ^ ix); TP.IX (int_of_string ix) }
45 | QT { let s = qstring lexbuf in out ("STR " ^ s); TP.STR s }
46 | "\\graph" { out "GRAPH"; TP.GRAPH }
47 | "\\decl" { out "DECL"; TP.DECL }
48 | "\\ax" { out "AX"; TP.AX }
49 | "\\cong" { out "CONG"; TP.CONG }
50 | "\\def" { out "DEF"; TP.DEF }
51 | "\\th" { out "TH"; TP.TH }
52 | "\\generate" { out "GEN"; TP.GEN }
53 | "\\require" { out "REQ"; TP.REQ }
54 | "\\open" { out "OPEN"; TP.OPEN }
55 | "\\close" { out "CLOSE"; TP.CLOSE }
56 | "\\sorts" { out "SORTS"; TP.SORTS }
57 | "(" { out "OP"; TP.OP }
58 | ")" { out "CP"; TP.CP }
59 | "[" { out "OB"; TP.OB }
60 | "]" { out "CB"; TP.CB }
61 | "<" { out "OA"; TP.OA }
62 | ">" { out "CA"; TP.CA }
63 | "." { out "FS"; TP.FS }
64 | ":" { out "CN"; TP.CN }
65 | "," { out "CM"; TP.CM }
66 | "=" { out "EQ"; TP.EQ }
67 | "*" { out "STAR"; TP.STAR }
68 | "#" { out "HASH"; TP.HASH }
69 | "+" { out "PLUS"; TP.PLUS }
70 | "~" { out "TE"; TP.TE }
71 | "->" { out "WTO"; TP.WTO }
72 | "=>" { out "STO"; TP.STO }
73 | "^" { out "CT"; TP.CT }
74 | eof { out "EOF"; TP.EOF }