tcllib/page: For Transformations on Text

风行水上 @ 2014-01-17 15:42:45
标签:

    Tcllib里的page其实不是一个package,而是一个命令行工具,用于各种文本格式之间的转换。

    基本上看下面的例子就有点概念了

    set tcllib = /some/path/to/tcllib
    setenv TCLLIBPATH   $tcllib/modules
    setenv PAGE_PLUGINS $tcllib/modules/page/plugins
    
    echo 'root {} {} a 0 {} d 3 {} e 3 {} b 0 {} c 0 {}' | \
      $tcllib/apps/page -r treeser -w tree
    

    上面的例子会输出下面的内容:

    info [Serialized Tree] Reading grammar from stdin
    info [Tree Dump] Writing to stdout
    root <>
      a <>
        d <>
        e <>
      b <>
      c <>
    

    输入的文本是struct::tree的表示,输出的是另一种形式的tree.

    所表示的struct::tree如下:

                 +- d
           +- a -+
     root -+- b  +- e
           +- c
    
    标签:

      分享到:
      comments powered by Disqus

      28/32ms