renaming pi to p-i
svn: r13872
This commit is contained in:
parent
12ffd359a7
commit
7af4a81eff
|
@ -1,11 +1,4 @@
|
|||
#lang scheme/base
|
||||
|
||||
(require "xml.ss")
|
||||
(provide (except-out (all-from-out "xml.ss")
|
||||
pi struct:pi pi? make-pi pi-target-name pi-instruction)
|
||||
(rename-out [pi p-i]
|
||||
[struct:pi struct:p-i]
|
||||
[pi? p-i?]
|
||||
[make-pi make-p-i]
|
||||
[pi-target-name p-i-target-name]
|
||||
[pi-instruction p-i-instruction]))
|
||||
(provide (all-from-out "xml.ss"))
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
(let read-more ()
|
||||
(let ([x (lex in pos)])
|
||||
(cond
|
||||
[(pi? x)
|
||||
[(p-i? x)
|
||||
(let-values ([(lst next) (read-more)])
|
||||
(values (cons x lst) next))]
|
||||
[(comment? x)
|
||||
|
@ -190,7 +190,7 @@
|
|||
(lex-error in pos "expected ; at the end of an entity")))])])
|
||||
(make-entity start (pos) data))))
|
||||
|
||||
; lex-tag-cdata-pi-comment : Input-port (-> Location) -> Start-tag | Element | End-tag | Cdata | Pi | Comment
|
||||
; lex-tag-cdata-pi-comment : Input-port (-> Location) -> Start-tag | Element | End-tag | Cdata | p-i | Comment
|
||||
; pre: the first char is a #\<
|
||||
(define (lex-tag-cdata-pi-comment in pos)
|
||||
(let ([start (pos)])
|
||||
|
@ -215,13 +215,13 @@
|
|||
[else (skip-dtd in pos)
|
||||
(skip-space in)
|
||||
(unless (eq? (peek-char-or-special in) #\<)
|
||||
(lex-error in pos "expected pi, comment, or element after doctype"))
|
||||
(lex-error in pos "expected p-i, comment, or element after doctype"))
|
||||
(lex-tag-cdata-pi-comment in pos)])]
|
||||
[(#\?) (read-char in)
|
||||
(let ([name (lex-name in pos)])
|
||||
(skip-space in)
|
||||
(let ([data (lex-pi-data in pos)])
|
||||
(make-pi start (pos) name data)))]
|
||||
(make-p-i start (pos) name data)))]
|
||||
[(#\/) (read-char in)
|
||||
(let ([name (lex-name in pos)])
|
||||
(skip-space in)
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
(struct external-dtd/system ()) ; XXX needs parent
|
||||
(struct element (name attributes content)) ; XXX needs parent
|
||||
(struct attribute (name value)) ; XXX needs parent
|
||||
(struct pi (target-name instruction)) ; XXX needs parent
|
||||
(struct p-i (target-name instruction)) ; XXX needs parent
|
||||
(struct entity (text)) ; XXX needs parent
|
||||
(contracted
|
||||
[content? (any/c . -> . boolean?)])))
|
||||
|
|
|
@ -54,9 +54,9 @@
|
|||
; Entity = (make-entity Location Location (U Nat Symbol))
|
||||
(define-struct (entity source) (text))
|
||||
|
||||
; Processing-instruction = (make-pi Location Location String String)
|
||||
; Processing-instruction = (make-p-i Location Location String String)
|
||||
; also represents XMLDecl
|
||||
(define-struct (pi source) (target-name instruction))
|
||||
(define-struct (p-i source) (target-name instruction))
|
||||
|
||||
; Comment = (make-comment String)
|
||||
(define-struct comment (text))
|
||||
|
@ -68,4 +68,4 @@
|
|||
(entity? x)
|
||||
(comment? x)
|
||||
(cdata? x)
|
||||
(pi? x))))
|
||||
(p-i? x))))
|
||||
|
|
|
@ -66,9 +66,9 @@
|
|||
; There is no syntax object representation for comments
|
||||
(define (make-comment x) #f)
|
||||
|
||||
; make-pi : src src sym str -> pi
|
||||
; There's not really a syntax object representation for pi's either
|
||||
(define (make-pi from to name val) #f)
|
||||
; make-p-i : src src sym str -> p-i
|
||||
; There's not really a syntax object representation for p-i's either
|
||||
(define (make-p-i from to name val) #f)
|
||||
|
||||
; make-attribute : src src sym str -> attribute
|
||||
(define (make-attribute from to name val)
|
||||
|
@ -126,11 +126,11 @@
|
|||
(define (external-dtd/public-public x)
|
||||
(error 'external-dtd/public-public "expected an external dtd, given ~e" x))
|
||||
|
||||
(define (pi-instruction x)
|
||||
(error 'pi-instruction "expected a pi, given ~e" x))
|
||||
(define (p-i-instruction x)
|
||||
(error 'p-i-instruction "expected a p-i, given ~e" x))
|
||||
|
||||
(define (pi-target-name x)
|
||||
(error 'pi-target-name "expected a pi, given ~e" x))
|
||||
(define (p-i-target-name x)
|
||||
(error 'p-i-target-name "expected a p-i, given ~e" x))
|
||||
|
||||
(define (prolog-dtd x)
|
||||
(error 'prolog-dtd "expected a prolog, given ~e" x))
|
||||
|
@ -181,7 +181,7 @@
|
|||
(define (external-dtd? x) #f)
|
||||
|
||||
(define (prolog? x) #f)
|
||||
(define (pi? x) #f)
|
||||
(define (p-i? x) #f)
|
||||
|
||||
; : tst -> bool
|
||||
(define (pcdata? x)
|
||||
|
@ -203,7 +203,7 @@
|
|||
(struct! external-dtd/system ())
|
||||
(struct! element (name attributes content))
|
||||
(struct! attribute (name value))
|
||||
(struct! pi (target-name instruction))
|
||||
(struct! p-i (target-name instruction))
|
||||
;(struct! source (start stop))
|
||||
(struct! pcdata (string))
|
||||
(struct! cdata (string))
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
(for-each (lambda (x)
|
||||
((cond
|
||||
[(comment? x) write-xml-comment]
|
||||
[(pi? x) write-xml-pi]) x 0 void out)
|
||||
[(p-i? x) write-xml-p-i]) x 0 void out)
|
||||
(newline out))
|
||||
misc))
|
||||
|
||||
|
@ -84,7 +84,7 @@
|
|||
[(cdata? el) write-xml-cdata]
|
||||
[(entity? el) write-xml-entity]
|
||||
[(comment? el) write-xml-comment]
|
||||
[(pi? el) write-xml-pi]
|
||||
[(p-i? el) write-xml-p-i]
|
||||
[else (error 'write-xml-content "received ~e" el)])
|
||||
el over dent out))
|
||||
|
||||
|
@ -136,9 +136,9 @@
|
|||
;; XXX: Different kind of quote is needed, for assume the user includes the <![CDATA[...]]> with proper quoting
|
||||
(write-xml-base (format "~a" (cdata-string cdata)) over dent out))
|
||||
|
||||
;; write-xml-pi : Processing-instruction Nat (Nat Output-Stream -> Void) Output-Stream -> Void
|
||||
(define (write-xml-pi pi over dent out)
|
||||
(write-xml-base (format "<?~a ~a?>" (pi-target-name pi) (pi-instruction pi)) over dent out))
|
||||
;; write-xml-p-i : Processing-instruction Nat (Nat Output-Stream -> Void) Output-Stream -> Void
|
||||
(define (write-xml-p-i p-i over dent out)
|
||||
(write-xml-base (format "<?~a ~a?>" (p-i-target-name p-i) (p-i-instruction p-i)) over dent out))
|
||||
|
||||
;; write-xml-comment : Comment Nat (Nat Output-Stream -> Void) Output-Stream -> Void
|
||||
(define (write-xml-comment comment over dent out)
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
((symbol? x) (true))
|
||||
((exact-nonnegative-integer? x) (true))
|
||||
((comment? x) (true))
|
||||
((pi? x) (true))
|
||||
((p-i? x) (true))
|
||||
((cdata? x) (true))
|
||||
((pcdata? x) (true))
|
||||
((list? x)
|
||||
|
@ -177,7 +177,7 @@
|
|||
(cons (element-name x) (combine atts body)))]
|
||||
[(pcdata? x) (pcdata-string x)]
|
||||
[(entity? x) (entity-text x)]
|
||||
[(or (comment? x) (pi? x) (cdata? x)) x]
|
||||
[(or (comment? x) (p-i? x) (cdata? x)) x]
|
||||
[(document? x) (error 'xml->xexpr "Expected content, given ~e\nUse document-element to extract the content." x)]
|
||||
[(permissive?) x]
|
||||
[else (error 'xml->xexpr "Expected content, given ~e" x)]))))
|
||||
|
@ -213,7 +213,7 @@
|
|||
[(string? x) (make-pcdata 'scheme 'scheme x)]
|
||||
[(or (symbol? x) (exact-nonnegative-integer? x))
|
||||
(make-entity 'scheme 'scheme x)]
|
||||
[(or (comment? x) (pi? x) (cdata? x) (pcdata? x)) x]
|
||||
[(or (comment? x) (p-i? x) (cdata? x) (pcdata? x)) x]
|
||||
[else ;(error 'xexpr->xml "malformed xexpr ~e" x)
|
||||
x]))
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user