]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/DEVEL/pxp/pxp/lexers/pxp_lex_misc.src
Initial revision
[helm.git] / helm / DEVEL / pxp / pxp / lexers / pxp_lex_misc.src
diff --git a/helm/DEVEL/pxp/pxp/lexers/pxp_lex_misc.src b/helm/DEVEL/pxp/pxp/lexers/pxp_lex_misc.src
new file mode 100644 (file)
index 0000000..2a0d29f
--- /dev/null
@@ -0,0 +1,146 @@
+(* $Id$
+ * ----------------------------------------------------------------------
+ *
+ *)
+
+
+{
+  open Pxp_types
+  open Pxp_lexer_types
+
+#insert open_pxp_lex_aux_*.src
+#insert pxp_lex_aux.src
+
+}
+
+#insert pxp_lex_defs_*.def
+
+(* The remaining, smaller lexers *)
+
+rule scan_characters = parse
+  character*
+    { () }
+| eof 
+    { () }
+| _
+    { raise Netconversion.Malformed_code }
+
+
+and scan_xml_pi = parse
+    name ws*
+      { let s = Lexing.lexeme lexbuf in
+       let j = get_name_end s 0 in
+       Pro_name (String.sub s 0 j)
+      }
+  | "=" ws*
+      { Pro_eq }
+  | "'" character_except_apos* "'" ws+
+      { let s = Lexing.lexeme lexbuf in
+       let j = String.index_from s 1 '\'' in
+       Pro_string (String.sub s 1 (j-1))
+      }
+  | "'"
+      { raise (WF_error ("Cannot find the second quotation mark"))
+      }
+  | '"' character_except_quot* '"' ws+
+      { let s = Lexing.lexeme lexbuf in
+       let j = String.index_from s 1 '"' in
+       Pro_string (String.sub s 1 (j-1))
+      }
+  | '"'
+      { raise (WF_error ("Cannot find the second quotation mark"))
+      }
+  | eof
+      { Pro_eof }
+  | character
+      { (* prerr_endline (Lexing.lexeme lexbuf); *)
+       raise (WF_error("Illegal token or character")) 
+      }
+  | _ 
+      { raise Netconversion.Malformed_code }
+
+and scan_only_xml_decl = parse
+    "<?xml" ws+ pi_string "?>"
+      { scan_pi (Lexing.lexeme lexbuf) scan_xml_pi }
+  | ""
+      { Eof }
+
+and scan_for_crlf = parse
+  | '\013' '\010'
+      { CharData "\n" }
+  | '\013'
+      { CharData "\n" }
+  | '\010'
+      { CharData "\n" }
+  | [^ '\010' '\013' ]+
+      { CharData (Lexing.lexeme lexbuf) }
+  | eof 
+      { Eof }
+
+and scan_content_comment = parse
+    "-->"
+      { Comment_end, Content }
+  | "--"
+      { raise (WF_error "Double hyphens are illegal inside comments") }
+  | "-"
+      { Comment_material "-", Content_comment }
+  | character_except_minus+
+      { Comment_material(Lexing.lexeme lexbuf), Content_comment }
+  | eof
+      { Eof, Content_comment }
+  | _
+      { raise Netconversion.Malformed_code }
+
+
+(* In declarations, comments are always thrown away. *)
+
+and scan_decl_comment = parse
+    "-->"
+      { Comment_end, Declaration }
+  | "--"
+      { raise (WF_error "Double hyphens are illegal inside comments") }
+  | "-"
+      { Comment_material "", Decl_comment }
+  | character_except_minus+
+      { Comment_material "", Decl_comment }
+  | eof
+      { Eof, Decl_comment }
+  | _
+      { raise Netconversion.Malformed_code }
+
+
+and scan_document_comment = parse
+    "-->"
+      { Comment_end, Document }
+  | "--"
+      { raise (WF_error "Double hyphens are illegal inside comments") }
+  | "-"
+      { Comment_material "-", Document_comment }
+  | character_except_minus+
+      { Comment_material(Lexing.lexeme lexbuf), Document_comment }
+  | eof
+      { Eof, Document_comment }
+  | _
+      { raise Netconversion.Malformed_code }
+
+(* ======================================================================
+ * History:
+ * 
+ * $Log$
+ * Revision 1.1  2000/11/17 09:57:32  lpadovan
+ * Initial revision
+ *
+ * Revision 1.4  2000/08/18 20:19:59  gerd
+ *     Comments return different comment tokens.
+ *
+ * Revision 1.3  2000/08/14 22:18:34  gerd
+ *     Bad_character_stream -> Netconversion.Malformed_code
+ *
+ * Revision 1.2  2000/05/29 23:53:12  gerd
+ *     Updated because Markup_* modules have been renamed to Pxp_*.
+ *
+ * Revision 1.1  2000/05/20 20:33:25  gerd
+ *     Initial revision.
+ *
+ * 
+ *)