gitweb on Svarog
projekti pod git sistemom za održavanje verzija -- projects under the git version control system
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 08dc193)
raw | patch | inline | side by side (parent: 08dc193)
author | Doni Pracner <quinnuendo@gmail.com> | |
Sat, 1 Sep 2012 20:45:26 +0000 (22:45 +0200) | ||
committer | Doni Pracner <quinnuendo@gmail.com> | |
Sat, 1 Sep 2012 20:45:26 +0000 (22:45 +0200) |
mjc2wsl.java | patch | blob | history | |
samples/sample0.wsl | patch | blob | history |
diff --git a/mjc2wsl.java b/mjc2wsl.java
index e65bd1dbbc33fd527f200677a2aad4addbedb9a6..c89fbab2750d759a19dfff2647a27c2f67167dd7 100644 (file)
--- a/mjc2wsl.java
+++ b/mjc2wsl.java
* @author Doni Pracner, http://perun.dmi.rs/pracner http://quemaster.com
*/
public class mjc2wsl{
- public static String versionN = "0.1";
+ public static String versionN = "0.1.2";
//regular comments from the original file
//OC when original code is inserted in the file, next to the translations
private InputStream mainIn;
private PrintWriter out = null;
+ private int counter = 0;
private void pr(int i){
out.print(i);
}catch (IOException ex){
ex.printStackTrace();
}
+ counter++;
return res;
}
for (int i=0;i<14;i++) get();
prl(getStandardStart());
-
+ prl("SKIP;\n ACTIONS A_S_start:\n A_S_start == CALL a14 END");
int op = get();
while (op>=0){
if (originalInComments) prl(createComment(""+op,C_OC));
+ prl("a"+counter+" == ");
switch(op) {
case load: {
prl(cmdToEStack(loc(get())));
}
case jmp: {
- prl(createComment("CALL "+get2()));
+ prl("CALL a"+(counter+get2())+";");
break;
}
case jeq: case jne: case jlt:
case jle: case jgt: case jge: {
prl(getTopTwo());
- prl(createComment("IF CALL "+get2()));
+ prl("IF tempb >= tempa THEN CALL a"+(counter+get2())+" FI;");
break;
}
default: prl(createComment("unknown op error: "+op,C_ERR)); break;
}
+
op = get();
+ if (op>=0) prl("CALL a"+counter+" END");
}
+ prl("CALL Z;\nSKIP END\nENDACTIONS;\n");
prl(getStandardEnd());
}
diff --git a/samples/sample0.wsl b/samples/sample0.wsl
index 905cb16ecbae3f0bc5b669bc63bfca1c193a3959..cc20ab3e9b05c75dd56df37cb07734eefa4c1841 100644 (file)
--- a/samples/sample0.wsl
+++ b/samples/sample0.wsl
VAR < tempa := 0, tempb := 0, tempres :=0,
loc0 := 0, loc1 := 0, loc2 := 0, loc3 := 0,
estack := < >, t_e_m_p := 0 > :
+SKIP;
ACTIONS A_S_start:
- A_S_start ==
-
+ A_S_start == CALL a14 END
+a15 ==
C:" enter not fully procesed yet";
+CALL a18 END
+a18 ==
estack := <0 > ++ estack;
-loc0 := HEAD(estack); estack := TAIL(estack);
CALL a19 END
-a19 ==
+a19 ==
+loc0 := HEAD(estack); estack := TAIL(estack);
+CALL a20 END
+a20 ==
estack := <loc0 > ++ estack;
+CALL a21 END
+a21 ==
estack := <5 > ++ estack;
+CALL a22 END
+a22 ==
tempa := HEAD(estack); estack := TAIL(estack);
tempb := HEAD(estack); estack := TAIL(estack);
-C:" IF CALL 13";
-IF tempb >= tempa THEN CALL a34 FI;
+IF tempb >= tempa THEN CALL a35 FI;
+CALL a25 END
+a25 ==
estack := <loc0 > ++ estack;
+CALL a26 END
+a26 ==
estack := <0 > ++ estack;
+CALL a27 END
+a27 ==
tempa := HEAD(estack); estack := TAIL(estack);
-tempa := HEAD(estack); estack := TAIL(estack);
-PRINT(tempa);
+tempb := HEAD(estack); estack := TAIL(estack);
+PRINT(tempb);
+CALL a28 END
+a28 ==
estack := <loc0 > ++ estack;
+CALL a29 END
+a29 ==
estack := <1 > ++ estack;
+CALL a30 END
+a30 ==
tempa := HEAD(estack); estack := TAIL(estack);
tempb := HEAD(estack); estack := TAIL(estack);
tempres := tempb + tempa;
estack := <tempres > ++ estack;
+CALL a31 END
+a31 ==
loc0 := HEAD(estack); estack := TAIL(estack);
-C:" CALL -12";
-CALL a19 END
-a34 ==
+CALL a32 END
+a32 ==
+CALL a20;
+CALL a35 END
+a35 ==
C:" exit not fully procesed yet";
+CALL a36 END
+a36 ==
C:" return not fully procesed yet";
-CALL Z
-END
+CALL Z;
+SKIP END
ENDACTIONS;
+
SKIP
ENDVAR