factor/basis/html/templates/chloe/syntax/syntax.factor

32 lines
925 B
Factor
Raw Normal View History

! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors sequences combinators kernel namespaces classes.tuple
assocs splitting words arrays memoize parser lexer io io.files
io.encodings.utf8 io.streams.string unicode mirrors fry math urls
multiline xml xml.data xml.writer xml.syntax html.components
html.templates ;
IN: html.templates.chloe.syntax
SYMBOL: tags
tags [ H{ } clone ] initialize
2008-06-02 16:00:03 -04:00
: define-chloe-tag ( name quot -- ) swap tags get set-at ;
SYNTAX: CHLOE:
scan-token parse-definition define-chloe-tag ;
CONSTANT: chloe-ns "http://factorcode.org/chloe/1.0"
2009-01-28 18:49:21 -05:00
: chloe-name? ( name -- ? )
url>> chloe-ns = ;
XML-NS: chloe-name http://factorcode.org/chloe/1.0
: required-attr ( tag name -- value )
[ nip ] [ chloe-name attr ] 2bi
[ ] [ " attribute is required" append throw ] ?if ;
: optional-attr ( tag name -- value )
2009-01-28 18:49:21 -05:00
chloe-name attr ;