Interpreter for PoC-Languages "Loop" and "While"
Go to file
404Simon ca797906b2 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	README.md
2023-12-28 00:15:55 +01:00
.idea add while support 2023-12-27 23:23:57 +01:00
lib project setup 2023-12-23 12:05:35 +01:00
src add tab support + language examples in readme 2023-12-28 00:14:58 +01:00
.gitignore project setup 2023-12-23 12:05:35 +01:00
pom.xml first working version (just LOOP) 2023-12-23 23:29:43 +01:00
README.md add tab support + language examples in readme 2023-12-28 00:14:58 +01:00
WHILEParser.jar add tab support + language examples in readme 2023-12-28 00:14:58 +01:00

Run it

java -jar WHILEParser.jar <whileprogram> <x1Value> <x2Value> ...

Build it

create parser with antlr

antlr4 -package parser.grammar -o main/java/parser/grammar -no-listener -visitor Loop.g4

create executable

mvn clean compile assembly:single

Language Example

//addWithWhile.txt
x0 = x2; // this is a comment
WHILE x1 != 0 DO
x0 = x0 +1;
x1 = x1 - 1;
END
//mulWithLoop.txt
z1 = x1;
z2 = x2;
x0 = 0;
y0 = 1;
LOOP z2 DO
    x1 = z1;
    x2 = y0 - 1;
    x3 = x0;
    y10 = y0;
    z11 = x1;
    z12 = x3;
    x0 = x1;
    y0 = 1;
    LOOP z12 DO
        x1 = z11;
        x2 = y0 - 1;
        x3 = x0;
        x0 = x3 + 1;
        y0 = y0 + 1;
    END
    y0 = y10;
    y0 = y0 + 1;
END