]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/pxp/pxp/lexers/pxp_lex_declaration.src
Initial revision
[helm.git] / helm / DEVEL / pxp / pxp / lexers / pxp_lex_declaration.src
1 (* $Id$
2  * ----------------------------------------------------------------------
3  *
4  *)
5
6
7 {
8   open Pxp_types
9   open Pxp_lexer_types
10
11 #insert pxp_lex_aux.src
12
13 #insert open_pxp_lex_aux_*.src
14 #insert open_pxp_lex_misc_*.src
15
16 }
17
18 #insert pxp_lex_defs_*.def
19
20 (* scan_declaration: after "[" in DTD until matching "]" *)
21
22 rule scan_declaration = parse
23     ws+
24       { tok_Ignore__Declaration }
25   | '%' name ';'
26       { let s = Lexing.lexeme lexbuf in
27         (PERef (String.sub s 1 (String.length s - 2))), Declaration }
28   | '%'
29       { tok_Percent__Declaration }
30   | '&' 
31       { raise(WF_error("References to general entities not allowed in DTDs")) }
32   | name
33       { Name (Lexing.lexeme lexbuf), Declaration }
34   | nmtoken
35       { Nametoken (Lexing.lexeme lexbuf), Declaration }
36   | '+'
37       { tok_Plus__Declaration }
38   | '*'
39       { tok_Star__Declaration }
40   | '|'
41       { tok_Bar__Declaration }
42   | ','
43       { tok_Comma__Declaration }
44   | '?'
45       { tok_Qmark__Declaration }
46   | '('
47       { tok_Lparen__Declaration }
48   | ")+" 
49       { tok_RparenPlus__Declaration }
50   | ")*" 
51       { tok_RparenStar__Declaration }
52   | ")?"
53       { tok_RparenQmark__Declaration }
54   | ')'
55       { tok_Rparen__Declaration }
56   | "#REQUIRED"
57       { tok_Required__Declaration }
58   | "#IMPLIED"
59       { tok_Implied__Declaration }
60   | "#FIXED"
61       { tok_Fixed__Declaration }
62   | "#PCDATA"
63       { tok_Pcdata__Declaration }
64   | "<!ELEMENT"
65       { tok_Decl_element__Declaration }
66   | "<!ATTLIST"
67       { tok_Decl_attlist__Declaration }
68   | "<!ENTITY"
69       { tok_Decl_entity__Declaration }
70   | "<!NOTATION"
71       { tok_Decl_notation__Declaration }
72   | "<!--"
73       { Comment_begin, Decl_comment }
74   | "<!["
75       { tok_Conditional_begin__Declaration }
76   | "]]>"
77       { tok_Conditional_end__Declaration }
78   | "["
79       { tok_Conditional_body__Declaration }
80
81   (* TODO: PIs modified *) 
82
83   | "<?" pi_string "?>"
84       { scan_pi (Lexing.lexeme lexbuf) scan_xml_pi, Declaration }
85   | "<?"
86       { raise (WF_error ("Illegal processing instruction")) }
87   | '"' [^ '"']* '"'
88       { let s = Lexing.lexeme lexbuf in
89         (* Check that characters are well-formed: *)
90         ignore(scan_characters (Lexing.from_string s));
91         (Unparsed_string (String.sub s 1 (String.length s - 2))), Declaration }
92   | '"'
93       { raise (WF_error ("Cannot find the second quotation mark"))
94       }
95   | "'" [^ '\'']* "'"
96       { let s = Lexing.lexeme lexbuf in
97         (* Check that characters are well-formed: *)
98         ignore(scan_characters (Lexing.from_string s));
99         (Unparsed_string (String.sub s 1 (String.length s - 2))), Declaration }
100   | "'"
101       { raise (WF_error ("Cannot find the second quotation mark"))
102       }
103   | '>'
104       { tok_Decl_rangle__Declaration }
105   | ']'
106       { tok_Dtd_end__Document_type }
107   | eof
108       { tok_Eof__Declaration }
109   | "<!"
110       { raise (WF_error "Declaration either malformed or not allowed in this context") 
111       }
112   | character
113       { raise (WF_error("Illegal token or character")) }
114   | _
115       { raise Netconversion.Malformed_code }
116
117
118 (* ======================================================================
119  * History:
120  * 
121  * $Log$
122  * Revision 1.1  2000/11/17 09:57:32  lpadovan
123  * Initial revision
124  *
125  * Revision 1.4  2000/08/18 20:19:59  gerd
126  *      Comments return different comment tokens.
127  *
128  * Revision 1.3  2000/08/14 22:18:34  gerd
129  *      Bad_character_stream -> Netconversion.Malformed_code
130  *
131  * Revision 1.2  2000/05/29 23:53:12  gerd
132  *      Updated because Markup_* modules have been renamed to Pxp_*.
133  *
134  * Revision 1.1  2000/05/20 20:33:25  gerd
135  *      Initial revision.
136  *
137  * 
138  *)