X-Git-Url: http://svarog.pmf.uns.ac.rs/gitweb/?p=mjc2wsl.git;a=blobdiff_plain;f=src-wsl%2Ftransf-exp.wsl;h=aeb3b32e1ea34491cf4bce4ac3d61c313785e8e3;hp=6e501370613d4eae93347a723f8813a3e7e18da1;hb=6b8431d69d76fec418cded9d74e4b3e7ee2ea624;hpb=34f67954f6c40e028250b6c0ac8367b811202740 diff --git a/src-wsl/transf-exp.wsl b/src-wsl/transf-exp.wsl index 6e50137..aeb3b32 100755 --- a/src-wsl/transf-exp.wsl +++ b/src-wsl/transf-exp.wsl @@ -1,5 +1,5 @@ C:" -Copyright (C) 2012 Doni Pracner http://perun.dmi.rs/pracner +Copyright (C) 2012,2014 Doni Pracner http://perun.dmi.rs/pracner This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public @@ -19,7 +19,9 @@ License along with this program. If not, see =========================================================="; C:"Automatic transformation tool for simplification of WSL"; -C:"code automaticaly translated from assembly using asm2wsl."; +C:"code automaticaly translated from a low level language."; +C:"such as assembly or bytecode generated by our translators."; + C:"experimental version"; C:"set the following so that Action Systems are not automaticaly treated as regular"; @@ -75,55 +77,7 @@ MW_PROC @Process_Prog() == SKIP END; -BEGIN -VAR< prog := < >, inifilename := "transf.ini", - filename:="", file := "", inifile:= "" ->: -IF @File_Exists?(inifilename) THEN - inifile := @Open_Input_File(inifilename); - filename := @Read_Line(inifile); - WHILE NOT @EOF?(filename) DO - IF @File_Exists?(filename) THEN - PRINT(""); - @New_Program(@Parse_File(filename, T_Statements)); - PRINT("Processing: ", filename); - prog := @Program; - @Process_Prog(); - Get_New_Name(VAR filename); - @PP_Item(@Program, 80, filename); - PRINT(""); - PRINT(filename); - Prog_Stat_Comp(prog, @Program); - PRINT("") - FI; - filename := @Read_Line(inifile) - OD; - @Close_Input_Port(inifile); -ELSE - PRINT("ini file (",inifilename,") not found.", - " it should contain a list of filenames to be converted"); - PRINT("you can input a filename now:"); - filename := @Read_Line(Standard_Input_Port); - IF @File_Exists?(filename) THEN - @New_Program(@Parse_File(filename, T_Statements)); - @Process_Prog(); - Get_New_Name(VAR filename); - @PP_Item(@Program, 80, filename) - FI; -FI -ENDVAR -WHERE - -PROC Prog_Stat(Pro VAR)== - PRINT ("Mc ", @McCabe(Pro)); - PRINT ("Statements ", @Stat_Count(Pro)); - PRINT ("Control/data Flow ", @CFDF_Metric(Pro)); - PRINT ("Size(nodes) ", @Total_Size(Pro)); - PRINT ("Struct ", @Struct_Metric(Pro)); - SKIP -END - -PROC Prog_Stat_Comp(Pro, After VAR)== +MW_PROC @Prog_Stat_Comp(Pro, After VAR)== VAR < ma := 0, mb :=1 > : ma := @McCabe(Pro); mb := @McCabe(After); @@ -142,13 +96,71 @@ PROC Prog_Stat_Comp(Pro, After VAR)== PRINT ("Struct ", ma, " ",mb, " ",(mb-ma)); SKIP ENDVAR -END +END; -PROC Get_New_Name(VAR str) == +MW_PROC @Get_New_Name(VAR str) == IF @Ends_With?(str, ".wsl") THEN str := SUBSTR(str, 0, SLENGTH(str)-4) FI; str := str ++ "_t.wsl" +END; + +MW_PROC @Process_File(filename) == + IF @File_Exists?(filename) THEN + @New_Program(@Parse_File(filename, T_Statements)); + PRINT("Processing: ", filename); + prog := @Program; + @Process_Prog(); + @Get_New_Name(VAR filename); + @PP_Item(@Program, 80, filename); + PRINT(""); + PRINT(filename); + @Prog_Stat_Comp(prog, @Program); + PRINT("") + ELSE + PRINT("ERROR: File ",filename," not found"); + FI +END; + +BEGIN +VAR< prog := < >, inifilename := "transf.ini", + filename:="", file := "", inifile:= "", + Argv := @Argv +>: +C:"First one is the script name that is being executed"; +Argv := TAIL(Argv); + +IF Argv = < > THEN + PRINT("no arguments passed; using ",inifilename); + IF @File_Exists?(inifilename) THEN + inifile := @Open_Input_File(inifilename); + filename := @Read_Line(inifile); + WHILE NOT @EOF?(filename) DO + PRINT(""); + @Process_File(filename); + filename := @Read_Line(inifile) + OD; + @Close_Input_Port(inifile); + ELSE + PRINT("ini file (",inifilename,") not found.", + " it should contain a list of filenames to be converted"); + PRINT("OR you can give command line arguments to be processed"); + FI +ELSE + FOR arg IN Argv DO + @Process_File(arg); + OD +FI +ENDVAR +WHERE + +PROC Prog_Stat(Pro VAR)== + PRINT ("Mc ", @McCabe(Pro)); + PRINT ("Statements ", @Stat_Count(Pro)); + PRINT ("Control/data Flow ", @CFDF_Metric(Pro)); + PRINT ("Size(nodes) ", @Total_Size(Pro)); + PRINT ("Struct ", @Struct_Metric(Pro)); + SKIP END PROC Get_Before_Name(VAR str) ==