]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/pxp/pxp/lexers/pxp_lex_misc.src
- the mathql interpreter is not helm-dependent any more
[helm.git] / helm / DEVEL / pxp / pxp / lexers / pxp_lex_misc.src
1 (* $Id$
2  * ----------------------------------------------------------------------
3  *
4  *)
5
6
7 {
8   open Pxp_types
9   open Pxp_lexer_types
10
11 #insert open_pxp_lex_aux_*.src
12 #insert pxp_lex_aux.src
13
14 }
15
16 #insert pxp_lex_defs_*.def
17
18 (* The remaining, smaller lexers *)
19
20 rule scan_characters = parse
21   character*
22     { () }
23 | eof 
24     { () }
25 | _
26     { raise Netconversion.Malformed_code }
27
28
29 and scan_xml_pi = parse
30     name ws*
31       { let s = Lexing.lexeme lexbuf in
32         let j = get_name_end s 0 in
33         Pro_name (String.sub s 0 j)
34       }
35   | "=" ws*
36       { Pro_eq }
37   | "'" character_except_apos* "'" ws+
38       { let s = Lexing.lexeme lexbuf in
39         let j = String.index_from s 1 '\'' in
40         Pro_string (String.sub s 1 (j-1))
41       }
42   | "'"
43       { raise (WF_error ("Cannot find the second quotation mark"))
44       }
45   | '"' character_except_quot* '"' ws+
46       { let s = Lexing.lexeme lexbuf in
47         let j = String.index_from s 1 '"' in
48         Pro_string (String.sub s 1 (j-1))
49       }
50   | '"'
51       { raise (WF_error ("Cannot find the second quotation mark"))
52       }
53   | eof
54       { Pro_eof }
55   | character
56       { (* prerr_endline (Lexing.lexeme lexbuf); *)
57         raise (WF_error("Illegal token or character")) 
58       }
59   | _ 
60       { raise Netconversion.Malformed_code }
61
62 and scan_only_xml_decl = parse
63     "<?xml" ws+ pi_string "?>"
64       { scan_pi (Lexing.lexeme lexbuf) scan_xml_pi }
65   | ""
66       { Eof }
67
68 and scan_for_crlf = parse
69   | '\013' '\010'
70       { CharData "\n" }
71   | '\013'
72       { CharData "\n" }
73   | '\010'
74       { CharData "\n" }
75   | [^ '\010' '\013' ]+
76       { CharData (Lexing.lexeme lexbuf) }
77   | eof 
78       { Eof }
79
80 and scan_content_comment = parse
81     "-->"
82       { Comment_end, Content }
83   | "--"
84       { raise (WF_error "Double hyphens are illegal inside comments") }
85   | "-"
86       { Comment_material "-", Content_comment }
87   | character_except_minus+
88       { Comment_material(Lexing.lexeme lexbuf), Content_comment }
89   | eof
90       { Eof, Content_comment }
91   | _
92       { raise Netconversion.Malformed_code }
93
94
95 (* In declarations, comments are always thrown away. *)
96
97 and scan_decl_comment = parse
98     "-->"
99       { Comment_end, Declaration }
100   | "--"
101       { raise (WF_error "Double hyphens are illegal inside comments") }
102   | "-"
103       { Comment_material "", Decl_comment }
104   | character_except_minus+
105       { Comment_material "", Decl_comment }
106   | eof
107       { Eof, Decl_comment }
108   | _
109       { raise Netconversion.Malformed_code }
110
111
112 and scan_document_comment = parse
113     "-->"
114       { Comment_end, Document }
115   | "--"
116       { raise (WF_error "Double hyphens are illegal inside comments") }
117   | "-"
118       { Comment_material "-", Document_comment }
119   | character_except_minus+
120       { Comment_material(Lexing.lexeme lexbuf), Document_comment }
121   | eof
122       { Eof, Document_comment }
123   | _
124       { raise Netconversion.Malformed_code }
125
126 (* ======================================================================
127  * History:
128  * 
129  * $Log$
130  * Revision 1.1  2000/11/17 09:57:32  lpadovan
131  * Initial revision
132  *
133  * Revision 1.4  2000/08/18 20:19:59  gerd
134  *      Comments return different comment tokens.
135  *
136  * Revision 1.3  2000/08/14 22:18:34  gerd
137  *      Bad_character_stream -> Netconversion.Malformed_code
138  *
139  * Revision 1.2  2000/05/29 23:53:12  gerd
140  *      Updated because Markup_* modules have been renamed to Pxp_*.
141  *
142  * Revision 1.1  2000/05/20 20:33:25  gerd
143  *      Initial revision.
144  *
145  * 
146  *)