From fc42fe56a57eace2dbdb31574c2e161f0eacf839 Mon Sep 17 00:00:00 2001 From: Ludovic Court`es Date: Wed, 15 Jun 2005 13:00:39 +0000 Subject: Initial import of Skribe 1.2d. Initial import of Skribe 1.2d. git-archimport-id: lcourtes@laas.fr--2004-libre/skribilo--devel--1.2--base-0 --- src/bigloo/xml.scm | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 src/bigloo/xml.scm (limited to 'src/bigloo/xml.scm') diff --git a/src/bigloo/xml.scm b/src/bigloo/xml.scm new file mode 100644 index 0000000..d4c662e --- /dev/null +++ b/src/bigloo/xml.scm @@ -0,0 +1,92 @@ +;*=====================================================================*/ +;* serrano/prgm/project/skribe/src/bigloo/xml.scm */ +;* ------------------------------------------------------------- */ +;* Author : Manuel Serrano */ +;* Creation : Mon Sep 1 12:08:39 2003 */ +;* Last change : Mon May 17 10:14:24 2004 (serrano) */ +;* Copyright : 2003-04 Manuel Serrano */ +;* ------------------------------------------------------------- */ +;* XML fontification */ +;*=====================================================================*/ + +;*---------------------------------------------------------------------*/ +;* The module */ +;*---------------------------------------------------------------------*/ +(module skribe_xml + + (include "new.sch") + + (import skribe_types + skribe_lib + skribe_resolve + skribe_eval + skribe_api + skribe_param + skribe_source) + + (export xml)) + +;*---------------------------------------------------------------------*/ +;* xml ... */ +;*---------------------------------------------------------------------*/ +(define xml + (new language + (name "xml") + (fontifier xml-fontifier) + (extractor #f))) + +;*---------------------------------------------------------------------*/ +;* xml-fontifier ... */ +;*---------------------------------------------------------------------*/ +(define (xml-fontifier s) + (let ((g (regular-grammar () + ((: #\; (in "") + ;; italic comments + (let ((str (split-string-newline (the-string)))) + (append (map (lambda (s) + (if (eq? s 'eol) + "\n" + (new markup + (markup '&source-line-comment) + (body s)))) + str) + (ignore)))) + ((+ (or #\Newline #\Space)) + ;; separators + (let ((str (the-string))) + (cons str (ignore)))) + ((or (: #\< (+ (out #\> #\space #\tab #\Newline))) #\>) + ;; markup + (let ((str (the-string))) + (let ((c (new markup + (markup '&source-module) + (body (the-string))))) + (cons c (ignore))))) + ((+ (out #\< #\> #\Space #\Tab #\= #\")) + ;; regular text + (let ((string (the-string))) + (cons string (ignore)))) + ((or (: "\"" (* (or (out #a000 #\\ #\") (: #\\ all))) "\"") + (: "\'" (* (or (out #a000 #\\ #\') (: #\\ all))) "\'")) + ;; strings + (let ((str (split-string-newline (the-string)))) + (append (map (lambda (s) + (if (eq? s 'eol) + "\n" + (new markup + (markup '&source-string) + (body s)))) + str) + (ignore)))) + ((in "\"=") + (let ((str (the-string))) + (cons str (ignore)))) + (else + (let ((c (the-failure))) + (if (eof-object? c) + '() + (error "source(xml)" "Unexpected character" c))))))) + (with-input-from-string s + (lambda () + (read/rp g (current-input-port)))))) + -- cgit v1.2.3