Advertisement

Translation of Tree-Processing Programs into Stream-Processing Programs Based on Ordered Linear Type

  • Koichi Kodama
  • Kohei Suenaga
  • Naoki Kobayashi
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3302)

Abstract

There are two ways to write a program for manipulating tree-structured data such as XML documents and S-expressions: One is to write a tree-processing program focusing on the logical structure of the data and the other is to write a stream-processing program focusing on the physical structure. While tree-processing programs are easier to write than stream-processing programs, tree-processing programs are less efficient in memory usage since they use trees as intermediate data. Our aim is to establish a method for automatically translating a tree-processing program to a stream-processing one in order to take the best of both worlds. We define a programming language for processing binary trees and a type system based on ordered linear type, and show that every well-typed program can be translated to an equivalent stream-processing program.

Keywords

Binary Tree Type System Input Stream Source Language Source Program 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Aho, A.V., Seth, R., Ullman, J.D.: Compilers. Addison-Wesley Pub. Co., Reading (1986)Google Scholar
  2. 2.
    Baker, H.G.: Lively linear lisp – look ma, no garbage! ACM SIGPLAN Notices 27(8), 89–98 (1992)CrossRefGoogle Scholar
  3. 3.
    Bray, T., Paoli, J., Sperberg-McQueen, C.M., Maler, E.: Extensible markup language (XML) 1.0. 2nd edn. Technical report, World Wide Web Consortium (October 2000), http://www.w3.org/TR/REC-xml
  4. 4.
    Ganzinger, H., Giegerich, R.: Attribute coupled grammars. In: Proceedings of the ACM SIGPLAN 1984 Symposium on Compiler Construction (1984)Google Scholar
  5. 5.
    Hosoya, H., Pierce, B.C.: XDuce: A typed XML processing language. ACM Transactions on Internet Technology (TOIT) 3(2), 117–148 (2003)CrossRefGoogle Scholar
  6. 6.
    Igarashi, A., Kobayashi, N.: Resource usage analysis. In: Proceedings of ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 331–342 (2002)Google Scholar
  7. 7.
    Kodama, K., Suenaga, K., Kobayashi, N.: Translation of tree-processing programs into stream-processing programs based on ordered linear type (Full paper), Available from: http://www.yl.is.s.u-tokyo.ac.jp/~kohei/doc/paper/translation.pdf
  8. 8.
    Meijer, E., Fokkinga, M., Paterson, R.: Functional programming with bananas, lenses, envelopes and barbed wire. In: Hughes, J. (ed.) FPCA 1991. LNCS, vol. 523, pp. 124–144. Springer, Heidelberg (1991)CrossRefGoogle Scholar
  9. 9.
    Nakano, K.: Composing stack-attributed tree transducers. Technical Report METR–2004–01, Department of Mathematical Informatics, University of Tokyo, Japan (2004)Google Scholar
  10. 10.
    Nakano, K., Nishimura, S.: Deriving event-based document transformers from tree-based specifications. In: van den Brand, M., Parigot, D. (eds.) Electronic Notes in Theoretical Computer Science, vol. 44. Elsevier Science Publishers, Amsterdam (2001)Google Scholar
  11. 11.
    Petersen, L., Harper, R., Crary, K., Pfenning, F.: A type theory for memory allocation and data layout. In: Proceedings of the 30th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (2003)Google Scholar
  12. 12.
    Polakow, J.: Ordered linear logic and applications. PhD thesis, Carnegie Mellon University, Available as Technical Report CMU-CS-01-152 (June 2001)Google Scholar
  13. 13.
    Turner, D.N., Wadler, P., Mossin, C.: Once upon a type. In: Proceedings of Functional Programming Languages and Computer Architecture, San Diego, California, pp. 1–11 (1995)Google Scholar
  14. 14.
    Wadler, P.: Deforestation: Transforming programs to eliminate trees. In: Ganzinger, H. (ed.) ESOP 1988. LNCS, vol. 300, pp. 344–358. Springer, Heidelberg (1988)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2004

Authors and Affiliations

  • Koichi Kodama
    • 1
  • Kohei Suenaga
    • 2
  • Naoki Kobayashi
    • 1
  1. 1.Tokyo Institute of TechnologyJapan
  2. 2.University of TokyoJapan

Personalised recommendations