- TXL (programming language)
Infobox programming language
name = TXL
logo =
paradigm =Pattern-matching andTerm-rewriting
designer =Charles Halpern-Hamu andJames Cordy
developer =Charles Halpern-Hamu andJames Cordy TXL is a special-purpose
programming language originally designed byCharles Halpern-Hamu andJames Cordy at theUniversity of Toronto in 1985. The acronym "TXL" originally stood for "Turing eXtender Language" after the language's original purpose, the specification and rapid prototyping of variants and extensions of the Turing programming language, but no longer has any meaningful interpretation.Modern TXL is specifically designed for creating, manipulating and rapidly prototyping language-based descriptions, tools and applications using source transformation. It is a hybrid functional / rule-based language using first order functional programming at the higher level and term rewriting at the lower level. The
formal semantics and implementation of TXL are based on formalterm rewriting , but the term structures are largely hidden from the user due to the example-like style of pattern specification.Each TXL program has two components, a description of the source structures to be transformed, specified as a BNF-like
grammar in context-free ambiguous form, and a set of structural source transformation rules, specified using pattern / replacement pairs combined using first order functional programming. TXL is designed to allow explicit programmer control over the interpretation, application, order and backtracking of both parsing and rewriting rules, allowing for expression of a wide range of grammar-based techniques such as agile parsing.The first component does the same job as
Lex does but on a higher level, i.e It extracts the tree representation of the input expression usingPattern-matching . The second component usesTerm-rewriting in a manner similar toYacc to produce the transformed output.TXL is most commonly used in software analysis and reengineering tasks such as design recovery, and in rapid prototyping of new
programming languages and dialects.Examples
BubbleSort [http://star.itc.it/ricca/swat/SORT/Sort.Txl]
%Syntax specification define program [repeat number] end define
%Transformation rules rule main replace $ [repeat number] N1 [number] N2 [number] Rest [repeat number] where N1 [> N2] by N2 N1 Rest end rule
Factorial [http://star.itc.it/ricca/swatII/Esercizi/factorial.txl]
%Syntax specification define program [number] end define
%Transformation rules function main replace [program] p [number] by p [fact] [fact0] end function
function fact replace [number] n [number] construct nMinusOne [number] n [- 1] where n [> 1] construct factMinusOne [number] nMinusOne [fact] by n [* factMinusOne] end function function fact0 replace [number] 0 by 1 end function
References
* [http://portal.acm.org/citation.cfm?id=114627.115074 J.R. Cordy, C.D. Halpern and E. Promislow, 1991. TXL: A Rapid Prototyping System for Programming Language Dialects. Computer Languages 16,1 (January 1991), 97-107.]
* [http://portal.acm.org/citation.cfm?id=1149672 J.R. Cordy, 2006. The TXL Source Transformation Language. Science of Computer Programming 61,3 (August 2006), 190-210.]See also
*
Turing (programming language)
* Refal (programming language)External links
* [http://www.txl.ca/ TXL website]
Wikimedia Foundation. 2010.