-
15
pages
-
English
-
Documents
Description
Tom TutorialPierre-Etienne Moreau(with Julien Guyon, Antoine Reilles and Anne-Claire Lonchamp)July 29, 2005This tutorial contains information for Tom version 2.2.This tutorial also exists in Postscript or pdf.TOM is a Pattern Matching Preprocessor that aims at integrating term rewriting and pattern match-ing facilities into imperative languages such as C and Java. The Tom web page: http://tom.loria.frcontains many information about the system.This tutorial introduces many concepts relatedtoTom,fromsimpletocomplex ones. In Section ??,the “Hello Word” example is introduced to illustrate string pattern matching capabilities. In Section??,Xml manipulation is illustrated by modeling a platform for Privacy Preferences Project (P3P). In Sec-tion ??,weshowhowtosortanXml document, using the associative pattern matching provided byTom. In Section ??, algebraic abstract data-types are introduced via the Vas notation. In Section ??,one of the key possibilities of Tom are introduced: how to define a mapping from abstract data-types toa concrete data-types.1 The “Hello World” exampleOne of the most simple Tom program is the following:public class HelloWorld {%include { string.tom }public String getWord(String t) {%match(String t) {"World" -> { return "World";}_ -> { "Unknown"; }}}public final static void main(String[] args) {HelloWorld o = new HelloWorld();System.out.println("Hello " + o.getWord("World"));}}The %include { string.tom } construct imports ...
-
Publié par
-
Langue
English