跳轉到內容

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
]
華夏公益教科書