1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 IN: html.templates.chloe.syntax
4 USING: accessors kernel sequences combinators kernel namespaces
5 classes.tuple assocs splitting words arrays memoize parser lexer
6 io io.files io.encodings.utf8 io.streams.string
7 unicode.case mirrors fry math urls
8 multiline xml xml.data xml.writer xml.syntax
14 tags [ H{ } clone ] initialize
16 : define-chloe-tag ( name quot -- ) swap tags get set-at ;
19 scan parse-definition define-chloe-tag ; parsing
21 CONSTANT: chloe-ns "http://factorcode.org/chloe/1.0"
23 : chloe-name? ( name -- ? )
26 XML-NS: chloe-name http://factorcode.org/chloe/1.0
28 : required-attr ( tag name -- value )
29 [ nip ] [ chloe-name attr ] 2bi
30 [ ] [ " attribute is required" append throw ] ?if ;
32 : optional-attr ( tag name -- value )