Download presentation

Presentation is loading. Please wait.

Published byVanessa Snyder Modified over 4 years ago

1
1 The TXL Programming Language (3) Mariano Ceccato FBK Fondazione Bruno Kessler ceccato@fbk.eu

2
2 Rules and functions function 2To42 replace [number] 2 by 42 end function rule 2To42 replace [number] 2 by 42 end rule 2 ----> 42 3 2 6 2 78 4 2 2 ----> 42 3 2 6 2 78 4 2 ----> 42 6 42 78 4 42 Rules search the pattern!

3
3 Searching functions function 2To42 replace * [number] 2 by 42 end function Note: change only * 2 ----> 42 3 2 6 2 78 4 2 ----> 42 6 2 78 4 2

4
4 Deconstruct and searching functions rule vectorizeScalarAssignments replace [repeat statement] C1 [statement] C2 [statement] rest [repeat statement] deconstruct C1 V1 [var] := E1 [expr]; deconstruct C2 V2 [var] := E2 [expr]; where not E2 [reference V1] where not E1 [reference V2] construct Passign [statement] := ; by Passign rest end rule function reference V [variable] match * [variable] V end function Example: x:=x+1; y:=t+4; := ; x:=x+1; y:=x+4; No!

5
5 Extreme programming and TXL Txl is ideally suited to extreme programming (XP). Begin with an explicit set of testcases, and treat these as the specification of your transformation. Program your transformation incrementally, as a sequence of successive approximations to the final result. Actually run your partial transforms against the testcases to keep track of your progress and test as you go. Always write the simplest possible transformation rules to achieve the result. Begin each rule with an explicit example pattern and replacement, and generalize from there.

6
6 Example: XP and TXL (1) Step 1 – start with an explicit concrete example case. rule convertAddIJK replace [statement] add I to J giving K % COBOL by K = I + J; % PL/I end rule Step 2 – generalize by introducing pattern variables. rule convertAddGiving replace [statement] add I [Var] to J [Var] giving K [Var] by K = I + J; end rule N.B. Test at every stage

7
7 Example: XP and TXL (2) Step 3 – Add new cases. rule convertAddNoGiving replace [statement] add I [Var] to J [Var] by J = I + J; end rule Step 4 – Integrate different cases. rule convertAdds replace [statement] AddStatement [cobol_add_statement] by AddStatement [convertAddNoGiving] [convertAddGiving] end rule N.B. Test at every stage

8
8 Exercises - Add to the commands language: 1)If cond then statements endIf 2)Case cond1->statement1 … condN->statementN endCase - Transform a list of contiguos if-statements in a case- statement If x>1 then x:=x+1 endIf If x=1 then x=0 endIf If x<1 then x:=x-1 endIf case x>1 -> x:=x+1; x=1 -> x=0; x x:=x-1; end case

9
9 Homework - Reading The Guided Tour (website www.txl.ca).www.txl.ca - Transform a case-statement in a list of contiguos if-statements. case x>1 -> x:=x+1; x=1 -> x=0; x x:=x-1; end case If x>1 then x:=x+1 endIf If x=1 then x=0 endIf If x<1 then x:=x-1 endIf

Similar presentations

Presentation is loading. Please wait....

OK

The Software Development Process

The Software Development Process

© 2018 SlidePlayer.com Inc.

All rights reserved.

To ensure the functioning of the site, we use **cookies**. We share information about your activities on the site with our partners and Google partners: social networks and companies engaged in advertising and web analytics. For more information, see the Privacy Policy and Google Privacy & Terms.
Your consent to our cookies if you continue to use this website.

Ads by Google

Ppt on network switching systems Ppt on peak load pricing examples Ppt on singular plural for grade 1 Ppt on milk products for students Ppt on combination of resistances training Download ppt on electric current and circuits Ppt on 2nd green revolution Download ppt on networking Ppt on ip addresses class and range Ppt on mass media services