]> gitweb.factorcode.org Git - factor.git/blob - basis/html/templates/chloe/syntax/syntax.factor
264559e2d8c04b296e56adef7e80b3a1dc08a1f6
[factor.git] / basis / html / templates / chloe / syntax / syntax.factor
1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors sequences combinators kernel namespaces classes.tuple
4 assocs splitting words arrays memoize parser lexer io io.files
5 io.encodings.utf8 io.streams.string unicode.case mirrors fry math urls
6 multiline xml xml.data xml.writer xml.syntax html.components
7 html.templates ;
8 IN: html.templates.chloe.syntax
9
10 SYMBOL: tags
11
12 tags [ H{ } clone ] initialize
13
14 : define-chloe-tag ( name quot -- ) swap tags get set-at ;
15
16 SYNTAX: CHLOE:
17     scan-token parse-definition define-chloe-tag ;
18
19 CONSTANT: chloe-ns "http://factorcode.org/chloe/1.0"
20
21 : chloe-name? ( name -- ? )
22     url>> chloe-ns = ;
23
24 XML-NS: chloe-name http://factorcode.org/chloe/1.0
25
26 : required-attr ( tag name -- value )
27     [ nip ] [ chloe-name attr ] 2bi
28     [ ] [ " attribute is required" append throw ] ?if ;
29
30 : optional-attr ( tag name -- value )
31     chloe-name attr ;