跳转到内容

Rebol 编程/build-tag

来自维基教科书,开放的书籍,开放的世界
BUILD-TAG values 

从一个组合的块生成一个标签。

BUILD-TAG 是一个函数值。

  • values -- 要评估的括号块和其他数据。 (类型:块)

源代码

[编辑 | 编辑源代码]
build-tag: func [
    "Generates a tag from a composed block." 
    values [block!] "Block of parens to evaluate and other data." 
    /local tag value-rule xml? name attribute value
][
    tag: make string! 7 * length? values 
    value-rule: [
        set value issue! (value: mold value) 
        | set value file! (value: replace/all copy value #" " "%20") 
        | set value any-type!
    ] 
    xml?: false 
    parse compose values [
        [
            set name ['?xml (xml?: true) | word!] (append tag name) 
            any [
                set attribute [word! | url!] value-rule (
                    repend tag [#" " attribute {="} value {"}]
                ) 
                | value-rule (repend tag [#" " value])
            ] 
            end (if xml? [append tag #"?"])
        ] 
        | 
        [set name refinement! to end (tag: mold name)]
    ] 
    to tag! tag
]
华夏公益教科书