From 7167b4341ef290d56fb96e2af10883a4b925d83b Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Thu, 26 Mar 2026 19:27:18 +0100 Subject: I found my old code! --- .../SlackYouInterpreter-1.1/src/Main.java | 325 +++++++++++++++++++++ 1 file changed, 325 insertions(+) create mode 100755 SlackYouInterpreter/SlackYouInterpreter-1.1/src/Main.java (limited to 'SlackYouInterpreter/SlackYouInterpreter-1.1/src/Main.java') diff --git a/SlackYouInterpreter/SlackYouInterpreter-1.1/src/Main.java b/SlackYouInterpreter/SlackYouInterpreter-1.1/src/Main.java new file mode 100755 index 0000000..879efc1 --- /dev/null +++ b/SlackYouInterpreter/SlackYouInterpreter-1.1/src/Main.java @@ -0,0 +1,325 @@ +/* +Copyright 2009 Sebastiano Tronto + +This file is part of SlackYouInterpreter. + + SlackYouInterpreter is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + SlackYouInterpreter is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with SlackYouInterpreter; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +import javax.swing.JFrame; +import java.util.Scanner; +public class Main { + public static Scanner scanner; + public static char totalCode[], charCodeAux[], charCode[], chars; + public static int i, j; + public static byte a[][]; + public static void main( String args[] ) { + System.out.println(""); + Frame frame = new Frame(); + frame.setSize( 200, 300 ); + frame.setVisible( true ); + frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); + } + public static void run( String code ) { + scanner = new Scanner( System.in ); + a = new byte[1024][1024]; + for ( int countX = 0; countX < a[0].length; countX++ ) + for ( int countY = 0; countY < a.length; countY++ ) + a[countX][countY] = 0; + chars = 'A'; + int z = 0; + totalCode = code.toCharArray(); + charCodeAux = new char[totalCode.length*2]; + for ( int k = 0; k < totalCode.length; k++ ) { + switch ( totalCode[k] ) { + case '>': + case '<': + case '+': + case '-': + case '.': + case ',': + case '^': + case 'v': + case 'y': + case 'g': + case 'h': + case 'j': + case '*': + case '/': + case '%': + case '=': + case 'r': + case 'w': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + charCodeAux[z] = totalCode[k]; + z++; + break; + case '?': + case '!': + charCodeAux[z] = totalCode[k]; + z++; + charCodeAux[z] = chars; + chars++; + z++; + break; + case ';': + case ':': + chars--; + charCodeAux[z] = chars; + z++; + charCodeAux[z] = totalCode[k]; + z++; + break; + } + } + charCode = new char[z]; + for ( int k = 0; k < charCode.length; k++ ) + charCode[k] = charCodeAux[k]; + i = 0; + j = 0; + execute( scanner, charCode, a, i, j, 0, charCode.length ); + } + public static void execute( Scanner scanner, char charCode[], byte a[][], int i, int j, int start, int stop ) { + + for (int count = start; count < stop; count++ ) { + switch ( charCode[count] ) { + case '>': + i++; + break; + case '<': + i--; + break; + case 'v': + j++; + break; + case '^': + j--; + break; + case '.': + a[j][i]++; + break; + case ',': + a[j][i]--; + break; + case 'y': + a[j-1][i] = a[j][i]; + j--; + break; + case 'h': + a[j+1][i] = a[j][i]; + j++; + break; + case 'g': + a[j][i-1] = a[j][i]; + i--; + break; + case 'j': + a[j][i+1] = a[j][i]; + i++; + break; + case '+': + a[j][i] += a[j][i+1]; + break; + case '-': + a[j][i] -= a[j][i+1]; + break; + case '*': + a[j][i] *= a[j][i+1]; + break; + case '/': + a[j][i] /= a[j][i+1]; + break; + case '%': + a[j][i] %= a[j][i+1]; + break; + case 'w': + System.out.print( (char) a[j][i] ); + break; + case 'r': + String stringa = scanner.nextLine(); + char character[] = stringa.toCharArray(); + switch ( character.length ) { + case 1: + a[j][i] = (byte) character[0]; + break; + default: + count --; + break; + } + break; + case '=': + if ( (charCode[count+1] == '0' || charCode[count+1] == '1' || charCode[count+1] == '2' || charCode[count+1] == '3' || + charCode[count+1] == '4' || charCode[count+1] == '5' || charCode[count+1] == '6' || charCode[count+1] == '7' || + charCode[count+1] == '8' || charCode[count+1] == '9' || charCode[count+1] == 'a' || charCode[count+1] == 'b' || + charCode[count+1] == 'c' || charCode[count+1] == 'd' || charCode[count+1] == 'e' || charCode[count+1] == 'f' ) && + (charCode[count+2] == '0' || charCode[count+2] == '1' || charCode[count+2] == '2' || charCode[count+2] == '3' || + charCode[count+2] == '4' || charCode[count+2] == '5' || charCode[count+2] == '6' || charCode[count+2] == '7' || + charCode[count+2] == '8' || charCode[count+2] == '9' || charCode[count+2] == 'a' || charCode[count+2] == 'b' || + charCode[count+2] == 'c' || charCode[count+2] == 'd' || charCode[count+2] == 'e' || charCode[count+2] == 'f' ) ) { + a[j][i] = 0; + switch ( charCode[count+1] ) { + case '0': + break; + case '1': + a[j][i] += 1 * 16; + break; + case '2': + a[j][i] += 2 * 16; + break; + case '3': + a[j][i] += 3 * 16; + break; + case '4': + a[j][i] += 4 * 16; + break; + case '5': + a[j][i] += 5 * 16; + break; + case '6': + a[j][i] += 6 * 16; + break; + case '7': + a[j][i] += 7 * 16; + break; + case '8': + a[j][i] += 8 * 16; + break; + case '9': + a[j][i] += 9 * 16; + break; + case 'a': + a[j][i] += 10 * 16; + break; + case 'b': + a[j][i] += 11 * 16; + break; + case 'c': + a[j][i] += 12 * 16; + break; + case 'd': + a[j][i] += 13 * 16; + break; + case 'e': + a[j][i] += 14 * 16; + break; + case 'f': + a[j][i] += 15 * 16; + break; + } + switch ( charCode[count+2] ) { + case '0': + break; + case '1': + a[j][i] += 1; + break; + case '2': + a[j][i] += 2; + break; + case '3': + a[j][i] += 3; + break; + case '4': + a[j][i] += 4; + break; + case '5': + a[j][i] += 5; + break; + case '6': + a[j][i] += 6; + break; + case '7': + a[j][i] += 7; + break; + case '8': + a[j][i] += 8; + break; + case '9': + a[j][i] += 9; + break; + case 'a': + a[j][i] += 10; + break; + case 'b': + a[j][i] += 11; + break; + case 'c': + a[j][i] += 12; + break; + case 'd': + a[j][i] += 13; + break; + case 'e': + a[j][i] += 14; + break; + case 'f': + a[j][i] += 15; + break; + } + } + break; + case '?': + if ( a[j][i] == 0 ) { + count++; + char key = charCode[count]; + count++; + for ( ; charCode[count] != key; count++ ) ; + count++; + } + break; + case '!': + if ( a[j][i] != 0 ) { + count ++; + char key = charCode[count]; + count ++; + for ( ; charCode[count] != key; count++ ) ; + count++; + } + break; + case ';': + if ( a[j][i] != 0 ) { + count --; + char key = charCode[count]; + count --; + for ( ; charCode[count] != key; count-- ) ; + } + break; + case ':': + if ( a[j][i] == 0 ) { + count --; + char key = charCode[count]; + count --; + for ( ; charCode[count] != key; count-- ) ; + } + break; + } + } + } +} \ No newline at end of file -- cgit v1.3