| TWEAST: a simple and effective technique to implement concrete-syntax AST rewriting using partial parsing |
| Full text |
Pdf
(502 KB)
|
Source
|
Symposium on Applied Computing
archive
Proceedings of the 2009 ACM symposium on Applied Computing
table of contents
Honolulu, Hawaii
SESSION: Programming languages track
table of contents
Pages 1924-1929
Year of Publication: 2009
ISBN:978-1-60558-166-8
|
|
Authors
|
|
Akim Demaille
|
EPITA Research and Development Laboratory (LRDE), Le Kremlin-Bicêtre, France
|
|
Roland Levillain
|
EPITA Research and Development Laboratory (LRDE), Le Kremlin-Bicêtre, France
|
|
Benoît Sigoure
|
EPITA Research and Development Laboratory (LRDE), Le Kremlin-Bicêtre, France
|
|
| Sponsor |
|
| Publisher |
|
| Bibliometrics |
Downloads (6 Weeks): 14, Downloads (12 Months): 34, Citation Count: 0
|
|
|
ABSTRACT
Abstract Syntax Trees (ASTs) are commonly used to represent an input/output program in compilers and language processing tools. Many of the tasks of these tools consist in generating and rewriting ASTs. Such an approach can become tedious and hard to maintain for complex operations, namely program transformation, optimization, instrumentation, etc. On the other hand, concrete syntax provides a natural and simpler representation of programs, but it is not usually available as a direct feature of the aforementioned tools. We propose a simple technique to implement AST generation and rewriting in general purpose languages using concrete syntax. Our approach relies on extensions made in the scanner and the parser and the use of objects supporting partial parsing called Texts With Embedded Abstract Syntax Trees (TWEASTs). A compiler for a simple language (Tiger) written in C++ serves as an example, featuring transformations in concrete syntax: syntactic desugaring, optimization, code instrumentation such as bounds-checking, etc. Extensions of this technique to provide a full-fledged concrete-syntax rewriting framework are presented as well.
REFERENCES
Note: OCR errors may be found in this Reference List extracted from the full text article. ACM has opted to expose the complete List rather than only correct and linked references.
| |
1
|
|
| |
2
|
E. Balland, P. Brauner, R. Kopetz, P.-E. Moreau, and A. Reilles. Tom: Piggybacking rewriting on Java. In Proceedings of the 18th Conference on Rewriting Techniques and Applications, Lecture Notes in Computer Science. Springer-Verlag, 2007.
|
 |
3
|
|
| |
4
|
R. Corbett, R. Stallman, and P. Hilfinger. Bison: GNU LALR(1) and GLR parser generator, 2003. http://www.gnu.org/software/bison/bison.html.
|
 |
5
|
|
| |
6
|
A. Demaille. The Tiger Compiler Reference Manual. EPITA Research and Development Laboratory (LRDE), 14--16 rue Voltaire, FR-94270 Le Kremlin-Bicêtre, France, 2007. http://www.lrde.epita.fr/~akim/ccmp/tiger.pdf.
|
| |
7
|
|
| |
8
|
|
| |
9
|
A. Leung. Prop: A C++-based pattern matching language. Technical report, Courant Institute of Mathematical Sciences, 1996.
|
| |
10
|
|
| |
11
|
V. Paxson, W. Estes, and J. Millaway. The Flex Manual. The Flex Project, September 2007. http://flex.sourceforge.net/manual/index.html.
|
| |
12
|
E. Visser. A family of syntax definition formalisms. In M. G. J. van den Brand et al., editors, ASF+SDF'95. A Workshop on Generating Tools from Algebraic Specifications, pages 89--126. Technical Report P9504, Programming Research Group, University of Amsterdam, May 1995.
|
| |
13
|
E. Visser. Scannerless generalized-LR parsing. Technical Report P9707, Programming Research Group, University of Amsterdam, July 1997.
|
| |
14
|
|
| |
15
|
E. Visser. Program transformation with Stratego/XT: Rules, strategies, tools, and systems in StrategoXT-0.9. In C. Lengauer et al., editors, Domain-Specific Program Generation, volume 3016 of Lecture Notes in Computer Science, pages 216--238. Springer-Verlag, June 2004.
|
| |
16
|
R. Weatherley. Treecc, the Tree Compiler-Compiler. http://www.southern-storm.com.au/treecc.html, 2002.
|
|